mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 02:49:46 +00:00
Fix data loss in user guide conversion to 2.0.x
When doing the lyx2lyx round trip of the 2.0.8 user guide from format 413 -> 474 -> 413 you do not get a zero diff. The most important problem is caused by the conversion of the argument insets to the old syntax: This conversion adds an additional empty line (harmless), and it destroys the document structure if the first inset in e.g. a subsection is not an argument inset, but e.g. an index or label inset. The fix is quite easy: Ensure that the paragraph begin is set to the first argument inset.
This commit is contained in:
parent
e754d00faa
commit
28bde98d76
@ -1552,12 +1552,18 @@ def revert_latexargs(document):
|
|||||||
continue
|
continue
|
||||||
parbeg = parent[1]
|
parbeg = parent[1]
|
||||||
parend = parent[2]
|
parend = parent[2]
|
||||||
realparbeg = parent[3]
|
# Do not set realparbeg to parent[3], since this does not work if we
|
||||||
|
# have another inset (e.g. label or index) before the first argument
|
||||||
|
# inset (this is the case in the user guide of LyX 2.0.8)
|
||||||
|
realparbeg = -1
|
||||||
# Collect all arguments in this paragraph
|
# Collect all arguments in this paragraph
|
||||||
realparend = parend
|
realparend = parend
|
||||||
for p in range(parbeg, parend):
|
for p in range(parbeg, parend):
|
||||||
m = rx.match(document.body[p])
|
m = rx.match(document.body[p])
|
||||||
if m:
|
if m:
|
||||||
|
if realparbeg < 0:
|
||||||
|
# This is the first argument inset
|
||||||
|
realparbeg = p
|
||||||
val = int(m.group(1))
|
val = int(m.group(1))
|
||||||
j = find_end_of_inset(document.body, p)
|
j = find_end_of_inset(document.body, p)
|
||||||
# Revert to old syntax
|
# Revert to old syntax
|
||||||
@ -1573,8 +1579,11 @@ def revert_latexargs(document):
|
|||||||
del document.body[p : j + 1]
|
del document.body[p : j + 1]
|
||||||
if p >= realparend:
|
if p >= realparend:
|
||||||
break
|
break
|
||||||
|
if realparbeg < 0:
|
||||||
|
# No argument inset found
|
||||||
|
realparbeg = parent[3]
|
||||||
# Now sort the arg insets
|
# Now sort the arg insets
|
||||||
subst = [""]
|
subst = []
|
||||||
for f in sorted(args):
|
for f in sorted(args):
|
||||||
subst += args[f]
|
subst += args[f]
|
||||||
del args[f]
|
del args[f]
|
||||||
|
@ -67,6 +67,8 @@ What's new
|
|||||||
- Add \justification parameter when converting to 2.1 format (avoids when
|
- Add \justification parameter when converting to 2.1 format (avoids when
|
||||||
converting back to 2.0 format).
|
converting back to 2.0 format).
|
||||||
|
|
||||||
|
- Fix conversion of argument insets fromn 2.1 to 2.0 format.
|
||||||
|
|
||||||
|
|
||||||
* USER INTERFACE
|
* USER INTERFACE
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user