commit c3f98d1fa4423f0d7cb50804f18cfad56f12a468
Author: Richard Kimberly Heck <[email protected]>
Date: Sun Jun 11 12:51:29 2023 -0400
The lyx2lyx for the previous commit.
---
lib/lyx2lyx/lyx_2_4.py | 37 +++++++++++++++++++++++++++++++++++--
src/version.h | 4 ++--
2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
index 20a1983..5af5872 100644
--- a/lib/lyx2lyx/lyx_2_4.py
+++ b/lib/lyx2lyx/lyx_2_4.py
@@ -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]],
diff --git a/src/version.h b/src/version.h
index 1bef621..c17c3d9 100644
--- a/src/version.h
+++ b/src/version.h
@@ -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
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs