textformat

优质
小牛编辑
130浏览
2023-12-01

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

属性类型是否必须缺省值描述
stylestringNon/a预处理风格
indentnumberNo0单行缩进的字符数目
indent_firstnumberNo0首行缩进的字符数目
indent_charstringNo(single space)填充缩进区域的字符(或字符串)
wrapnumberNo80单行长度,超过该长度自动折行
wrap_charstringNo\n折行使用的字符(或字符串),被附加在行尾
wrap_cutbooleanNofalse如果设置为真,换行时不考虑换行点所在位置是否为完整单词,直接换行. 反之将在单词的边界处换行.
assignstringNon/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.