]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx_2_1.py
Add system/local icon to available modules list
[lyx.git] / lib / lyx2lyx / lyx_2_1.py
index c8500c779e51632109ec343a8b88eb889d52de63..8838a64042918cc1d961d1b61736f659e3bb9680 100644 (file)
@@ -34,7 +34,7 @@ from parser_tools import count_pars_in_inset, del_complete_lines, del_token, \
   #find_end_of_inset, find_end_of_layout, \
   #is_in_inset, del_token, check_token
 
-from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert
+from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert, revert_language
 
 #from lyx2lyx_tools import insert_to_preamble, \
 #  lyx2latex, latex_length, revert_flex_inset, \
@@ -556,8 +556,6 @@ def handle_longtable_captions(document, forward):
                     get_option_value(document.body[begin_row], 'endlastfoot') != 'true'):
                     document.body[begin_row] = set_option_value(document.body[begin_row], 'caption', 'true", endfirsthead="true')
             elif get_option_value(document.body[begin_row], 'caption') == 'true':
-                if get_option_value(document.body[begin_row], 'endfirsthead') == 'true':
-                    document.body[begin_row] = set_option_value(document.body[begin_row], 'endfirsthead', 'false')
                 if get_option_value(document.body[begin_row], 'endhead') == 'true':
                     document.body[begin_row] = set_option_value(document.body[begin_row], 'endhead', 'false')
                 if get_option_value(document.body[begin_row], 'endfoot') == 'true':
@@ -1171,24 +1169,16 @@ def revert_ancientgreek(document):
 def revert_languages(document):
     "Set the document language for new supported languages to English"
 
-    languages = [
-                 "coptic", "divehi", "hindi", "kurmanji", "lao", "marathi", "occitan", "sanskrit",
-                 "syriac", "tamil", "telugu", "urdu"
-                ]
-    for n in range(len(languages)):
-        if document.language == languages[n]:
-            document.language = "english"
-            i = find_token(document.header, "\\language", 0)
-            if i != -1:
-                document.header[i] = "\\language english"
-        j = 0
-        while j < len(document.body):
-            j = find_token(document.body, "\\lang " + languages[n], j)
-            if j != -1:
-                document.body[j] = document.body[j].replace("\\lang " + languages[n], "\\lang english")
-                j += 1
-            else:
-                j = len(document.body)
+    # polyglossia-only
+    polyglossia_languages = ["coptic", "divehi", "hindi", "lao", "marathi",
+                             "occitan", "sanskrit", "syriac", "tamil",
+                             "telugu", "urdu"]
+    # babel-only
+    babel_languages = ["kurmanji"]
+    for lang in polyglossia_languages:
+        revert_language(document, lang, "", lang)
+    for lang in babel_languages:
+        revert_language(document, lang, lang, "")
 
 
 def convert_armenian(document):
@@ -3659,23 +3649,22 @@ def convert_captionlayouts(document):
         "Bicaption" : "Bicaption",
         }
 
-    i = 0
-    while True:
-        i = find_token(document.body, "\\begin_layout", i)
-        if i == -1:
-            return
-        val = get_value(document.body, "\\begin_layout", i)
-        if val in list(caption_dict.keys()):
+    for captype in caption_dict.keys():
+        i = 0
+        while True:
+            i = find_token(document.body, "\\begin_layout " + captype, i)
+            if i == -1:
+                break
             j = find_end_of_layout(document.body, i)
             if j == -1:
                 document.warning("Malformed LyX document: Missing `\\end_layout'.")
-                return
+                break
 
             document.body[j:j] = ["\\end_layout", "", "\\end_inset", "", ""]
             document.body[i:i+1] = ["\\begin_layout %s" % document.default_layout,
-                                    "\\begin_inset Caption %s" % caption_dict[val], "",
+                                    "\\begin_inset Caption %s" % caption_dict[captype], "",
                                     "\\begin_layout %s" % document.default_layout]
-        i += 1
+            i = j + 1
 
 
 def revert_captionlayouts(document):
@@ -4564,19 +4553,7 @@ def revert_aa2(document):
 def revert_tibetan(document):
     "Set the document language for Tibetan to English"
 
-    if document.language == "tibetan":
-        document.language = "english"
-        i = find_token(document.header, "\\language", 0)
-        if i != -1:
-            document.header[i] = "\\language english"
-    j = 0
-    while j < len(document.body):
-        j = find_token(document.body, "\\lang tibetan", j)
-        if j != -1:
-            document.body[j] = document.body[j].replace("\\lang tibetan", "\\lang english")
-            j += 1
-        else:
-            j = len(document.body)
+    revert_language(document, "tibetan", "", "tibetan")
 
 
 #############