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 => "filter", id => "txt", call => \&filter);
18 hook(type => "htmlize", id => "txt", call => \&htmlize);
20 eval q{use URI::Find};
26 # We use filter to convert raw text to HTML
27 # (htmlize is called after other plugins insert HTML)
30 my $content = $params{content};
32 if (defined $pagesources{$params{page}} && $pagesources{$params{page}} =~ /\.txt$/) {
33 encode_entities($content);
35 my $finder = URI::Find->new(sub {
36 my ($uri, $orig_uri) = @_;
37 return qq|<a href="$uri">$orig_uri</a>|;
39 $finder->find(\$content);
41 $content = "<pre>" . $content . "</pre>";
47 # We need this to register the .txt file extension
50 return $params{content};