Skip to content

Instantly share code, notes, and snippets.

@geryxyz
Created September 9, 2022 15:08
Show Gist options
  • Save geryxyz/6c66d25dc9db5fa4142871ea90a21e9d to your computer and use it in GitHub Desktop.
Save geryxyz/6c66d25dc9db5fa4142871ea90a21e9d to your computer and use it in GitHub Desktop.
from textwrap import TextWrapper
class LineSafeTextWrapper(TextWrapper):
def fill(self, text: str) -> str:
return '\n'.join(['\n'.join(self.wrap(line)) for line in text.splitlines() if line.strip() != ''])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment