Remove extra whitespace at the end of line

This commit is contained in:
José Matos 2024-02-10 22:01:01 +00:00
parent 1cc3128011
commit a46b5f2de9

View File

@ -674,16 +674,16 @@ def revert_language(document, lyxname, babelname="", polyglossianame=""):
parent = get_containing_layout(document.body, i) parent = get_containing_layout(document.body, i)
i_e = parent[2] # end line no, i_e = parent[2] # end line no,
# print(i, texname, parent, document.body[i+1], file=sys.stderr) # print(i, texname, parent, document.body[i+1], file=sys.stderr)
# Move leading space to the previous line: # Move leading space to the previous line:
if document.body[i+1].startswith(" "): if document.body[i+1].startswith(" "):
document.body[i+1] = document.body[i+1][1:] document.body[i+1] = document.body[i+1][1:]
document.body.insert(i, " ") document.body.insert(i, " ")
continue continue
# TODO: handle nesting issues with font attributes, e.g. # TODO: handle nesting issues with font attributes, e.g.
# \begin_layout Standard # \begin_layout Standard
# #
# \emph on # \emph on
# \lang macedonian # \lang macedonian
# Македонски јазик # Македонски јазик
@ -692,7 +692,7 @@ def revert_language(document, lyxname, babelname="", polyglossianame=""):
# семејство на индоевропски јазици. # семејство на индоевропски јазици.
# Македонскиот е службен и национален јазик во Македонија. # Македонскиот е службен и национален јазик во Македонија.
# \end_layout # \end_layout
# Ensure correct handling of list labels # Ensure correct handling of list labels
if (parent[0] in ["Labeling", "Description"] if (parent[0] in ["Labeling", "Description"]
and not " " in "\n".join(document.body[parent[3]:i])): and not " " in "\n".join(document.body[parent[3]:i])):
@ -711,7 +711,7 @@ def revert_language(document, lyxname, babelname="", polyglossianame=""):
labelline[1]] labelline[1]]
document.body[i+1:i+2] = lines document.body[i+1:i+2] = lines
i_e += 4 i_e += 4
# Find out where to end the language change. # Find out where to end the language change.
langswitch = i langswitch = i
while True: while True:
@ -727,14 +727,14 @@ def revert_language(document, lyxname, babelname="", polyglossianame=""):
continue continue
i_e = langswitch i_e = langswitch
break break
# use function or environment? # use function or environment?
singlepar = i_e - i < 3 singlepar = i_e - i < 3
if not singlepar and parent[0] == "Plain Layout": if not singlepar and parent[0] == "Plain Layout":
# environment not allowed in some insets # environment not allowed in some insets
container = get_containing_inset(document.body, i) container = get_containing_inset(document.body, i)
singlepar = container[0] in singlepar_insets singlepar = container[0] in singlepar_insets
# Delete empty language switches: # Delete empty language switches:
if not "".join(document.body[i+1:i_e]): if not "".join(document.body[i+1:i_e]):
del document.body[i:i_e] del document.body[i:i_e]