Closed xoox closed 7 years ago
You know pandoc already has a templating system, don't you? See the manual under Templates. It is different from the one you link to, but at least as powerful.
Oops, I think I used wrong words.
Basically It is an extension to pandoc's markdown instead of pandoc's templates. That extension would enable variables and tags in markdown.
{% include "./test.md" %}
Importing an other file's content.
{% for author in authors %}
- {{ author.name }}
{% endfor %}
will generate a list of authors.
The extension may be a pre-processing function in Markdown.hs reader.
There are several Haskell packages supporting similar syntax and features to Jinja2. With them, the extension should need not too much work.
For information of other template system, see Web template system
So the real issue is that you'd like some kind of preprocessor, run before Markdown parsing, that interpolates variables from metadata and can include external files.
This wouldn't be easy, since pandoc allows YAML metadata blocks anywhere in the document. So you really have to parse Markdown in order to know what the metadata is.
I would suggest, if you want a preprocessor, that you just write one yourself and pipe your input through it before sending it to pandoc. Or use an existing one as suggested here.
EDIT: Just looked at the gitbook templating link. I guess all their variables are set in an external json file.
Hi, Gitbook Templating would be a powerful extension to pandoc's markdown (not for pandoc's templates). That could also be a substitution to macros.
Besides, many static site generators are powered by similar templating feature. With it, pandoc will get the capability sharing the same markdown source with others, which could utilize pandoc as their renderer if configurable.
There're so many template systems. To find the one acceptable to pandoc community, a survey might be needed.