1N/A
1N/A# Test that Pod::LaTeX works
1N/A# This test relies on the DATA filehandle
1N/A# DATA contains the latex that is used for comparison
1N/A# and the pod that was used to generate it. The two
1N/A# are separated by '=pod'
1N/A# Note that if the translator is adjusted the output tex
1N/A# will probably not match what is currently there. You
1N/A# will need to adjust it to match (assuming it is correct).
1N/A
1N/Ause Test;
1N/Ause strict;
1N/A
1N/ABEGIN { plan tests => 172 }
1N/A
1N/Ause Pod::LaTeX;
1N/A
1N/A# The link parsing changed between v0.22 and v0.30 of Pod::ParseUtils
1N/Ause Pod::ParseUtils;
1N/Amy $linkver = $Pod::ParseUtils::VERSION;
1N/A
1N/A# Set up an END block to remove the test output file
1N/AEND {
1N/A unlink "test.tex";
1N/A};
1N/A
1N/Aok(1);
1N/A
1N/A# First thing to do is to read the expected output from
1N/A# the DATA filehandle and store it in a scalar.
1N/A# Do this until we read an =pod
1N/Amy @reference;
1N/Awhile (my $line = <DATA>) {
1N/A last if $line =~ /^=pod/;
1N/A push(@reference,$line);
1N/A}
1N/A
1N/A# Create a new parser
1N/Amy $parser = Pod::LaTeX->new;
1N/Aok($parser);
1N/A$parser->Head1Level(1);
1N/A# Add the preamble but remember not to compare the timestamps
1N/A$parser->AddPreamble(1);
1N/A$parser->AddPostamble(1);
1N/A
1N/A# For a laugh add a table of contents
1N/A$parser->TableOfContents(1);
1N/A
1N/A# Create an output file
1N/Aopen(OUTFH, "> test.tex" ) or die "Unable to open test tex file: $!\n";
1N/A
1N/A# Read from the DATA filehandle and write to a new output file
1N/A# Really want to write this to a scalar
1N/A$parser->parse_from_filehandle(\*DATA,\*OUTFH);
1N/A
1N/Aclose(OUTFH) or die "Error closing OUTFH test.tex: $!\n";
1N/A
1N/A# Now read in OUTFH and compare
1N/Aopen(INFH, "< test.tex") or die "Unable to read test tex file: $!\n";
1N/Amy @output = <INFH>;
1N/A
1N/Aok(@output, @reference);
1N/Afor my $i (0..$#reference) {
1N/A next if $reference[$i] =~ /^%%/; # skip timestamp comments
1N/A
1N/A # if we are running a new version of Pod::ParseUtils we need
1N/A # to change the link text. This is a kluge until we drop support
1N/A # for older versions of Pod::ParseUtils
1N/A if ($linkver < 0.29 && $output[$i] =~ /manpage/) {
1N/A # convert our expectations from new to old new format
1N/A $reference[$i] =~ s/Standard link: \\emph\{Pod::LaTeX\}/Standard link: the \\emph\{Pod::LaTeX\} manpage/;
1N/A $reference[$i] =~ s/\\textsf\{sec\} in \\emph\{Pod::LaTeX\}/the section on \\textsf\{sec\} in the \\emph\{Pod::LaTeX\} manpage/;
1N/A }
1N/A ok($output[$i], $reference[$i]);
1N/A}
1N/A
1N/Aclose(INFH) or die "Error closing INFH test.tex: $!\n";
1N/A
1N/A
1N/A__DATA__
1N/A\documentclass{article}
1N/A\usepackage[T1]{fontenc}
1N/A\usepackage{textcomp}
1N/A
1N/A%% Latex generated from POD in document (unknown)
1N/A%% Using the perl module Pod::LaTeX
1N/A%% Converted on Sat Apr 5 21:16:02 2003
1N/A
1N/A
1N/A\usepackage{makeidx}
1N/A\makeindex
1N/A
1N/A
1N/A\begin{document}
1N/A
1N/A\tableofcontents
1N/A
1N/A\section{Introduction\label{Introduction}\index{Introduction}}
1N/A\begin{itemize}
1N/A
1N/A\item
1N/A
1N/AAlways check the return codes of system calls. Good error messages should
1N/Ago to STDERR, include which program caused the problem, what the failed
1N/Asystem call and arguments were, and (\textbf{very important}) should contain
1N/Athe standard system error message for what went wrong. Here's a simple
1N/Abut sufficient example:
1N/A
1N/A\begin{verbatim}
1N/A opendir(D, $dir) or die "can't opendir $dir: $!";
1N/A\end{verbatim}
1N/A
1N/A\item
1N/A
1N/ALine up your transliterations when it makes sense:
1N/A
1N/A\begin{verbatim}
1N/A tr [abc]
1N/A [xyz];
1N/A\end{verbatim}
1N/A
1N/A
1N/AThe above should be aligned since it includes an embedded tab.
1N/A
1N/A
1N/A\item
1N/A
1N/AThink about reusability. Why waste brainpower on a one-shot when you
1N/Amight want to do something like it again? Consider generalizing your
1N/Acode. Consider writing a module or object class. Consider making your
1N/Acode run cleanly with \texttt{use strict} and \texttt{-w} (or \texttt{use warnings} in
1N/APerl 5.6) in effect. Consider giving away your code. Consider changing
1N/Ayour whole world view. Consider... oh, never mind.
1N/A
1N/A
1N/A\item
1N/A
1N/ABe consistent.
1N/A
1N/A
1N/A\item
1N/A
1N/ABe nice.
1N/A
1N/A\end{itemize}
1N/A\section{Links\label{Links}\index{Links}}
1N/A
1N/A
1N/AThis link should just include one word: \textsf{Pod::LaTeX}
1N/A
1N/A
1N/A
1N/AThis link should include the text \texttt{test} even though
1N/Ait refers to \texttt{Pod::LaTeX}: \textsf{test}.
1N/A
1N/A
1N/A
1N/AStandard link: \emph{Pod::LaTeX}.
1N/A
1N/A
1N/A
1N/ANow refer to an external section: \textsf{sec} in \emph{Pod::LaTeX}
1N/A
1N/A\section{Lists\label{Lists}\index{Lists}}
1N/A
1N/A
1N/ATest description list with long lines
1N/A
1N/A\begin{description}
1N/A
1N/A\item[Some short text] \mbox{}
1N/A
1N/ASome additional para.
1N/A
1N/A\begin{itemize}
1N/A
1N/A\item
1N/A
1N/ANested itemized list
1N/A
1N/A
1N/A\item
1N/A
1N/ASecond item
1N/A
1N/A\end{itemize}
1N/A
1N/A\item[some longer text than that] \mbox{}
1N/A
1N/Aand again.
1N/A
1N/A
1N/A\item[this text is even longer and greater than] \textbf{40 characters}
1N/A
1N/ASome more content for the item.
1N/A
1N/A
1N/A\item[this is some text with \textit{something across}] \textbf{the 40 char boundary}
1N/A
1N/AThis is item content.
1N/A
1N/A\end{description}
1N/A
1N/A
1N/AAnd this should be an enumerated list without any cruft after the numbers or additional numbers at all.
1N/A
1N/A\begin{enumerate}
1N/A
1N/A\item
1N/A
1N/Aitem 1
1N/A
1N/A
1N/A\item
1N/A
1N/Aitem 2
1N/A
1N/A\end{enumerate}
1N/A\section{Escapes\label{Escapes}\index{Escapes}}
1N/A
1N/A
1N/ATest some normal escapes such as $<$ (lt) and $>$ (gt) and $|$ (verbar) and
1N/A\texttt{\~{}} (tilde) and \& (amp) as well as $<$ (Esc lt) and $|$ (Esc
1N/Averbar) and \textfractionsolidus{} (Esc sol) and $>$ (Esc gt) and \& (Esc amp)
1N/Aand " (Esc quot) and even $\alpha$ (Esc alpha).
1N/A
1N/A\section{For blocks\label{For_blocks}\index{For blocks}}
1N/A Some latex code \textbf{here}.
1N/A
1N/A
1N/A
1N/ASome text that should appear.
1N/A
1N/A
1N/A
1N/ASome more text that should appear
1N/A
1N/ASome latex in a \textsf{begin block}
1N/A
1N/Aand some more
1N/A
1N/A\begin{equation}
1N/Aa = \frac{3}{2}
1N/A\end{equation}
1N/A
1N/A
1N/A
1N/ABack to pod.
1N/A
1N/A\printindex
1N/A
1N/A\end{document}
1N/A=pod
1N/A
1N/A=head1 Introduction
1N/A
1N/A=over 4
1N/A
1N/A=item *
1N/A
1N/AAlways check the return codes of system calls. Good error messages should
1N/Ago to STDERR, include which program caused the problem, what the failed
1N/Asystem call and arguments were, and (B<very important>) should contain
1N/Athe standard system error message for what went wrong. Here's a simple
1N/Abut sufficient example:
1N/A
1N/A opendir(D, $dir) or die "can't opendir $dir: $!";
1N/A
1N/A=item *
1N/A
1N/ALine up your transliterations when it makes sense:
1N/A
1N/A tr [abc]
1N/A [xyz];
1N/A
1N/AThe above should be aligned since it includes an embedded tab.
1N/A
1N/A=item *
1N/A
1N/AThink about reusability. Why waste brainpower on a one-shot when you
1N/Amight want to do something like it again? Consider generalizing your
1N/Acode. Consider writing a module or object class. Consider making your
1N/Acode run cleanly with C<use strict> and C<-w> (or C<use warnings> in
1N/APerl 5.6) in effect. Consider giving away your code. Consider changing
1N/Ayour whole world view. Consider... oh, never mind.
1N/A
1N/A=item *
1N/A
1N/ABe consistent.
1N/A
1N/A=item *
1N/A
1N/ABe nice.
1N/A
1N/A=back
1N/A
1N/A=head1 Links
1N/A
1N/AThis link should just include one word: L<Pod::LaTeX|Pod::LaTeX>
1N/A
1N/AThis link should include the text C<test> even though
1N/Ait refers to C<Pod::LaTeX>: L<test|Pod::LaTeX>.
1N/A
1N/AStandard link: L<Pod::LaTeX>.
1N/A
1N/ANow refer to an external section: L<Pod::LaTeX/"sec">
1N/A
1N/A
1N/A=head1 Lists
1N/A
1N/ATest description list with long lines
1N/A
1N/A=over 4
1N/A
1N/A=item Some short text
1N/A
1N/ASome additional para.
1N/A
1N/A=over 4
1N/A
1N/A=item *
1N/A
1N/ANested itemized list
1N/A
1N/A=item *
1N/A
1N/ASecond item
1N/A
1N/A=back
1N/A
1N/A=item some longer text than that
1N/A
1N/Aand again.
1N/A
1N/A=item this text is even longer and greater than 40 characters
1N/A
1N/ASome more content for the item.
1N/A
1N/A=item this is some text with I<something across> the 40 char boundary
1N/A
1N/AThis is item content.
1N/A
1N/A=back
1N/A
1N/AAnd this should be an enumerated list without any cruft after the numbers or additional numbers at all.
1N/A
1N/A=over 4
1N/A
1N/A=item 1)
1N/A
1N/Aitem 1
1N/A
1N/A=item 2.
1N/A
1N/Aitem 2
1N/A
1N/A=back
1N/A
1N/A=head1 Escapes
1N/A
1N/ATest some normal escapes such as < (lt) and > (gt) and | (verbar) and
1N/A~ (tilde) and & (amp) as well as E<lt> (Esc lt) and E<verbar> (Esc
1N/Averbar) and E<sol> (Esc sol) and E<gt> (Esc gt) and E<amp> (Esc amp)
1N/Aand E<quot> (Esc quot) and even E<alpha> (Esc alpha).
1N/A
1N/A=head1 For blocks
1N/A
1N/A=for latex
1N/A Some latex code \textbf{here}.
1N/A
1N/ASome text that should appear.
1N/A
1N/A=for comment
1N/A Should not print anything
1N/A
1N/ASome more text that should appear
1N/A
1N/A=begin latex
1N/A
1N/ASome latex in a \textsf{begin block}
1N/A
1N/Aand some more
1N/A
1N/A\begin{equation}
1N/Aa = \frac{3}{2}
1N/A\end{equation}
1N/A
1N/A=end latex
1N/A
1N/ABack to pod.
1N/A
1N/A=cut