Skip to content
Eric McConville edited this page Oct 13, 2015 · 3 revisions

Markdown Definitions for ImageGeneration

Markdown-CodeBlock Instructions

Overview of Markdown CodeBlock attributes for managing the behavior of image generation scripts.

Skip CodeBlocks

Any block of code containing a skip CSS classname will be omitted from image generation script.

~~~{.skip}
Codeblock not to be executed
~~~

Hidden CodeBlocks

Many documents require additional embedded commands to be run; however, they are not directly related to the topic of the document/example. The common hide classname is inherited by many CSS frameworks, and can be used to inject additional image-generation statements.

~~~{.hide}
# Create a browser friendly version of MVG format
convert example.mvg example.mvg.gif
~~~

Capturing Output

Both stderr and stdout can be captured. The expected handling of captured output is to redirect the stream to a text file, and generate a GIF image displaying the content of.

~~~{data-capture-out="example_stdout.txt"}
identify -verbose rose:
~~~
[![](example_stdout.txt.gif)](example.stdout.txt)

Use data-capture-err="file.txt" to capture stderr

Pre & Post ambles

Many instances of CodeBlocks just need a quick set-up command, or perhaps a follow-up tear-down statement. Although, for visibility, any such commands should be included within the document block.

~~~{data-preamble="convert rose: rose.png" data-postamble="convert example.stdout.txt info.txt.gif"}
identify -verbose rose.png > example.stdout.txt
~~~

Pandoc LUA writer

Pandoc offers the ability to define custom document writers. For image generation, we can ignore all document elements except CodeBlocks, and determine expected behavior by evaluating the attributes of given element.

The custom document writer can be found @ _writers/script.lua, and is expected to be a "work-in-progress" for the near future.