]> git.lyx.org Git - lyx.git/commitdiff
tex2lyx: Fix two bugs in nomencl import
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 22 Jul 2024 07:51:54 +0000 (09:51 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 22 Jul 2024 07:51:54 +0000 (09:51 +0200)
* The comment character % is made active to serve as an escape char
* quotation marks need to be escaped

src/tex2lyx/text.cpp

index cd16531d18576e5fb73d532a852397e6c0ee903d..57fc2f0668df43f8694a5e1e8a66ef36d0f18094 100644 (file)
@@ -5009,10 +5009,18 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        string prefix = convert_literate_command_inset_arg(p.getArg('[', ']'));
                        if (!prefix.empty())
                                os << "prefix " << '"' << prefix << '"' << "\n";
+                       // nomencl activates %
+                       CatCode savecc = p.catcode('%');
+                       p.setCatcode('%', catActive);
                        string symbol = p.verbatim_item();
+                       p.setCatcode('%', savecc);
+                       // escape quotation marks
+                       symbol = subst(symbol, "\"", "\\\"");
                        pair<bool, string> sym = convert_latexed_command_inset_arg(symbol);
                        bool literal = !sym.first;
                        string description = p.verbatim_item();
+                       // escape quotation marks
+                       description = subst(description, "\"", "\\\"");
                        pair<bool, string> desc = convert_latexed_command_inset_arg(description);
                        literal |= !desc.first;
                        if (literal) {