]> git.lyx.org Git - lyx.git/commitdiff
lyx2lyx/lyx_1_6.py: fix lyx2lyx for MathMacro conversions, fixes part of http://bugzi...
authorUwe Stöhr <uwestoehr@web.de>
Sun, 19 Oct 2008 10:50:32 +0000 (10:50 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Sun, 19 Oct 2008 10:50:32 +0000 (10:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26964 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_1_6.py

index a82c266d13b55334d4e5ac9061f226665ff080cc..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
@@ -3037,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, []],