1 |
#!/usr/bin/env perl |
2 |
|
3 |
use strict; |
4 |
use warnings; |
5 |
use utf8; |
6 |
|
7 |
use constant rcsid => '$Id: genpdf,v 1.5 2007-08-28 17:08:06 pippijn Exp $'; |
8 |
|
9 |
BEGIN { |
10 |
unshift @INC, "lib"; |
11 |
} |
12 |
|
13 |
use Pod::POM; |
14 |
|
15 |
use LaTeX; |
16 |
|
17 |
my $parser = new Pod::POM; |
18 |
my $current; |
19 |
|
20 |
my @podfiles = <podhelp/*.pod>; |
21 |
|
22 |
sub latexise { |
23 |
my ($data) = @_; |
24 |
my $name = $current; |
25 |
$name =~ s/serv/Serv/; |
26 |
$name = ucfirst $name; |
27 |
$$data =~ s/&nick&/$name/g; |
28 |
|
29 |
$$data =~ s/~/\$\\sim\$/g; |
30 |
$$data =~ s/#/\\#/g; |
31 |
$$data =~ s/%/\\%/g; |
32 |
$$data =~ s/&/\\&/g; |
33 |
$$data =~ s/_/\\_/g; |
34 |
$$data =~ s/</\\textless{}/g; |
35 |
$$data =~ s/>/\\textgreater{}/g; |
36 |
$$data =~ s/\|/\$|\$/g; |
37 |
|
38 |
$$data |
39 |
} |
40 |
|
41 |
sub delatexise { |
42 |
my ($data) = @_; |
43 |
my $result = ""; |
44 |
for (split /\n/, $$data) { |
45 |
if (/^ /) { |
46 |
$_ =~ s/\$\\sim\$/~/g; |
47 |
$_ =~ s/\\#/#/g; |
48 |
$_ =~ s/\\%/%/g; |
49 |
$_ =~ s/\\&/&/g; |
50 |
$_ =~ s/\\_/_/g; |
51 |
$_ =~ s/\\textless\{\}/</g; |
52 |
$_ =~ s/\\textgreater\{\}/>/g; |
53 |
$_ =~ s/\$\|\$/|/g; |
54 |
} |
55 |
$result .= "$_\n"; |
56 |
} |
57 |
|
58 |
$$data = $result |
59 |
} |
60 |
|
61 |
mkdir "latex"; |
62 |
mkdir "latex/podhelp"; |
63 |
mkdir "latex/poddoc"; |
64 |
|
65 |
for my $file (@podfiles) { |
66 |
($current) = $file =~ /podhelp\/(.+)\.pod$/; |
67 |
my $data = do { local $/; open my $fh, "<$file" or die "$file: $!"; <$fh> }; |
68 |
$data .= "\n" . do { local $/; open my $fh, "<podmisc/help.pod" or die "podmisc/help.pod: $!"; <$fh> }; |
69 |
my $pom = $parser->parse_text ($data) |
70 |
or die $parser->error(); |
71 |
open my $fh, ">latex/podhelp/$current.tex"; |
72 |
print $fh $pom->present ("LaTeX::Help"); |
73 |
close $fh; |
74 |
} |
75 |
|
76 |
@podfiles = <poddoc/*.pod>; |
77 |
|
78 |
for my $file (@podfiles) { |
79 |
($current) = $file =~ /poddoc\/(.+)\.pod$/; |
80 |
my $data = do { local $/; open my $fh, "<$file" or die "$file: $!"; <$fh> }; |
81 |
my $pom = $parser->parse_text ($data) |
82 |
or die $parser->error(); |
83 |
open my $fh, ">latex/poddoc/$current.tex"; |
84 |
print $fh $pom->present ("LaTeX::Doc"); |
85 |
close $fh; |
86 |
} |
87 |
|
88 |
@podfiles = <podsvs/*.pod>; |
89 |
|
90 |
for my $file (@podfiles) { |
91 |
($current) = $file =~ /podsvs\/(.+)\.pod$/; |
92 |
my $data = do { local $/; open my $fh, "<$file" or die "$file: $!"; <$fh> }; |
93 |
my $pom = $parser->parse_text ($data) |
94 |
or die $parser->error(); |
95 |
open my $fh, ">latex/poddoc/$current.tex"; |
96 |
print $fh $pom->present ("LaTeX::Doc"); |
97 |
close $fh; |
98 |
} |
99 |
|
100 |
=head1 AUTHOR |
101 |
|
102 |
Copyright © 2007 Pippijn van Steenhoven |
103 |
|
104 |
=head1 LICENSE |
105 |
|
106 |
This library is free software, you can redistribute it and/or modify |
107 |
it under the terms of the GNU General Public License as documented in COPYING. |
108 |
|
109 |
=cut |