]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/blob - wrpylib/lib_sledrun_json_to_wikitext.py
Use strip_eol() to treat whitespace after generating wikitext.
[philipp/winterrodeln/wrpylib.git] / wrpylib / lib_sledrun_json_to_wikitext.py
1 def strip_eol(text: str) -> str:
2     """Remove each whitespace from end of lines of string and also remove trailing empty lines."""
3     result = '\n'.join(line.rstrip() for line in text.splitlines(False))
4     result = result.rstrip()
5     if len(result) > 0:
6         return result + '\n'
7     return ''