1 |
# -*- Perl -*- |
2 |
|
3 |
=head1 NAME |
4 |
|
5 |
pod.pl -- namazu filter for pod |
6 |
|
7 |
=cut |
8 |
|
9 |
package pod; |
10 |
use strict; |
11 |
use File::Copy; |
12 |
require 'util.pl'; |
13 |
require 'gfilter.pl'; |
14 |
require 'html.pl'; |
15 |
|
16 |
sub mediatype() { |
17 |
return ('application/x-perl'); |
18 |
} |
19 |
|
20 |
sub status() { |
21 |
return 'yes'; |
22 |
} |
23 |
|
24 |
sub recursive() { |
25 |
return 1; |
26 |
} |
27 |
|
28 |
sub pre_codeconv() { |
29 |
return 0; |
30 |
} |
31 |
|
32 |
sub post_codeconv () { |
33 |
return 1; |
34 |
} |
35 |
|
36 |
sub add_magic ($) { |
37 |
my ($magic) = @_; |
38 |
$magic->addSpecials("application/x-perl", "#!perl"); |
39 |
$magic->addSpecials("application/x-perl", "#!/usr/bin/perl"); |
40 |
$magic->addSpecials("application/x-perl", "#!/usr/local/bin/perl"); |
41 |
$magic->addSpecials("application/x-perl", "=pod"); |
42 |
$magic->addSpecials("application/x-perl", "=head"); |
43 |
$magic->addSpecials("application/x-perl", "=cut"); |
44 |
$magic->addSpecials("application/x-perl", "use strict"); |
45 |
$magic->addSpecials("application/x-perl", "no strict"); |
46 |
$magic->addSpecials("application/x-perl", "package "); |
47 |
$magic->addSpecials("application/x-perl", "-*- Perl -*-"); |
48 |
$magic->addFileExts('\\.pl$', 'application/x-perl'); |
49 |
$magic->addFileExts('\\.pm$', 'application/x-perl'); |
50 |
$magic->addFileExts('\\.ph$', 'application/x-perl'); |
51 |
$magic->addFileExts('\\.cgi$', 'application/x-perl'); |
52 |
$magic->addFileExts('\\.pod$', 'application/x-perl'); |
53 |
return; |
54 |
} |
55 |
|
56 |
sub filter ($$$$$) { |
57 |
my ($orig_cfile, $cont, $weighted_str, $headings, $fields) |
58 |
= @_; |
59 |
my $tmpfile = util::tmpnam('NMZ.pod'); |
60 |
my $tmpfile2 = util::tmpnam('NMZ.pod2'); |
61 |
util::vprint("Processing pod file...\n"); |
62 |
{ |
63 |
util::vprint("temp: >$tmpfile\n"); |
64 |
my $fh = util::efopen("> $tmpfile"); |
65 |
print $fh $$cont; |
66 |
} |
67 |
{ |
68 |
require Pod2Html; |
69 |
if ($$orig_cfile =~ m#/.*?([^/]+)$#) { |
70 |
$Pod2Html::pConfig{title} = "$1 (Perl)"; |
71 |
} |
72 |
Pod2Html::pod2html("--infile=$tmpfile", |
73 |
"--outfile=$tmpfile2"); |
74 |
} |
75 |
{ |
76 |
util::vprint("temp: <$tmpfile\n"); |
77 |
my $fh = util::efopen("< $tmpfile2"); |
78 |
$$cont = util::readfile($fh); |
79 |
util::vprint("$$cont\n"); |
80 |
} |
81 |
unlink($tmpfile); |
82 |
unlink($tmpfile2); |
83 |
|
84 |
return undef; |
85 |
} |
86 |
|
87 |
=head1 LICENSE |
88 |
|
89 |
Copyright wakaba 2001 All rights reserved. |
90 |
|
91 |
# This program is free software; you can redistribute it and/or modify |
92 |
# it under the terms of the GNU General Public License as published by |
93 |
# the Free Software Foundation; either versions 2, or (at your option) |
94 |
# any later version. |
95 |
# |
96 |
# This program is distributed in the hope that it will be useful |
97 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
98 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
99 |
# GNU General Public License for more details. |
100 |
# |
101 |
# You should have received a copy of the GNU General Public License |
102 |
# along with this program; if not, write to the Free Software |
103 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
104 |
# 02111-1307, USA |
105 |
|
106 |
=head1 CHANGE |
107 |
|
108 |
2001-11-09 wakaba <wakaba@suika.fam.cx> |
109 |
|
110 |
* new. |
111 |
|
112 |
=cut |
113 |
|
114 |
1; |