commit 0a89b08f687dfeb7b687b54eab98ae18cc889883
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
    (cherry picked from commit da62299f3773dc8412a49953fb366bd804c360a7)
---
 src/tex2lyx/text.cpp |   20 +++++++++++++++++++-
 status.23x           |    4 +++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index d79ad8a..b85020d 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -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);
+                               }
+                       }
                }
        }
 }
diff --git a/status.23x b/status.23x
index bfeef26..ef9ee2c 100644
--- a/status.23x
+++ b/status.23x
@@ -99,7 +99,9 @@ What's new
 - Consider required modules when checking for layout definitions in modules
   (bug 11156).
 
-- Fix import of Arabic polyglossia environment (part of  bug 10111).
+- Fix import of Arabic polyglossia environment (part of bug 10111).
+
+- Fix import of unknown commands'/environments' options (bug 8685).
 
 
 * ADVANCED FIND AND REPLACE

Reply via email to