]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx_1_6.py
Prepare for attic movement.
[lyx.git] / lib / lyx2lyx / lyx_1_6.py
index 1d819e1ab3c2ddd91129b9690d5088c0e73b5d89..bfe4113059dabf613c95319fdf3095fda1be8f1e 100644 (file)
@@ -1536,6 +1536,22 @@ def convert_usorbian(document):
         j = j + 1
 
 
+def convert_macro_global(document):
+    "Remove TeX code command \global when it is in front of a macro"
+    # math macros are nowadays already defined \global, so that an additional
+    # \global would make the document uncompilable, see
+    # http://bugzilla.lyx.org/show_bug.cgi?id=5371
+    i = 0
+    while True:
+        i = find_token(document.body, "\\begin_inset FormulaMacro", i)
+        if i != -1 and i > 13:
+            if document.body[i-6] == "global":
+                del document.body[i-13 : i]
+        else:
+            return
+        i = i - 12
+
+
 def revert_macro_optional_params(document):
     "Convert macro definitions with optional parameters into ERTs"
     # Stub to convert macro definitions with one or more optional parameters
@@ -2989,6 +3005,28 @@ def convert_default_options(document):
     document.header.insert(i, '\\use_default_options false')
 
 
+def revert_backref_options(document):
+    ' Revert option pdf_backref=page to pagebackref '
+    i = find_token(document.header, "\\pdf_backref page", 0)
+    if i != -1:
+        document.header[i] = "\\pdf_pagebackref true"
+
+
+def convert_backref_options(document):
+    ' We have changed the option pagebackref to backref=true '
+    i = find_token(document.header, "\\pdf_pagebackref true", 0)
+    if i != -1:
+        document.header[i] = "\\pdf_backref page"
+    j = find_token(document.header, "\\pdf_pagebackref false", 0)
+    if j != -1:
+        del document.header[j]
+    # backref=true was not a valid option, we meant backref=section
+    k = find_token(document.header, "\\pdf_backref true", 0)
+    if k != -1 and i != -1:
+        del document.header[k]
+    elif k != -1 and j != -1:
+        document.header[k] = "\\pdf_backref section"
+
 ##
 # Conversion hub
 #
@@ -3015,7 +3053,7 @@ convert = [[277, [fix_wrong_tables]],
            [295, [convert_htmlurl, convert_url]],
            [296, [convert_include]],
            [297, [convert_usorbian]],
-           [298, []],
+           [298, [convert_macro_global]],
            [299, []],
            [300, []],
            [301, []],
@@ -3060,10 +3098,12 @@ convert = [[277, [fix_wrong_tables]],
            [340, [add_plain_layout]],
            [341, []],
            [342, []],
-           [343, [convert_default_options]]
+           [343, [convert_default_options]],
+           [344, [convert_backref_options]]
           ]
 
-revert =  [[342, [revert_default_options]],
+revert =  [[343, [revert_backref_options]],
+           [342, [revert_default_options]],
            [341, [revert_mongolian]],
            [340, [revert_tabulators, revert_tabsize]],
            [339, []],