summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorgregor herrmann <gregoa@debian.org>2018-03-19 19:49:44 +0100
committergregor herrmann <gregoa@debian.org>2018-03-19 19:49:44 +0100
commit0d538510ec1aafe54f4ad6bca455c1f67d4f9b78 (patch)
tree5fae12fb1bacbf3e48df3b3124fea4c4d50367ac /README.md
parentec06787d2bdda608b8b24ca8b29d9edbea81ac6a (diff)
New upstream version 2.3.0
Diffstat (limited to 'README.md')
-rw-r--r--README.md24
1 files changed, 23 insertions, 1 deletions
diff --git a/README.md b/README.md
index 0796222..3f56543 100644
--- a/README.md
+++ b/README.md
@@ -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