]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/typography.pm
plugin safe/rebuild controls
[git.ikiwiki.info.git] / IkiWiki / Plugin / typography.pm
1 #!/usr/bin/perl
3 package IkiWiki::Plugin::typography;
5 use warnings;
6 use strict;
7 use IkiWiki 2.00;
9 sub import { #{{{
10         hook(type => "getopt", id => "typography", call => \&getopt);
11         hook(type => "getsetup", id => "typography", call => \&getsetup);
12         IkiWiki::hook(type => "sanitize", id => "typography", call => \&sanitize);
13 } # }}}
15 sub getopt () { #{{{
16         eval q{use Getopt::Long};
17         error($@) if $@;
18         Getopt::Long::Configure('pass_through');
19         GetOptions("typographyattributes=s" => \$config{typographyattributes});
20 } #}}}
22 sub getsetup () { #{{{
23         eval q{use Text::Typography};
24         error($@) if $@;
26         return
27                 typographyattributes => {
28                         type => "string",
29                         example => "3",
30                         description => "Text::Typography attributes value",
31                         advanced => 1,
32                         safe => 1,
33                         rebuild => 1,
34                 },
35 } #}}}
37 sub sanitize (@) { #{{{
38         my %params=@_;
40         eval q{use Text::Typography};
41         return $params{content} if $@;
43         my $attributes=defined $config{typographyattributes} ? $config{typographyattributes} : '3';
44         return Text::Typography::typography($params{content}, $attributes);
45 } # }}}
47 1