Fixed bug with textbox formatting.

This commit is contained in:
Mark Wolfman
2021-04-16 11:27:50 -05:00
parent 30369ce1d4
commit 0c3dbc73fc
+4 -2
View File
@@ -124,10 +124,12 @@ PDFTK_CMD = "pdftk"
def text_box(string):
"""Format a string for displaying in a text box."""
# remove multiple whitespace without removing linebreaks
new_string = " ".join(string.replace("\n", r"\m").split())
new_string = " ".join(string.replace("\n", "\m").split()) # noqa: W605
# Remove *single* line breaks, swap *multi* line breaks to single (fdf: \r)
new_string = (
new_string.replace(r"\m \m", r"\r").replace(r"\m\m", r"\r").replace(r"\m", " ")
new_string.replace("\m \m", "\r") # noqa: W605
.replace("\m\m", "\r") # noqa: W605
.replace("\m", " ") # noqa: W605
)
return new_string