-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
4,104 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,61 @@ | ||
#!perl -w | ||
# -------------------------------------------------------------------- | ||
use strict; | ||
use Pod::PseudoPod::LaTeX 1.101050; | ||
use warnings; | ||
use feature ':5.10'; | ||
use Getopt::Long; | ||
use Perl6BookLatex; | ||
use Template; | ||
|
||
# -------------------------------------------------------------------- | ||
main(); | ||
sub main { | ||
my $paper; | ||
GetOptions( | ||
# Should be one of: a4, letter. | ||
'paper:s' => \$paper, | ||
) or die; | ||
# We set these two dimensions the same for both A4 and letter | ||
# paper sizes, so that the page breaks occur at the same place | ||
# in both versions. | ||
my $textheight = 611; | ||
my $textwidth = 360; | ||
# This value is based on knowing the paper widths (A4: 595, | ||
# paper: 612) and the LaTeX \oddsidemargin for those paper | ||
# sizes. | ||
my $hoffset; | ||
if ($paper eq 'a4') { | ||
$hoffset = ((595 - $textwidth) / 2) - 72 - 2; | ||
} | ||
elsif ($paper eq 'letter') { | ||
$hoffset = ((612 - $textwidth) / 2) - 72 - 4; | ||
} | ||
else { | ||
die "Invalid 'paper' option: '$paper'. Should be 'a4' or 'letter'."; | ||
} | ||
my $page_dim = << "EOT"; | ||
\\textheight ${textheight}pt | ||
\\textwidth ${textwidth}pt | ||
\\hoffset ${hoffset}pt | ||
EOT | ||
|
||
my $output; | ||
for (@ARGV) { | ||
my $parser = Perl6BookLatex->new(); | ||
$parser->emit_environments( sidebar => "sidebar" ); | ||
$parser->codes_in_verbatim(1); | ||
$parser->output_string( \$output ); | ||
$parser->parse_file($_); | ||
} | ||
|
||
my $tt = Template->new( { | ||
INCLUDE_PATH => 'lib', | ||
} ); | ||
|
||
print $tt->process( 'book.sty', { | ||
content => $output, | ||
paper => $paper, | ||
page_dim => $page_dim, | ||
} ); | ||
|
||
print <<'HEADER'; | ||
\documentclass[11pt,a4paper,oneside]{report} | ||
\usepackage{graphics,graphicx} | ||
\usepackage{colortbl} | ||
\usepackage{fancyvrb} | ||
\usepackage[T1]{fontenc} | ||
\usepackage{bera} | ||
\usepackage[utf8]{inputenc} | ||
\usepackage{makeidx} | ||
\usepackage[colorlinks=true,pagebackref]{hyperref} | ||
\makeindex | ||
\title{Using Perl~6} | ||
\author{Jonathan S. Duff, Moritz Lenz, Carl Mäsak, Patrick R. Michaud, Jonathan Worthington} | ||
\begin{document} | ||
\maketitle | ||
\tableofcontents | ||
HEADER | ||
|
||
for (@ARGV) { | ||
my $parser = Pod::PseudoPod::LaTeX->new(); | ||
$parser->codes_in_verbatim(1); | ||
$parser->output_fh( *STDOUT ); | ||
$parser->parse_file( $_ ); | ||
} | ||
|
||
print <<'FOOTER'; | ||
\printindex | ||
\end{document} | ||
FOOTER |
Oops, something went wrong.