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