]> 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 39b4b3fd6af9172bd18f31eb3113cdc1b37b3d16..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
@@ -2990,14 +3006,10 @@ def convert_default_options(document):
 
 
 def revert_backref_options(document):
-    ' Remove pageref additional options '
+    ' 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"
-        return
-    j = find_token(document.header, "\\pdf_backref", 0)
-    if j != -1:
-        del document.header[j]
 
 
 def convert_backref_options(document):
@@ -3008,6 +3020,12 @@ def convert_backref_options(document):
     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
@@ -3035,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, []],