Foolproof HTML
The article describes Markdown[1], basically. In my opinion, content should be written once and transformed to any format[2], including ConTeXt[3], docx, HTML, EPUB, or plain text. But here&#x27;s a puzzler.<p>Every software developer defines and uses variables. If variables are so powerful, why do WYSIWYG word processors lack the ability to quickly and easily insert variable definitions?[4] In the screenshot, the left-hand side provides an editable variable definition hierarchy, the middle pane provides a Markdown editor, and the right-hand side provides a real-time HTML preview of the content with variables interpolated and substituted.<p>After variables, programming language integration--such as R[5]--comes naturally. Consider the following syntax (that could be hidden through a UI):<p><pre><code>    `r#csv2md(&#x27;data.csv&#x27;,totals=TRUE)`
</code></pre>
The function imports data from an external data source and converts it to Markdown. The HTML version can be styled, or piped through pandoc to create beautiful PDF output[6]. In the screenshot, the left-hand side shows the csv2md command (totals are calculated automatically for numeric columns), the middle pane shows an HTML preview (real-time), and the right-hand side shows a PDF produced from the same source document using pandoc and ConTeXt.<p>The CSV file could also be a JSON request over HTTP, or database query, meaning that the document is always up-to-date with the most recent data: a living document. This could be accomplished without having to change the source document, as well:<p><pre><code>    `r#import(v$data$source,totals=TRUE)`
</code></pre>
Here, v$data$source is a variable that defines a data source. In this case, the value might be &#x27;data.csv&#x27;, but could be &#x27;protocol:&#x2F;&#x2F;host&#x2F;app&#x2F;api&#x2F;json&#x27;. The variables themselves could be sourced from a YAML file, JSON data stream, or remote database.<p>This is what I&#x27;ve been working towards for the last several months.[7] There&#x27;s more that this editor can do, but it&#x27;s still in early beta stages, should anyone care to try it.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;jgm&#x2F;pandoc&#x2F;issues&#x2F;168" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jgm&#x2F;pandoc&#x2F;issues&#x2F;168</a><p>[2]: <a href="http:&#x2F;&#x2F;pandoc.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;pandoc.org&#x2F;</a><p>[3]: <a href="http:&#x2F;&#x2F;wiki.contextgarden.net&#x2F;" rel="nofollow">http:&#x2F;&#x2F;wiki.contextgarden.net&#x2F;</a><p>[4]: <a href="https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveJarvis&#x2F;scrivenvar&#x2F;master&#x2F;images&#x2F;screenshot.png" rel="nofollow">https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveJarvis&#x2F;scrivenvar&#x2F;mast...</a><p>[5]: <a href="https:&#x2F;&#x2F;github.com&#x2F;bedatadriven&#x2F;renjin&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bedatadriven&#x2F;renjin&#x2F;</a><p>[6]: <a href="http:&#x2F;&#x2F;i.imgur.com&#x2F;Qe6mTpx.png" rel="nofollow">http:&#x2F;&#x2F;i.imgur.com&#x2F;Qe6mTpx.png</a><p>[7]: <a href="https:&#x2F;&#x2F;github.com&#x2F;DaveJarvis&#x2F;scrivenvar" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DaveJarvis&#x2F;scrivenvar</a>