[LyX/master] amend 11e4a24e6edbd1f

2018-03-11 Thread Juergen Spitzmueller
commit 386d9953e83a35dcc3b0f173faa92d9e9fc16f0f
Author: Juergen Spitzmueller 
Date:   Sun Mar 11 19:49:28 2018 +0100

amend 11e4a24e6edbd1f
---
 src/tex2lyx/Preamble.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 50a56e8..247422e 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -1600,12 +1600,13 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
continue;
}
 
-   else if (t.cs() == "date") {
+   if (t.cs() == "date") {
string argument = p.getArg('{', '}');
if (argument.empty())
h_suppress_date = "true";
else
h_preamble << t.asInput() << '{' << argument << 
'}';
+   continue;
}
 
if (t.cs() == "color") {


[LyX/master] update test

2018-03-11 Thread Juergen Spitzmueller
commit f30474a26c5e89b8572810fb01610c9915ccdecb
Author: Juergen Spitzmueller 
Date:   Sun Mar 11 19:50:22 2018 +0100

update test
---
 src/tex2lyx/test/test-structure.lyx.lyx |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/tex2lyx/test/test-structure.lyx.lyx 
b/src/tex2lyx/test/test-structure.lyx.lyx
index 44dc649..85f5534 100644
--- a/src/tex2lyx/test/test-structure.lyx.lyx
+++ b/src/tex2lyx/test/test-structure.lyx.lyx
@@ -27,7 +27,7 @@
 
 \usepackage{fixltx2e}% this should cause the fixltx2e module to be loaded
 
-\date
+
 
 
 


[LyX/2.3.2-staging] amend 11e4a24e6edbd1f

2018-03-11 Thread Juergen Spitzmueller
commit bbaf2b6a29fb507e9174ee66919cf2ac40aa8a02
Author: Juergen Spitzmueller 
Date:   Sun Mar 11 19:49:28 2018 +0100

amend 11e4a24e6edbd1f

(cherry picked from commit 386d9953e83a35dcc3b0f173faa92d9e9fc16f0f)
---
 src/tex2lyx/Preamble.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index e0a5de3..1b9d509 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -1585,12 +1585,13 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
continue;
}
 
-   else if (t.cs() == "date") {
+   if (t.cs() == "date") {
string argument = p.getArg('{', '}');
if (argument.empty())
h_suppress_date = "true";
else
h_preamble << t.asInput() << '{' << argument << 
'}';
+   continue;
}
 
if (t.cs() == "color") {


[LyX/master] tex2lyx: support tipa \t*{} macro.

2018-03-11 Thread Juergen Spitzmueller
commit cc6f2dae8219b40cd8602f70110926296403a0f7
Author: Juergen Spitzmueller 
Date:   Sun Mar 11 11:46:37 2018 +0100

tex2lyx: support tipa \t*{} macro.
---
 src/tex2lyx/TODO.txt |1 -
 src/tex2lyx/text.cpp |9 +++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt
index 522c0ec..0ec2ca6 100644
--- a/src/tex2lyx/TODO.txt
+++ b/src/tex2lyx/TODO.txt
@@ -50,7 +50,6 @@ Format LaTeX featureLyX feature
 407vertical offset for multirowsInsetTabular
 411support for polyglossia  \language_package  (the cases of 
no package, of babel and of custom package is supported)
 415automatic undertilde loading \use_package undertilde
-438\t*{ }   InsetTIPA
 443unicode-math.sty InsetMath*
 448
 451beamer overlay arguments InsetArgument
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 2ef3a9f..9ef22fb 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -3700,9 +3700,14 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
continue;
}
 
-   if (t.cs() == "texttoptiebar" || t.cs() == "textbottomtiebar") {
+   if ((preamble.isPackageUsed("tipa") && t.cs() == "t" && 
p.next_token().asInput() == "*")
+   || t.cs() == "texttoptiebar" || t.cs() == 
"textbottomtiebar") {
context.check_layout(os);
-   begin_inset(os, "IPADeco " + t.cs().substr(4) + "\n");
+   if (t.cs() == "t")
+   // swallow star
+   p.get_token();
+   string const type = (t.cs() == "t") ? "bottomtiebar" : 
t.cs().substr(4);
+   begin_inset(os, "IPADeco " + type + "\n");
os << "status open\n";
parse_text_in_inset(p, os, FLAG_ITEM, outer, context);
end_inset(os);


[LyX/2.2.x] Win installer: prepare 2.2.4 release

2018-03-11 Thread Uwe Stöhr
commit 4c7f46020acfd93049d4a2db2e9932108f0debc7
Author: Uwe Stöhr 
Date:   Sun Mar 11 14:36:40 2018 +0100

Win installer: prepare 2.2.4 release
---
 .../Win32/packaging/installer/ChangeLog.txt|2 +-
 .../Win32/packaging/installer/include/LaTeX.nsh|   86 +--
 .../Win32/packaging/installer/include/filelist.nsh |3 +-
 3 files changed, 79 insertions(+), 12 deletions(-)

diff --git a/development/Win32/packaging/installer/ChangeLog.txt 
b/development/Win32/packaging/installer/ChangeLog.txt
index 6c52438..821559c 100644
--- a/development/Win32/packaging/installer/ChangeLog.txt
+++ b/development/Win32/packaging/installer/ChangeLog.txt
@@ -4,7 +4,7 @@
 - fix installation of Arabic spell checker
 - LyX will work under Windows Vista but is no longer supported
 - updated to MiKTeX 2.9 build 6615
-- updated to ImageMagick 7.0.7-22
+- updated to ImageMagick 7.0.7-25
 - updated to Qt 5.9.4
 - new thesaurus for Arabic
 - updated thesaurus for Ukrainian
diff --git a/development/Win32/packaging/installer/include/LaTeX.nsh 
b/development/Win32/packaging/installer/include/LaTeX.nsh
index ecb82b4..c06d866 100644
--- a/development/Win32/packaging/installer/include/LaTeX.nsh
+++ b/development/Win32/packaging/installer/include/LaTeX.nsh
@@ -1,4 +1,4 @@
-/*
+/*
 LaTeX.nsh
 
 Handling of LaTeX distributions
@@ -388,21 +388,89 @@ FunctionEnd
 Function UpdateMiKTeX
  # asks to update MiKTeX
 
-  MessageBox MB_YESNO|MB_ICONINFORMATION "$(MiKTeXInfo)" /SD IDNO IDYES 
UpdateNow IDNO UpdateLater
-  UpdateNow:
-  # the update wizard is started by the miktex-update.exe
+  # only for the 2.2.4 installer: force a silent update of MiKTeX then restore
+  # MiKTeX's inernal links
+  # The reason is that MikTeX uses a new package handling system LyX must use
+  # Due to a bug in the old MikTeX package handling the update to the new 
package
+  # handling might fail and users cannot use LaTeX at all afterwards - they 
then
+  # would have no other choice than to reinstall MiKTeX
+  # This case is fixed by forcing the restoration of the internal links
+  # There is another issue: the MiKTeX update program needs to be replaced by
+  # the new MiKTeX console. This is a 3-step process.
+  #MessageBox MB_YESNO|MB_ICONINFORMATION "$(MiKTeXInfo)" #/SD IDNO IDYES 
UpdateNow IDNO UpdateLater
+  #UpdateNow:
+  # graphical update:
+  #MessageBox MB_OK|MB_ICONINFORMATION 'To assure that LyX can create PDF 
files the MiKTeX update program must be run two times.$\r$\n\
+  # Please click in the MiKTeX update program only on the "Next" button.$\r$\n\
+  # If "Next" is disabled, click on "Cancel" or "Finish".'
+  #${if} $MultiUser.Privileges != "Admin"
+  #${andif} $MultiUser.Privileges != "Power"
+  # # call the non-admin version
+  # nsExec::ExecToLog '"$PathLaTeX\internal\miktex-update.exe"'
+  #${else}
+  # ${if} $MiKTeXUser != "HKCU" # call the admin version
+  #  nsExec::ExecToLog '"$PathLaTeX\internal\miktex-update_admin.exe"'
+  # ${else}
+  #   nsExec::ExecToLog '"$PathLaTeX\internal\miktex-update.exe"'
+  # ${endif}
+  #${endif}
+  # silent update:
+  MessageBox MB_OK|MB_ICONINFORMATION "MiKTeX must be updated to assure that 
LyX can create PDF files.$\r$\n\
+   This update can take several minutes, depending on your Internet 
speed.$\r$\n\
+   Please do not close the LyX installer until it is finished!" /SD IDOK
   ${if} $MultiUser.Privileges != "Admin"
   ${andif} $MultiUser.Privileges != "Power"
# call the non-admin version
-ExecWait '"$PathLaTeX\internal\miktex-update.exe"'
+   # the order of the different commands is important!
+   ${if} $Is64bit == "true"
+nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--update=miktex-bin-x64-2.9"'
+nsExec::ExecToLog '"$PathLaTeX\mpm.exe" 
"--install=miktex-console-bin-x64-2.9"'
+nsExec::ExecToLog '"$PathLaTeX\mpm.exe" 
"--uninstall=miktex-mpm-bin-x64-2.9"'
+   ${else}
+nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--update=miktex-bin-2.9"'
+nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--install=miktex-console-bin-2.9"'
+nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--uninstall=miktex-mpm-bin-2.9"'
+   ${endif}
+   nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--update"'
+  ${else}
+   ${if} $MiKTeXUser != "HKCU" # call the admin version
+# the order of the different commands is important!
+${if} $Is64bit == "true"
+ nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--admin" 
"--update=miktex-bin-x64-2.9"'
+ nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--admin" 
"--install=miktex-console-bin-x64-2.9"'
+ nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--admin" 
"--uninstall=miktex-mpm-bin-x64-2.9"'
+${else}
+ nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--admin" 
"--update=miktex-bin-2.9"'
+ nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--admin" 
"--install=miktex-console-bin-2.9"'
+ nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--admin" 
"--uninstall=miktex-mpm-bin-2.9"'
+${endif}
+nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--admin" 

[LyX/master] Win installer: fix a typo

2018-03-11 Thread Uwe Stöhr
commit 23ba5e8389a0b3a012cc4cdefc3493191385def1
Author: Uwe Stöhr 
Date:   Sun Mar 11 14:37:48 2018 +0100

Win installer: fix a typo
---
 .../packaging/installer/include/EnvVarUpdate.nsh   |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/development/Win32/packaging/installer/include/EnvVarUpdate.nsh 
b/development/Win32/packaging/installer/include/EnvVarUpdate.nsh
index 12de15f..e67472c 100644
--- a/development/Win32/packaging/installer/include/EnvVarUpdate.nsh
+++ b/development/Win32/packaging/installer/include/EnvVarUpdate.nsh
@@ -261,7 +261,7 @@ Function ${UN}EnvVarUpdate
   ${If} $6 == 1
 DetailPrint "appended to $1"
   ${Else}
-#DetailPrint "Target was appended to $1"
+DetailPrint "Target was appended to $1"
   ${EndIf}
 ${Else};  If Prepend (and EnvVar is not 
empty),
   StrCpy $0 $4;$0  ; prepend PathString


[LyX/master] Update tex2lyx tests after cc6f2dae82

2018-03-11 Thread Juergen Spitzmueller
commit e5e6e16274e39a851decdab11e9eb547996a5bec
Author: Juergen Spitzmueller 
Date:   Sun Mar 11 18:04:02 2018 +0100

Update tex2lyx tests after cc6f2dae82
---
 src/tex2lyx/test/test-insets-basic.lyx.lyx |   18 --
 src/tex2lyx/test/test-insets.lyx.lyx   |   18 --
 2 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/src/tex2lyx/test/test-insets-basic.lyx.lyx 
b/src/tex2lyx/test/test-insets-basic.lyx.lyx
index 02ae767..9bed023 100644
--- a/src/tex2lyx/test/test-insets-basic.lyx.lyx
+++ b/src/tex2lyx/test/test-insets-basic.lyx.lyx
@@ -6476,22 +6476,12 @@ tz
 \begin_inset IPA
 
 \begin_layout Standard
-:;eˈˌ|‖.͡*
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
+:;eˈˌ|‖.
+\begin_inset IPADeco bottomtiebar
+status open
 
+\begin_layout Standard
  
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
 \end_layout
 
 \end_inset
diff --git a/src/tex2lyx/test/test-insets.lyx.lyx 
b/src/tex2lyx/test/test-insets.lyx.lyx
index b2866ae..f93fde1 100644
--- a/src/tex2lyx/test/test-insets.lyx.lyx
+++ b/src/tex2lyx/test/test-insets.lyx.lyx
@@ -6922,22 +6922,12 @@ tz
 \begin_inset IPA
 
 \begin_layout Standard
-:;eˈˌ|‖.͡*
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
+:;eˈˌ|‖.
+\begin_inset IPADeco bottomtiebar
+status open
 
+\begin_layout Standard
  
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
 \end_layout
 
 \end_inset


[LyX/2.3.2-staging] Status updates.

2018-03-11 Thread Juergen Spitzmueller
commit 8f69f7af01629b04256a1abadaafeaf430edf5a3
Author: Juergen Spitzmueller 
Date:   Sun Mar 11 18:33:45 2018 +0100

Status updates.
---
 status.23x |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/status.23x b/status.23x
index ea89b77..2cd3d67 100644
--- a/status.23x
+++ b/status.23x
@@ -29,6 +29,9 @@ What's new
 
 - Add support for URW Classico, MinionPro and the new Libertine fonts.
 
+- Implement better parsing of some command options (via "literate"
+  function of some insets) (bug 9563).
+
 
 * USER INTERFACE
 
@@ -115,6 +118,8 @@ What's new
 - Add support for alignment pseudo-environments as used inside floats
   (bug 7857).
 
+- Fix parsing issue in nested CJK (bug 9562).
+
 
 * ADVANCED FIND AND REPLACE
 


[LyX/2.3.2-staging] tex2lyx: honor grouping in optional arguments.

2018-03-11 Thread Juergen Spitzmueller
commit 590185d3ef903714090c0461d4e1c427679a2833
Author: Juergen Spitzmueller 
Date:   Fri Mar 9 13:14:13 2018 +0100

tex2lyx: honor grouping in optional arguments.

E.g., \cite[{a literal ] character}]{key}

(cherry picked from commit cba38881d6b9fa3ff5dd0ebe50239fc384309082)
---
 src/tex2lyx/Parser.cpp |   16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp
index 35748b9..6e29623 100644
--- a/src/tex2lyx/Parser.cpp
+++ b/src/tex2lyx/Parser.cpp
@@ -494,6 +494,7 @@ Parser::Arg Parser::getFullArg(char left, char right, bool 
allow_escaping)
if (! good())
return make_pair(false, string());
 
+   int group_level = 0;
string result;
Token t = get_token();
 
@@ -504,6 +505,15 @@ Parser::Arg Parser::getFullArg(char left, char right, bool 
allow_escaping)
} else {
while (good()) {
t = get_token();
+   // honor grouping
+   if (left != '{' && t.cat() == catBegin) {
+   ++group_level;
+   continue;
+   }
+   if (left != '{' && t.cat() == catEnd) {
+   --group_level;
+   continue;
+   }
// Ignore comments
if (t.cat() == catComment) {
if (!t.cs().empty())
@@ -511,13 +521,15 @@ Parser::Arg Parser::getFullArg(char left, char right, 
bool allow_escaping)
continue;
}
if (allow_escaping) {
-   if (t.cat() != catEscape && t.character() == 
right)
+   if (t.cat() != catEscape && t.character() == 
right
+   && group_level == 0)
break;
} else {
if (t.character() == right) {
if (t.cat() == catEscape)
result += '\\';
-   break;
+   if (group_level == 0)
+   break;
}
}
result += t.asInput();


[LyX/2.3.2-staging] Fix copy and paste error in 6659304f7f8b

2018-03-11 Thread Juergen Spitzmueller
commit ce2e1554908785d7accba292985017fb961b1450
Author: Juergen Spitzmueller 
Date:   Fri Mar 9 12:29:07 2018 +0100

Fix copy and paste error in 6659304f7f8b

(cherry picked from commit 0513622fd0ce600cbf283f6afdbde9841d46a546)
---
 src/tex2lyx/text.cpp |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 2d9bf4b..c5d7ce2 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -3918,7 +3918,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
if (!before.empty()) {
before.erase(0, 1);
before.erase(before.length() - 1, 1);
-   bef = convert_latexed_command_inset_arg(after);
+   bef = convert_latexed_command_inset_arg(before);
literal |= !bef.first;
before = literal ? subst(before, "\n", " ") : 
bef.second;
if (literal && !after.empty())
@@ -4018,7 +4018,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
if (!before.empty()) {
before.erase(0, 1);
before.erase(before.length() - 1, 1);
-   bef = convert_latexed_command_inset_arg(after);
+   bef = convert_latexed_command_inset_arg(before);
literal |= !bef.first;
before = literal ? subst(before, "\n", " ") : 
bef.second;
}
@@ -4170,7 +4170,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
if (!before.empty()) {
before.erase(0, 1);
before.erase(before.length() - 1, 1);
-   bef = convert_latexed_command_inset_arg(after);
+   bef = convert_latexed_command_inset_arg(before);
literal |= !bef.first;
before = literal ? subst(before, "\n", " ") : 
bef.second;
if (literal && !after.empty())


[LyX/2.3.2-staging] tex2lyx: towards proper support of "literal"/"latexified" inset commands

2018-03-11 Thread Juergen Spitzmueller
commit bd876d816330b56ad1e6dd62302e52f7462ffc08
Author: Juergen Spitzmueller 
Date:   Thu Mar 8 15:00:33 2018 +0100

tex2lyx: towards proper support of "literal"/"latexified" inset commands

We now report whether the attempt to recode the macros to glyphs
succeeded. If yes, we set "literate" to false, if not to true.

Also, do not attempt to recode for non-latexifying fields.

Fixes: #9563
(cherry picked from commit 6659304f7f8b57f12a1bf453a11ea359c83a7d14)
---
 src/tex2lyx/text.cpp |  212 --
 1 files changed, 153 insertions(+), 59 deletions(-)

diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 285a818..2d9bf4b 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -518,8 +518,12 @@ bool skip_braces(Parser & p)
 
 /// replace LaTeX commands in \p s from the unicodesymbols file with their
 /// unicode points
-docstring convert_unicodesymbols(docstring s)
+pair convert_unicodesymbols(docstring s)
 {
+   bool res = true;
+   int const nchars_escape = 8;
+   static char_type const chars_escape[nchars_escape] = {
+   '&', '_', '$', '%', '#', '^', '{', '}'};
odocstringstream os;
for (size_t i = 0; i < s.size();) {
if (s[i] != '\\') {
@@ -540,23 +544,41 @@ docstring convert_unicodesymbols(docstring s)
s = rem;
if (s.empty() || s[0] != '\\')
i = 0;
-   else
+   else {
+   res = false;
+   for (int k = 0; k < nchars_escape; k++)
+   if (prefixIs(s, from_ascii("\\") + 
chars_escape[k]))
+   res = true;
i = 1;
+   }
}
-   return os.str();
+   return make_pair(res, os.str());
 }
 
 
 /// try to convert \p s to a valid InsetCommand argument
-string convert_command_inset_arg(string s)
+/// return whether this succeeded. If not, these command insets
+/// get the "literate" flag.
+pair convert_latexed_command_inset_arg(string s)
 {
-   if (isAscii(s))
+   bool success = false;
+   if (isAscii(s)) {
// since we don't know the input encoding we can't use from_utf8
-   s = to_utf8(convert_unicodesymbols(from_ascii(s)));
+   pair res = 
convert_unicodesymbols(from_ascii(s));
+   success = res.first;
+   s = to_utf8(res.second);
+   }
// LyX cannot handle newlines in a latex command
-   return subst(s, "\n", " ");
+   return make_pair(success, subst(s, "\n", " "));
 }
 
+/// try to convert \p s to a valid InsetCommand argument
+/// without trying to recode macros.
+string convert_literate_command_inset_arg(string s)
+{
+   // LyX cannot handle newlines in a latex command
+   return subst(s, "\n", " ");
+}
 
 void output_ert(ostream & os, string const & s, Context & context)
 {
@@ -3012,20 +3034,17 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
context.set_item();
context.check_layout(os);
eat_whitespace(p, os, context, false);
-   string label = 
convert_command_inset_arg(p.verbatimOption());
-   string key = 
convert_command_inset_arg(p.verbatim_item());
-   if (contains(label, '\\') || contains(key, '\\')) {
-   // LyX can't handle LaTeX commands in labels or 
keys
-   output_ert_inset(os, t.asInput() + '[' + label +
-  "]{" + p.verbatim_item() + '}',
-  context);
-   } else {
-   begin_command_inset(os, "bibitem", "bibitem");
-   os << "label \"" << label << "\"\n"
-  << "key \"" << key << "\"\n"
-  << "literal \"true\"\n";
-   end_inset(os);
-   }
+   string label = p.verbatimOption();
+   pair lbl = 
convert_latexed_command_inset_arg(label);
+   bool const literal = !lbl.first;
+   label = literal ? subst(label, "\n", " ") : lbl.second;
+   string lit = literal ? "\"true\"" : "\"false\"";
+   string key = 
convert_literate_command_inset_arg(p.verbatim_item());
+   begin_command_inset(os, "bibitem", "bibitem");
+   os << "label \"" << label << "\"\n"
+  << "key \"" << key << "\"\n"
+  << "literal " << lit << "\n";
+   end_inset(os);
 

Re: [LyX/master] tex2lyx: support tipa \t*{} macro.

2018-03-11 Thread Jürgen Spitzmüller
Am Sonntag, den 11.03.2018, 11:47 +0100 schrieb Juergen Spitzmueller:
> commit cc6f2dae8219b40cd8602f70110926296403a0f7
> Author: Juergen Spitzmueller 
> Date:   Sun Mar 11 11:46:37 2018 +0100
> 
> tex2lyx: support tipa \t*{} macro.

Also candidate for 2.3.2-staging

(as you see, I am currently going through the tex2lyx/TODO file and try
to resolve some simple issues)

Jürgen

signature.asc
Description: This is a digitally signed message part


[LyX/2.3.2-staging] tex2lyx: make nested CJK parsing slightly less dumb.

2018-03-11 Thread Juergen Spitzmueller
commit 624a6642e93367d52a4a94f295b0036701ebdec5
Author: Juergen Spitzmueller 
Date:   Sat Mar 10 14:58:55 2018 +0100

tex2lyx: make nested CJK parsing slightly less dumb.

Fixes: #9562
(cherry picked from commit 0f4c9027056a6f4f771382e9ebfc7940274bf5c0)
---
 src/tex2lyx/text.cpp |   19 ++-
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index c5d7ce2..4f7f5a7 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -343,6 +343,10 @@ bool minted_float_has_caption = false;
 // The caption for non-floating minted listings
 string minted_nonfloat_caption = "";
 
+// Characters that have to be escaped by \\ in LaTeX
+char const * const known_escaped_chars[] = {
+   "&", "_", "$", "%", "#", "^", "{", "}"};
+
 
 /// splits "x=z, y=b" into a map and an ordered keyword vector
 void split_map(string const & s, map & res, vector & 
keys)
@@ -521,9 +525,6 @@ bool skip_braces(Parser & p)
 pair convert_unicodesymbols(docstring s)
 {
bool res = true;
-   int const nchars_escape = 8;
-   static char_type const chars_escape[nchars_escape] = {
-   '&', '_', '$', '%', '#', '^', '{', '}'};
odocstringstream os;
for (size_t i = 0; i < s.size();) {
if (s[i] != '\\') {
@@ -546,8 +547,8 @@ pair convert_unicodesymbols(docstring s)
i = 0;
else {
res = false;
-   for (int k = 0; k < nchars_escape; k++)
-   if (prefixIs(s, from_ascii("\\") + 
chars_escape[k]))
+   for (auto const & c : known_escaped_chars)
+   if (prefixIs(s, from_ascii("\\") + c))
res = true;
i = 1;
}
@@ -1719,10 +1720,10 @@ void parse_environment(Parser & p, ostream & os, bool 
outer,
//things like comments are completely wrong.
string const s = p.plainEnvironment("CJK");
for (string::const_iterator it = s.begin(), et = 
s.end(); it != et; ++it) {
-   if (*it == '\\')
-   output_ert_inset(os, "\\", 
parent_context);
-   else if (*it == '$')
-   output_ert_inset(os, "$", 
parent_context);
+   string snip;
+   snip += *it;
+   if (snip == "\\" || is_known(snip, 
known_escaped_chars))
+   output_ert_inset(os, snip, 
parent_context);
else if (*it == '\n' && it + 1 != et && 
s.begin() + 1 != it)
os << "\n ";
else


[LyX/master] tex2lyx: update quote handling

2018-03-11 Thread Juergen Spitzmueller
commit 8184f08f4af6efea6d1499e3f8c8d3c20ebb1b97
Author: Juergen Spitzmueller 
Date:   Sun Mar 11 18:04:23 2018 +0100

tex2lyx: update quote handling

* Consider new quote styles
* Consider changed quote styles
* Try to be a bit smarter with ambiguous quotation marks
---
 src/tex2lyx/Preamble.cpp   |  108 +++-
 src/tex2lyx/Preamble.h |2 +
 src/tex2lyx/TODO.txt   |   17 
 src/tex2lyx/test/CJK.lyx.lyx   |2 +-
 src/tex2lyx/test/CJKutf8.lyx.lyx   |2 +-
 src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx |2 +-
 src/tex2lyx/text.cpp   |  124 ++--
 7 files changed, 172 insertions(+), 85 deletions(-)

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 0101014..50a56e8 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -88,35 +88,51 @@ const char * const known_coded_languages[] = {"french", 
"afrikaans", "albanian",
 "vietnamese", "welsh",
 0};
 
+/// languages with british quotes (.lyx names)
+const char * const known_british_quotes_languages[] = {"british", "welsh", 0};
+
+/// languages with cjk quotes (.lyx names)
+const char * const known_cjk_quotes_languages[] = {"chinese-traditional",
+"japanese", "japanese-cjk", 0};
+
+/// languages with cjk-angle quotes (.lyx names)
+const char * const known_cjkangle_quotes_languages[] = {"korean", 0};
+
 /// languages with danish quotes (.lyx names)
 const char * const known_danish_quotes_languages[] = {"danish", 0};
 
 /// languages with english quotes (.lyx names)
 const char * const known_english_quotes_languages[] = {"american", 
"australian",
 "bahasa", "bahasam", "brazilian", "canadian", "chinese-simplified", "english",
-"esperanto", "hebrew", "irish", "korean", "newzealand", "portuguese", 
"scottish",
-"thai", 0};
+"esperanto", "farsi", "interlingua", "irish", "newzealand", "scottish",
+"thai", "turkish", "vietnamese", 0};
 
 /// languages with french quotes (.lyx names)
-const char * const known_french_quotes_languages[] = {"albanian",
-"arabic_arabi", "arabic_arabtex", "asturian", "basque", "canadien", "catalan",
-"french", "friulan", "galician", "greek", "italian", "norsk", "nynorsk",
-"piedmontese", "polutonikogreek", "russian", "spanish", "spanish-mexico",
-"turkish", "turkmen", "ukrainian", "vietnamese", 0};
+const char * const known_french_quotes_languages[] = {"ancientgreek",
+"arabic_arabi", "arabic_arabtex", "asturian", "belarusian", "breton",
+"canadien", "catalan", "french", "friulan", "galician", "italian", "occitan",
+"piedmontese", "portuguese", "spanish", "spanish-mexico", 0};
 
 /// languages with german quotes (.lyx names)
 const char * const known_german_quotes_languages[] = {"austrian", "bulgarian",
-"czech", "german", "georgian", "icelandic", "lithuanian", "lowersorbian", 
"macedonian",
-"naustrian", "ngerman", "romansh", "serbian", "serbian-latin", "slovak", 
"slovene",
+"czech", "estonian", "georgian", "german", "icelandic", "latvian", 
"lithuanian",
+"lowersorbian", "macedonian", "naustrian", "ngerman", "romansh", "slovak", 
"slovene",
 "uppersorbian", 0};
 
 /// languages with polish quotes (.lyx names)
 const char * const known_polish_quotes_languages[] = {"afrikaans", "bosnian", 
"croatian",
-"dutch", "estonian", "magyar", "polish", "romanian", 0};
+"dutch", "magyar", "polish", "romanian", "serbian", "serbian-latin", 0};
+
+/// languages with russian quotes (.lyx names)
+const char * const known_russian_quotes_languages[] = {"russian", "ukrainian", 
0};
 
 /// languages with swedish quotes (.lyx names)
-const char * const known_swedish_quotes_languages[] = {"finnish",
-"swedish", 0};
+const char * const known_swedish_quotes_languages[] = {"finnish", "swedish", 
0};
+
+/// languages with swiss quotes (.lyx names)
+const char * const known_swiss_quotes_languages[] = {"albanian",
+"armenian", "basque", "german-ch", "german-ch-old",
+"norsk", "nynorsk", "turkmen", "ukrainian", "vietnamese", 0};
 
 /// known language packages from the times before babel
 const char * const known_old_language_packages[] = {"french", "frenchle",
@@ -1214,33 +1230,6 @@ void Preamble::handle_if(Parser & p, bool 
in_lyx_preamble)
 
 bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & 
outfiledir)
 {
-   // set the quote language
-   // LyX only knows the following quotes languages:
-   // english, swedish, german, polish, french and danish
-   // (quotes for "japanese" and "chinese-traditional" are missing because
-   //  they wouldn't be useful: https://www.lyx.org/trac/ticket/6383)
-   // conversion list taken from
-   // https://en.wikipedia.org/wiki/Quotation_mark,_non-English_usage
-   // (quotes for kazakh and interlingua are unknown)
-   // danish
-   if (is_known(h_language, known_danish_quotes_languages))
-   h_quotes_style = "danish";
-   // french
-   

[LyX/2.3.2-staging] update tex2lyx tests.

2018-03-11 Thread Juergen Spitzmueller
commit 64981aa48c309690d64185065c2aaf9e1820a0c9
Author: Juergen Spitzmueller 
Date:   Sun Mar 11 19:31:19 2018 +0100

update tex2lyx tests.
---
 .../test/box-color-size-space-align.lyx.lyx|   42 -
 src/tex2lyx/test/test-insets-basic.lyx.lyx |   66 +++-
 src/tex2lyx/test/test-insets.lyx.lyx   |   66 +++-
 src/tex2lyx/test/test-structure.lyx.lyx|3 -
 4 files changed, 167 insertions(+), 10 deletions(-)

diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx 
b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
index 30a2b15..b6926c7 100644
--- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
+++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
@@ -2878,7 +2878,47 @@ Characters
 \begin_layout Standard
 
 \size normal
-from package "ascii" and "ifsym": ®↨◻◼◙
+from package 
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+ascii
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+ and 
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+ifsym
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+: ®↨◻◼◙
 \end_layout
 
 \begin_layout Standard
diff --git a/src/tex2lyx/test/test-insets-basic.lyx.lyx 
b/src/tex2lyx/test/test-insets-basic.lyx.lyx
index 3e29da2..4d7a58a 100644
--- a/src/tex2lyx/test/test-insets-basic.lyx.lyx
+++ b/src/tex2lyx/test/test-insets-basic.lyx.lyx
@@ -7063,7 +7063,27 @@ literal "true"
 \end_layout
 
 \begin_layout Standard
-index "idx":
+index 
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+idx
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+:
 \end_layout
 
 \begin_layout Standard
@@ -7079,7 +7099,27 @@ literal "true"
 \end_layout
 
 \begin_layout Standard
-index "new":
+index 
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+new
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+:
 \end_layout
 
 \begin_layout Standard
@@ -7095,7 +7135,27 @@ literal "true"
 \end_layout
 
 \begin_layout Standard
-subindex "new":
+subindex 
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+new
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+:
 \end_layout
 
 \begin_layout Standard
diff --git a/src/tex2lyx/test/test-insets.lyx.lyx 
b/src/tex2lyx/test/test-insets.lyx.lyx
index 0aa2ee8..60f7d40 100644
--- a/src/tex2lyx/test/test-insets.lyx.lyx
+++ b/src/tex2lyx/test/test-insets.lyx.lyx
@@ -7516,7 +7516,27 @@ literal "true"
 \end_layout
 
 \begin_layout Standard
-index "idx":
+index 
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+idx
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+:
 \end_layout
 
 \begin_layout Standard
@@ -7532,7 +7552,27 @@ literal "true"
 \end_layout
 
 \begin_layout Standard
-index "new":
+index 
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+new
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+:
 \end_layout
 
 \begin_layout Standard
@@ -7548,7 +7588,27 @@ literal "true"
 \end_layout
 
 \begin_layout Standard
-subindex "new":
+subindex 
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+new
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+"
+\end_layout
+
+\end_inset
+
+:
 \end_layout
 
 \begin_layout Standard
diff --git a/src/tex2lyx/test/test-structure.lyx.lyx 
b/src/tex2lyx/test/test-structure.lyx.lyx
index b1cb680..76f9c89 100644
--- a/src/tex2lyx/test/test-structure.lyx.lyx
+++ b/src/tex2lyx/test/test-structure.lyx.lyx
@@ -604,7 +604,6 @@ klöä
 
 
 \end_layout
-
 \end_inset
 
 
@@ -651,7 +650,6 @@ te%st
 
 
 \end_layout
-
 \end_inset
 
 
@@ -686,7 +684,6 @@ subfigure 2ö
 
 
 \end_layout
-
 \end_inset
 
 


[LyX/master] tex2lyx: support for URW Classico, MinionPro and the new Libertine fonts.

2018-03-11 Thread Juergen Spitzmueller
commit a3836d990926dfd8e7e35b266274c372c72206ce
Author: Juergen Spitzmueller 
Date:   Sun Mar 11 11:12:42 2018 +0100

tex2lyx: support for URW Classico, MinionPro and the new Libertine fonts.
---
 src/tex2lyx/Preamble.cpp |   39 +++
 src/tex2lyx/TODO.txt |4 
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 7086897..0101014 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -126,17 +126,17 @@ char const * const known_fontsizes[] = { "10pt", "11pt", 
"12pt", 0 };
 
 const char * const known_roman_fonts[] = { "ae", "beraserif", "bookman",
 "ccfonts", "chancery", "charter", "cmr", "cochineal", "crimson", "fourier",
-"garamondx", "libertine", "libertine-type1", "lmodern", "mathdesign", 
"mathpazo",
-"mathptmx", "newcent", "NotoSerif-TLF", "PTSerif-TLF", "tgbonum", "tgchorus",
+"garamondx", "libertine", "libertineRoman", "libertine-type1", "lmodern", 
"mathdesign", "mathpazo",
+"mathptmx", "MinionPro", "newcent", "NotoSerif-TLF", "PTSerif-TLF", "tgbonum", 
"tgchorus",
 "tgpagella", "tgschola", "tgtermes", "utopia", 0 };
 
-const char * const known_sans_fonts[] = { "avant", "berasans", 
"biolinum-type1",
-"cmbr", "cmss", "helvet", "iwona", "iwonac", "iwonal", "iwonalc", "kurier",
-"kurierc", "kurierl", "kurierlc", "lmss", "NotoSans-TLF", "PTSans-TLF", 
"tgadventor",
-"tgheros", 0 };
+const char * const known_sans_fonts[] = { "avant", "berasans", "biolinum",
+"biolinum-type1", "cmbr", "cmss", "helvet", "iwona", "iwonac", "iwonal", 
"iwonalc",
+"kurier", "kurierc", "kurierl", "kurierlc", "lmss", "NotoSans-TLF", 
"PTSans-TLF",
+"tgadventor", "tgheros", "uop", 0 };
 
 const char * const known_typewriter_fonts[] = { "beramono", "cmtl", "cmtt",
-"courier", "lmtt", "luximono", "fourier", "libertineMono-type1", "lmodern",
+"courier", "lmtt", "luximono", "fourier", "libertineMono", 
"libertineMono-type1", "lmodern",
 "mathpazo", "mathptmx", "newcent", "NotoMono-TLF", "PTMono-TLF", "tgcursor", 
"txtt", 0 };
 
 const char * const known_math_fonts[] = { "eulervm", "newtxmath", 0};
@@ -734,22 +734,37 @@ void Preamble::handle_package(Parser , string const & 
name,
h_font_roman[0] = "libertine";
// this automatically invokes biolinum
h_font_sans[0] = "biolinum";
+   // as well as libertineMono
+   h_font_typewriter[0] = "libertine-mono";
if (opts == "osf")
h_font_osf = "true";
else if (opts == "lining")
h_font_osf = "false";
}
 
-   if (name == "libertine-type1") {
+   if (name == "libertineRoman" || name == "libertine-type1") {
h_font_roman[0] = "libertine";
-   // NOTE: contrary to libertine.sty, libertine-type1
-   // does not automatically invoke biolinum
+   // NOTE: contrary to libertine.sty, libertineRoman
+   // and libertine-type1 do not automatically invoke
+   // biolinum and libertineMono
if (opts == "lining")
h_font_osf = "false";
else if (opts == "osf")
h_font_osf = "true";
}
 
+   if (name == "MinionPro") {
+   h_font_roman[0] = "minionpro";
+   if (opts.find("lf") != string::npos)
+   h_font_osf = "false";
+   else
+   h_font_osf = "true";
+   if (opts.find("onlytext") != string::npos)
+   h_font_math[0] = "default";
+   else
+   h_font_math[0] = "auto";
+   }
+
if (name == "mathdesign") {
if (opts.find("charter") != string::npos)
h_font_roman[0] = "md-charter";
@@ -818,7 +833,7 @@ void Preamble::handle_package(Parser , string const & 
name,
}
}
 
-   if (name == "biolinum-type1") {
+   if (name == "biolinum" || name == "biolinum-type1") {
h_font_sans[0] = "biolinum";
// biolinum can have several options, e.g. [osf,scaled=0.97]
string::size_type pos = opts.find("osf");
@@ -847,7 +862,7 @@ void Preamble::handle_package(Parser , string const & 
name,
}
}
 
-   if (name == "libertineMono-type1")
+   if (name == "libertineMono" || name == "libertineMono-type1")
h_font_typewriter[0] = "libertine-mono";
 
if (name == "PTMono") {
diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt
index 9e99848..522c0ec 100644
--- a/src/tex2lyx/TODO.txt
+++ b/src/tex2lyx/TODO.txt
@@ -51,11 +51,7 @@ Format LaTeX featureLyX feature
 411support for polyglossia  \language_package  (the cases of 
no package, of babel and of custom package is supported)
 415automatic undertilde 

[LyX/2.2.x] Update tex2lyx tests

2018-03-11 Thread Juergen Spitzmueller
commit 93dd9cd22906fde82e4fa73df86de99e6dac5015
Author: Juergen Spitzmueller 
Date:   Sun Mar 11 09:11:31 2018 +0100

Update tex2lyx tests

Fixes: #10800.
---
 src/tex2lyx/test/test-structure.lyx.lyx |2 +-
 status.22x  |2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/tex2lyx/test/test-structure.lyx.lyx 
b/src/tex2lyx/test/test-structure.lyx.lyx
index feff755..2c7f2ac 100644
--- a/src/tex2lyx/test/test-structure.lyx.lyx
+++ b/src/tex2lyx/test/test-structure.lyx.lyx
@@ -212,7 +212,7 @@ This causes the
 \begin_inset Flex Flex:Strong
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
 logikalmkup
 \end_layout
 
diff --git a/status.22x b/status.22x
index eac9891..4b50e77 100644
--- a/status.22x
+++ b/status.22x
@@ -190,3 +190,5 @@ What's new
 
 * BUILD/INSTALLATION
 
+- Update tex2lyx tests (bug 10800).
+


[LyX/2.3.2-staging] tex2lyx: get rid of another large if-else if chain.

2018-03-11 Thread Juergen Spitzmueller
commit 5fc0dafac33f6244054d61f558fceead5b396932
Author: Juergen Spitzmueller 
Date:   Sat Mar 10 15:00:30 2018 +0100

tex2lyx: get rid of another large if-else if chain.

(cherry picked from commit 11e4a24e6edbd1f69b60a194b31ac2d7c4dd5034)
---
 src/tex2lyx/Preamble.cpp |  153 ++---
 1 files changed, 102 insertions(+), 51 deletions(-)

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 8565d59..4ad6bad 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -1451,14 +1451,18 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
 t.cat() == catBegin ||
 t.cat() == catEnd ||
 t.cat() == catAlign ||
-t.cat() == catParameter))
+t.cat() == catParameter)) {
h_preamble << t.cs();
+   continue;
+   }
 
-   else if (!in_lyx_preamble &&
-(t.cat() == catSpace || t.cat() == catNewline))
+   if (!in_lyx_preamble &&
+   (t.cat() == catSpace || t.cat() == catNewline)) {
h_preamble << t.asInput();
+   continue;
+   }
 
-   else if (t.cat() == catComment) {
+   if (t.cat() == catComment) {
static regex const islyxfile("%% LyX .* created this 
file");
static regex const usercommands("User specified LaTeX 
commands");
 
@@ -1483,18 +1487,22 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
in_lyx_preamble = false;
else if (!in_lyx_preamble)
h_preamble << t.asInput();
+   continue;
}
 
-   else if (t.cs() == "PassOptionsToPackage") {
+   if (t.cs() == "PassOptionsToPackage") {
string const poptions = p.getArg('{', '}');
string const package = p.verbatim_item();
extra_package_options_.insert(make_pair(package, 
poptions));
+   continue;
}
 
-   else if (t.cs() == "pagestyle")
+   if (t.cs() == "pagestyle") {
h_paperpagestyle = p.verbatim_item();
+   continue;
+   }
 
-   else if (t.cs() == "setdefaultlanguage") {
+   if (t.cs() == "setdefaultlanguage") {
xetex = true;
// We don't yet care about non-language variant options
// because LyX doesn't support this yet, see bug #8214
@@ -1517,22 +1525,25 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
h_language = p.verbatim_item();
//finally translate the poyglossia name to a LyX name
h_language = polyglossia2lyx(h_language);
+   continue;
}
 
-   else if (t.cs() == "setotherlanguage") {
+   if (t.cs() == "setotherlanguage") {
// We don't yet care about the option because LyX 
doesn't
// support this yet, see bug #8214
p.hasOpt() ? p.getOpt() : string();
p.verbatim_item();
+   continue;
}
 
-   else if (t.cs() == "setmainfont") {
+   if (t.cs() == "setmainfont") {
// we don't care about the option
p.hasOpt() ? p.getOpt() : string();
h_font_roman[1] = p.getArg('{', '}');
+   continue;
}
 
-   else if (t.cs() == "setsansfont" || t.cs() == "setmonofont") {
+   if (t.cs() == "setsansfont" || t.cs() == "setmonofont") {
// LyX currently only supports the scale option
string scale;
if (p.hasOpt()) {
@@ -1556,6 +1567,7 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
h_font_tt_scale[1] = scale;
h_font_typewriter[1] = p.getArg('{', '}');
}
+   continue;
}
 
else if (t.cs() == "date") {
@@ -1566,7 +1578,7 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
h_preamble << t.asInput() << '{' << argument << 
'}';
}
 
-   else if (t.cs() == "color") {
+   if (t.cs() == "color") {
string const space =
(p.hasOpt() ? p.getOpt() : string());
string argument = p.getArg('{', '}');
@@