commit d716df7b65c1cea34df44a15c705bc83aca9c527
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Wed Aug 6 18:15:16 2025 +0200

    tex2lyx: do not choke on unsupported advances index commands (part of 
#13183)
    
    Import them as ERT
---
 src/tex2lyx/Preamble.cpp |  2 +-
 src/tex2lyx/text.cpp     | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index e6b2c3d793..7d73195ce5 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -2980,7 +2980,7 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
                        continue;
                }
 
-               if (t.cs() == "makeindex") {
+               if (t.cs() == "makeindex" && !p.hasOpt()) {
                        // LyX will re-add this if a print index command is 
found
                        p.skip_spaces();
                        continue;
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index e5bb6279f1..ec4da204b0 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -5108,7 +5108,16 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                        continue;
                }
 
-               if (t.cs() == "index" ||
+               if (t.cs() == "index" && p.hasOpt()) {
+                       // advanced index command (maybe from package imakeidx)
+                       // output as ERT
+                       string const opt = p.getOpt();
+                       output_ert_inset(os, t.asInput() + opt + "{" +
+                                        p.verbatim_item() + '}', context);
+                       continue;
+               }
+
+               if ((t.cs() == "index") ||
                    (t.cs() == "sindex" && preamble.use_indices() == "true")) {
                        context.check_layout(os);
                        string const arg = (t.cs() == "sindex" && p.hasOpt()) ?
@@ -5163,6 +5172,14 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                        continue;
                }
 
+               if (t.cs() == "printindex" && p.hasOpt() && 
preamble.use_indices() != "true") {
+                       // advanced printindex command (maybe from package 
imakeidx)
+                       // output as ERT
+                       string const opt = p.getOpt();
+                       output_ert_inset(os, t.asInput() + opt, context);
+                       continue;
+               }
+
                if (t.cs() == "printindex" || t.cs() == "printsubindex") {
                        context.check_layout(os);
                        string commandname = t.cs();
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to