wrap long lines of text
WrapText( text, width, opts )
string; Maple string
posint; (optional) width
The WrapText(text, width) calling sequence attempts to wrap long lines in the string text to a specified width width by inserting line breaks in the text to break lines longer than width bytes. Line breaks inserted by the command are inserted between "words" in the input; a word is defined to be a maximal contiguous sequence of non-space characters. Any word longer than width is not broken, but appears on a line by itself in the output.
The width argument is optional, and is equal to 80 by default. It must be a positive integer.
Tab characters in the input string text are expanded, by default. An option of the form tabs = n or tabs = loi may be passed to control tab expansion, where n is a positive integer and loi is a strictly increasing sequence of positive integers. See StringTools[ExpandTabs].
The obeylines option controls whether WrapText will respect newlines present in the input. If obeylines = true is passed, then newlines in the input text are preserved in the output. The default is obeylines = false.
The obeyspaces option controls whether space characters in the input are preserved in the output. By default, where obeyspaces = false, contiguous sequences of space characters are replaced by a single space.
The expandtabs option controls whether TAB characters ("\t") are expanded as spaces or output literally. The default is expandtabs = true.
Note that if text has length less than or equal to width, it is returned unchanged if none of the obeylines, obeyspaces and expandtabs options are set.
All of the StringTools package commands treat strings as (null-terminated) sequences of 8-bit (ASCII) characters. Thus, there is no support for multibyte character encodings, such as unicode encodings.
WrapText⁡To break a string into 20 byte lines, use this command.,20
To break a string
into 20 byte lines,
use this command.
Note the effect of the obeylines option.
WrapText⁡This text\ncontains newlines\nthat may or may not\nbe respected,30
may or may not
WrapText⁡This text\ncontains newlines\nthat may or may not\nbe respected,30,obeylines
that may or may not
Again, the obeyspaces option causes some differences in output as illustrated here:
Download Help Document
What kind of issue would you like to report? (Optional)