commit da62299f3773dc8412a49953fb366bd804c360a7
Author: Juergen Spitzmueller <[email protected]>
Date: Tue Aug 28 10:31:29 2018 +0200
tex2lyx: fix import of unknown commands'/environments' options
If we detect options via hasOpt(), output the brackets as ERT.
Fixes: #8685
---
src/tex2lyx/text.cpp | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 34bf04d..e23b959 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -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);
+ }
+ }
}
}
}