[uf-discuss] hRecipe - one suggestion, a lot of comments
Toby A Inkster
mail at tobyinkster.co.uk
Wed Sep 24 14:07:36 PDT 2008
Thomas Loertsch wrote:
> as I already posted here we're planning to implement hRecipe at
> "essen &
> trinken" [1]. I think hRecipe is in quite a good shape already.
> Cognition
> [2] has recently included "experimental support for the proposed
> hRecipe
> microformat" (though the document [3] is a bit vague about what
> exactly they
> make required and optional respectively).
I've put together slightly better documentation of Cognition's
support for it here:
http://buzzword.org.uk/cognition/uf-plus.html#hrecipe
> * Suggestion: idle period / off-time / rest period / unattended time
Perhaps preparation-time could be made into a plural type+value
property (like "tel" in hCard).
<span class="preparation-time">
<span class="type">Preparation</span>:
<abbr class="value" title="PT5M">10 mins</abbr>
</span>
<span class="preparation-time">
<span class="type">Waiting</span>:
<abbr class="value" title="PT25M">25 mins</abbr>
</span>
<span class="preparation-time">
<span class="type">Cooking</span>:
<abbr class="value" title="PT35M">35 mins</abbr>
</span>
> TobyInk proposes an optimization for Ingredient which makes sense,
> but...
> first I wonder how much harder the optimization makes it to develop
> parsers.
It's very little effort to implement, but saves a lot of typing when
publishing recipes, especially when there are a lot of ingredients.
Implementation is easy by just performing a tiny pre-processing step.
(Code below in Javascript, assumes that the hRecipe root element is
"hroot". Should be very easy to port to other DOM-compatible languages.)
var nodes = hroot.getElementsByClassName('ingredients');
for (var i=0; nodes[i]; i++)
{
var kids = nodes[i].getChildrenByTagName('*');
for (var j=0; kids[j]; j++)
{ kids[j].className += " ingredient"; }
}
Pretty easy. And if you think it's a bit messy to change the DOM tree
prior to parsing, you should realise that most parsers make a lot of
DOM changes prior to the proper parsing stage in order to implement
the include pattern.
--
Toby A Inkster
<mailto:mail at tobyinkster.co.uk>
<http://tobyinkster.co.uk>
More information about the microformats-discuss
mailing list