mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
commit
c4d8d9a116
1 changed files with 2 additions and 2 deletions
|
|
@ -473,7 +473,7 @@ def iter_to_str(iterable, sep=",", endsep=", and", addquote=False):
|
|||
list_to_string = iter_to_str
|
||||
iter_to_string = iter_to_str
|
||||
|
||||
re_empty = re.compile("\n\s*\n")
|
||||
re_empty = re.compile("\n\\s*\n")
|
||||
|
||||
|
||||
def compress_whitespace(text, max_linebreaks=1, max_spacing=2):
|
||||
|
|
@ -494,7 +494,7 @@ def compress_whitespace(text, max_linebreaks=1, max_spacing=2):
|
|||
# this allows the blank-line compression to eliminate them if needed
|
||||
text = re_empty.sub("\n\n", text)
|
||||
# replace groups of extra spaces with the maximum number of spaces
|
||||
text = re.sub(f"(?<=\S) {{{max_spacing},}}", " " * max_spacing, text)
|
||||
text = re.sub(fr"(?<=\S) {{{max_spacing},}}", " " * max_spacing, text)
|
||||
# replace groups of extra newlines with the maximum number of newlines
|
||||
text = re.sub(f"\n{{{max_linebreaks},}}", "\n" * max_linebreaks, text)
|
||||
return text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue