StringTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : English Text : StringTools/WrapText

StringTools

  

WrapText

  

wrap long lines of text

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

WrapText( text, width, opts  )

Parameters

text

-

string; Maple string

width

-

posint; (optional) width

opts

-

options

Description

• 

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.

Examples

withStringTools:

WrapTextTo break a string into 20 byte lines, use this command.,20

To break a string into 20 byte lines, use this command.

(1)

Note the effect of the obeylines option.

WrapTextThis text contains newlines that may or may not be respected,30

This text contains newlines that may or may not be respected

(2)

WrapTextThis text contains newlines that may or may not be respected,30,'obeylines'

This text contains newlines that may or may not be respected

(3)

Again, the obeyspaces option causes some differences in output as illustrated here:

WrapTexta b,10

a b

(4)

WrapTexta b,10,'obeyspaces'

a b

(5)

See Also

string

StringTools

StringTools[ExpandTabs]

StringTools[Words]