- Timestamp:
- 09/11/13 19:49:05 (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/recipe.html.xsl
r2 r4 2 2 3 3 <xsl:stylesheet version="1.0" 4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 5 xmlns:fo="http://www.w3.org/1999/XSL/Format"> 4 xmlns="http://www.w3.org/1999/xhtml" 5 xmlns:recipe="http://xmlns.grim.ath.cx/recipe" 6 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 6 7 7 <!-- TODO: come up with various page configurations, 8 e.g. index card, half letter, full letter hole-punched, etc. 9 --> 10 <xsl:param name="size">5x8</xsl:param> 11 <xsl:variable name="height" select="substring-before($size, 'x')"/> 12 <xsl:variable name="width" select="substring-after($size, 'x')"/> 13 14 <xsl:template match="recipe"> 15 <fo:root font-family="DejaVuSerif" font-size="10pt"> 16 <fo:layout-master-set> 17 <fo:simple-page-master master-name="recipe-card" page-height="{$height}in" page-width="{$width}in"> 18 <fo:region-body margin=".25in .5in .25in .25in"/> 19 </fo:simple-page-master> 20 </fo:layout-master-set> 21 22 <fo:page-sequence master-reference="recipe-card"> 23 <fo:flow flow-name="xsl-region-body"> 24 <xsl:apply-templates/> 25 </fo:flow> 26 </fo:page-sequence> 27 </fo:root> 8 <xsl:template match="recipe:recipe"> 9 <html> 10 <head> 11 <xsl:apply-templates select="title" mode="head"/> 12 </head> 13 <body class="hRecipe"> 14 <xsl:apply-templates/> 15 </body> 16 </html> 28 17 </xsl:template> 29 18 30 <xsl:template match="title"> 31 <fo:block margin-bottom=".5em" font-weight="bold"> 32 <xsl:value-of select="."/> 33 </fo:block> 19 <xsl:template match="recipe:title" mode="head"> 20 <title><xsl:value-of select="."/></title> 34 21 </xsl:template> 35 22 36 <xsl:template match="ingredients"> 37 <fo:block margin-bottom=".5em"> 38 <xsl:apply-templates/> 39 </fo:block> 23 <xsl:template match="recipe:title"> 24 <h1 class="fn"><xsl:value-of select="."/></h1> 40 25 </xsl:template> 41 26 42 <xsl:template match="ingredient"> 43 <fo:block line-height="1.25"><xsl:value-of select="."/></fo:block> 27 <xsl:template match="recipe:ingredients"> 28 <ul> 29 <xsl:apply-templates/> 30 </ul> 44 31 </xsl:template> 45 32 46 <xsl:template match=" note">47 < fo:block line-height="1.25" margin-left="1em" font-size="90%"><xsl:value-of select="."/></fo:block>33 <xsl:template match="recipe:ingredient"> 34 <li class="ingredient"><xsl:value-of select="."/></li> 48 35 </xsl:template> 49 36 50 <xsl:template match="para"> 51 <fo:block margin-bottom=".5em"> 37 <xsl:template match="recipe:note"> 38 <div style="margin-left:1em; font-size: 90%"><xsl:value-of select="."/></div> 39 </xsl:template> 40 41 <xsl:template match="recipe:para"> 42 <p> 52 43 <xsl:value-of select="."/> 53 </ fo:block>44 </p> 54 45 </xsl:template> 55 46 -
trunk/recipe.xsl
r2 r4 3 3 <xsl:stylesheet version="1.0" 4 4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 5 xmlns:recipe="http://xmlns.grim.ath.cx/recipe" 5 6 xmlns:fo="http://www.w3.org/1999/XSL/Format"> 6 7 … … 12 13 <xsl:variable name="width" select="substring-after($size, 'x')"/> 13 14 14 <xsl:template match="recipe ">15 <xsl:template match="recipe:recipe"> 15 16 <fo:root font-family="DejaVuSerif" font-size="10pt"> 16 17 <fo:layout-master-set> … … 28 29 </xsl:template> 29 30 30 <xsl:template match=" title">31 <xsl:template match="recipe:title"> 31 32 <fo:block margin-bottom=".5em" font-weight="bold"> 32 33 <xsl:value-of select="."/> … … 34 35 </xsl:template> 35 36 36 <xsl:template match=" ingredients">37 <xsl:template match="recipe:ingredients"> 37 38 <fo:block margin-bottom=".5em"> 38 39 <xsl:apply-templates/> … … 40 41 </xsl:template> 41 42 42 <xsl:template match=" ingredient">43 <xsl:template match="recipe:ingredient"> 43 44 <fo:block line-height="1.25"><xsl:value-of select="."/></fo:block> 44 45 </xsl:template> 45 46 46 <xsl:template match=" note">47 <xsl:template match="recipe:note"> 47 48 <fo:block line-height="1.25" margin-left="1em" font-size="90%"><xsl:value-of select="."/></fo:block> 48 49 </xsl:template> 49 50 50 <xsl:template match=" para">51 <xsl:template match="recipe:para"> 51 52 <fo:block margin-bottom=".5em"> 52 53 <xsl:value-of select="."/> -
trunk/recipe2xml
r2 r4 2 2 use strict; 3 3 4 #TODO: look at this existing XML format: http://www.happy-monkey.net/recipebook/doc/author-tutorial.html 5 4 6 $/ = ''; 5 7 6 print "<recipe>\n";8 print qq{<recipe xmlns="http://xmlns.grim.ath.cx/recipe">\n}; 7 9 while (<>) { 8 10 chomp; … … 37 39 s/(\d)x/$1⨯/g; 38 40 # temperature 39 s/(\d)\s*deg .(\s*F)?/$1℉/g;41 s/(\d)\s*deg(\.|rees)(\s*F)?/$1℉/g; 40 42 # fractions 41 43 s{1/3}{⅓}g;
Note: See TracChangeset
for help on using the changeset viewer.