[NTG-context] Improving pandoc's ConTeXt output

Thangalin thangalin at gmail.com
Mon Jun 6 01:52:52 CEST 2022


Hi folks,

I would like to blog about it, but we are still tweaking the process.
>

I put together a multipart series about the process of going from Markdown
to Pandoc to ConTeXt:

https://dave.autonoma.ca/blog/2019/05/22/typesetting-markdown-part-1/

To speed up the "write > typeset > review" process, I developed KeenWrite:

https://github.com/DaveJarvis/keenwrite

Behind the scenes, KeenWrite uses a Java library similar to pandoc with
some additions, such as the ability to use pandoc's annotation syntax.

The biggest issue for rolling this out is providing users a way to easily
install ConTeXt in a cross-platform manner. At the moment, trying to export
from KeenWrite without a local ConTeXt install simply directs the user to
download and install the most appropriate version for their system.

We make use of the yaml preface in the markdown files especially for
> offers. The sales consultant only has to fill out the yaml part and
>

KeenWrite goes a bit beyond this to completely separate YAML variables from
the Markdown files. The text editor also provides a hierarchical editor for
YAML trees along with the ability to reference those YAML variables when
building. This can be accomplished from the user preferences or the
command-line:

https://github.com/DaveJarvis/keenwrite/blob/master/docs/cmd.md

What's more is that the variables can be inserted into documents, isolating
duplicated information to a single location: the externalized YAML data.
Great for templating.

One of the reasons I wrote KeenWrite was so that I could simplify the use
of variables within documents. In the Typesetting Markdown series, the
build script essentially performs:

   1. pandoc document-vars.md + vars.yaml > document-final.md
   2. pandoc document-final.md > document.tex
   3. context document.tex > document.pdf

Using KeenWrite, this process becomes:

keenwrite --input document-vars.md --theme=boschet --variables vars.yaml
--output document.pdf

This ends up converting an annotated Markdown file into XML then uses
ConTeXt to typeset the XML using a particular theme.KeenWrite has a number
of themes, some basic, some advanced:

https://github.com/DaveJarvis/keenwrite-themes/

This allows me to eliminate the dependency on both Pandoc and Inkscape.
I've also encountered some problems with SVG to MP, but Hans is usually
quick to fix the bugs given a minimal working example that pinpoints the
problem. Either way, it's possible to retain the Inkscape step by telling
ConTeXt not to use the MP conversion, as you alluded to, Juh.

There are other handy features built into KeenWrite. For example, it's
possible to separate chapters into individual files. As long as they are
named something natural (ch1.md, ch2.md, a_chap.md, b_chap.md), they'll get
collated in the correct order. From there, Control+P will export to PDF for
the current file and Control+Shift+P will combine all chapters into a
single PDF.

Then there's the F12 button that captures errors and output from ConTeXt.

If you check it out, let me know what you think!

Cheers!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20220605/afb28759/attachment-0001.htm>


More information about the ntg-context mailing list