mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Fix math package conversion to 2.0 format
When doing the lyx2lyx round trip of the 2.0.8 user guide from format 413 -> 474 -> 413 you get an invalid document, because the math packages mhchem and undertilde are incorrectly converted. It turned out that the old reversion code did only work for particular package oderings. The new one works for abitrary sorted packages.
This commit is contained in:
parent
28bde98d76
commit
d47a556b46
@ -546,18 +546,26 @@ def convert_use_packages(document):
|
|||||||
|
|
||||||
def revert_use_packages(document):
|
def revert_use_packages(document):
|
||||||
"use_package xxx yyy => use_xxx yyy"
|
"use_package xxx yyy => use_xxx yyy"
|
||||||
packages = ["amsmath", "esint", "mathdots", "mhchem", "undertilde"]
|
packages = ["amsmath", "esint", "mhchem", "mathdots", "undertilde"]
|
||||||
# the order is arbitrary for the use_package version, and not all packages need to be given.
|
# the order is arbitrary for the use_package version, and not all packages need to be given.
|
||||||
# Ensure a complete list and correct order (important for older LyX versions and especially lyx2lyx)
|
# Ensure a complete list and correct order (important for older LyX versions and especially lyx2lyx)
|
||||||
j = 0
|
# first loop: find line with first package
|
||||||
|
j = -1
|
||||||
for p in packages:
|
for p in packages:
|
||||||
regexp = re.compile(r'(\\use_package\s+%s)' % p)
|
regexp = re.compile(r'(\\use_package\s+%s)' % p)
|
||||||
i = find_re(document.header, regexp, j)
|
i = find_re(document.header, regexp, 0)
|
||||||
|
if i != -1 and (j < 0 or i < j):
|
||||||
|
j = i
|
||||||
|
# second loop: replace or insert packages in front of all existing ones
|
||||||
|
for p in packages:
|
||||||
|
regexp = re.compile(r'(\\use_package\s+%s)' % p)
|
||||||
|
i = find_re(document.header, regexp, 0)
|
||||||
if i != -1:
|
if i != -1:
|
||||||
value = get_value(document.header, "\\use_package %s" % p, i).split()[1]
|
value = get_value(document.header, "\\use_package %s" % p, i).split()[1]
|
||||||
del document.header[i]
|
del document.header[i]
|
||||||
j = i
|
document.header.insert(j, "\\use_%s %s" % (p, value))
|
||||||
document.header.insert(j, "\\use_%s %s" % (p, value))
|
else:
|
||||||
|
document.header.insert(j, "\\use_%s 1" % p)
|
||||||
j += 1
|
j += 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +67,9 @@ 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.
|
- Fix conversion of argument insets from 2.1 to 2.0 format.
|
||||||
|
|
||||||
|
- Fix use math package settings conversion from 2.1 to 2.0 format.
|
||||||
|
|
||||||
|
|
||||||
* USER INTERFACE
|
* USER INTERFACE
|
||||||
|
Loading…
Reference in New Issue
Block a user