For more information... RTFM!
NAVIGATION
ACCOUNT LOGIN

You are not logged in

Powered by Interchange version 5.7.0

restrict_html

Replace the leading "<" with a "&lt;" for all HTML tags in the body text, except for the tags listed in this filter's arguments.

Availability

Availability

This filter was introduced in version 5.4.0, and is therefore not available for use with any earlier Interchange version.

Example

  1. [filter restrict_html.p.br.ul.li.b]
  2. <ul>
  3. <li> Item lists are allowed.
  4. </ul>
  5. <p>
  6. As are paragraphs<br>
  7. and line breaks.
  8. </p>
  9. Links, such as <a href="http://www.interchange.rtfm.info/">RTFM</a> are <b>not</b> allowed.
  10. [/filter]

Results in:

  1. <ul>
  2. <li> Item lists are allowed.
  3. </ul>
  4. <p>
  5. As are paragraphs<br>
  6. and line breaks.
  7. </p>
  8. Links, such as &lt;a href="http://www.interchange.rtfm.info/">RTFM&lt;/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} ? '<' : '&lt;') . $1 }ge;
    return $val;
}

Category:  Filters
Last modified by: Kevin Walsh
Modification date: Thursday 1 March 2007 at 3:50 PM (EST)
Home  |  Legal nonsense  |  Privacy policy  |  Contact us