tex2lyx: fix import of unknown commands'/environments' options

If we detect options via hasOpt(), output the brackets as ERT.

Fixes: #8685
(cherry picked from commit da62299f37)
This commit is contained in:
Juergen Spitzmueller 2018-08-28 10:31:29 +02:00
parent 93f3727b53
commit 0a89b08f68
2 changed files with 22 additions and 2 deletions

View File

@ -1576,6 +1576,14 @@ void parse_unknown_environment(Parser & p, string const & name, ostream & os,
if (specialfont)
parent_context.new_layout_allowed = false;
output_ert_inset(os, "\\begin{" + name + "}", parent_context);
// Try to handle options: Look if we have an optional arguments,
// and if so, put the brackets in ERT.
while (p.hasOpt()) {
p.get_token(); // eat '['
output_ert_inset(os, "[", parent_context);
os << parse_text_snippet(p, FLAG_BRACK_LAST, outer, parent_context);
output_ert_inset(os, "]", parent_context);
}
parse_text_snippet(p, os, flags, outer, parent_context);
output_ert_inset(os, "\\end{" + name + "}", parent_context);
if (specialfont)
@ -5849,8 +5857,18 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
p.get_token(); // Eat '*'
name += '*';
}
if (!parse_command(name, p, os, outer, context))
if (!parse_command(name, p, os, outer, context)) {
output_ert_inset(os, name, context);
// Try to handle options of unknown commands:
// Look if we have an optional arguments,
// and if so, put the brackets in ERT.
while (p.hasOpt()) {
p.get_token(); // eat '['
output_ert_inset(os, "[", context);
os << parse_text_snippet(p, FLAG_BRACK_LAST, outer, context);
output_ert_inset(os, "]", context);
}
}
}
}
}

View File

@ -101,6 +101,8 @@ What's new
- Fix import of Arabic polyglossia environment (part of bug 10111).
- Fix import of unknown commands'/environments' options (bug 8685).
* ADVANCED FIND AND REPLACE