mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-03 06:13:01 +00:00
Add limits to searches in convert_TeX_brace_to_Argument.
(cherry picked from commit eb26d85dc9
)
This commit is contained in:
parent
1fa06296b6
commit
ccd8cd89ad
@ -120,21 +120,28 @@ def convert_TeX_brace_to_Argument(document, line, n, nmax, inset, environment, o
|
||||
|
||||
Todo: this routine can currently handle only one mandatory argument of environments
|
||||
'''
|
||||
|
||||
end_layout = find_end_of_layout(document.body, line)
|
||||
lineERT = line
|
||||
endn = line
|
||||
loop = 1
|
||||
while lineERT != -1 and n < nmax + 1:
|
||||
lineERT = find_token(document.body, "\\begin_inset ERT", lineERT)
|
||||
if environment == False and lineERT != -1:
|
||||
bracePair = -1
|
||||
while n < nmax + 1:
|
||||
lineERT = find_token(document.body, "\\begin_inset ERT", lineERT, end_layout)
|
||||
if lineERT == -1:
|
||||
break
|
||||
if environment == False:
|
||||
end_ERT = find_end_of_inset(document.body, lineERT)
|
||||
if end_ERT == -1:
|
||||
document.warning("Can't find end of ERT!!")
|
||||
break
|
||||
# Note that this only checks for ][ or }{ at the beginning of a line
|
||||
if opt:
|
||||
bracePair = find_token(document.body, "][", lineERT)
|
||||
bracePair = find_token(document.body, "][", lineERT, end_ERT)
|
||||
else:
|
||||
bracePair = find_token(document.body, "}{", lineERT)
|
||||
# assure that the "}{" is in this ERT
|
||||
if bracePair == lineERT + 5:
|
||||
bracePair = find_token(document.body, "}{", lineERT, end_ERT)
|
||||
if bracePair != -1:
|
||||
end = find_token(document.body, "\\end_inset", bracePair)
|
||||
document.body[lineERT : end + 1] = ["\\end_layout", "", "\\end_inset"]
|
||||
document.body[lineERT : end_ERT + 1] = ["\\end_layout", "", "\\end_inset"]
|
||||
if loop == 1:
|
||||
# in the case that n > 1 we have optional arguments before
|
||||
# therefore detect them if any
|
||||
@ -156,24 +163,22 @@ def convert_TeX_brace_to_Argument(document, line, n, nmax, inset, environment, o
|
||||
document.body[line + 1 : line + 1] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"]
|
||||
else:
|
||||
document.body[line + 4 : line + 4] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"]
|
||||
else:
|
||||
else: # if loop != 1
|
||||
document.body[endn : endn] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"]
|
||||
n += 1
|
||||
endn = end
|
||||
loop = loop + 1
|
||||
loop += 1
|
||||
# now check the case that we have "}" + "{" in two ERTs
|
||||
else:
|
||||
endBrace = -1
|
||||
else: # no brace pair found
|
||||
if opt:
|
||||
endBrace = find_token(document.body, "]", lineERT)
|
||||
endBrace = find_token(document.body, "]", lineERT, end_layout)
|
||||
else:
|
||||
endBrace = find_token(document.body, "}", lineERT)
|
||||
endBrace = find_token(document.body, "}", lineERT, end_layout)
|
||||
if endBrace == lineERT + 5:
|
||||
beginBrace = -1
|
||||
if opt:
|
||||
beginBrace = find_token(document.body, "[", endBrace)
|
||||
beginBrace = find_token(document.body, "[", endBrace, end_layout)
|
||||
else:
|
||||
beginBrace = find_token(document.body, "{", endBrace)
|
||||
beginBrace = find_token(document.body, "{", endBrace, end_layout)
|
||||
# assure that the ERTs are consecutive (11 or 12 depending if there is a space between the ERTs or not)
|
||||
if beginBrace == endBrace + 11 or beginBrace == endBrace + 12:
|
||||
end = find_token(document.body, "\\end_inset", beginBrace)
|
||||
@ -212,27 +217,32 @@ def convert_TeX_brace_to_Argument(document, line, n, nmax, inset, environment, o
|
||||
lineERT += 1
|
||||
else:
|
||||
lineERT += 1
|
||||
if environment == True and lineERT != -1:
|
||||
opening = -1
|
||||
if environment == True:
|
||||
end_ERT = find_end_of_inset(document.body, lineERT)
|
||||
if end_ERT == -1:
|
||||
document.warning("Can't find end of ERT!!")
|
||||
break
|
||||
# Note that this only checks for [ or { at the beginning of a line
|
||||
if opt:
|
||||
opening = find_token(document.body, "[", lineERT)
|
||||
opening = find_token(document.body, "[", lineERT, end_ERT)
|
||||
else:
|
||||
opening = find_token(document.body, "{", lineERT)
|
||||
if opening == lineERT + 5: # assure that the "{" is in this ERT
|
||||
end = find_token(document.body, "\\end_inset", opening)
|
||||
document.body[lineERT : end + 1] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"]
|
||||
opening = find_token(document.body, "{", lineERT, end_ERT)
|
||||
if opening != -1:
|
||||
document.body[lineERT : end_ERT + 1] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"]
|
||||
n += 1
|
||||
lineERT2 = find_token(document.body, "\\begin_inset ERT", lineERT)
|
||||
closing = -1
|
||||
if opt:
|
||||
closing = find_token(document.body, "]", lineERT)
|
||||
else:
|
||||
closing = find_token(document.body, "}", lineERT2)
|
||||
if closing == lineERT2 + 5: # assure that the "}" is in this ERT
|
||||
end2 = find_token(document.body, "\\end_inset", closing)
|
||||
document.body[lineERT2 : end2 + 1] = ["\\end_layout", "", "\\end_inset"]
|
||||
else:
|
||||
lineERT += 1
|
||||
lineERT2 = find_token(document.body, "\\begin_inset ERT", end_ERT, end_layout)
|
||||
if lineERT2 != -1:
|
||||
end_ERT2 = find_end_of_inset(document.body, lineERT)
|
||||
if end_ERT2 == -1:
|
||||
document.warning("Can't find end of second ERT!!")
|
||||
break
|
||||
if opt:
|
||||
closing = find_token(document.body, "]", lineERT2, end_ERT2)
|
||||
else:
|
||||
closing = find_token(document.body, "}", lineERT2, end_ERT2)
|
||||
if closing != -1: # assure that the "}" is in this ERT
|
||||
end2 = find_token(document.body, "\\end_inset", closing)
|
||||
document.body[lineERT2 : end2 + 1] = ["\\end_layout", "", "\\end_inset"]
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
@ -82,6 +82,8 @@ What's new
|
||||
|
||||
- Honor the NextNoIndent layout parameter also in the exported output.
|
||||
|
||||
- Fix import of some argument insets.
|
||||
|
||||
|
||||
* USER INTERFACE
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user