aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2017-05-16 11:29:30 +0100
committerSimon McVittie <smcv@debian.org>2017-05-16 12:08:55 +0100
commit01f2a843602ad19716db9e17f93c943e0c71cff9 (patch)
tree7d891eaeda20ed40cd3dc76bfe3fd7adf5bd0fdc /IkiWiki
parent49de9594b71159d2a1755c80a096f1886b5fb05c (diff)
downloadikiwiki-01f2a843602ad19716db9e17f93c943e0c71cff9.tar
ikiwiki-01f2a843602ad19716db9e17f93c943e0c71cff9.tar.gz
color: Use markup for the preserved CSS, not character data
This still smuggles it past the sanitize step, but avoids having other plugins that want to capture text content without markup (notably toc) see the CSS as if it was text content.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/color.pm8
1 files changed, 3 insertions, 5 deletions
diff --git a/IkiWiki/Plugin/color.pm b/IkiWiki/Plugin/color.pm
index 9bb2359ce..e80130d92 100644
--- a/IkiWiki/Plugin/color.pm
+++ b/IkiWiki/Plugin/color.pm
@@ -38,12 +38,11 @@ sub preserve_style ($$$) {
($background =~ /^[a-z]+$/ || $background =~ /^#[0-9a-f]{3,6}$/));
my $preserved = '';
- $preserved .= '<span class="color">';
+ $preserved .= '<span class="color"><span value="';
$preserved .= 'color: '.$foreground if ($foreground);
$preserved .= '; ' if ($foreground && $background);
$preserved .= 'background-color: '.$background if ($background);
- $preserved .= '</span>';
- $preserved .= '<span class="colorend">'.$text.'</span>';
+ $preserved .= '"></span>'.$text.'</span>';
return $preserved;
@@ -52,8 +51,7 @@ sub preserve_style ($$$) {
sub replace_preserved_style ($) {
my $content = shift;
- $content =~ s!<span class="color">((color: ([a-z]+|\#[0-9a-f]{3,6})?)?((; )?(background-color: ([a-z]+|\#[0-9a-f]{3,6})?)?)?)</span>!<span class="color" style="$1">!g;
- $content =~ s!<span class="colorend">!!g;
+ $content =~ s!<span class="color">\s*<span value="((color: ([a-z]+|\#[0-9a-f]{3,6})?)?((; )?(background-color: ([a-z]+|\#[0-9a-f]{3,6})?)?)?)">\s*</span>!<span class="color" style="$1">!g;
return $content;
}