2 # Test that Pod::LaTeX works
3 # This test relies on the DATA filehandle
4 # DATA contains the latex that is used for comparison
5 # and the pod that was used to generate it. The two
6 # are separated by '=pod'
7 # Note that if the translator is adjusted the output tex
8 # will probably not match what is currently there. You
9 # will need to adjust it to match (assuming it is correct).
14 BEGIN { plan tests => 172 }
18 # The link parsing changed between v0.22 and v0.30 of Pod::ParseUtils
20 my $linkver = $Pod::ParseUtils::VERSION;
22 # Set up an END block to remove the test output file
29 # First thing to do is to read the expected output from
30 # the DATA filehandle and store it in a scalar.
31 # Do this until we read an =pod
33 while (my $line = <DATA>) {
34 last if $line =~ /^=pod/;
35 push(@reference,$line);
39 my $parser = Pod::LaTeX->new;
41 $parser->Head1Level(1);
42 # Add the preamble but remember not to compare the timestamps
43 $parser->AddPreamble(1);
44 $parser->AddPostamble(1);
46 # For a laugh add a table of contents
47 $parser->TableOfContents(1);
49 # Create an output file
50 open(OUTFH, "> test.tex" ) or die "Unable to open test tex file: $!\n";
52 # Read from the DATA filehandle and write to a new output file
53 # Really want to write this to a scalar
54 $parser->parse_from_filehandle(\*DATA,\*OUTFH);
56 close(OUTFH) or die "Error closing OUTFH test.tex: $!\n";
58 # Now read in OUTFH and compare
59 open(INFH, "< test.tex") or die "Unable to read test tex file: $!\n";
62 ok(@output, @reference);
63 for my $i (0..$#reference) {
64 next if $reference[$i] =~ /^%%/; # skip timestamp comments
66 # if we are running a new version of Pod::ParseUtils we need
67 # to change the link text. This is a kluge until we drop support
68 # for older versions of Pod::ParseUtils
69 if ($linkver < 0.29 && $output[$i] =~ /manpage/) {
70 # convert our expectations from new to old new format
71 $reference[$i] =~ s/Standard link: \\emph\{Pod::LaTeX\}/Standard link: the \\emph\{Pod::LaTeX\} manpage/;
72 $reference[$i] =~ s/\\textsf\{sec\} in \\emph\{Pod::LaTeX\}/the section on \\textsf\{sec\} in the \\emph\{Pod::LaTeX\} manpage/;
74 ok($output[$i], $reference[$i]);
77 close(INFH) or die "Error closing INFH test.tex: $!\n";
81 \documentclass{article}
82 \usepackage[T1]{fontenc}
85 %% Latex generated from POD in document (unknown)
86 %% Using the perl module Pod::LaTeX
87 %% Converted on Sat Apr 5 21:16:02 2003
98 \section{Introduction\label{Introduction}\index{Introduction}}
103 Always check the return codes of system calls. Good error messages should
104 go to STDERR, include which program caused the problem, what the failed
105 system call and arguments were, and (\textbf{very important}) should contain
106 the standard system error message for what went wrong. Here's a simple
107 but sufficient example:
110 opendir(D, $dir) or die "can't opendir $dir: $!";
115 Line up your transliterations when it makes sense:
123 The above should be aligned since it includes an embedded tab.
128 Think about reusability. Why waste brainpower on a one-shot when you
129 might want to do something like it again? Consider generalizing your
130 code. Consider writing a module or object class. Consider making your
131 code run cleanly with \texttt{use strict} and \texttt{-w} (or \texttt{use warnings} in
132 Perl 5.6) in effect. Consider giving away your code. Consider changing
133 your whole world view. Consider... oh, never mind.
146 \section{Links\label{Links}\index{Links}}
149 This link should just include one word: \textsf{Pod::LaTeX}
153 This link should include the text \texttt{test} even though
154 it refers to \texttt{Pod::LaTeX}: \textsf{test}.
158 Standard link: \emph{Pod::LaTeX}.
162 Now refer to an external section: \textsf{sec} in \emph{Pod::LaTeX}
164 \section{Lists\label{Lists}\index{Lists}}
167 Test description list with long lines
171 \item[Some short text] \mbox{}
173 Some additional para.
188 \item[some longer text than that] \mbox{}
193 \item[this text is even longer and greater than] \textbf{40 characters}
195 Some more content for the item.
198 \item[this is some text with \textit{something across}] \textbf{the 40 char boundary}
200 This is item content.
205 And this should be an enumerated list without any cruft after the numbers or additional numbers at all.
219 \section{Escapes\label{Escapes}\index{Escapes}}
222 Test some normal escapes such as $<$ (lt) and $>$ (gt) and $|$ (verbar) and
223 \texttt{\~{}} (tilde) and \& (amp) as well as $<$ (Esc lt) and $|$ (Esc
224 verbar) and \textfractionsolidus{} (Esc sol) and $>$ (Esc gt) and \& (Esc amp)
225 and " (Esc quot) and even $\alpha$ (Esc alpha).
227 \section{For blocks\label{For_blocks}\index{For blocks}}
228 Some latex code \textbf{here}.
232 Some text that should appear.
236 Some more text that should appear
238 Some latex in a \textsf{begin block}
261 Always check the return codes of system calls. Good error messages should
262 go to STDERR, include which program caused the problem, what the failed
263 system call and arguments were, and (B<very important>) should contain
264 the standard system error message for what went wrong. Here's a simple
265 but sufficient example:
267 opendir(D, $dir) or die "can't opendir $dir: $!";
271 Line up your transliterations when it makes sense:
276 The above should be aligned since it includes an embedded tab.
280 Think about reusability. Why waste brainpower on a one-shot when you
281 might want to do something like it again? Consider generalizing your
282 code. Consider writing a module or object class. Consider making your
283 code run cleanly with C<use strict> and C<-w> (or C<use warnings> in
284 Perl 5.6) in effect. Consider giving away your code. Consider changing
285 your whole world view. Consider... oh, never mind.
299 This link should just include one word: L<Pod::LaTeX|Pod::LaTeX>
301 This link should include the text C<test> even though
302 it refers to C<Pod::LaTeX>: L<test|Pod::LaTeX>.
304 Standard link: L<Pod::LaTeX>.
306 Now refer to an external section: L<Pod::LaTeX/"sec">
311 Test description list with long lines
315 =item Some short text
317 Some additional para.
331 =item some longer text than that
335 =item this text is even longer and greater than 40 characters
337 Some more content for the item.
339 =item this is some text with I<something across> the 40 char boundary
341 This is item content.
345 And this should be an enumerated list without any cruft after the numbers or additional numbers at all.
361 Test some normal escapes such as < (lt) and > (gt) and | (verbar) and
362 ~ (tilde) and & (amp) as well as E<lt> (Esc lt) and E<verbar> (Esc
363 verbar) and E<sol> (Esc sol) and E<gt> (Esc gt) and E<amp> (Esc amp)
364 and E<quot> (Esc quot) and even E<alpha> (Esc alpha).
369 Some latex code \textbf{here}.
371 Some text that should appear.
374 Should not print anything
376 Some more text that should appear
380 Some latex in a \textsf{begin block}