Use Jinja templates as input
mainmd2pdf supports Jinja templating. You can provide dynamic content in two ways:
- Frontmatter Header: Define variables in a YAML-style frontmatter block at the top of your Markdown file.
- Context Argument: Pass a dictionary to the
contextargument when using the library.
Example Markdown with Jinja
---
groceries:
- name: apple
quantity: 4
- name: orange
quantity: 10
---
# Groceries
| Item | Quantity |
| ---- | -------- |
{% for item in groceries -%}
| {{ item.name }} | {{ item.quantity }} |
{% endfor %}$ md2pdf \
--css examples/gutenberg-modern.min.css \
-i examples/my-music.md.j2 \
-o examples/my-music.pdf