Pandoc::Filter::ImagesFromCode - transform code blocks into images


This Pandoc::Filter transforms CodeBlock elements into Image elements. Content of transformed code section and resulting image files are written to files.

Attribute title is mapped to the image title and attribute caption to an image caption, if available.



File extension of input files extracted from code blocks. Defaults to code.


File extension of created image files. Can be a fixed string or a code reference that gets the document output format (for instance latex or html) as argument to produce different image formats depending on output format.


Code reference that maps the CodeBlock element to a filename (without directory and extension). By default the element's id is used if it contains characters no other than a-zA-Z0-9_-. Otherwise the name is the MD5 hash of the element's content.


Directory where to place input and output files, relative to the current directory. This directory (default .) is prepended to all image references in the target document.


Command to transform input files to output files. Variable references $...$ can be used to refer to current values of from, to, name, dir, infile and outfile. Example:

  run => ['ditaa', '-o', '$infile$', '$outfile$'],

Capture output of command and write it to outfile. Disabled by default.


Apply transformation also if input and output file already exists unchanged. Disabled by default.