Chapter B: Global Filters
Global tag attribute filters
The following is a list of global filters that can be applied to any tag.
decode_htmlWith a value of "1" decodes all HTML entities in the tag value.
decode_xmlWith a value of "1" decodes all XML entities in the tag value.
dirifyWith a value of "1" encodes the tag value into a string suitable for usage in a file or directory name. "Dirification" is a multi-step process. First the value is converted to lower case. Any HTML tags and entities are stripped. Characters that are not alphanumeric, the underscore (_) or whitespace characters (i.e. space, tab) are stripped. Finally whitespace characters are converted to an underscore characters.
dirify also converts certain high-ASCII characters (accented characters, etc) to their low-ASCII characters, meaning that something like
cruditéwill be converted tocrudite.The above paragraph needs more clarification. Exact which characters and what are they coverted to?
For example, if the value of the tag without this attribute were
Foo "Baz" is<br> Bar!, the dirified version would befoo_baz_is_bar.encode_htmlWith a value of "1" HTML-encodes the tag value.
encode_jsWith a value of "1" encodes the tag value into a format suitable for usage in a Javascript string value.
encode_phpEncodes the tag value into a format suitable for usage in one of three PHP string values: single-quote, double-quote, or here document. The value of this tag attribute should be either
q(single-quote),qq(double-quote), orheredoc(here document).encode_urlEncodes the tag value into a format suitable for usage in a URL. This means encoding non-alphanumeric characters into their hex equivalents.
encode_xmlWith a value of "1" encodes into entities any characters that XML requires to be encoded. These are:
&,",<, and>.The difference between this and encode_html is that the latter encodes a much wider set of special characters into HTML entities if you have the HTML::Entities module installed and you have not turned on the NoHTMLEntities option in mt-config.cgi.
filtersLists a set of Text Formatting filters that will be applied to the tag value. The filter names should be the key names that uniquely identify the filters, not the labels shown in the Text Formatting options pulldown menu. Multiple text formatting keys should be separated with commas (
,). Multiple filters will be executed in the order in which they are listed.lower_caseTransforms the text into lower case characters.
ltrimRemoves leading whitespace from the string.
remove_htmlWith a value of "1" strips all markup tags (such as HTML or XML) from the tag value.
rtrimRemoves trailing whitespace from the string.
sanitizeRuns a sanitize filter over the text. If the value of the attribute is
1, the default sanitize spec for the weblog is used. If the value is0, the value will not be sanitized. All other values will be interpreted as a sanitize specification. See the article on GlobalSanitizeSpec for much more information on this function.space_padPads the tag value with spaces so that the total length is Ncharacters. N is specified as the value of the attribute.
spam_protectObscures an email address by entity-encoding the key characters, such as the at symbol (@), so it is more difficult to automated agents to recognize. This filter isn't truly global, but can be used with any variable tag that outputs an email address.
sprintfA general purpose formatter based on the
sprintfcommand found in a number of programming languages. The value of the attribute should be the format string. The tag value will be passed in as the argument to sprintf.strip_linefeedsRemoves carriage return and line feed characters from the text.
trimRemoves leading and trailing whitespace from the string.
trim_toTrims the string to the first Ncharacters. N is specified as the value of the attribute.
upper_caseTransforms the text into upper case characters.
zero_padPads the tag value with zeros so that the total length is N characters. N is specified as the value of the attribute.


