Releases: obsidianmd/knap
Releases · obsidianmd/knap
Release list
0.6.0
This release makes filter chains preserve semantic value types. Review templates that serialize transformed values to YAML or depend on the exact text produced by collection filters.
Breaking changes
yamlandyaml_propertynow quote all strings, including"null","true", and"123". Typed nulls, booleans, and numbers remain unquoted. Templates that intentionally store JSON text can decode it withparse_jsonbefore serialization. Closes #11calc,round, andlengthnow return numbers instead of numeric text. Downstream assignments and serializers preserve that type, so YAML such asprice: "42.57"becomesprice: 42.57.number_formatcontinues to return text.- Numeric parsing is stricter. Blank
calcinput and partially numericroundinput such as"42abc"are preserved with a warning instead of being coerced. Non-finite arithmetic results preserve the original input rather than emittingInfinityornull. roundpreserves collection structure and converts successfully rounded numeric-string members to numbers.lengthcounts singleton arrays as collections, so[42] | lengthchanges from2to1.firstandlastpreserve the selected value's type. Selected objects and nested arrays now render as JSON, and empty arrays returnnullinstead of[].nthreturns a typed subset array. A singleton primitive result now unwraps during interpolation and before downstream text filters, so[1, 2] | nth:2renders as2instead of[2].- The exported
applyFiltersWithRegistryhelper now renders a finalnullresult as empty text instead of"null", matching template interpolation.
0.5.1
Attach VS Code and Sublime Text syntax packages to tagged GitHub releases.
0.5.0
- Add VS Code and Sublime Text syntax packages for Knap Markdown, with shared generated grammars, template comments, and snippets.
- Add Prism, CodeMirror, and highlight.js adapters, with the website using the shared CodeMirror stream parser.
0.4.2
Add {% comment %} syntax for unrendered comments. See Docs.
Example:
{#
This template is used for reading notes.
{{ title }} is ignored inside this comment.
#}0.4.1
CLI
- Add offline CLI help for syntax, filters, and logic tags, with per-filter and per-tag examples and help hints in template diagnostics.
- Add
knap validateto check template syntax and static filter arguments without data or rendering.
0.4.0
- Add CLI with
knap renderandknap batch. - Add configurable limits for template size, output size, intermediate values, work operations, and nesting.
- Add
allowRegex: falseto makesplituse literal separators and disable regex searches inreplace. Native regex matching remains enabled by default. - Resolve only own data properties when reading template variables and filter paths, skipping inherited values and getters. Assign variables without invoking prototype setters.
- Escape literal link labels, image alt text, and Markdown destination delimiters. Omit
javascript:,vbscript:, anddata:destinations while preserving relative links and application protocols. - Require literal tag names in
replace_tags. - Check opened batch output files before truncating them and avoid following final-path symlinks where supported.
0.3.2
- Support dot property access after array indexing, including chained paths such as
cast[0].details.nameand keys that share a keyword name. - Merge through
mergeusing the original array value rather than its serialized form, and treat a single comma-separated argument as a list. - Preserve regular expression escapes such as
\sin filter arguments while still decoding escaped quotes and backslashes. - Remove the extra output line before standalone conditional closing tags, preserving intentional blank lines.
- Preserve intentional blank lines between loop iterations, including separate Markdown tables.
- Skip loop iterations that render nothing so a false condition cannot leave a blank separator or a trailing empty item.
- Apply whitespace control from an
iftag when anelseiforelsebranch is taken.
0.3.0
Adds Markdown formatting, collection transformations, and YAML frontmatter generation, with typed arguments and consistent collection chaining.
New filters
Markdown
h1throughh6for headings.boldanditalic, with optional underscore delimiters;strikeandhighlight, including named highlight colors.hrwithbefore,after, andbothplacement.codefor inline code or automatic multiline code blocks, andcode_blockfor explicit fenced blocks. Both accept an optional language.mathfor inline or automatic multiline math, andmath_blockfor explicit blocks.comment,escape_md,hard_break, andindent.embedfor embedded wikilinks.table_prettyfor padded Markdown tables, using the same UTF-16 string-length padding as Obsidian's table editor.yaml_propertyfor complete YAML properties with automatic indentation.
Text and collections
compactremoves null and blank-string values while retaining0andfalse.encode_uriencodes URI components.parse_jsonconverts JSON text into typed values.sortsupports ascending or descending order and nested property selection.truncateuses grapheme-aware character limits, with the suffix counting toward the limit.truncate_wordslimits the number of words and accepts a configurable suffix.wherefilters arrays by an exact typed property value.sumtotals numeric array values or nested object properties.
Collection handling
- Format string values recursively in typed and serialized collections with Markdown and compatible utility filters.
- Expose original typed values through
context.rawValue. Collection operations preserve singleton arrays, while existing text filters retain plain singleton output. - Support pipelines such as
split | sort | join,map | bold | join, andmap:"name" | reverse. - Add property shorthand to
map, including nested paths such asmap:"author.name", while retaining the existing arrow syntax. - Preserve selected value types and use
nullfor missing properties. Use own-property lookup formap,where, andsumpaths. - Render singleton wikilinks and embeds as plain references while keeping their typed arrays available to downstream collection and YAML filters.
Arguments and validation
- Expose evaluated filter arguments through
context.rawArgumentsin template rendering andapplyFiltersWithRegistry. - Preserve the compatibility string inputs for custom filters. Parameter validators also receive typed arguments when available.
- Validate literal arguments during template validation and dynamic arguments after resolution. Reject invalid property-path and comparison-value types.
- Preserve typed strings containing embedded quotes and commas during validation.
- Improve quoted delimiter, apostrophe, backslash, quoted regex-pattern, and parenthesized argument-list handling.
- Support grouped expressions such as
{{ (title ?? "Untitled") | h1 }}. - Initialize
Intl.Segmenterwhen character truncation is used, so importing Knap and using unrelated filters does not require it.
YAML formatting
- Extend
yamlwith block formatting for arrays and objects, andyaml:flowfor compact inline collections. - Preserve nested collections, escaped multiline strings, numeric values, booleans, and explicit
null. - Render complete frontmatter properties with
yaml_property, including singleton lists after wikilink formatting.
0.2.3
- Fix parsing of
nthoffset expressions such asn+3.