Markmeld is a markdown melder. It merges
markdown content using
jinja2 templates. You configure markmeld with your content in computer-readable
.yaml files, and markmeld helps produce polished, publication-ready versions of your content. Markmeld is useful for many types of output document, including resumes, biosketches, manuscripts, proposals, books, and more.
How it works
- Store your content in computer-readable formats:
.mdfor unstructured text,
.yamlformat for structured content like lists or objects.
- Write or find a jinja template that produces the output document you are trying to create. We have a variety of common examples in a public repository.
- Configure markmeld with a
yamlconfiguration file to point to 1) your content files; and 2) your jinja template.
Markmeld is useful independently, but is particularly powerful when combined with pandoc -- you pipe the markmeld output in markdown format to pandoc, making it easy to format the output in a variety of downstream output types, such as HTML or PDF via LaTeX. This lets you design design powerful multi-file documents, restructured into different output formats.
Why is this better than just stringing inputs together with pandoc?
For simple use cases, you can use pandoc without markmeld. You just provide a list of markdown files, which pandoc concatenates. This works for very basic documents that do nothing more than string together a list of markdown files. Markmeld adds power to this approach by providing several benefits:
Structured content. Most importantly, markmeld integrates structured yaml data. While pandoc alone can easily concatenate prose content (in markdown format), markmeld allow you to also integrate structured content (in yaml format) into one output. This is useful for something like a CV, where I have both prose components and lists, which I'd rather draw from a structured YAML file.
Templated output. Markmeld's jinja template gives you more control over the structure of the output. Vanilla pandoc can only concatenate
mdinputs in a sequence. Jinja templates let you re-arrange, subset, merge, and even compute on the input, allowing you to create arbitrarily complex output. For simple documents that don't need structured content, you can get by with concatenating
.mdfiles with vanilla pandoc. But even in these situations, you gain something from going the route of the jinja template with markmeld: it formalizes the linking of documents into a separate file, instead of relying the on order and content of CLI arguments to pandoc. So you can more easily write a little recipe saying, "provide these pieces of content under these names, and then use this jinja template to produce the output". Markmeld makes that recipe reproducible.
Flexible downstream uses. Markmeld outputs are not restricted to markdown, but could directly produce whatever you design with your jinja template. For example, you could use markmeld to restructure data into a JSON output to pipe into some other downstream system.
Pre-build hooks. Markmeld can also incorporate non-file-producing commands. You can also build "meta-targets", which are targets made up of other targets, so a single command can build multiple outputs. Markmeld replaces the need for a script or Makefile that runs prepwork, like updating a bibtex database.
Mail merge. Markmeld provides loop functions that allow you to generate multiple similar documents that differ based on structured input content, like a traditional mail merge.
Target factories. Markmeld provides a plugin system that allows you to auto-create targets using your own Python code.
Plus, there's more! Read on to see if Markmeld can help solve some of your content management issues.