modify-repos/src/modify_repos/wrap.py
2025-01-11 16:21:57 -08:00

12 lines
330 B
Python

from __future__ import annotations
import textwrap
from inspect import cleandoc
def wrap(text: str, width: int = 80) -> str:
"""Wrap a multi-line, multi-paragraph string."""
return "\n\n".join(
textwrap.fill(p, width=width, tabsize=4, break_long_words=False)
for p in cleandoc(text).split("\n\n")
)