Dave Jarvis' Repositories

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

This page describes how XML snippets are mapped to LaTeX snippets.

All internationalization is performed in the database. This allows the user interface to be consistent, linguistically, with the database.

# Recipe Book Container

A recipe book's main element is **book**.

## XML

```
#!xml

<book id="">
	<title>Creative Caramel Catastrophes</title>
	<author/>
	<isbn/>
	<created format="YYYY-MM-DD">2013-02-02</created>
	<photo use="front-cover">
		<uri>http://i.imgur.com/p71y6mq.jpg</uri>
	</photo>
	<recipe id="">
		...
	</recipe>
	<recipe id="">
		...
	</recipe>
</book>
```

The recipes are listed in the order they must appear in the book.

# Recipe Container

A recipe's main element is **recipe**.

## XML

```
#!xml

<recipe>
	<description>
		<title>Pizza Dôugh</title>
		<photo use="recipe-inset">
			<uri>http://www.templeofthai.com/images/recipes/duck-curry-1000x665-Pangfolio-shutterstock.jpg</uri>
		</photo>
	</description>
	...
</recipe>
```

## LaTeX

```
#!latex

\begin{recipe}{Pizza Dôugh}
   …
\end{recipe}

```

## Photo

Note that LaTeX accepts only JPG, PNG and PDF images. (`photo` tag is not yet implemented?)

XML code:

````
<photo>pizza-dough.jpg</photo>
````

LaTeX code:

````
\photo{pizza-dough}
````

## Preparation

XML code:

````
<preparation>
	<oven unit="F" temperature="350"/>
</preparation>
````

LaTeX code:

````
\oven{350\,\textdegree F}
````

* Format temperature unit -- doable with XSL
* (Does preparation involve only preheating the oven?)

## Equipment

XMl code:

````
<equipment>
	<bakeware>
		<object id="2">bowl</object>
	</bakeware>
	<cookware/>
	<kitchenware/>
	<electric>
		<object id="1">mixer</object>
	</electric>
	<miscellaneous/>
	<utensils/>
</equipment>
````

LaTeX code:

````
\begin{equipment}
	\item[Bakeware] Bowl
	\item[Electric] Mixer
\end{equipment}
````

Only non-empty equipment is output to LaTeX code.

## Ingredients

XML code:

````
<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>
````

LaTeX code:

````
\begin{ingredients}[Dry Ingredients]
	\item 6.5 cups bread flour
	\item 2 teaspoons yeast
	\item 3.25 cups cold water
	\item 6 tablespoons olive oil
	\item 2--3 teaspoons salt sugar
\end{ingredients}
````

Necessary tweaks:

* Make the ingredients list heading title-cased (XSL)
* Add plurals to units wherever necessary (XSL)
* Use fractions instead -- 3¼ is easier to read than 3.25 (XSL)

### Condition Attribute ###

The `condition` attribute contains a set of actions performed on the ingredient. For example:

`<ingredient id="5" min-quantity="0.5" unit="cup" condition="chop" optional="false">onion</ingredient>`

The onion has a "chopped" precondition. Using the active voice it becomes: Chop onion.

## Directions ##

XML code:

````
<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>
	…
</directions>
````

LaTeX code:

````
\begin{instructions}[Instructions]
	\item Mix yeast, sugar and salt together with a cup of water.
	\item Put 5 cups of flour in mixer.
\end{instructions}
````

Necessary tweaks:

* Make directions heading title-cased
* Capitalise `action`

When both `min-time` and `max-time` attributes are present, the text should read:

* Boil for `min-time` - `max-time` minutes.
* Cook for 8 - 10 minutes.

The mdash could be used, or the word "to". Using an mdash is likely easier for translation.