html-to-md/docs/html-to-md.transformer.html

26 lines
6 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>html-to-md.transformer documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Html-to-md</span> <span class="project-version">0.3.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to html-to-md</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>html-to-md</span></div></div></li><li class="depth-2 branch"><a href="html-to-md.blogger-to-md.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>blogger-to-md</span></div></a></li><li class="depth-2 branch"><a href="html-to-md.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2 branch"><a href="html-to-md.html-to-md.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>html-to-md</span></div></a></li><li class="depth-2 current"><a href="html-to-md.transformer.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>transformer</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="html-to-md.transformer.html#var-process"><div class="inner"><span>process</span></div></a></li><li class="depth-1"><a href="html-to-md.transformer.html#var-transform"><div class="inner"><span>transform</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">html-to-md.transformer</h1><div class="doc"><div class="markdown"><p>The actual transformation engine, which is actually far more general than just something to generate <a href="https://daringfireball.net/projects/markdown/">Markdown</a>. It isnt as general as <a href="https://www.w3.org/standards/xml/transformation">XSL-T</a> but can nevertheless do a great deal of transformation on [HT|SG|X]ML documents.</p>
<h2><a href="#terminology" name="terminology"></a>Terminology</h2>
<p>In this documentation the following terminology is used:</p>
<ul>
<li><strong>dispatcher</strong>: a <code>dispatcher</code> is a function (or more probably a map) which takes one argument, the tag of the element as a keyword, and returns a <code>processor</code>, q.v.</li>
<li><strong>processor</strong>: a <code>processor</code> is a function of two arguments, an <a href="https://github.com/cgrand/enlive">Enlive</a> encoded (X)HTML element and a <code>dispatcher</code> as described above, which processes elements into the desired format.</li>
</ul>
<h2><a href="#generality" name="generality"></a>Generality</h2>
<p><strong>NOTE</strong> that while <code>processors</code> within the <code>html-to-md</code> package generally process elements into strings (since Markdown is a text format), when processing into an XML format it will generally be preferable that <code>processors</code> should return Enlive style elements.</p></div></div><div class="public anchor" id="var-process"><h3>process</h3><div class="usage"><code>(process element dispatcher)</code></div><div class="doc"><div class="markdown"><p>Process this <code>element</code>, assumed to be a [HT|SG|X]ML element in <a href="https://github.com/cgrand/enlive">Enlive</a> encoding, using this <code>dispatcher</code>,</p>
<p>Such a function should take two arguments, the <code>element</code> itself and a dispatcher which will normally (but not necessarily) be the <code>dispatcher</code> supplied to this function.</p>
<p>If the dispatcher returns <code>nil</code>, the default behaviour is that <code>process</code> is mapped over the content of the element.</p>
<p>If <code>element</code> is not an [HT|SG|X]ML element in Enlive encoding as descibed above, then</p>
<ol>
<li>if the <code>element</code> is a string, returns that string unaltered;</li>
<li>if the <code>element</code> is a sequence or vector, maps <code>process</code> across the members of the sequence;</li>
<li>otherwise, returns <code>nil</code>.</li>
</ol></div></div><div class="src-link"><a href="https://github.com/simon-brooke/html-to-md/blob/master/src/html_to_md/transformer.clj#L32">view source</a></div></div><div class="public anchor" id="var-transform"><h3>transform</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Transform the <code>obj</code> which is my first argument using the <code>dispatcher</code> which is my second argument. <code>obj</code> can be:</p>
<ol>
<li>A URL or URI;</li>
<li>A string representation of a URL or URI;</li>
<li>A string representation of an (X)HTML fragment;</li>
<li>An <a href="https://github.com/cgrand/enlive">Enlive</a> encoded (X)HTML element;</li>
<li>A sequence of <a href="https://github.com/cgrand/enlive">Enlive</a> encoded (X)HTML elements.</li>
</ol></div></div><div class="src-link"><a href="https://github.com/simon-brooke/html-to-md/blob/master/src/html_to_md/transformer.clj#L69">view source</a></div></div></div></body></html>