summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/typography.pm
blob: 6229e6c33258b9d6a12a43c8957cb5facbcb3739 (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. hook(type => "getsetup", id => "typography", call => \&getsetup);
  9. IkiWiki::hook(type => "sanitize", id => "typography", call => \&sanitize);
  10. } # }}}
  11. sub getopt () { #{{{
  12. eval q{use Getopt::Long};
  13. error($@) if $@;
  14. Getopt::Long::Configure('pass_through');
  15. GetOptions("typographyattributes=s" => \$config{typographyattributes});
  16. } #}}}
  17. sub getsetup () { #{{{
  18. eval q{use Text::Typography};
  19. error($@) if $@;
  20. return
  21. typographyattributes => {
  22. type => "string",
  23. example => "3",
  24. description => "Text::Typography attributes value",
  25. safe => 1,
  26. rebuild => 1,
  27. },
  28. } #}}}
  29. sub sanitize (@) { #{{{
  30. my %params=@_;
  31. eval q{use Text::Typography};
  32. return $params{content} if $@;
  33. my $attributes=defined $config{typographyattributes} ? $config{typographyattributes} : '3';
  34. return Text::Typography::typography($params{content}, $attributes);
  35. } # }}}
  36. 1