* Add typographyattributes configuration setting to typography plugin.
[ikiwiki.git] / IkiWiki / Plugin / typography.pm
1 #!/usr/bin/perl
2
3 package IkiWiki::Plugin::typography;
4
5 use warnings;
6 use strict;
7 use IkiWiki 2.00;
8
9 sub import { #{{{
10         hook(type => "getopt", id => "typography", call => \&getopt);
11         IkiWiki::hook(type => "sanitize", id => "typography", call => \&sanitize);
12 } # }}}
13
14 sub getopt () { #{{{
15         eval q{use Getopt::Long};
16         error($@) if $@;
17         Getopt::Long::Configure('pass_through');
18         GetOptions("typographyattributes=s" => \$config{typographyattributes});
19 } #}}}
20
21 sub sanitize (@) { #{{{
22         my %params=@_;
23
24         eval q{use Text::Typography};
25         return $params{content} if $@;
26
27         my $attributes=defined $config{typographyattributes} ? $config{typographyattributes} : '3';
28         return Text::Typography::typography($params{content}, $attributes);
29 } # }}}
30
31 1