Skip to content
プロジェクト

概要

データをMarkdownに変換するシンプルなテンプレート言語。

開発ツール

この数値の測り方

計測したスター増加

24時間
+2
7日間
+9
15日間
+21
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

Knap

Knap is a simple template language that turns data into Markdown using variables, filters, and logic. It powers templating in Obsidian Web Clipper and Obsidian Importer.

Documentation · Playground

Knap parses templates into an AST and interprets them without eval or arbitrary JavaScript execution. Applications control the data and integrations available to templates.

Install

npm install knap

Node.js 20 or later is required for the CLI.

CLI

Render a template with JSON data:

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

Knap also supports inline templates, validation, batch rendering, CSV input, and offline language help. See the CLI guide.

Library

import { createEngine, standardFilters } from 'knap';

const engine = createEngine({ filters: standardFilters });

const markdown = await engine.renderOrThrow(
	'# {{ title | trim }}\n\n{{ tags | list }}',
	{
		variables: {
			title: '  An imported note  ',
			tags: ['reference', 'reading'],
		},
	},
);

See the API guide for rendering, validation, custom filters, asynchronous variables, HTML filters, and execution limits.

Syntax highlighting

Knap syntax highlighting is available for .knap and .knap.md templates:

  • VS Code and Cursor: Download knap.vsix from the latest release, then choose Extensions: Install from VSIX from the command palette.
  • Sublime Text 4: Download Knap.sublime-package from the latest release and place it in Sublime Text's Installed Packages folder.
  • Prism: Run npm install knap prismjs, then import the adapter from knap/prism.
  • CodeMirror 6: Run npm install knap @codemirror/language, then import the adapter from knap/codemirror.
  • highlight.js: Run npm install knap highlight.js, then import the adapter from knap/highlightjs.

See the syntax highlighting guide for setup examples, CodeMirror 5 support, and editor-specific details.

Documentation

Development

pnpm install
pnpm check

The portable rendering fixtures make selected documentation examples and regression expectations reusable by implementations in other languages.

Knap is available under the MIT License.

関連プロジェクトを探す

読み込み中…