Fix handling of extra_query_params in Business::OnlinePayment wrapper.
[interchange.git] / code / Filter / strip_html.filter
1 # Copyright 2009 Interchange Development Group and others
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
7
8 CodeDef strip_html Filter
9 CodeDef strip_html Description Strip HTML
10 CodeDef strip_html Routine <<EOR
11 sub {
12     my $val = shift;
13
14         # get rid of HTML comments
15         $val =~ s/<!(?:--(?:[^-]*|-[^-]+)*--\s*)>//s;
16
17     # replace these container tags with a space
18     $val =~ s{</?(?:p|ol|ul|li|div|h[123456]|pre|dl|dd|dt|form|option|textarea|blockquote)(?:\s[^>]*)?>}{ }ig;
19
20     # replace these self-closing tags with a space
21     $val =~ s{<[bh]r(?:\s*/|\s[^>]*)?>}{ }ig;
22
23     # remove all remaining tags and leave no space
24     $val =~ s{</?\w[^>]*>}{}g;
25
26     # collapse all whitespace, as HTML does when rendering anyway,
27     # to facilitate truncating at a certain number of characters
28     $val =~ s{\A\s+}{};
29     $val =~ s{\s+\z}{};
30     $val =~ s{\s+}{ }g;
31
32     return $val;
33 }
34 EOR