textutil-cmds - Utility commands for processing text
These commands support common tasks of processin text chunks in webserver applications.
Returns the contents of HTML with certain characters that are special in HTML replaced with an escape code. The resulting text can be literally displayed in a webpage with an HTML renderer. Specifically:
& becomes &
< becomes <
> becomes >
' becomes '
" becomes "
All other characters are unmodified in the output.
Returns the contents of html with all HTML tags removed. This function replaces as well all known HTML4 named entities and three digit numeric entities by its UTF-8 representations and removes HTML comments.
Reflow a text to the specified length. The arguments width (default 80) and offset (default 0) are integers referring to number of characters. The prefix can be used to prefix every resulting line with a constant string.
Multi-line trim with optional delimiter and builtin substitution (latter is not really needed but convenient). Trim leading spaces on multiple lines. The delimiter has to be a single character.
The command is e.g. useful, when the indentation in the source code file should not be preserved on the output (such as SQL statements, HTML markup, etc.).
% ns_quotehtml "Hello World!"
Hello World!
% ns_quotehtml "The <STRONG> tag is used to indicate strongly emphasized text."
The <STRONG> tag is used to indicate strongly emphasized text.
% ns_quotehtml {<span class="foo">}
<span class="foo">
% ns_reflow_text -width 15 -prefix "> " "one two three four five six seven eight nine ten" > one two three > four five six > seven eight > nine ten
% ns_striphtml "<MARQUEE direction='right'><BLINK>Hello World!</BLINK></MARQUEE>" Hello World!
% ns_trim {
SELECT object_id, object_name
FROM acs_objects
WHERE object_id > 10000
}
SELECT object_id, object_name
FROM acs_objects
WHERE object_id > 10000
% ns_trim -delimiter | {
| <ul>
| <li> one
| <li> two
| <li> three
| </ul>
}
<ul>
<li> one
<li> two
<li> three
</ul>