From e80907e8a20c855262a932a0d460e05cdcb64e04 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Sun, 25 Jan 2015 06:03:20 +0200 Subject: [PATCH] div-foo.pl: syntax for setting the "title" attribute; /x in regexes The syntax is ... --- modules/div-foo.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/div-foo.pl b/modules/div-foo.pl index c3d165e6..c8cbe38d 100644 --- a/modules/div-foo.pl +++ b/modules/div-foo.pl @@ -22,16 +22,17 @@ $DivFooPrefix = 'foo_'; push(@MyRules, \&DivFooRule); sub DivFooRule { - if (m/\G\<([a-z-_][a-z-_ ]+[a-z-_])\>\s*\n/cg) { + if (m/\G \< ([a-z-_][a-z-_ ]+[a-z-_]) \> \s*\n /cgx) { return CloseHtmlEnvironment('p') . AddHtmlEnvironment('div', 'class="' . join(' ', map {"$DivFooPrefix$_"} split /\s+/, $1) . '"'); } - if (m/\G\<([a-z-_][a-z-_ ]+[a-z-_])\>/cg) { - return AddHtmlEnvironment('span', 'class="' . join(' ', map {"$DivFooPrefix$_"} split /\s+/, $1) . '"'); + if (m/\G \< ([a-z-_][a-z-_ ]+[a-z-_]) (\?(.*?(?=\>)))? \> /cgx) { + my $title = $3 ? ' title="' . QuoteHtml($3) . '"' : ''; + return AddHtmlEnvironment('span', 'class="' . join(' ', map {"$DivFooPrefix$_"} split /\s+/, $1) . '"' . $title); } - if (m/\G\<\/\/\>/cg) { + if (m/\G \< \/ \/ \> /cgx) { return CloseHtmlEnvironment('div') . (InElement('div') ? '' : AddHtmlEnvironment('p')); } - if (m/\G\<\/\>/cg) { + if (m/\G \< \/ \> /cgx) { return CloseHtmlEnvironment('span'); } return undef;