Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/recipe-books.git

Added styling for hyperlinks. Currently uses primary and secondary colours.

AuthorDave Jarvis <email>
Date2013-02-05 21:50:06 GMT-0800
Commitdbfb048dcf7e83896805b83b9e0cc372d364c7d3
Parentede0604
example-web.pdf
Binary files differ
pdf/hyperlinks.tex
+% PDF hyperlink style and configuration
+\hypersetup{
+ % Show bookmarks bar?
+ bookmarks=true,
+ % Non-Latin characters in Acrobat's bookmarks
+ unicode=true,
+ % Show Acrobat's toolbar?
+ pdftoolbar=true,
+ % Show Acrobat's menu?
+ pdfmenubar=true,
+ % Window fit to page when opened
+ pdffitwindow=false,
+ % Fit the width of the page to the window
+ pdfstartview={FitH},
+ % TODO: Title
+ %pdftitle={Recipe Title},
+ % TODO: author
+ %pdfauthor={Recipe Book Author},
+ % subject of the document
+ pdfsubject={Recipes},
+ % Creator of the document
+ pdfcreator={LianTze Lim},
+ % Producer of the document
+ pdfproducer={pdflatex},
+ % TODO: List of keywords
+ pdfkeywords={recipe},
+ % Links in new window
+ pdfnewwindow=true,
+ % false: boxed links; true: colored links
+ colorlinks=true,
+ % Color of internal links
+ linkcolor=primarycolor,
+ % Color of links to bibliography
+ citecolor=black,
+ % Color of file links
+ filecolor=black,
+ % Color of external links
+ urlcolor=secondarycolor,
+ % No border around links
+ pdfborder={0 0 0}
+}
xsl/latex.xsl
<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:r="http://www.whitemagicsoftware.com/software/recipe"
- xmlns:string="http://symphony-cms.com/functions"
- xmlns:str="http://exslt.org/strings"
- exclude-result-prefixes="r str string">
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:r="http://www.whitemagicsoftware.com/software/recipe"
+ xmlns:string="http://symphony-cms.com/functions"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="r str string">
<xsl:import href="string-utilities.xsl" />
<xsl:output method="text" encoding="utf-8"/>
<xsl:strip-space elements="*" />
<!-- LaTeX premable inserted at the top of the document as text. -->
-<xsl:param name="preamble" />
+<xsl:param name="preamble" select="''" />
-<!-- If fullbook is true, cover, TOC, index etc will be generated. -->
-<xsl:param name="fullbook" />
+<!-- If recipetoc is true, generate TOC. -->
+<xsl:param name="recipe-toc" select="true()" />
+
+<!-- If ingredientindex is true, generate the ingredient index. -->
+<xsl:param name="ingredient-index" select="true()" />
+
+<!-- If bookcopyright is true, generate the copyright page. -->
+<xsl:param name="book-copyright" select="true()" />
+
+<!-- These will come from the XML...
+<xsl:param name="bookfrontcover" select="" />
+<xsl:param name="bookbackcover" select="" />
+-->
<xsl:template match="/" >
- <xsl:apply-templates />
+ <xsl:apply-templates />
</xsl:template>
<xsl:template match="recipe-book">
<xsl:text>\documentclass{recipe-book}&#xa;</xsl:text>
+ <xsl:text>\usepackage{hyperref}&#xa;</xsl:text>
<xsl:value-of select="$preamble" />
<xsl:text>\makeindex&#xa;</xsl:text>
- <xsl:text>\usepackage{hyperref}&#xa;</xsl:text>
<xsl:text>\begin{document}&#xa;</xsl:text>
- <xsl:if test="$fullbook='true'">
- <xsl:text>\frontmatter&#xa;</xsl:text>
- <xsl:text>\tableofcontents*&#xa;</xsl:text>
- </xsl:if>
- <xsl:text>\mainmatter&#xa;</xsl:text>
+ <xsl:if test="$recipe-toc">
+ <xsl:text>\frontmatter&#xa;</xsl:text>
+ <xsl:text>\tableofcontents*&#xa;</xsl:text>
+ </xsl:if>
+ <xsl:text>\mainmatter&#xa;</xsl:text>
<xsl:apply-templates />
- <xsl:if test="$fullbook='true'">
- <xsl:text>\printindex&#xa;</xsl:text>
- </xsl:if>
+ <xsl:if test="$ingredient-index">
+ <xsl:text>\printindex&#xa;</xsl:text>
+ </xsl:if>
<xsl:text>\end{document}&#xa;</xsl:text>
</xsl:template>
<xsl:template match="book">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="recipe">
- <xsl:text>\begin{recipe}{</xsl:text>
- <xsl:value-of select="normalize-space(string:capitalize-words(description/title))" />
- <xsl:text>}&#xa;</xsl:text>
- <xsl:apply-templates select="*"/>
- <xsl:text>\end{recipe}&#xa;&#xa;</xsl:text>
+ <xsl:text>\begin{recipe}{</xsl:text>
+ <xsl:value-of select="normalize-space(string:capitalize-words(description/title))" />
+ <xsl:text>}&#xa;</xsl:text>
+ <xsl:apply-templates select="*"/>
+ <xsl:text>\end{recipe}&#xa;&#xa;</xsl:text>
</xsl:template>
<xsl:template match="preparation">
- <xsl:apply-templates select="*"/>
+ <xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="oven">
- <xsl:text>\oven{</xsl:text>
- <xsl:value-of select="@temperature" />
- <xsl:text>\,</xsl:text>
- <xsl:choose>
- <xsl:when test="@unit='C' or @unit='F'">
- <xsl:text>\textdegree </xsl:text>
- </xsl:when>
- </xsl:choose>
- <xsl:value-of select="@unit" />
- <xsl:text>}&#xa;&#xa;</xsl:text>
+ <xsl:text>\oven{</xsl:text>
+ <xsl:value-of select="@temperature" />
+ <xsl:text>\,</xsl:text>
+ <xsl:choose>
+ <xsl:when test="@unit='C' or @unit='F'">
+ <xsl:text>\textdegree </xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:value-of select="@unit" />
+ <xsl:text>}&#xa;&#xa;</xsl:text>
</xsl:template>
<xsl:template match="equipment[descendant::text()]">
- <xsl:text>\begin{equipment}&#xa;</xsl:text>
- <!-- select non-empty child nodes -->
- <xsl:for-each select="*[child::*]">
- <xsl:text> \item[</xsl:text>
- <xsl:value-of select="normalize-space(string:capitalize-words(name()))" />
- <xsl:text>] </xsl:text>
- <xsl:value-of select="normalize-space(string:capitalize-words(.))" />
- <xsl:text>&#xa;</xsl:text>
- </xsl:for-each>
- <xsl:text>\end{equipment}&#xa;&#xa;</xsl:text>
+ <xsl:text>\begin{equipment}&#xa;</xsl:text>
+ <!-- select non-empty child nodes -->
+ <xsl:for-each select="*[child::*]">
+ <xsl:text> \item[</xsl:text>
+ <xsl:value-of select="normalize-space(string:capitalize-words(name()))" />
+ <xsl:text>] </xsl:text>
+ <xsl:value-of select="normalize-space(string:capitalize-words(.))" />
+ <xsl:text>&#xa;</xsl:text>
+ </xsl:for-each>
+ <xsl:text>\end{equipment}&#xa;&#xa;</xsl:text>
</xsl:template>
<xsl:template match="ingredients[descendant::text()]">
- <xsl:text>\begin{ingredients}</xsl:text>
- <xsl:if test="@label">
- <xsl:text>[</xsl:text>
- <xsl:value-of select="normalize-space(string:capitalize-words(@label))"/>
- <xsl:text>]</xsl:text>
- </xsl:if>
- <xsl:text>&#xa;</xsl:text>
- <xsl:apply-templates select="ingredient"/>
- <xsl:text>\end{ingredients}&#xa;&#xa;</xsl:text>
+ <xsl:text>\begin{ingredients}</xsl:text>
+ <xsl:if test="@label">
+ <xsl:text>[</xsl:text>
+ <xsl:value-of select="normalize-space(string:capitalize-words(@label))"/>
+ <xsl:text>]</xsl:text>
+ </xsl:if>
+ <xsl:text>&#xa;</xsl:text>
+ <xsl:apply-templates select="ingredient"/>
+ <xsl:text>\end{ingredients}&#xa;&#xa;</xsl:text>
</xsl:template>
<xsl:template match="ingredient">
- <xsl:text> \ingred{</xsl:text>
- <xsl:value-of select="@min-quantity"/>
- <xsl:if test="@max-quantity">
- <xsl:text>--</xsl:text>
- <xsl:value-of select="@max-quantity"/>
- </xsl:if>
- <xsl:text>}{</xsl:text>
- <xsl:value-of select="@unit"/>
- <xsl:text>}{</xsl:text>
- <xsl:if test="@condition !=''">
- <xsl:value-of select="@condition" />
- <xsl:text> </xsl:text>
- </xsl:if>
- <xsl:value-of select="."/>
- <xsl:text>}\index{</xsl:text>
- <xsl:value-of select="."/>
- <xsl:text>}&#xa;</xsl:text>
+ <xsl:text> \ingred{</xsl:text>
+ <xsl:value-of select="@min-quantity"/>
+ <xsl:if test="@max-quantity">
+ <xsl:text>--</xsl:text>
+ <xsl:value-of select="@max-quantity"/>
+ </xsl:if>
+ <xsl:text>}{</xsl:text>
+ <xsl:value-of select="@unit"/>
+ <xsl:text>}{</xsl:text>
+ <xsl:if test="@condition !=''">
+ <xsl:value-of select="@condition" />
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ <xsl:value-of select="."/>
+ <xsl:text>}\index{</xsl:text>
+ <xsl:value-of select="."/>
+ <xsl:text>}&#xa;</xsl:text>
</xsl:template>
<xsl:template match="directions[1]">
- <xsl:text>\startinstructions&#xa;&#xa;</xsl:text>
+ <xsl:text>\startinstructions&#xa;&#xa;</xsl:text>
</xsl:template>
<xsl:template match="directions[descendant::text()]">
- <xsl:text>\begin{instructions}</xsl:text>
- <xsl:if test="@label">
- <xsl:text>[</xsl:text>
- <xsl:value-of select="normalize-space(string:capitalize-words(@label))"/>
- <xsl:text>]</xsl:text>
- </xsl:if>
- <xsl:text>&#xa;</xsl:text>
- <xsl:apply-templates select="step" />
- <xsl:text>\end{instructions}&#xa;&#xa;</xsl:text>
+ <xsl:text>\begin{instructions}</xsl:text>
+ <xsl:if test="@label">
+ <xsl:text>[</xsl:text>
+ <xsl:value-of select="normalize-space(string:capitalize-words(@label))"/>
+ <xsl:text>]</xsl:text>
+ </xsl:if>
+ <xsl:text>&#xa;</xsl:text>
+ <xsl:apply-templates select="step" />
+ <xsl:text>\end{instructions}&#xa;&#xa;</xsl:text>
</xsl:template>
<xsl:template match="step">
- <xsl:text> \item </xsl:text>
- <xsl:value-of select="normalize-space(string:capitalize(@action))" />
- <xsl:text> </xsl:text>
- <xsl:value-of select="." />
- <xsl:text>.&#xa;</xsl:text>
+ <xsl:text> \item </xsl:text>
+ <xsl:value-of select="normalize-space(string:capitalize(@action))" />
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="." />
+ <xsl:text>.&#xa;</xsl:text>
</xsl:template>
Delta137 lines added, 85 lines removed, 52-line increase