diff options
author | gregor herrmann <gregoa@debian.org> | 2018-03-19 19:49:44 +0100 |
---|---|---|
committer | gregor herrmann <gregoa@debian.org> | 2018-03-19 19:49:44 +0100 |
commit | 0d538510ec1aafe54f4ad6bca455c1f67d4f9b78 (patch) | |
tree | 5fae12fb1bacbf3e48df3b3124fea4c4d50367ac /README.md | |
parent | ec06787d2bdda608b8b24ca8b29d9edbea81ac6a (diff) |
New upstream version 2.3.0
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -4,7 +4,7 @@ HTML::Restrict - Strip unwanted HTML tags and attributes # VERSION -version 2.2.4 +version v2.3.0 # SYNOPSIS @@ -156,6 +156,28 @@ HTML::Restrict recognizes: # $processed now equals: <img alt="Alt Text"> + As of 2.3.0, the value to be tested against can also be a code reference. The + code reference will be passed the value of the attribute, and should return + either a string to use for the attribute value, or undef to remove the attribute. + + my $hr = HTML::Restrict->new( + rules => { + span => [ + { style => sub { + my $value = shift; + # all colors are orange + $value =~ s/\bcolor\s*:\s*[^;]+/color: orange/g; + return $value; + } } + ], + }, + ); + + my $html = '<span style="color: #0000ff;">This is blue</span>'; + my $processed = $hr->process( $html ); + + # $processed now equals: <span style="color: orange;"> + - `trim => [0|1]` By default all leading and trailing spaces will be removed when text is |