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

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

Fixes: #8685
This commit is contained in:
Juergen Spitzmueller 2018-08-28 10:31:29 +02:00
parent 0cab640035
commit da62299f37

View File

@ -1595,6 +1595,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)
@ -6092,8 +6100,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);
}
}
}
}
}