]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/typography.pm
finish adding getsetup hooks to plugins
[ikiwiki.git] / IkiWiki / Plugin / typography.pm
index 3b66ab0d087e871e8152992552ade197610c8039..8ae1f3445c966e39bef6dfea77cd8072326c0027 100644 (file)
@@ -7,16 +7,41 @@ use strict;
 use IkiWiki 2.00;
 
 sub import { #{{{
+       hook(type => "getopt", id => "typography", call => \&getopt);
+       hook(type => "getsetup", id => "typography", call => \&getsetup);
        IkiWiki::hook(type => "sanitize", id => "typography", call => \&sanitize);
 } # }}}
 
+sub getopt () { #{{{
+       eval q{use Getopt::Long};
+       error($@) if $@;
+       Getopt::Long::Configure('pass_through');
+       GetOptions("typographyattributes=s" => \$config{typographyattributes});
+} #}}}
+
+sub getsetup () { #{{{
+       eval q{use Text::Typography};
+       error($@) if $@;
+
+       return
+               typographyattributes => {
+                       type => "string",
+                       default => "3",
+                       example => "tag",
+                       description => "Text::Typography attributes value",
+                       safe => 1,
+                       rebuild => 1,
+               },
+} #}}}
+
 sub sanitize (@) { #{{{
        my %params=@_;
 
        eval q{use Text::Typography};
-       return $params{content} if $@;
+       error($@) if $@;
 
-       return Text::Typography::typography($params{content});
+       my $attributes=defined $config{typographyattributes} ? $config{typographyattributes} : '3';
+       return Text::Typography::typography($params{content}, $attributes);
 } # }}}
 
 1