src/cowsay/__init__.py
def fit_text(text: str,
             width: int,
             wrap_text: bool = True) -> list[str]:
    """
    Wraps each paragraph in the given text to the specified width and pads
    each line such that they are all the same length with at least one space
    of padding. If wrap_text is False, paragraphs are not wrapped but are
    still padded with spaces.
    """
    text = text.replace('\t', ' ' * 4)
    if not wrap_text:
        lines = text.splitlines()
    else:
        lines = []
        paragraphs = re.split(r'(?:\r\n?|\n)\s+', text)
        for i in range(len(paragraphs)):
            lines += wrap(paragraphs[i], width=width) or ' '
            lines.append('')
        lines.pop()
    return pad_lines(lines)

    Wraps each paragraph in the given text to the specified width and pads
    each line such that they are all the same length with at least one space
    of padding. If wrap_text is False, paragraphs are not wrapped but are
    still padded with spaces.
    
Wraps each paragraph in the given text to the specified width and pads
each line such that they are all the same length with at least one space
of padding. If wrap_text is False, paragraphs are not wrapped but are
still padded with spaces.
Wraps each paragraph in the given text to the specified width and pads each line such that they are all the same length with at least one space of padding . If wrap_text is False paragraphs are not wrapped but are still padded with spaces .
def fit_text(text: str,
             width: int,
             wrap_text: bool = True) -> list[str]:
    text = text.replace('\t', ' ' * 4)
    if not wrap_text:
        lines = text.splitlines()
    else:
        lines = []
        paragraphs = re.split(r'(?:\r\n?|\n)\s+', text)
        for i in range(len(paragraphs)):
            lines += wrap(paragraphs[i], width=width) or ' '
            lines.append('')
        lines.pop()
    return pad_lines(lines)
def fit_text ( text : str , width : int , wrap_text : bool = True ) -> list [ str ] : text = text . replace ( '\t' , ' ' * 4 ) if not wrap_text : lines = text . splitlines ( ) else : lines = [ ] paragraphs = re . split ( r'(?:\r\n?|\n)\s+' , text ) for i in range ( len ( paragraphs ) ) : lines += wrap ( paragraphs [ i ] , width = width ) or ' ' lines . append ( '' ) lines . pop ( ) return pad_lines ( lines )
Wraps each paragraph in the given text to the specified width and pads
each line such that they are all the same length with at least one space
of padding.
Wraps each paragraph in the given text to the specified width and pads each line such that they are all the same length with at least one space of padding .
"""
    Wraps each paragraph in the given text to the specified width and pads
    each line such that they are all the same length with at least one space
    of padding. If wrap_text is False, paragraphs are not wrapped but are
    still padded with spaces.
    """
text
str
width
int
wrap_text
bool