5 require Test; import Test;
9 # Test that Pod::LaTeX works
10 # This test relies on the DATA filehandle
11 # DATA contains the latex that is used for comparison
12 # and the pod that was used to generate it. The two
13 # are separated by '=pod'
14 # Note that if the translator is adjusted the output tex
15 # will probably not match what is currently there. You
16 # will need to adjust it to match (assuming it is correct).
22 # Set up an END block to remove the test output file
23 END { unlink "test.tex" };
27 # First thing to do is to read the expected output from
28 # the DATA filehandle and store it in a scalar.
29 # Do this until we read an =pod
31 while (my $line = <DATA>) {
32 last if $line =~ /^=pod/;
33 push(@reference,$line);
37 my $parser = Pod::LaTeX->new;
39 $parser->Head1Level(1);
40 # Add the preamble but remember not to compare the timestamps
41 $parser->AddPreamble(1);
42 $parser->AddPostamble(1);
44 # For a laugh add a table of contents
45 $parser->TableOfContents(1);
47 # Create an output file
48 open(OUTFH, "> test.tex" ) or die "Unable to open test tex file: $!\n";
50 # Read from the DATA filehandle and write to a new output file
51 # Really want to write this to a scalar
52 $parser->parse_from_filehandle(\*DATA,\*OUTFH);
54 close(OUTFH) or die "Error closing OUTFH test.tex: $!\n";
56 # Now read in OUTFH and compare
57 open(INFH, "< test.tex") or die "Unable to read test tex file: $!\n";
60 ok(@output, @reference);
61 for my $i (0..$#reference) {
62 next if $reference[$i] =~ /^%%/; # skip timestamp comments
63 ok($output[$i], $reference[$i]);
66 close(INFH) or die "Error closing INFH test.tex: $!\n";
70 \documentclass{article}
72 %% Latex generated from POD in document ...
73 %% Using the perl module Pod::LaTeX
74 %% Converted on Tue Nov 20 20:43:05 2001
85 \section{Introduction\label{Introduction}\index{Introduction}}
90 Always check the return codes of system calls. Good error messages should
91 go to STDERR, include which program caused the problem, what the failed
92 system call and arguments were, and (\textbf{very important}) should contain
93 the standard system error message for what went wrong. Here's a simple
94 but sufficient example:
97 opendir(D, $dir) or die "can't opendir $dir: $!";
102 Line up your transliterations when it makes sense:
110 The above should be aligned since it includes an embedded tab.
115 Think about reusability. Why waste brainpower on a one-shot when you
116 might want to do something like it again? Consider generalizing your
117 code. Consider writing a module or object class. Consider making your
118 code run cleanly with \texttt{use strict} and \texttt{-w} (or \texttt{use warnings} in
119 Perl 5.6) in effect. Consider giving away your code. Consider changing
120 your whole world view. Consider... oh, never mind.
133 \section{Links\label{Links}\index{Links}}
136 This link should just include one word: \textsf{Pod::LaTeX}
140 This link should include the text \texttt{test} even though
141 it refers to \texttt{Pod::LaTeX}: \textsf{test}.
145 Standard link: \emph{Pod::LaTeX}.
149 Now refer to an external section: \textsf{sec} in \emph{Pod::LaTeX}
151 \section{Lists\label{Lists}\index{Lists}}
154 Test description list with long lines
158 \item[Some short text] \mbox{}
160 Some additional para.
175 \item[some longer text than that] \mbox{}
180 \item[this text is even longer and greater than] \textbf{40 characters}
182 Some more content for the item.
185 \item[this is some text with \textit{something across}] \textbf{the 40 char boundary}
187 This is item content.
190 \section{Escapes\label{Escapes}\index{Escapes}}
193 Test some normal escapes such as $<$ (lt) and $>$ (gt) and $|$ (verbar) and
194 \texttt{\~{}} (tilde) and \& (amp) as well as $<$ (Esc lt) and $|$ (Esc
195 verbar) and / (Esc sol) and $>$ (Esc gt) and \& (Esc amp)
196 and " (Esc quot) and even $\alpha$ (Esc alpha).
198 \section{For blocks\label{For_blocks}\index{For blocks}}
199 Some latex code \textbf{here}.
203 Some text that should appear.
207 Some more text that should appear
209 Some latex in a \textsf{begin block}
232 Always check the return codes of system calls. Good error messages should
233 go to STDERR, include which program caused the problem, what the failed
234 system call and arguments were, and (B<very important>) should contain
235 the standard system error message for what went wrong. Here's a simple
236 but sufficient example:
238 opendir(D, $dir) or die "can't opendir $dir: $!";
242 Line up your transliterations when it makes sense:
247 The above should be aligned since it includes an embedded tab.
251 Think about reusability. Why waste brainpower on a one-shot when you
252 might want to do something like it again? Consider generalizing your
253 code. Consider writing a module or object class. Consider making your
254 code run cleanly with C<use strict> and C<-w> (or C<use warnings> in
255 Perl 5.6) in effect. Consider giving away your code. Consider changing
256 your whole world view. Consider... oh, never mind.
270 This link should just include one word: L<Pod::LaTeX|Pod::LaTeX>
272 This link should include the text C<test> even though
273 it refers to C<Pod::LaTeX>: L<test|Pod::LaTeX>.
275 Standard link: L<Pod::LaTeX>.
277 Now refer to an external section: L<Pod::LaTeX/"sec">
282 Test description list with long lines
286 =item Some short text
288 Some additional para.
302 =item some longer text than that
306 =item this text is even longer and greater than 40 characters
308 Some more content for the item.
310 =item this is some text with I<something across> the 40 char boundary
312 This is item content.
318 Test some normal escapes such as < (lt) and > (gt) and | (verbar) and
319 ~ (tilde) and & (amp) as well as E<lt> (Esc lt) and E<verbar> (Esc
320 verbar) and E<sol> (Esc sol) and E<gt> (Esc gt) and E<amp> (Esc amp)
321 and E<quot> (Esc quot) and even E<alpha> (Esc alpha).
326 Some latex code \textbf{here}.
328 Some text that should appear.
331 Should not print anything
333 Some more text that should appear
337 Some latex in a \textsf{begin block}