Indent - Maple Help

# Online Help

###### All Products    Maple    MapleSim

StringTools

 Indent
 indent text a specified amount

 Calling Sequence Indent( s ) Indent( s, lineindent )

Parameters

 s - Maple string; string to be indented lineindent - {posint,string}; (optional) number of spaces or string to use for indent

Description

 • The procedure Indent indents a string s by replacing the beginning of each line in s by lineindent spaces, if lineindent is a non-negative integer, or if lineindent is a string by that string.
 • The indented string is returned.
 • The lineindent argument is optional. It is equal to $8$ by default, which causes the input text to be indented by $8$ spaces.
 • 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.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left("a\nb\nc"\right)\right)$
 a         b         c
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left("a\nb\nc",2\right)\right)$
 a   b   c
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left("a\nb\nc","-"\right)\right)$
 - a  - b  - c
 > $\mathrm{txt}≔"Arma virumque cano, Troiae qui primus ab oris\nItaliam, fato profugus, Laviniaque venit\nlitora, multum ille et terris iactatus et alto\nvi superum saevae memorem Iunonis ob iram;\nmulta quoque et bello passus, dum conderet urbem,\ninferretque deos Latio, genus unde Latinum,\nAlbanique patres, atque altae moenia Romae.":$
 > $\mathrm{printf}\left("%s\n",\mathrm{txt}\right)$
 Arma virumque cano, Troiae qui primus ab oris Italiam, fato profugus, Laviniaque venit litora, multum ille et terris iactatus et alto vi superum saevae memorem Iunonis ob iram; multa quoque et bello passus, dum conderet urbem, inferretque deos Latio, genus unde Latinum, Albanique patres, atque altae moenia Romae.
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left(\mathrm{txt}\right)\right)$
 Arma virumque cano, Troiae qui primus ab oris         Italiam, fato profugus, Laviniaque venit         litora, multum ille et terris iactatus et alto         vi superum saevae memorem Iunonis ob iram;         multa quoque et bello passus, dum conderet urbem,         inferretque deos Latio, genus unde Latinum,         Albanique patres, atque altae moenia Romae.
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left(\mathrm{txt},2\right)\right)$
 Arma virumque cano, Troiae qui primus ab oris   Italiam, fato profugus, Laviniaque venit   litora, multum ille et terris iactatus et alto   vi superum saevae memorem Iunonis ob iram;   multa quoque et bello passus, dum conderet urbem,   inferretque deos Latio, genus unde Latinum,   Albanique patres, atque altae moenia Romae.
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left(\mathrm{txt},"--"\right)\right)$
 --Arma virumque cano, Troiae qui primus ab oris --Italiam, fato profugus, Laviniaque venit --litora, multum ille et terris iactatus et alto --vi superum saevae memorem Iunonis ob iram; --multa quoque et bello passus, dum conderet urbem, --inferretque deos Latio, genus unde Latinum, --Albanique patres, atque altae moenia Romae.
 > $\mathrm{pandp}≔"It is a truth universally acknowledged, that a single man in\npossession of a good fortune, must be in want of a wife.\n\nHowever little known the feelings or views of such a man may\nbe on his first entering a neighbourhood, this truth is so well\nfixed in the minds of the surrounding families, that he is considered\nthe rightful property of some one or other of their daughters.":$
 > $\mathrm{printf}\left("%s\n",\mathrm{pandp}\right)$
 It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife. However little known the feelings or views of such a man may be on his first entering a neighbourhood, this truth is so well fixed in the minds of the surrounding families, that he is considered the rightful property of some one or other of their daughters.
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left(\mathrm{pandp}\right)\right)$
 It is a truth universally acknowledged, that a single man in         possession of a good fortune, must be in want of a wife.                  However little known the feelings or views of such a man may         be on his first entering a neighbourhood, this truth is so well         fixed in the minds of the surrounding families, that he is considered         the rightful property of some one or other of their daughters.
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left(\mathrm{pandp},2\right)\right)$
 It is a truth universally acknowledged, that a single man in   possession of a good fortune, must be in want of a wife.      However little known the feelings or views of such a man may   be on his first entering a neighbourhood, this truth is so well   fixed in the minds of the surrounding families, that he is considered   the rightful property of some one or other of their daughters.

Specifying an indent amount is just a special case of specifying an indent string.

 > $\mathrm{randj}≔"Two households, both alike in dignity,\nIn fair Verona, where we lay our scene,\nFrom ancient grudge break to new mutiny,\nWhere civil blood makes civil hands unclean.\nFrom forth the fatal loins of these two foes\nA pair of star-cross\text{'}d lovers take their life;\nWhose misadventur\text{'}d piteous overthrows\nDoth with their death bury their parents\text{'} strife.\nThe fearful passage of their death-mark\text{'}d love,\nAnd the continuance of their parents\text{'} rage,\nWhich, but their children\text{'}s end, naught could remove,\nIs now the two hours\text{'} traffic of our stage;\nThe which if you with patient ears attend,\nWhat here shall miss, our toil shall strive to mend.":$
 > $\mathrm{printf}\left("%s\n",\mathrm{randj}\right)$
 Two households, both alike in dignity, In fair Verona, where we lay our scene, From ancient grudge break to new mutiny, Where civil blood makes civil hands unclean. From forth the fatal loins of these two foes A pair of star-cross'd lovers take their life; Whose misadventur'd piteous overthrows Doth with their death bury their parents' strife. The fearful passage of their death-mark'd love, And the continuance of their parents' rage, Which, but their children's end, naught could remove, Is now the two hours' traffic of our stage; The which if you with patient ears attend, What here shall miss, our toil shall strive to mend.
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left(\mathrm{randj},""\right)\right)$
 Two households, both alike in dignity,   In fair Verona, where we lay our scene,   From ancient grudge break to new mutiny,   Where civil blood makes civil hands unclean.   From forth the fatal loins of these two foes   A pair of star-cross'd lovers take their life;   Whose misadventur'd piteous overthrows   Doth with their death bury their parents' strife.   The fearful passage of their death-mark'd love,   And the continuance of their parents' rage,   Which, but their children's end, naught could remove,   Is now the two hours' traffic of our stage;   The which if you with patient ears attend,   What here shall miss, our toil shall strive to mend.
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left(\mathrm{randj},2\right)\right)$
 Two households, both alike in dignity,   In fair Verona, where we lay our scene,   From ancient grudge break to new mutiny,   Where civil blood makes civil hands unclean.   From forth the fatal loins of these two foes   A pair of star-cross'd lovers take their life;   Whose misadventur'd piteous overthrows   Doth with their death bury their parents' strife.   The fearful passage of their death-mark'd love,   And the continuance of their parents' rage,   Which, but their children's end, naught could remove,   Is now the two hours' traffic of our stage;   The which if you with patient ears attend,   What here shall miss, our toil shall strive to mend.

You can use this command to create simple plain-text bulleted lists.

 > $\mathrm{txt}≔"first\nsecond\nthird":$
 > $\mathrm{printf}\left("%s\n",\mathrm{txt}\right)$
 first second third
 > $\mathrm{printf}\left("%s\n",\mathrm{Indent}\left(\mathrm{txt},"-"\right)\right)$
 - first  - second  - third

 See Also