]> git.lyx.org Git - features.git/commitdiff
The lyx2lyx for the previous commit.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 11 Jun 2023 16:51:29 +0000 (12:51 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 11 Jun 2023 16:55:51 +0000 (12:55 -0400)
lib/lyx2lyx/lyx_2_4.py
src/version.h

index 20a19836f9af0c602e54af0a2e31fc65e4f8242d..5af5872b23d355c5685604daf5a4b395eb6c2ac5 100644 (file)
@@ -4969,6 +4969,37 @@ def revert_ack_theorems(document):
         document.del_local_layout(ackStar_theorem_def)
         document.del_local_layout(ack_theorem_def)
 
+def revert_empty_macro(document):
+    '''Remove macros with empty LaTeX part'''
+    i = 0
+    while True:
+        i = find_token(document.body, '\\begin_inset FormulaMacro', i)
+        if i == -1:
+            break
+        cmd = document.body[i+1]
+        if cmd[-3:] != "}{}" and cmd[-3:] != "]{}":
+            i += 1
+            continue
+        j = find_end_of_inset(document.body, i)
+        document.body[i:j+1] = []
+
+
+def convert_empty_macro(document):
+    '''In the unlikely event someone defined a macro with empty LaTeX, add {}'''
+    i = 0
+    while True:
+        i = find_token(document.body, '\\begin_inset FormulaMacro', i)
+        if i == -1:
+            break
+        cmd = document.body[i+1]
+        if cmd[-3:] != "}{}" and cmd[-3:] != "]{}":
+            i += 1
+            continue
+        newstr = cmd[:-2] + "{\\{\\}}"
+        document.body[i+1] = newstr
+        i += 1
+
+
 ##
 # Conversion hub
 #
@@ -5045,10 +5076,12 @@ convert = [
            [612, [convert_starred_refs]],
            [613, []],
            [614, [convert_hyper_other]],
-           [615, [convert_acknowledgment,convert_ack_theorems]]
+           [615, [convert_acknowledgment,convert_ack_theorems]],
+           [616, [convert_empty_macro]]
           ]
 
-revert =  [[614, [revert_ack_theorems,revert_acknowledgment]],
+revert =  [[615, [revert_empty_macro]],
+           [614, [revert_ack_theorems,revert_acknowledgment]],
            [613, [revert_hyper_other]],
            [612, [revert_familydefault]],
            [611, [revert_starred_refs]],
index 1bef62115d6c1f643f21a1dbe63e0907f5768200..c17c3d9c677c482e3ffa9055621a3b9273c7418c 100644 (file)
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 615 // spitz: acknowledgement > acknowledgment
-#define LYX_FORMAT_TEX2LYX 615
+#define LYX_FORMAT_LYX 616 // forenr: empty macros
+#define LYX_FORMAT_TEX2LYX 616
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER