Functions | |
def | wrap_always |
def | wrap_onspace |
def | wrap_onspace_strict |
def wordWrappers::wrap_always | ( | text, | |
width | |||
) |
A simple word-wrap function that wraps text on exactly width characters. It doesn't split the text in words.
Definition at line 5 of file wordWrappers.py.
def wordWrappers::wrap_onspace | ( | text, | |
width | |||
) |
A word-wrap function that preserves existing line breaks and most spaces in the text. Expects that existing line breaks are posix newlines (\n).
Definition at line 13 of file wordWrappers.py.
00014 : 00015 """ 00016 A word-wrap function that preserves existing line breaks 00017 and most spaces in the text. Expects that existing line 00018 breaks are posix newlines (\n). 00019 """ 00020 return reduce(lambda line, word, width=width: '%s%s%s' % 00021 (line, 00022 ' \n'[(len(line[line.rfind('\n')+1:]) 00023 + len(word.split('\n',1)[0] 00024 ) >= width)], 00025 word), 00026 text.split(' ') )
def wordWrappers::wrap_onspace_strict | ( | text, | |
width | |||
) |
Similar to wrap_onspace, but enforces the width constraint: words longer than width are split.
Definition at line 27 of file wordWrappers.py.