Dave Jarvis' Repositories

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

Ingredients are now more customisable via the syntax \ingred{quantity}{unit}{ingredient name}. \normalingredients will display as a normal bulleted list; \compactingredients as an inline list; \tabularingredients as a tabular list. XSL updated to generate \ingred from XML.

Author liantze <email>
Date 2013-02-03 15:29:04 GMT+0800
Commit 3699748d93b00ad2548fd1bfd504219689bc6d87
Parent 4963320
example-recipe.tex
\documentclass{recipe-book}
-%\input{theme/Modern}
-\input{theme/Notebook}
+
+\input{theme/Modern}
+%\input{theme/Notebook}
%%% Fonts, colours and header/footer selections:
%%% List styles i.e. normal vs inline (compact) lists.
%\compactequipment
+
+%\normalingredients
%\compactingredients
+\tabularingredients
+
%\compactinstructions
\begin{equipment}
- \item[Bakeware] Bowl.
+ \item[Bakeware] Bowl
\item[Electric] Mixer
\end{equipment}
\begin{ingredients}[Dry Ingredients]
- \item 6\textonehalf\ cups bread flour
- \item 2 teaspoons yeast
- \item 3\textonequarter\ cups cold water
- \item 6 tablespoons olive oil
- \item 2--3 teaspoons salted sugar
+ \ingred{6\textonehalf}{cups}{bread flour}
+ \ingred{2}{teaspoons}{yeast}
+ \ingred{3\textonequarter}{cups}{cold water}
+ \ingred{6}{tablespoons}{olive oil}
+ \ingred{2--3}{teaspoons}{salted sugar}
+% \item 6\textonehalf\ cups bread flour
+% \item 2 teaspoons yeast
+% \item 3\textonequarter\ cups cold water
+% \item 6 tablespoons olive oil
+% \item 2--3 teaspoons salted sugar
\end{ingredients}
\begin{ingredients}[Ingredients]
- \item 1 duck
- \item 900 ml coconut milk
- \item 4 tablespoon curry paste
+ \ingred{1}{}{duck}
+ \ingred{900}{ml}{coconut milk}
+ \ingred{4}{tablespoons}{curry paste}
+% \item 1 duck
+% \item 900 ml coconut milk
+% \item 4 tablespoon curry paste
\end{ingredients}
\begin{ingredients}[Seasoning]
- \item 1.5 tablespoon fish sauce
+% \item 1.5 tablespoon fish sauce
+ \ingred{1.5}{tablespoons}{fish sauce}
\end{ingredients}
\begin{ingredients}
-\item 4 cups water
-\item 4-inch konbu kelp
-\item 1 handful dried bonito flakes
+\ingred{4}{cups}{water}
+\ingred{4}{inch}{konbu kelp}
+\ingred{1}{handful}{dried bonito flakes}
+%\item 4 cups water
+%\item 4-inch konbu kelp
+%\item 1 handful dried bonito flakes
\end{ingredients}
\begin{ingredients}
-\item 12$\frac{2}{3}$ oz rice
-\item 2 slices salted salmon
-\item 8 green shiso leaves
-\item 1 sheet nori seaweed, toasted
-\item 2 tablespoons minced shibazuke pickles
-\item 2 tablespoons white sesame seeds, toasted
+\ingred{12$\frac{2}{3}$}{oz}{rice}
+\ingred{2}{slices}{salted}{salmon}
+\ingred{8}{green}{shisho leaves}
+\ingred{1}{sheet}{nori seaweed, toasted}
+\ingred{2}{tablespoons}{minced}{shibazuke pickles}
+\ingred{2}{tablespoons}{white sesame seeds, toasted}
+%\item 12$\frac{2}{3}$ oz rice
+%\item 2 slices salted salmon
+%\item 8 green shiso leaves
+%\item 1 sheet nori seaweed, toasted
+%\item 2 tablespoons minced shibazuke pickles
+%\item 2 tablespoons white sesame seeds, toasted
\end{ingredients}
recipe-book.cls
}
+%\RequirePackage{pgfkeys}
+%\pgfkeys{
+% /myparbox/.is family, /myparbox,
+% width/.estore in = \myparboxWidth,
+% height/.estore in = \myparboxHeight,
+%}
+\newcommand{\ingred}[3]{%
+{#1} {#2} {#3}
+}
+
\newenvironment{ingredientlist}{%
+ \renewcommand{\ingred}[3]{\item {##1} {##2} {##3}}
\begin{itemize}
}{%
\end{itemize}
+}
+
+\newcommand{\tabularingredients}{%
+ \renewcommand{\ingred}[3]{{##1} {##2} & {##3}\\}
+ \renewenvironment{ingredientlist}{%
+ \begin{tabular}{r l}
+ }{%
+ \end{tabular}
+ }
}
\newcommand{\compactingredients}{%
+ \renewcommand{\ingred}[3]{\item {##1} {##2} {##3}}
\renewenvironment{ingredientlist}{%
\begin{itemize*}[label={},afterlabel={},itemjoin={{; }}]
}{%
\end{itemize*}.
}
}
\newcommand{\normalingredients}{%
+ \renewcommand{\ingred}[3]{\item {##1} {##2} {##3}}
\renewenvironment{ingredientlist}{%
\begin{itemize}
xsl/latex.xsl
<xsl:template match="ingredient">
- <xsl:text> \item </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:text>}{</xsl:text>
<xsl:value-of select="@unit"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="@condition" />
- <xsl:text> </xsl:text>
+ <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>&#xa;</xsl:text>
+ <xsl:text>}&#xa;</xsl:text>
</xsl:template>
Delta 74 lines added, 27 lines removed, 47-line increase