knap 2026.10.9
knap: ^2026.10.9 copied to clipboard
A safe, lightweight template engine for Markdown in Dart, inspired by Obsidian Knap.
2026.10.9 #
- 100% Upstream (
obsidianmd/knap) Parity:- 6 New Built-in Filters:
embed(![[target|alias]]),table_pretty(column-width padded Markdown tables),truncatewords,yaml_property,stripmdalias, andhtml_to_json(plus exportedhtmlFiltersmap). - Filter Parameter Enhancements:
bold:_anditalic:_underscore style markers.list:numbered,list:task,list:numbered-task, and nested array indentation.yamlmulti-line block rendering for collections andyaml:flowinline mode.safe_name:windows(including reserved device names),safe_name:mac, andsafe_name:linux.maparrow expressions (map:item => item.name,map:x => "${x.title}", object projections).sortby object property and direction (sort:"age":"desc").replaceregular expression literals (replace:"/\\d+/g":"#") and multi-pair replacements.footnotedefinitions fromMapandListvalues.calloutfold state parameter (truefor-,falsefor+).- Auto-incrementing backtick fences in
codeandcode_blockwhen content contains backticks.
- Lexer, Parser & Runtime Enhancements:
- Symbolic logical operators (
&&,||), arrow token (=>), negative numeric literals, and CSS selector literals (selector:,selectorHtml:). - Parenthesized filter arguments (
replace:(a ?? "x"):"y",slice:(0, 5)). - Support for
{{key}}-wrapped data map keys, dynamicvariableResolver/asyncVariableResolver, JSON array strings in{% for %}, and<iterator>_indexloop variables.
- Symbolic logical operators (
- Resource Protection & Diagnostics API:
- Added
RenderLimits,defaultRenderLimits,RenderBudget, andKnapLimitException. - Added
validate,validateFilters,validateVariables,renderWithDiagnostics(TemplateResult),renderOrThrow, andapplyFiltersWithRegistry.
- Added
- CLI Expansion (
bin/knap.dart):- Added
knap validate,knap batch(with RFC 4180parseCsv), andknap help(filters,syntax,examples).
- Added
- 6 New Built-in Filters:
- Quality & Documentation:
- Achieved 100.00% line test coverage across all 14 library files.
- Added Effective Dart (
///) documentation comments with executable code examples across all public APIs.
2026.9.26 #
- Upstream Parity & Operators:
- Added null coalescing operator
??({{ title ?? fallback }}). - Added
containsoperator for Lists, Strings, and Maps ({% if tags contains "dart" %}). - Added
elseifkeyword as alias forelif. - Added multi-word identifier support for Clipper attributes (e.g.
{{ First name | upper }}). - Added colon-chained argument support for filters (e.g.
replace:"old":"new").
- Added null coalescing operator
- New Built-in Filters:
- Web Clipper & Filesystem:
safe_name,strip_tags(remove_html,remove_tags). - Markdown:
strip_md,blockquote,image,footnote,fragment_link. - Collections:
where,map,compact,split. - Math & Numbers:
sum,round,number_format. - Utilities:
duration,indent,encode_uri,decode_uri,parse_json.
- Web Clipper & Filesystem:
2026.9.25 #
- Initial release of Knap for Dart.
- Security & Safety: AST-based parser and interpreter with zero
evalor arbitrary code execution. - Markdown-first Templating:
- Liquid/Jinja-compatible syntax (
{{ ... }},{% ... %}). - Whitespace trimming control (
{{- -}},{%- -%}). - Built-in Markdown filters:
wikilink,link,list,task_list,table,callout,quote,tag,codeblock,inline_code,bold,italic,strikethrough,escape_md.
- Liquid/Jinja-compatible syntax (
- Logic & Flow Control:
if / elif / elseconditional branches.for ... in ... elseiterations with loop metadata (loop.index,loop.index0,loop.revindex,loop.revindex0,loop.first,loop.last,loop.length).- Variable assignment statements (
{% set name = expr %}). - Comment tags (
{# comment #},{#- comment -#}).
- Rich Standard Filters:
- String manipulation:
trim,upper,lower,capitalize,title,slug,replace,truncate,default. - Case formatting:
snake,camel,kebab,pascal. - Collection helpers:
first,last,join,sort,reverse,slice,length,merge,unique. - Formatting & Data:
json,yaml,hard_break. - Date helpers:
date,date_modify.
- String manipulation:
- Async Execution Support: Synchronous (
render()) and asynchronous (renderAsync()) evaluation with async custom filters. - Built-in CLI: Standalone command-line tool
dart run knap render.