restrict_html
Replace the leading "<" with a
"<" for all HTML tags in the body text,
except for the tags listed in this filter's arguments.
|
Availability
This filter was introduced in version 5.4.0,
and is therefore not available for use with any earlier Interchange version.
|
Example
- [filter restrict_html.p.br.ul.li.b]
- <ul>
- <li> Item lists are allowed.
- </ul>
- <p>
- As are paragraphs<br>
- and line breaks.
- </p>
- Links, such as <a href="http://www.interchange.rtfm.info/">RTFM</a> are <b>not</b> allowed.
- [/filter]
|
Results in:
- <ul>
- <li> Item lists are allowed.
- </ul>
- <p>
- As are paragraphs<br>
- and line breaks.
- </p>
- Links, such as <a href="http://www.interchange.rtfm.info/">RTFM</a> are <b>not</b> allowed.
|
Source code
sub {
my $val = shift;
shift;
my %allowed;
$allowed{lc $_} = 1 for @_;
$val =~ s{<(/?(\w[-\w]*)[\s>])}{ ($allowed{lc $2} ? '<' : '<') . $1 }ge;
return $val;
}
|