mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Speed up convert_captionlayouts. Part of #11200.
This commit is contained in:
parent
16e838de2c
commit
4cb209b121
@ -3659,23 +3659,22 @@ def convert_captionlayouts(document):
|
|||||||
"Bicaption" : "Bicaption",
|
"Bicaption" : "Bicaption",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for captype in caption_dict.keys():
|
||||||
i = 0
|
i = 0
|
||||||
while True:
|
while True:
|
||||||
i = find_token(document.body, "\\begin_layout", i)
|
i = find_token(document.body, "\\begin_layout " + captype, i)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
return
|
break
|
||||||
val = get_value(document.body, "\\begin_layout", i)
|
|
||||||
if val in list(caption_dict.keys()):
|
|
||||||
j = find_end_of_layout(document.body, i)
|
j = find_end_of_layout(document.body, i)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
document.warning("Malformed LyX document: Missing `\\end_layout'.")
|
document.warning("Malformed LyX document: Missing `\\end_layout'.")
|
||||||
return
|
break
|
||||||
|
|
||||||
document.body[j:j] = ["\\end_layout", "", "\\end_inset", "", ""]
|
document.body[j:j] = ["\\end_layout", "", "\\end_inset", "", ""]
|
||||||
document.body[i:i+1] = ["\\begin_layout %s" % document.default_layout,
|
document.body[i:i+1] = ["\\begin_layout %s" % document.default_layout,
|
||||||
"\\begin_inset Caption %s" % caption_dict[val], "",
|
"\\begin_inset Caption %s" % caption_dict[val], "",
|
||||||
"\\begin_layout %s" % document.default_layout]
|
"\\begin_layout %s" % document.default_layout]
|
||||||
i += 1
|
i = j + 1
|
||||||
|
|
||||||
|
|
||||||
def revert_captionlayouts(document):
|
def revert_captionlayouts(document):
|
||||||
|
Loading…
Reference in New Issue
Block a user