mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
Fix reversion of mathtools xarrows (bug #9620).
This commit is contained in:
parent
a7a43d0866
commit
aa4d41d282
@ -292,17 +292,20 @@ def revert_swissgerman(document):
|
|||||||
j = j + 1
|
j = j + 1
|
||||||
|
|
||||||
|
|
||||||
def revert_use_package(document, pkg, commands, oldauto):
|
def revert_use_package(document, pkg, commands, oldauto, supported):
|
||||||
# oldauto defines how the version we are reverting to behaves:
|
# oldauto defines how the version we are reverting to behaves:
|
||||||
# if it is true, the old version uses the package automatically.
|
# if it is true, the old version uses the package automatically.
|
||||||
# if it is false, the old version never uses the package.
|
# if it is false, the old version never uses the package.
|
||||||
|
# If "supported" is true, the target version also supports this
|
||||||
|
# package natively.
|
||||||
regexp = re.compile(r'(\\use_package\s+%s)' % pkg)
|
regexp = re.compile(r'(\\use_package\s+%s)' % pkg)
|
||||||
i = find_re(document.header, regexp, 0)
|
p = find_re(document.header, regexp, 0)
|
||||||
value = "1" # default is auto
|
value = "1" # default is auto
|
||||||
if i != -1:
|
if p != -1:
|
||||||
value = get_value(document.header, "\\use_package" , i).split()[1]
|
value = get_value(document.header, "\\use_package" , p).split()[1]
|
||||||
del document.header[i]
|
if not supported:
|
||||||
if value == "2": # on
|
del document.header[p]
|
||||||
|
if value == "2" and not supported: # on
|
||||||
add_to_preamble(document, ["\\usepackage{" + pkg + "}"])
|
add_to_preamble(document, ["\\usepackage{" + pkg + "}"])
|
||||||
elif value == "1" and not oldauto: # auto
|
elif value == "1" and not oldauto: # auto
|
||||||
i = 0
|
i = 0
|
||||||
@ -318,7 +321,10 @@ def revert_use_package(document, pkg, commands, oldauto):
|
|||||||
code = "\n".join(document.body[i:j])
|
code = "\n".join(document.body[i:j])
|
||||||
for c in commands:
|
for c in commands:
|
||||||
if code.find("\\%s" % c) != -1:
|
if code.find("\\%s" % c) != -1:
|
||||||
add_to_preamble(document, ["\\usepackage{" + pkg + "}"])
|
if supported:
|
||||||
|
document.header[p] = "\\use_package " + pkg + " 2"
|
||||||
|
else:
|
||||||
|
add_to_preamble(document, ["\\usepackage{" + pkg + "}"])
|
||||||
return
|
return
|
||||||
i = j
|
i = j
|
||||||
|
|
||||||
@ -331,7 +337,7 @@ mathtools_commands = ["xhookrightarrow", "xhookleftarrow", "xRightarrow", \
|
|||||||
|
|
||||||
def revert_xarrow(document):
|
def revert_xarrow(document):
|
||||||
"remove use_package mathtools"
|
"remove use_package mathtools"
|
||||||
revert_use_package(document, "mathtools", mathtools_commands, False)
|
revert_use_package(document, "mathtools", mathtools_commands, False, True)
|
||||||
|
|
||||||
|
|
||||||
def revert_beamer_lemma(document):
|
def revert_beamer_lemma(document):
|
||||||
|
Loading…
Reference in New Issue
Block a user