knap
kepano/obsidian-skills
Render Markdown from templates and structured data using Knap CLI.
What is knap?
Knap CLI renders Markdown templates with variables, filters, and logic. Use it to apply templates to JSON or CSV data, batch-generate Markdown files, or format web content into notes.
- Render Markdown templates with variable substitution, filters, and conditional logic
- Batch-generate multiple Markdown files from CSV, JSON arrays, or folders of JSON objects
- Pipe JSON data from external tools like Defuddle into templates
- Validate templates for syntax and filter errors before rendering
- Override template variables via command-line arguments or inline JSON
How to install knap
npx skills add https://github.com/kepano/obsidian-skills --skill knap- Node.js 20 or later
- npm (to install Knap globally) or npx (to run without installation)
How to use knap
- 1.Install Knap globally with `npm install -g knap` or use `npx knap` to run without installation
- 2.Create a Markdown template file using `{{ variable }}` syntax for values, `|` for filters, and `{% ... %}` for logic
- 3.Prepare data as JSON (object or array) or CSV format
- 4.Run `knap render template.md --data data.json -o output.md` to render a single file, or `knap batch template.md --data data.csv --output-dir notes --filename '{{ title | safe_name }}.md'` for batch generation
- 5.Use `knap validate template.md` to check template syntax before rendering with real data
Use cases
- Convert structured data (CSV, JSON) into formatted Markdown notes in bulk
- Extract web pages with Defuddle and render them into notes using a template
- Generate multiple documents from a template and a data source (e.g., create one note per article)
- Apply consistent formatting and frontmatter to dynamically generated content
- Validate template syntax and filter availability without executing a full render
- Knowledge workers managing note templates and bulk content generation
- Developers automating Markdown file creation from data sources
- Users integrating web scrapers or data pipelines with note-taking workflows
knap FAQ
Knap uses `{{ variable }}` for values, `| filter_name` for filters, and `{% if condition %} ... {% endif %}` for logic. Run `knap help syntax`, `knap help filters`, and `knap help tags` to explore available filters and tags.
Yes. Use `cat data.json | knap render template.md --data -` to read JSON from stdin, or pipe output from tools like Defuddle: `defuddle parse url --md --json | knap render template.md --data - -o note.md`.
Use `knap batch template.md --data file.csv --output-dir output --filename '{{ title | safe_name }}.md'`. For JSON, supply an array or a folder of JSON objects. CSV headers become variable names.
Run `knap validate template.md` to check syntax and filter names without rendering. Validation does not check variable existence or runtime values; render with real data to verify those.
Yes. Use `--set key=value` to override top-level variables as strings, or `--data-json '{...}'` to supply inline JSON for complex values.
Full instructions (SKILL.md)
Source of truth, from kepano/obsidian-skills.
name: knap description: Render Markdown from templates and structured data using Knap CLI. Use when the user asks to apply a Knap template, turn JSON or CSV data into notes, batch-generate Markdown files, or format Defuddle output into a note.
Knap
Use Knap CLI to render Markdown templates with variables, filters, and logic.
If not installed: npm install -g knap (requires Node.js 20 or later). Alternatively, use npx knap.
Run knap --help for available commands and options. Discover the language through the CLI's offline reference:
knap help syntax
knap help filters
knap help filter date
knap help tags
knap help tag for
Use the lists to find names, then request individual help for syntax, parameters, and examples with expected output.
Usage
Render a template with JSON variables:
knap render template.md --data article.json -o note.md
Supply a template and data inline:
knap render -t '# {{ title | trim }}' --data-json '{"title":"Hello"}'
Override a variable or pipe JSON data:
knap render template.md --data article.json --set 'title=Custom title'
cat article.json | knap render template.md --data -
Data must be a JSON object; its properties become template variables. --set overrides literal top-level keys with strings. Use JSON for nested objects, arrays, numbers, and booleans.
Choose one template source (file, -t, or stdin) and one data source (--data or --data-json). Only one input can read stdin. Without a template file or -t, Knap reads the template from stdin.
Output defaults to stdout. -o creates parent directories and overwrites the destination after rendering succeeds. Errors exit with status 1; diagnostics go to stderr. Warnings can accompany successful output.
Templates
Use {{ variable }} for values, | for filters, and {% ... %} for logic. For example, save this as template.md:
---
{{ title | yaml_property:"title" }}
{{ tags | yaml_property:"tags" }}
---
# {{ title | trim }}
{% if author %}
By {{ author }}
{% endif %}
{{ content }}
Use yaml_property for complete frontmatter properties so values are quoted and indented correctly. The CLI includes standard filters, but does not supply Web Clipper browser variables, selectors, prompts, or DOM-dependent HTML filters. Supply variables through JSON.
Check a template before rendering:
knap validate template.md
Validation checks syntax, filter names, and static filter arguments without data or file output. It does not check variable existence, runtime values, or dynamic arguments; render with real data to check runtime behavior. Diagnostics go to stderr and include relevant help commands.
Defuddle pipeline
Extract a web page as JSON with Markdown content, then render it into a note:
defuddle parse https://example.com/article --md --json \
| knap render template.md --data - -o note.md
Defuddle's JSON properties, such as title and content, become template variables directly.
Batch rendering
Create one file per CSV row, JSON array object, or JSON file in a folder:
knap batch template.md --data articles.csv --output-dir notes \
--filename '{{ title | safe_name }}.md'
Use --data articles.json for an array or --data ./articles for a folder of JSON objects. CSV headers become variable names and values remain strings. Piped data defaults to JSON; add --format csv for piped CSV.
Use --dry-run to validate and list output paths without writing files. Existing files require --overwrite, including during a dry run. Duplicate output names within a batch are errors even with --overwrite.
Filename templates must produce a single filename with its extension, without directories. Use safe_name for data-derived names. Without --filename, Knap preserves source JSON basenames or numbers CSV rows and array items as 1.md, 2.md, and so on.
Related skills
More from kepano/obsidian-skills and the wider catalog.

obsidian-bases
Create and edit Obsidian Bases (.base files) with views, filters, formulas, and summaries.

obsidian-cli
Interact with Obsidian vaults from the command line—read, create, search, manage notes, and develop plugins.

obsidian-markdown
Create and edit Obsidian Flavored Markdown with wikilinks, embeds, callouts, and properties.

defuddle
Extract clean Markdown from HTML pages, removing ads and clutter to reduce token usage.

text-watermark-cleaner-zh-tw
Remove invisible Unicode, zero-width characters, and statistical AI watermarks from Traditional Chinese text while preserving formatting and meaning.

dart-best-practices
|-