summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/typography.pm
blob: fe69968981029f07e0a60c2903bfb9e02fe6a4a6 (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::typography;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 2.00;
  6. sub import { #{{{
  7. hook(type => "getopt", id => "typography", call => \&getopt);
  8. IkiWiki::hook(type => "sanitize", id => "typography", call => \&sanitize);
  9. } # }}}
  10. sub getopt () { #{{{
  11. eval q{use Getopt::Long};
  12. error($@) if $@;
  13. Getopt::Long::Configure('pass_through');
  14. GetOptions("typographyattributes=s" => \$config{typographyattributes});
  15. } #}}}
  16. sub sanitize (@) { #{{{
  17. my %params=@_;
  18. eval q{use Text::Typography};
  19. error($@) if $@;
  20. my $attributes=defined $config{typographyattributes} ? $config{typographyattributes} : '3';
  21. return Text::Typography::typography($params{content}, $attributes);
  22. } # }}}
  23. 1