summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/wikitext.pm
blob: 310b86724358db7ea68a0af9f8da0d4d899772c2 (plain)
  1. #!/usr/bin/perl
  2. # WikiText markup
  3. package IkiWiki::Plugin::wikitext;
  4. use warnings;
  5. use strict;
  6. use Text::WikiFormat;
  7. sub import { #{{{
  8. IkiWiki::hook(type => "filter", id => "wiki", call => \&filter);
  9. IkiWiki::hook(type => "htmlize", id => "wiki", call => \&htmlize);
  10. } # }}}
  11. sub filter (@) { #{{{
  12. my %params=@_;
  13. # Make CamelCase links work by promoting them to fullfledged
  14. # WikiLinks. This regexp is based on the one in Text::WikiFormat.
  15. $params{content}=~s#(?<![["/>=])\b((?:[A-Z][a-z0-9]\w*){2,})#[[$1]]#g;
  16. return $params{content};
  17. } #}}}
  18. sub htmlize ($) { #{{{
  19. my $content = shift;
  20. return Text::WikiFormat::format($content, undef, { implicit_links => 0 });
  21. } # }}}
  22. 1