aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-07-28 12:17:48 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-07-28 12:17:48 -0700
commit276f2807bf7c5f3226c6d649b0bbf7bc5f964880 (patch)
treeee94725037c0e15513ecec5700abb9350a0164ff /tools
parent06e899d9e860b11c5ffac3f936024d04ecd0bbe4 (diff)
Fixed various problems with spec.pdf generation.
Closes #353.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/makespec.py7
-rwxr-xr-xtools/specfilter.hs9
-rw-r--r--tools/template.tex47
3 files changed, 22 insertions, 41 deletions
diff --git a/tools/makespec.py b/tools/makespec.py
index cde8d14..26247c5 100755
--- a/tools/makespec.py
+++ b/tools/makespec.py
@@ -68,7 +68,10 @@ with open('spec.txt', 'r', encoding='utf-8') as spec:
if stage == 0:
example += 1
mdlines.append("\n<div class=\"example\" id=\"example-{0}\" data-section=\"{1}\">\n".format(example, section))
- mdlines.append("<div class=\"examplenum\"><a href=\"#example-{0}\">Example {0}</a>&nbsp;&nbsp;<a class=\"dingus\" title=\"open in interactive dingus\">(interact)</a></div>\n\n".format(example))
+ mdlines.append("<div class=\"examplenum\"><a href=\"#example-{0}\">Example {0}</a>".format(example))
+ if specformat == "html":
+ mdlines.append("&nbsp;&nbsp;<a class=\"dingus\" title=\"open in interactive dingus\">(interact)</a>")
+ mdlines.append("</div>\n\n")
mdlines.append("````````````````````````````````````````````````````````` markdown\n")
stage = 1
elif stage == 1:
@@ -105,7 +108,7 @@ with open('spec.txt', 'r', encoding='utf-8') as spec:
lastnum[level - 1] = lastnum[level - 1] + 1
number = '.'.join([str(x) for x in lastnum])
ident = toIdentifier(section)
- ln = re.sub(r' ', ' ' + number + ' ', ln, count=1)
+ ln = re.sub(r' ', ' <span class="number">' + number + '</span> ', ln, count=1)
sections.append(dict(level=level,
contents=section,
ident=ident,
diff --git a/tools/specfilter.hs b/tools/specfilter.hs
index 7a7676b..7f4df9f 100755
--- a/tools/specfilter.hs
+++ b/tools/specfilter.hs
@@ -15,12 +15,12 @@ exampleDivs (Div (ident, ["example"], kvs)
]) = Div (ident, ["example"], kvs)
[ rawtex "\\begin{minipage}[t]{\\textwidth}\n{\\scriptsize "
, d
- , rawtex "\\vspace{-1em}}"
- , rawtex "\\begin{minipage}[t]{0.49\\textwidth}\n\\definecolor{shadecolor}{gray}{0.85}\n"
+ , rawtex "}\\vspace{-0.4em}\n"
+ , rawtex "\\begin{minipage}[t]{0.49\\textwidth}\n\\definecolor{shadecolor}{gray}{0.85}\n\\begin{snugshade}\\small\n"
, addBreaks c1
- , rawtex "\\end{minipage}\n\\hfill\n\\begin{minipage}[t]{0.49\\textwidth}\n\\definecolor{shadecolor}{gray}{0.95}\n"
+ , rawtex "\\end{snugshade}\n\\end{minipage}\n\\hfill\n\\begin{minipage}[t]{0.49\\textwidth}\n\\definecolor{shadecolor}{gray}{0.95}\n\\begin{snugshade}\\small\n"
, addBreaks c2
- , rawtex "\\end{minipage}\n\\end{minipage}"
+ , rawtex "\\end{snugshade}\n\\end{minipage}\n\\end{minipage}"
]
where rawtex = RawBlock (Format "latex")
addBreaks (CodeBlock attrs code) = CodeBlock attrs $ addBreaks' code
@@ -33,4 +33,5 @@ exampleDivs x = x
anchors :: Inline -> [Inline]
anchors (Link text ('@':lab,_)) =
[RawInline (Format "latex") ("\\hyperdef{}{" ++ lab ++ "}{\\label{" ++ lab ++ "}}"), Strong text]
+anchors (Span ("",["number"],[]) xs) = [] -- remove sect numbers
anchors x = [x]
diff --git a/tools/template.tex b/tools/template.tex
index d083b72..64893c2 100644
--- a/tools/template.tex
+++ b/tools/template.tex
@@ -44,6 +44,8 @@ $endif$
% use microtype if available
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
\usepackage[margin=1in]{geometry}
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
$if(natbib)$
\usepackage{natbib}
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
@@ -61,40 +63,10 @@ $if(lhs)$
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
\usepackage{fancyvrb}
+$if(highlighting-macros)$
+$highlighting-macros$
+$endif$
\usepackage{color,framed}
-\newcommand{\VerbBar}{|}
-\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
-\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\},fontsize=\small}
-% Add ',fontsize=\small' for more characters per line
-\definecolor{shadecolor}{gray}{1}
-\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
-\newcommand{\NormalTok}[1]{{#1}}
-\let\KeywordTok\NormalTok
-\let\DataTypeTok\NormalTok
-\let\DecValTok\NormalTok
-\let\BaseNTok\NormalTok
-\let\FloatTok\NormalTok
-\let\CharTok\NormalTok
-\let\StringTok\NormalTok
-\let\CommentTok\NormalTok
-\let\OtherTok\NormalTok
-\let\AlertTok\NormalTok
-\let\FunctionTok\NormalTok
-\let\RegionMarkerTok\NormalTok
-\let\ErrorTok\NormalTok
-%\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
-%\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
-%\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
-%\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
-%\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
-%\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
-%\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
-%\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
-%\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
-%\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
-%\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
-%\newcommand{\RegionMarkerTok}[1]{{#1}}
-%\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
$if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
@@ -158,8 +130,13 @@ $if(lang)$
\fi
$endif$
-\usepackage{titlesec}
-\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\ }{0pt}{\Huge\bfseries}
+\usepackage[small]{titlesec}
+\titleformat{\chapter}
+ {\Large\bfseries} % format
+ {\Large\thechapter} % label
+ {0pt} % sep
+ {\Large} % before-code
+
\usepackage{fancyhdr}
\pagestyle{fancy}