[LyX/2.4.x] tex2lyx: Fix two bugs in nomencl import

Juergen Spitzmueller spitz at lyx.org
Mon Jul 22 17:03:30 UTC 2024


commit 4a796889e9d62c8167c57fad460732109646a2a3
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Mon Jul 22 09:51:54 2024 +0200

    tex2lyx: Fix two bugs in nomencl import
    
    * The comment character % is made active to serve as an escape char
    * quotation marks need to be escaped
    
    (cherry picked from commit 5bc4c11fd601773a7ffba850524afa03eafe13f9)
---
 src/tex2lyx/text.cpp | 8 ++++++++
 status.24x           | 1 +
 2 files changed, 9 insertions(+)

diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 7c63b7679f..af0be81231 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -4946,10 +4946,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) {
diff --git a/status.24x b/status.24x
index 2be245c92d..7e4886fea3 100644
--- a/status.24x
+++ b/status.24x
@@ -84,6 +84,7 @@ What's new
 
 * TEX2LYX
 
+- Fix import of nomenclature entries which contain '%' or '"' characters.
 
 
 * LYXHTML


More information about the lyx-cvs mailing list