Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/recipe-books.git
example-recipe.pdf
Binary files differ
example-recipe.tex
\begin{recipe}{Pizza Dôugh}
% from http://stockfresh.com/image/949544/preparing-pizza-dough-in-a-kitchen
- \illustration{stockfresh-pizzadough}
+ \photo{stockfresh-pizzadough}
\oven{350\,\textdegree F}
example-recipe.xml
-<?xml version="1.0" standalone="yes" ?>
+<?xml version="1.0" standalone="yes"?>
<recipe>
- <description>
- <title>Pizza D�ugh</title>
- </description>
- <preparation>
- <oven unit="F" temperature="350"/>
- </preparation>
- <equipment>
- <bakeware>
- <object id="2">bowl</object>
- </bakeware>
- <cookware/>
- <kitchenware/>
- <electric>
- <object id="1">mixer</object>
- </electric>
- <miscellaneous/>
- <utensils/>
- </equipment>
- <ingredients id="1" label="dry ingredients">
- <ingredient id="1" min-quantity="6.5" unit="cup" condition="" optional="false">bread flour</ingredient>
- <ingredient id="2" min-quantity="2" unit="teaspoon" condition="" optional="false">yeast</ingredient>
- <ingredient id="3" min-quantity="3.25" unit="cup" condition="" optional="false">cold water</ingredient>
- <ingredient id="4" min-quantity="6" unit="tablespoon" condition="" optional="false">olive oil</ingredient>
- <ingredient id="5" min-quantity="2" max-quantity="3" unit="teaspoon" condition="salt" optional="false">sugar</ingredient>
- </ingredients>
- <directions/>
- <directions label="instructions">
- <step action="mix" min-time="1" seq="1">yeast, sugar and salt together with a cup of water</step>
- <step action="put" min-time="1" seq="2">5 cups of flour in mixer</step>
- <step action="add" min-time="1" seq="3">yeast mixture, olive oil and water</step>
- <step action="start" min-time="1" seq="4">mixing</step>
- <step action="add" min-time="1" seq="5">remaining flour until you get a moist ball of dough</step>
- <step action="do" min-time="1" seq="6">not put to much flour in because the dough will get too dry</step>
- <step action="dough" min-time="1" seq="7">for around 10 minutes</step>
- <step action="leave" min-time="1" seq="8">it in the mixer and let the dough hook do the trick</step>
- <step action="cut" min-time="1" seq="9">the dough ball into 8 individual balls</step>
- <step action="coat" min-time="1" seq="10">each ball with more olive oil, put them in a bowl and let them rise over night in the fridge</step>
- <step action="take" min-time="1" seq="11">them out of the fridge an hour prior to cooking</step>
- <step action="take" min-time="1" seq="12">3 or 4 minutes to cook depending on toppings</step>
- </directions>
- <directions label="more instructions">
- <step action="put" min-time="1" seq="13">the cake on a wire rack</step>
- </directions>
- <tags></tags>
+ <description>
+ <title>Pizza Dôugh</title>
+ </description>
+ <preparation>
+ <oven unit="F" temperature="350"/>
+ </preparation>
+ <equipment>
+ <bakeware>
+ <object id="2">bowl</object>
+ </bakeware>
+ <cookware/>
+ <kitchenware/>
+ <electric>
+ <object id="1">mixer</object>
+ </electric>
+ <miscellaneous/>
+ <utensils/>
+ </equipment>
+ <ingredients id="1" label="dry ingredients">
+ <ingredient id="1" min-quantity="6.5" unit="cup" condition="" optional="false">bread flour</ingredient>
+ <ingredient id="2" min-quantity="2" unit="teaspoon" condition=""
+ optional="false">yeast</ingredient>
+ <ingredient id="3" min-quantity="3.25" unit="cup" condition="" optional="false">cold water</ingredient>
+ <ingredient id="4" min-quantity="6" unit="tablespoon" condition=""
+ optional="false">olive oil</ingredient>
+ <ingredient id="5" min-quantity="2" max-quantity="3" unit="teaspoon"
+ condition="salt" optional="false">sugar</ingredient>
+ </ingredients>
+ <directions/>
+ <directions label="instructions">
+ <step action="mix" min-time="1" seq="1">yeast, sugar and salt together with a cup of water</step>
+ <step action="put" min-time="1" seq="2">5 cups of flour in mixer</step>
+ <step action="add" min-time="1" seq="3">yeast mixture, olive oil and water</step>
+ <step action="start" min-time="1" seq="4">mixing</step>
+ <step action="add" min-time="1" seq="5">remaining flour until you get a moist ball of dough</step>
+ <step action="do" min-time="1" seq="6">not put to much flour in because the dough will get too dry</step>
+ <step action="dough" min-time="1" seq="7">for around 10 minutes</step>
+ <step action="leave" min-time="1" seq="8">it in the mixer and let the dough hook do the trick</step>
+ <step action="cut" min-time="1" seq="9">the dough ball into 8 individual balls</step>
+ <step action="coat" min-time="1" seq="10">each ball with more olive oil, put them in a bowl and let them rise over night in the fridge</step>
+ <step action="take" min-time="1" seq="11">them out of the fridge an hour prior to cooking</step>
+ <step action="take" min-time="1" seq="12">3 or 4 minutes to cook depending on toppings</step>
+ </directions>
+ <directions label="more instructions">
+ <step action="put" min-time="1" seq="13">the cake on a wire rack</step>
+ </directions>
+ <tags></tags>
</recipe>
+
recipe-book.cls
\includegraphics[width=.4\textwidth]{#1}\par
}
+\newcommand{\photo}[1]{\illustration{#1}}
\newenvironment{equipment}[1][Equipment]{%
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">
+
+<xsl:import href="string-utilities.xsl" />
+<xsl:import href="constants.xsl" />
+<xsl:import href="footer.xsl" />
+
+<xsl:output method="text" encoding="utf-8"/>
+<xsl:strip-space elements="*" />
+
+<xsl:template match="/" >
+ <xsl:apply-templates select="*" />
+</xsl:template>
+
+<xsl:template match="*" />
+
+
+<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:template>
+
+
+<xsl:template match="preparation">
+ <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:template>
+
+<xsl:template match="equipment">
+ <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">
+ <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> \item </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:value-of select="@condition" />
+ <xsl:text> </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:template>
+
+<xsl:template match="directions">
+ <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:template>
+</xsl:stylesheet>

Initial commit for latex.xsl, which transforms a recipe XML node to a LaTeX recipe environment.

Author liantze <email>
Date 2013-01-18 00:02:10 GMT+0800
Commit 42ffb29dd18bcec5da84e372fe4c2d03a734244f
Parent b618d36
Delta 163 lines added, 46 lines removed, 117-line increase