mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Consider paragraph params when placing arguments at paragraph start (#8449)
This commit is contained in:
parent
30b53ba4a0
commit
280861cd7d
@ -1269,6 +1269,7 @@ def revert_latexargs(document):
|
||||
continue
|
||||
parbeg = parent[1]
|
||||
parend = parent[2]
|
||||
realparbeg = parent[3]
|
||||
# Collect all arguments in this paragraph
|
||||
realparend = parend
|
||||
for p in range(parbeg, parend):
|
||||
@ -1295,9 +1296,9 @@ def revert_latexargs(document):
|
||||
subst += args[f]
|
||||
del args[f]
|
||||
# Insert the sorted arg insets at paragraph begin
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
|
||||
i = parbeg + 1 + len(subst)
|
||||
i = realparbeg + 1 + len(subst)
|
||||
|
||||
|
||||
def revert_Argument_to_TeX_brace(document, line, n, nmax, environment):
|
||||
@ -1785,7 +1786,7 @@ def revert_itemargs(document):
|
||||
document.warning("Malformed lyx document: Can't find parent paragraph layout")
|
||||
i = i + 1
|
||||
continue
|
||||
parbeg = parent[1]
|
||||
parbeg = parent[3]
|
||||
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", i)
|
||||
endPlain = find_end_of_layout(document.body, beginPlain)
|
||||
content = document.body[beginPlain + 1 : endPlain]
|
||||
@ -2094,6 +2095,7 @@ def revert_beamerargs(document):
|
||||
continue
|
||||
parbeg = parent[1]
|
||||
parend = parent[2]
|
||||
realparbeg = parent[3]
|
||||
layoutname = parent[0]
|
||||
realparend = parend
|
||||
for p in range(parbeg, parend):
|
||||
@ -2135,7 +2137,7 @@ def revert_beamerargs(document):
|
||||
pre += put_cmd_in_ert("[") + argcontent + put_cmd_in_ert("]")
|
||||
pre += put_cmd_in_ert("{")
|
||||
document.body[parbeg] = "\\begin_layout Standard"
|
||||
document.body[parbeg + 1 : parbeg + 1] = pre
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = pre
|
||||
pe = find_end_of_layout(document.body, parbeg)
|
||||
post = put_cmd_in_ert("}")
|
||||
document.body[pe : pe] = post
|
||||
@ -2154,7 +2156,7 @@ def revert_beamerargs(document):
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
if layoutname == "Overprint":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
@ -2169,7 +2171,7 @@ def revert_beamerargs(document):
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
if layoutname == "OverlayArea":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
@ -2184,7 +2186,7 @@ def revert_beamerargs(document):
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("{") + content + put_cmd_in_ert("}")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
if layoutname in list_layouts:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
@ -2199,7 +2201,7 @@ def revert_beamerargs(document):
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
elif argnr == "item:1":
|
||||
j = find_end_of_inset(document.body, i)
|
||||
# Find containing paragraph layout
|
||||
@ -2208,7 +2210,7 @@ def revert_beamerargs(document):
|
||||
content = document.body[beginPlain + 1 : endPlain]
|
||||
del document.body[i:j+1]
|
||||
subst = put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
|
||||
document.body[parbeg + 1 : parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
elif argnr == "item:2":
|
||||
j = find_end_of_inset(document.body, i)
|
||||
# Find containing paragraph layout
|
||||
@ -2217,7 +2219,7 @@ def revert_beamerargs(document):
|
||||
content = document.body[beginPlain + 1 : endPlain]
|
||||
del document.body[i:j+1]
|
||||
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
if layoutname in quote_layouts:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
@ -2232,7 +2234,7 @@ def revert_beamerargs(document):
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
if layoutname in corollary_layouts:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
@ -2247,7 +2249,7 @@ def revert_beamerargs(document):
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
|
||||
i = realparend
|
||||
|
||||
@ -2276,6 +2278,7 @@ def revert_beamerargs2(document):
|
||||
continue
|
||||
parbeg = parent[1]
|
||||
parend = parent[2]
|
||||
realparbeg = parent[3]
|
||||
layoutname = parent[0]
|
||||
realparend = parend
|
||||
for p in range(parbeg, parend):
|
||||
@ -2302,7 +2305,7 @@ def revert_beamerargs2(document):
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
if layoutname == "OverlayArea":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
@ -2317,7 +2320,7 @@ def revert_beamerargs2(document):
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("{") + content + put_cmd_in_ert("}")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
if layoutname == "AgainFrame":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
@ -2332,7 +2335,7 @@ def revert_beamerargs2(document):
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("[<") + content + put_cmd_in_ert(">]")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
i = realparend
|
||||
|
||||
|
||||
@ -2357,6 +2360,7 @@ def revert_beamerargs3(document):
|
||||
continue
|
||||
parbeg = parent[1]
|
||||
parend = parent[2]
|
||||
realparbeg = parent[3]
|
||||
layoutname = parent[0]
|
||||
realparend = parend
|
||||
for p in range(parbeg, parend):
|
||||
@ -2377,7 +2381,7 @@ def revert_beamerargs3(document):
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
document.body[realparbeg + 1 : realparbeg + 1] = subst
|
||||
i = realparend
|
||||
|
||||
|
||||
|
@ -128,7 +128,8 @@ get_containing_inset(lines, i):
|
||||
on line 306.
|
||||
|
||||
get_containing_layout(lines, i):
|
||||
As get_containing_inset, but for layout.
|
||||
As get_containing_inset, but for layout. Additionally returns the
|
||||
position of real paragraph start (after par params) as 4th value.
|
||||
|
||||
|
||||
find_nonempty_line(lines, start[, end):
|
||||
@ -441,7 +442,8 @@ def get_containing_layout(lines, i):
|
||||
'''
|
||||
Finds out what kind of layout line i is within. Returns a
|
||||
list containing (i) what follows \begin_layout on the the line
|
||||
on which the layout begins, plus the starting and ending line.
|
||||
on which the layout begins, plus the starting and ending line
|
||||
and the start of the apargraph (after all params).
|
||||
Returns False on any kind of error.
|
||||
'''
|
||||
j = i
|
||||
@ -458,4 +460,14 @@ def get_containing_layout(lines, i):
|
||||
if lay == "":
|
||||
# shouldn't happen
|
||||
return False
|
||||
return (lay, stlay, endlay)
|
||||
par_params = ["\\noindent", "\\indent", "\\indent-toggle", "\\leftindent",
|
||||
"\\start_of_appendix", "\\paragraph_spacing single",
|
||||
"\\paragraph_spacing onehalf", "\\paragraph_spacing double",
|
||||
"\\paragraph_spacing other", "\\align", "\\labelwidthstring"]
|
||||
stpar = stlay
|
||||
while True:
|
||||
if lines[stpar + 1] in par_params:
|
||||
stpar += 1
|
||||
else:
|
||||
break
|
||||
return (lay, stlay, endlay, stpar)
|
||||
|
Loading…
Reference in New Issue
Block a user