Knap · Turn data into Markdown

2 min read Original article ↗

for data shaped into .md

Knap is a simple template language that turns data into Markdown using logic, variables, and filters.

How it works

Add variables inline with Markdown. Filters modify values and formatting.

# {{ title }}

**Plot:**
{{ plot | blockquote }}

Output

# The Matrix**Plot:**> A hacker discovers that reality is a simulation and joins a rebellion against its machines.

Use logic to render variables conditionally and iterate over arrays.

{% if cast %}
{{ cast | sort:"Actor" | table }}
{% endif %}

Output

| Actor | Role || - | - || Carrie-Anne Moss | Trinity || Hugo Weaving | Agent Smith || Keanu Reeves | Neo || Laurence Fishburne | Morpheus |

Generate YAML frontmatter and use extended Markdown syntax for apps like Obsidian.

---
year: {{ year }}
{{ directors | wikilink | yaml_property:"directors" }}
---

Output

---year: 1999directors:  - "[[Lana Wachowski]]"  - "[[Lilly Wachowski]]"---

Knap in your terminal

Generate Markdown from Knap templates. Read the CLI guide for options.

npx knap render template.md --data data.json --output note.md

Knap in your app

Add Knap templating to your app using the API.

Explore

Knap in use

Knap is open source. It started as the templating language for Obsidian. Now any tool can use it. Knap is named after knapping, the process of shaping stones to form arrowheads, scrapers, and other tools.