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
36 # We use filter to convert raw text to HTML
37 # (htmlize is called after other plugins insert HTML)
40 my $content = $params{content};
42 if (defined $pagesources{$params{page}} && $pagesources{$params{page}} =~ /\.txt$/) {
43 encode_entities($content, "<>&");
45 my $finder = URI::Find->new(sub {
46 my ($uri, $orig_uri) = @_;
47 return qq|<a href="$uri">$orig_uri</a>|;
49 $finder->find(\$content);
51 $content = "<pre>" . $content . "</pre>";
57 # We need this to register the .txt file extension
60 return $params{content};