<< Back to man.ChinaUnix.net

textformat

Attribute NameTypeRequiredDefaultDescription
stylestringNon/apreset style
indentnumberNo0The number of chars to indent every line
indent_firstnumberNo0The number of chars to indent the first line
indent_charstringNo(single space)The character (or string of chars) to indent with
wrapnumberNo80How many characters to wrap each line to
wrap_charstringNo\nThe character (or string of chars) to break each line with
wrap_cutbooleanNofalseIf true, wrap will break the line at the exact character instead of at a word boundary
assignstringNon/athe template variable the output will be assigned to

属性 类型 是否必须 缺省值 描述
style string No n/a 预处理风格
indent number No 0 单行缩进的字符数目
indent_first number No 0 首行缩进的字符数目
indent_char string No (single space) 填充缩进区域的字符(或字符串)
wrap number No 80 单行长度,超过该长度自动折行
wrap_char string No \n 折行使用的字符(或字符串),被附加在行尾
wrap_cut boolean No false 如果设置为真,换行时不考虑换行点所在位置是否为完整单词,直接换行. 反之将在单词的边界处换行.
assign string No n/a 输出值将被赋给模板变量的名称

textformat is a block function used to format text. It basically cleans up spaces and special characters, and formats paragraphs by wrapping at a boundary and indenting lines.

textformat 用于格式化文本. 该函数主要清理空格和特殊字符,对段落按单词边界换行和行缩进等段落格式化处理.

You can set the parameters explicitly, or use a preset style. Currently "email" is the only available style.

用户可以明确设置各参数,或使用预处理风格. 目前只有唯一可用风格"email".

 

Example 8-18. textformat
例 8-18. textformat 函数演示

{textformat wrap=40}

This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.

This is bar.

bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.

{/textformat}

OUTPUT:

This is foo. This is foo. This is foo.
This is foo. This is foo. This is foo.

This is bar.

bar foo bar foo foo. bar foo bar foo
foo. bar foo bar foo foo. bar foo bar
foo foo. bar foo bar foo foo. bar foo
bar foo foo. bar foo bar foo foo.


{textformat wrap=40 indent=4}

This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.

This is bar.

bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.

{/textformat}

OUTPUT:

    This is foo. This is foo. This is
    foo. This is foo. This is foo. This
    is foo.

    This is bar.

    bar foo bar foo foo. bar foo bar foo
    foo. bar foo bar foo foo. bar foo
    bar foo foo. bar foo bar foo foo.
    bar foo bar foo foo. bar foo bar
    foo foo.

{textformat wrap=40 indent=4 indent_first=4}

This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.

This is bar.

bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.

{/textformat}

OUTPUT:

        This is foo. This is foo. This
    is foo. This is foo. This is foo.
    This is foo.

        This is bar.

        bar foo bar foo foo. bar foo bar
    foo foo. bar foo bar foo foo. bar
    foo bar foo foo. bar foo bar foo
    foo. bar foo bar foo foo. bar foo
    bar foo foo.

{textformat style="email"}

This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.

This is bar.

bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.
bar foo bar foo     foo.

{/textformat}

OUTPUT:

This is foo. This is foo. This is foo. This is foo. This is foo. This is
foo.

This is bar.

bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo
bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo
foo.