]> git.lyx.org Git - features.git/commitdiff
lyx2lyx: skip mathed in convert_hebrew_parentheses (#12824)
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 4 Jul 2023 05:37:06 +0000 (07:37 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 4 Jul 2023 05:37:06 +0000 (07:37 +0200)
Those have not been swapped in Hebrew.

lib/lyx2lyx/lyx_2_4.py

index a295e0a4b82d15505b0233ff8a37dd26c51c37cb..8c0b9c303908fec1f3f9b78f28a81ec0c0889a76 100644 (file)
@@ -1529,7 +1529,9 @@ def convert_hebrew_parentheses(document):
     """
     # print("convert hebrew parentheses")
     current_languages = [document.language]
-    for i, line in enumerate(document.body):
+    i = 0
+    while i < len(document.body):
+        line = document.body[i]
         if line.startswith('\\lang '):
             current_languages[-1] = line.lstrip('\\lang ')
         elif line.startswith('\\begin_layout'):
@@ -1537,8 +1539,13 @@ def convert_hebrew_parentheses(document):
             # print (line, current_languages[-1])
         elif line.startswith('\\end_layout'):
             current_languages.pop()
+        elif line.startswith('\\begin_inset Formula'):
+            # In math, parentheses must not be changed
+            i = find_end_of_inset(document.body, i)
+            continue
         elif current_languages[-1] == 'hebrew' and not line.startswith('\\'):
             document.body[i] = line.replace('(','\x00').replace(')','(').replace('\x00',')')
+        i += 1
 
 
 def revert_hebrew_parentheses(document):