]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx_2_4.py
RELEASE-NOTES: document encoding defaults change
[lyx.git] / lib / lyx2lyx / lyx_2_4.py
index 6e69e3605e5a32d344340f51f4fd733b8c4089fb..fa61754f80a88d186023aaee6d55f467c22330a4 100644 (file)
@@ -283,6 +283,22 @@ def revert_fonts(document, fm, fontmap):
 ###
 ###############################################################################
 
+def convert_inputencoding_namechange(document):
+    " Rename inputencoding settings. "
+    i = find_token(document.header, "\\inputencoding", 0)
+    if i == -1:
+        return
+    s = document.header[i].replace("auto", "auto-legacy")
+    document.header[i] = s.replace("default", "auto-legacy-plain")
+
+def revert_inputencoding_namechange(document):
+    " Rename inputencoding settings. "
+    i = find_token(document.header, "\\inputencoding", 0)
+    if i == -1:
+        return
+    s = document.header[i].replace("auto-legacy-plain", "default")
+    document.header[i] = s.replace("auto-legacy", "auto")
+
 def convert_notoFonts(document):
     " Handle Noto fonts definition to LaTeX "
 
@@ -1419,14 +1435,23 @@ def revert_lformatinfo(document):
 
 
 def convert_hebrew_parentheses(document):
-    " Don't reverse parentheses in Hebrew text"
-    current_language = document.language
+    """ Swap opening/closing parentheses in Hebrew text. 
+    
+    Up to LyX 2.4, ")" was used as opening parenthesis and
+    "(" as closing parenthesis for Hebrew in the LyX source.
+    """
+    
+    print("convert hebrew parentheses")
+    current_languages = [document.language]
     for i, line in enumerate(document.body):
         if line.startswith('\\lang '):
-            current_language = line[len('\\lang '):]
+            current_languages[-1] = line.lstrip('\\lang ')
+        elif line.startswith('\\begin_layout'):
+            current_languages.append(current_languages[-1])
+            print (line, current_languages[-1])      
         elif line.startswith('\\end_layout'):
-            current_language = document.language
-        elif current_language == 'hebrew' and not line.startswith('\\'):
+            current_languages.pop()
+        elif current_languages[-1] == 'hebrew' and not line.startswith('\\'):
             document.body[i] = line.replace('(','\x00').replace(')','(').replace('\x00',')')
 
 
@@ -1635,10 +1660,11 @@ convert = [
            [569, []],
            [570, []],
            [571, []],
-           [572, [convert_notoFonts]]  # Added options thin, light, extralight for Noto
+           [572, [convert_notoFonts]],  # Added options thin, light, extralight for Noto
+           [573, [convert_inputencoding_namechange]],
           ]
 
-revert =  [
+revert =  [[572, [revert_inputencoding_namechange]],
            [571, [revert_notoFonts]],
            [570, [revert_cmidruletrimming]],
            [569, [revert_bibfileencodings]],