add more formatter tags
authorAdrian Oldham <adriann@visualthought.com.au>
Wed, 20 Feb 2013 22:06:37 +0000 (09:06 +1100)
committerTony Cook <tony@develop-help.com>
Sat, 16 Mar 2013 00:41:13 +0000 (11:41 +1100)
site/cgi-bin/modules/DevHelp/Formatter.pm
t/010-modules/050-format.t

index 308adc26523ee3c15062428e576e37b07fd132b2..10783aa113dcace247f312c351c0be19af89ec0e 100644 (file)
@@ -3,7 +3,7 @@ use strict;
 use DevHelp::HTML;
 use Carp 'confess';
 
-our $VERSION = "1.003";
+our $VERSION = "1.004";
 
 use constant DEBUG => 0;
 
@@ -173,28 +173,28 @@ sub link {
 
 sub replace_char {
   my ($self, $rpart) = @_;
-  $$rpart =~ s#(acronym|abbr|dfn)\[(?:\r?\n)?([^|\]\[]+)\|([^\]\[]+)\|([^\]\[]+?)(?:\r?\n)?\]#
+  $$rpart =~ s#(acronym|abbr|dfn|cite)\[(?:\r?\n)?([^|\]\[]+)\|([^\]\[]+)\|([^\]\[]+?)(?:\r?\n)?\]#
     $self->_fix_spanned(qq/<$1 class="$3" title="$2">/, "</$1>", $4)#egi
     and return 1;
-  $$rpart =~ s#(acronym|abbr|dfn)\[(?:\r?\n)?([^|\]\[]+)\|([^\]\[]+?)(?:\r?\n)?\]#
+  $$rpart =~ s#(acronym|abbr|dfn|cite)\[(?:\r?\n)?([^|\]\[]+)\|([^\]\[]+?)(?:\r?\n)?\]#
     $self->_fix_spanned(qq/<$1 title="$2">/, "</$1>", $3)#egi
     and return 1;
-  $$rpart =~ s#(acronym|abbr|dfn)\[(?:\r?\n)?\|([^\]\[]+?)(?:\r?\n)?\]#
+  $$rpart =~ s#(acronym|abbr|dfn|cite)\[(?:\r?\n)?\|([^\]\[]+?)(?:\r?\n)?\]#
     $self->_fix_spanned("<$1>", "</$1>", $2)#egi
     and return 1;
-  $$rpart =~ s#(acronym|abbr|dfn)\[(?:\r?\n)?([^\]\[]+?)(?:\r?\n)?\]#
+  $$rpart =~ s#(acronym|abbr|dfn|cite)\[(?:\r?\n)?([^\]\[]+?)(?:\r?\n)?\]#
     $self->_fix_spanned("<$1>", "</$1>", $2)#egi
     and return 1;
   $$rpart =~ s#bdo\[(?:\r?\n)?([^|\]\[]+)\|([^\]\[]+?)(?:\r?\n)?\]#
     $self->_fix_spanned(qq/<bdo dir="$1">/, "</bdo>", $2)#egi
     and return 1;
-  $$rpart =~ s#(strong|em|samp|code|var|sub|sup|kbd|q|b|i|tt|span)\[(?:\r?\n)?([^|\]\[]+)\|([^\]\[]+?)(?:\r?\n)?\]#
+  $$rpart =~ s#(strong|em|samp|code|var|sub|sup|kbd|q|b|i|tt|span|small|large)\[(?:\r?\n)?([^|\]\[]+)\|([^\]\[]+?)(?:\r?\n)?\]#
     $self->_fix_spanned(qq/<$1 class="$2">/, "</$1>", $3)#egi
     and return 1;
-  $$rpart =~ s#(strong|em|samp|code|var|sub|sup|kbd|q|b|i|tt|span)\[(?:\r?\n)?\|([^\]\[]+?)(?:\r?\n)?\]#
+  $$rpart =~ s#(strong|em|samp|code|var|sub|sup|kbd|q|b|i|tt|span|small|large)\[(?:\r?\n)?\|([^\]\[]+?)(?:\r?\n)?\]#
     $self->_fix_spanned("<$1>", "</$1>", $2)#egi
     and return 1;
-  $$rpart =~ s#(strong|em|samp|code|var|sub|sup|kbd|q|b|i|tt|span)\[(?:\r?\n)?([^\]\[]+?)(?:\r?\n)?\]#
+  $$rpart =~ s#(strong|em|samp|code|var|sub|sup|kbd|q|b|i|tt|span|small|large)\[(?:\r?\n)?([^\]\[]+?)(?:\r?\n)?\]#
     $self->_fix_spanned("<$1>", "</$1>", $2)#egi
     and return 1;
   $$rpart =~ s#poplink\[([^|\]\[]+)\|([^\]\[]+)\]#
@@ -418,19 +418,19 @@ sub remove_format {
     TRY: while (1) {
        $self->remove(\$part)
          and next TRY;
-       $part =~ s#(?:acronym|abbr|dfn)\[([^|\]\[]+)\|([^\]\[]+)\|([^\]\[]*)\]#$3#ig
+       $part =~ s#(?:acronym|abbr|dfn|cite)\[([^|\]\[]+)\|([^\]\[]+)\|([^\]\[]*)\]#$3#ig
          and next TRY;
-       $part =~ s#(?:acronym|abbr|dfn|bdo)\[([^|\]\[]+)\|([^\]\[]*)\]#$2#ig
+       $part =~ s#(?:acronym|abbr|dfn|cite|bdo)\[([^|\]\[]+)\|([^\]\[]*)\]#$2#ig
          and next TRY;
-       $part =~ s#(?:acronym|abbr|dfn|bdo)\[\|([^|\]\[]*)\]#$1#ig
+       $part =~ s#(?:acronym|abbr|dfn|cite|bdo)\[\|([^|\]\[]*)\]#$1#ig
          and next TRY;
-       $part =~ s#(?:acronym|abbr|dfn)\[([^|\]\[]*)\]#$1#ig
+       $part =~ s#(?:acronym|abbr|dfn|cite)\[([^|\]\[]*)\]#$1#ig
          and next TRY;
-       $part =~ s#(?:strong|em|samp|code|var|sub|sup|kbd|q|address|blockquote|b|i|tt|span)\[([^|\]\[]+)\|([^\]\[]*)\]#$2#ig
+       $part =~ s#(?:strong|em|samp|code|var|sub|sup|kbd|q|address|blockquote|b|i|tt|span|small|large)\[([^|\]\[]+)\|([^\]\[]*)\]#$2#ig
          and next TRY;
-       $part =~ s#(?:strong|em|samp|code|var|sub|sup|kbd|q|address|blockquote|b|i|tt|span)\[\|([^\]\[]*)\]#$1#ig
+       $part =~ s#(?:strong|em|samp|code|var|sub|sup|kbd|q|address|blockquote|b|i|tt|span|small|large)\[\|([^\]\[]*)\]#$1#ig
          and next TRY;
-       $part =~ s#(?:strong|em|samp|code|var|sub|sup|kbd|q|address|blockquote|b|i|tt|span)\[([^\]\[]*)\]#$1#ig
+       $part =~ s#(?:strong|em|samp|code|var|sub|sup|kbd|q|address|blockquote|b|i|tt|span|small|large)\[([^\]\[]*)\]#$1#ig
          and next TRY;
        $part =~ s#div\[([^\[\]\|]+)\|([^\[\]]*)\](?:\r?\n)?#$2#ig
          and next TRY;
index 1d8976eec526950bf9255ac37c0019aadf835d70..64bb45427869fba2cf6e7049a6fb21b9ee5afbb7 100644 (file)
@@ -21,6 +21,16 @@ SKIP: {
   format_test 'blockquote[hello]', '<blockquote><p>hello</p></blockquote>', 'blockquote';
   format_test 'blockquote[|hello]', '<blockquote><p>hello</p></blockquote>', 'blockquote with empty class';
   format_test 'blockquote[foo|hello]', '<blockquote class="foo"><p>hello</p></blockquote>', 'blockquote with class';
+  format_test 'cite[hello]', '<p><cite>hello</cite></p>', 'cite';
+  format_test 'cite[|hello]', '<p><cite>hello</cite></p>', 'cite with empty title';
+  format_test 'cite[foo|hello]', '<p><cite title="foo">hello</cite></p>', 'cite with title';
+  format_test 'cite[foo|bar|hello]', '<p><cite class="bar" title="foo">hello</cite></p>', 'cite with class and title';
+  format_test 'small[hello]', '<p><small>hello</small></p>', 'small';
+  format_test 'small[|hello]', '<p><small>hello</small></p>', 'small empty class';
+  format_test 'small[foo|hello]', '<p><small class="foo">hello</small></p>', 'small with class';
+  format_test 'large[hello]', '<p><large>hello</large></p>', 'large';
+  format_test 'large[|hello]', '<p><large>hello</large></p>', 'large empty class';
+  format_test 'large[foo|hello]', '<p><large class="foo">hello</large></p>', 'large with class';
   format_test <<IN, <<OUT, 'strong over paras', 'both';
 strong[foo|hello