From 01f2a843602ad19716db9e17f93c943e0c71cff9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 May 2017 11:29:30 +0100 Subject: 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. --- IkiWiki/Plugin/color.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'IkiWiki') 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 .= ''; + $preserved .= ''.$text.''; + $preserved .= '">'.$text.''; return $preserved; @@ -52,8 +51,7 @@ sub preserve_style ($$$) { sub replace_preserved_style ($) { my $content = shift; - $content =~ s!((color: ([a-z]+|\#[0-9a-f]{3,6})?)?((; )?(background-color: ([a-z]+|\#[0-9a-f]{3,6})?)?)?)!!g; - $content =~ s!!!g; + $content =~ s!\s*\s*!!g; return $content; } -- cgit v1.2.3