summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/typography.pm
blob: 27089b39008455b92b24e69669627bc624fbf10d (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. plugin => {
  22. safe => 1,
  23. rebuild => 1,
  24. },
  25. typographyattributes => {
  26. type => "string",
  27. example => "3",
  28. description => "Text::Typography attributes value",
  29. advanced => 1,
  30. safe => 1,
  31. rebuild => 1,
  32. },
  33. } #}}}
  34. sub sanitize (@) { #{{{
  35. my %params=@_;
  36. eval q{use Text::Typography};
  37. return $params{content} if $@;
  38. my $attributes=defined $config{typographyattributes} ? $config{typographyattributes} : '3';
  39. return Text::Typography::typography($params{content}, $attributes);
  40. } # }}}
  41. 1