À propos
Un langage de modèles simple qui transforme les données en Markdown.
Outils de développementProgression mesurée des étoiles
- in 24h
- +1
- in 7 days
- +10
- in 15 days
- +20
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalKnap
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.
Explorer des projets similaires
Chargement…