关于
一种将数据转换为 Markdown 的简单模板语言。
开发工具实测星标增长
- 24小时
- +2
- 7天
- +9
- 15天
- +21
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文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.
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.vsixfrom the latest release, then choose Extensions: Install from VSIX from the command palette. - Sublime Text 4: Download
Knap.sublime-packagefrom the latest release and place it in Sublime Text'sInstalled Packagesfolder. - Prism: Run
npm install knap prismjs, then import the adapter fromknap/prism. - CodeMirror 6: Run
npm install knap @codemirror/language, then import the adapter fromknap/codemirror. - highlight.js: Run
npm install knap highlight.js, then import the adapter fromknap/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.
探索相关项目
加载中…