html-to-md.transformer
The actual transformation engine, which is actually far more general than just something to generate Markdown. It isn’t as general as XSL-T but can nevertheless do a great deal of transformation on [HT|SG|X]ML documents.
Terminology
In this documentation the following terminology is used:
- dispatcher: a
dispatcheris a function (or more probably a map) which takes one argument, the tag of the element as a keyword, and returns aprocessor, q.v. - processor: a
processoris a function of two arguments, an Enlive encoded (X)HTML element and adispatcheras described above, which processes elements into the desired format.
Generality
NOTE that while processors within the html-to-md package generally process elements into strings (since Markdown is a text format), when processing into an XML format it will generally be preferable that processors should return Enlive style elements.
process
(process element dispatcher)Process this element, assumed to be a [HT|SG|X]ML element in Enlive encoding, using this dispatcher,
Such a function should take two arguments, the element itself and a dispatcher which will normally (but not necessarily) be the dispatcher supplied to this function.
If the dispatcher returns nil, the default behaviour is that process is mapped over the content of the element.
If element is not an [HT|SG|X]ML element in Enlive encoding as descibed above, then
- if the
elementis a string, returns that string unaltered; - if the
elementis a sequence or vector, mapsprocessacross the members of the sequence; - otherwise, returns
nil.