Index: trunk/font.cfg
===================================================================
--- trunk/font.cfg	(revision 2)
+++ trunk/font.cfg	(revision 2)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fop>
+  <renderers>
+    <renderer mime="application/pdf">
+      <!-- set up the DejaVu unicode font for the recipe cards -->
+      <fonts>
+        <font embed-url="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf">
+          <font-triplet name="DejaVuSerif" style="normal" weight="normal"/>
+        </font>
+        <font embed-url="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Bold.ttf">
+          <font-triplet name="DejaVuSerif" style="normal" weight="bold"/>
+        </font>
+        <font embed-url="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Italic.ttf">
+          <font-triplet name="DejaVuSerif" style="italic" weight="normal"/>
+        </font>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>
Index: trunk/mkrecipe
===================================================================
--- trunk/mkrecipe	(revision 2)
+++ trunk/mkrecipe	(revision 2)
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+./recipe2xml $1 | xsltproc --stringparam size 11x8.5 recipe.xsl - > recipe.fo
+
+fop -c font.cfg -fo recipe.fo -pdf $1.pdf 2> /dev/null
+
+rm recipe.fo
Index: trunk/recipe.xsl
===================================================================
--- trunk/recipe.xsl	(revision 2)
+++ trunk/recipe.xsl	(revision 2)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+  <!-- TODO: come up with various page configurations,
+       e.g. index card, half letter, full letter hole-punched, etc.
+  -->
+  <xsl:param name="size">5x8</xsl:param>
+  <xsl:variable name="height" select="substring-before($size, 'x')"/>
+  <xsl:variable name="width" select="substring-after($size, 'x')"/>
+
+  <xsl:template match="recipe">
+    <fo:root font-family="DejaVuSerif" font-size="10pt">
+      <fo:layout-master-set>
+	<fo:simple-page-master master-name="recipe-card" page-height="{$height}in" page-width="{$width}in">
+	  <fo:region-body margin=".25in .5in .25in .25in"/>
+	</fo:simple-page-master>
+      </fo:layout-master-set>
+
+      <fo:page-sequence master-reference="recipe-card">
+	<fo:flow flow-name="xsl-region-body">
+	  <xsl:apply-templates/>
+	</fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </xsl:template>
+
+  <xsl:template match="title">
+    <fo:block margin-bottom=".5em" font-weight="bold">
+      <xsl:value-of select="."/>
+    </fo:block>
+  </xsl:template>
+
+  <xsl:template match="ingredients">
+    <fo:block margin-bottom=".5em">
+      <xsl:apply-templates/>
+    </fo:block>
+  </xsl:template>
+
+  <xsl:template match="ingredient">
+    <fo:block line-height="1.25"><xsl:value-of select="."/></fo:block>
+  </xsl:template>
+
+  <xsl:template match="note">
+    <fo:block line-height="1.25" margin-left="1em" font-size="90%"><xsl:value-of select="."/></fo:block>
+  </xsl:template>
+
+  <xsl:template match="para">
+    <fo:block margin-bottom=".5em">
+      <xsl:value-of select="."/>
+    </fo:block>
+  </xsl:template>
+
+</xsl:stylesheet>
Index: trunk/recipe2xml
===================================================================
--- trunk/recipe2xml	(revision 2)
+++ trunk/recipe2xml	(revision 2)
@@ -0,0 +1,56 @@
+#!/usr/bin/perl -w
+use strict;
+
+$/ = '';
+
+print "<recipe>\n";
+while (<>) {
+    chomp;
+    s/^\s+//g;
+    s/\s+$//g;
+    if (/^##\s+(.*)/) {
+	# title
+	print "<title>$1</title>";
+    } elsif (/^\d/) {
+	# ingredient list
+	print '<ingredients>';
+	foreach (split /\n/, $_) {
+            /^\s+/ ? print '<note>' . apply_symbols($_) . '</note>'
+                   : print '<ingredient>' . apply_symbols($_) . '</ingredient>';
+	}
+	print '</ingredients>';
+    } else {
+        # TODO: catch special body paragraphs, like "Note:", "Serves", "Yields", etc.
+	# body
+	# fold the lines together
+	s/\n/ /;
+	print '<para>' . apply_symbols($_) . '</para>';
+    }
+}
+print '</recipe>';
+
+
+sub apply_symbols {
+    my $string = shift;
+    for ($string) {
+	# numeric dimensions
+	s/(\d)x/$1⨯/g;
+	# temperature
+	s/(\d)\s*deg.(\s*F)?/$1℉/g;
+	# fractions
+	s{1/3}{⅓}g;
+	s{2/3}{⅔}g;
+	s{1/4}{¼}g;
+	s{1/2}{½}g;
+	s{3/4}{¾}g;
+        s{1/8}{⅛}g;
+	# inches
+	s/(\d)[ -]?(in\.|in\b|inch)/$1″/g;
+	# numeric range en dashes
+	s/(\d)-(\d)/$1–$2/g;
+	# remove dash before vulgar fractions
+	s/(\d)-([¼½¾⅓⅔])/$1$2/g;
+    }
+    return $string;
+}
+
