]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx_1_6.py
- support for polytonic Greek, fileformat incremented to 338, fixes bug 4969, patch...
[lyx.git] / lib / lyx2lyx / lyx_1_6.py
index e352014f17a34db6bac741a049198ab53bf0b6e7..138ccae5884df6d63ff318d2e1a7ade5184ca8d7 100644 (file)
@@ -2504,34 +2504,38 @@ def convert_display_enum(document):
     " Convert 'display foo' to 'display false/true'"
     i = 0
     while True:
-        i = find_token(document.body, "display", i)
+        i = find_token(document.body, "\tdisplay", i)
         if i == -1:
             return
-        if check_token(i, "none"):
+        val = get_value(document.body, 'display', i)
+        if val == "none":
             document.body[i] = document.body[i].replace('none', 'false')
-        if check_token(i, "default"):
+        if val == "default":
             document.body[i] = document.body[i].replace('default', 'true')
-        if check_token(i, "monochrome"):
+        if val == "monochrome":
             document.body[i] = document.body[i].replace('monochrome', 'true')
-        if check_token(i, "grayscale"):
+        if val == "grayscale":
             document.body[i] = document.body[i].replace('grayscale', 'true')
-        if check_token(i, "color"):
+        if val == "color":
             document.body[i] = document.body[i].replace('color', 'true')
-        if check_token(i, "preview"):
+        if val == "preview":
             document.body[i] = document.body[i].replace('preview', 'true')
+        i += 1
 
 
 def revert_display_enum(document):
     " Revert 'display false/true' to 'display none/color'"
     i = 0
     while True:
-        i = find_token(document.body, "display", i)
+        i = find_token(document.body, "\tdisplay", i)
         if i == -1:
             return
-        if check_token(i, "false"):
+        val = get_value(document.body, 'display', i)
+        if val == "false":
             document.body[i] = document.body[i].replace('false', 'none')
-        if check_token(i, "true"):
+        if val == "true":
             document.body[i] = document.body[i].replace('true', 'default')
+        i += 1
 
 
 def remove_fontsCJK(document):
@@ -2542,41 +2546,59 @@ def remove_fontsCJK(document):
 
 
 def convert_plain_layout(document):
-       " Convert 'PlainLayout' to 'Plain Layout'" 
-       i = 0
-       while True:
-               i = find_token(document.body, '\\begin_layout PlainLayout', i)
-               if i == -1:
-                       return
-               document.body[i] = document.body[i].replace('\\begin_layout PlainLayout', \
-                                                           '\\begin_layout Plain Layout')
-               i += 1
+    " Convert 'PlainLayout' to 'Plain Layout'" 
+    i = 0
+    while True:
+        i = find_token(document.body, '\\begin_layout PlainLayout', i)
+        if i == -1:
+            return
+        document.body[i] = document.body[i].replace('\\begin_layout PlainLayout', \
+          '\\begin_layout Plain Layout')
+        i += 1
 
 
 def revert_plain_layout(document):
-       " Convert 'PlainLayout' to 'Plain Layout'" 
-       i = 0
-       while True:
-               i = find_token(document.body, '\\begin_layout Plain Layout', i)
-               if i == -1:
-                       return
-               document.body[i] = document.body[i].replace('\\begin_layout Plain Layout', \
-                                                           '\\begin_layout PlainLayout')
-               i += 1
+    " Convert 'PlainLayout' to 'Plain Layout'" 
+    i = 0
+    while True:
+        i = find_token(document.body, '\\begin_layout Plain Layout', i)
+        if i == -1:
+            return
+        document.body[i] = document.body[i].replace('\\begin_layout Plain Layout', \
+          '\\begin_layout PlainLayout')
+        i += 1
+
 
 def revert_plainlayout(document):
-       " Convert 'PlainLayout' to 'Plain Layout'" 
-       i = 0
-       while True:
-               i = find_token(document.body, '\\begin_layout PlainLayout', i)
-               if i == -1:
-                       return
-               # This will be incorrect for some document classes, since Standard is not always
-               # the default. But (a) it is probably the best we can do and (b) it will actually
-               # work, in fact, since an unknown layout will be converted to default.
-               document.body[i] = document.body[i].replace('\\begin_layout PlainLayout', \
-                                                           '\\begin_layout Standard')
-               i += 1
+    " Convert 'PlainLayout' to 'Plain Layout'" 
+    i = 0
+    while True:
+        i = find_token(document.body, '\\begin_layout PlainLayout', i)
+        if i == -1:
+            return
+        # This will be incorrect for some document classes, since Standard is not always
+        # the default. But (a) it is probably the best we can do and (b) it will actually
+        # work, in fact, since an unknown layout will be converted to default.
+        document.body[i] = document.body[i].replace('\\begin_layout PlainLayout', \
+          '\\begin_layout Standard')
+        i += 1
+
+
+def revert_polytonicgreek(document):
+    "Set language polytonic Greek to Greek"
+    i = 0
+    if document.language == "polutonikogreek":
+        document.language = "greek"
+        i = find_token(document.header, "\\language", 0)
+        if i != -1:
+            document.header[i] = "\\language greek"
+    j = 0
+    while True:
+        j = find_token(document.body, "\\lang polutonikogreek", j)
+        if j == -1:
+            return
+        document.body[j] = document.body[j].replace("\\lang polutonikogreek", "\\lang greek")
+        j = j + 1
 
 
 ##
@@ -2645,9 +2667,11 @@ convert = [[277, [fix_wrong_tables]],
            [335, [convert_InsetSpace]],
            [336, []],
            [337, [convert_display_enum]],
+           [338, []],
           ]
 
-revert =  [[336, [revert_display_enum]],
+revert =  [[337, [revert_polytonicgreek]],
+           [336, [revert_display_enum]],
            [335, [remove_fontsCJK]],
            [334, [revert_InsetSpace]],
            [333, [revert_paper_sizes]],