commit 48344c587e49eb7add5256c489f8a4989908b967
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Sat Mar 15 13:51:10 2025 +0100

    Amend 9ffacb341d
    
    We need to consider DOS line endings (as produced by tex2lyx on Windows),
    otherwise we end up with stray "\r"s which break mathed parsing
    
    (cherry picked from commit 096d75b8fb27f06ea2c99d46d5521297b3dab694)
---
 src/mathed/InsetMathHull.cpp | 7 ++++++-
 status.24x                   | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 4a21457e0e..c9b4ab18e7 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -821,7 +821,12 @@ void InsetMathHull::usedMacros(MathData const & md, 
DocIterator const & pos,
                                // with legacy preview and tightpage (#13120).
                                // So remove all preceding and trailing line 
breaks
                                // and re-add one at the end of the snippet
-                               defs.insert(trim(macro_def.str(), "\n") + "\n");
+                               // Convert possible DOS line endings to prevent 
ending
+                               // up with stray "\r"s
+                               defs.insert(trim(subst(macro_def.str(),
+                                                      from_ascii("\r\n"),
+                                                      from_ascii("\n")),
+                                                "\n") + "\n");
                                asArray(data->definition(), ar);
                        }
                        usedMacros(ar, pos, macros, defs);
diff --git a/status.24x b/status.24x
index 367d7ad406..e51b37b800 100644
--- a/status.24x
+++ b/status.24x
@@ -78,6 +78,9 @@ What's new
 - Improve detection of removed documents. We did not distinguish between
   rewrite and removal in some cases (bug 12819).
 
+- Fix parsing error with math code when LyX file contains DOS line endings
+  (which might happen when importing via tex2lyx on Windows).
+
 
 * USER INTERFACE
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to