[LyX/master] Add conversion routine for format 612.
Richard Kimberly Heck
rikiheck at lyx.org
Mon Dec 5 18:50:49 UTC 2022
commit 4966da6864df0f53a12fe1453ce749452431df88
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date: Mon Dec 5 14:45:40 2022 -0500
Add conversion routine for format 612.
I forgot that this is needed, because the new parameter is written to
the file no matter its value.
Also, fix two typos in the reversion routine.
---
lib/lyx2lyx/lyx_2_4.py | 32 ++++++++++++++++++++++++++------
1 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
index e10475b..22acfe4 100644
--- a/lib/lyx2lyx/lyx_2_4.py
+++ b/lib/lyx2lyx/lyx_2_4.py
@@ -4571,11 +4571,11 @@ def revert_starred_refs(document):
continue
# If we are not using hyperref, then we just need to delete the line
if not use_hyperref:
- i = find_token(document.body, "nolink", i, e)
+ i = find_token(document.body, "nolink", i, end)
if i == -1:
continue
del document.body[i]
- i = e - 1
+ i = end - 1
continue
# If we are using hyperref, then we'll need to do more.
in_inset = True
@@ -4620,9 +4620,29 @@ def revert_starred_refs(document):
nolink = (tmp == "true")
nolinkline = i
i += 1
-
-
-
+
+
+def convert_starred_refs(document):
+ i = 0
+ while True:
+ i = find_token(document.body, "\\begin_inset CommandInset ref", i)
+ if i == -1:
+ break
+ start = i
+ end = find_end_of_inset(document.body, i)
+ if end == -1:
+ document.warning("Malformed LyX document: Can't find end of inset at line %d" % i)
+ i += 1
+ continue
+ noprefixline = document.body[i + 5]
+ document.warning(noprefixline)
+ if not noprefixline.startswith("noprefix"):
+ document.warning("Malformed LyX document: No noprefix line. We will do the best we can.")
+ newlineat = end - 2
+ else:
+ newlineat = i + 6
+ document.body.insert(newlineat, "nolink \"false\"")
+ i = end + 1
##
@@ -4698,7 +4718,7 @@ convert = [
[609, []],
[610, []],
[611, []],
- [612, []]
+ [612, [convert_starred_refs]]
]
revert = [[611, [revert_starred_refs]],
More information about the lyx-cvs
mailing list