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