2 # .txt as a wiki page type - links WikiLinks and URIs.
4 # Copyright (C) 2008 Gabriel McManus <gmcmanus@gmail.com>
5 # Licensed under the GNU General Public License, version 2 or later
7 package IkiWiki::Plugin::txt;
17 hook(type => "getsetup", id => "txt", call => \&getsetup);
18 hook(type => "filter", id => "txt", call => \&filter);
19 hook(type => "htmlize", id => "txt", call => \&htmlize);
21 eval q{use URI::Find};
31 rebuild => 1, # format plugin
35 # We use filter to convert raw text to HTML
36 # (htmlize is called after other plugins insert HTML)
39 my $content = $params{content};
41 if (defined $pagesources{$params{page}} && $pagesources{$params{page}} =~ /\.txt$/) {
42 encode_entities($content, "<>&");
44 my $finder = URI::Find->new(sub {
45 my ($uri, $orig_uri) = @_;
46 return qq|<a href="$uri">$orig_uri</a>|;
48 $finder->find(\$content);
50 $content = "<pre>" . $content . "</pre>";
56 # We need this to register the .txt file extension
59 return $params{content};