Skip to content

Releases: obsidianmd/knap

0.6.0

Choose a tag to compare

@github-actions github-actions released this 14 Sep 18:21

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

  • yaml and yaml_property now quote all strings, including "null", "true", and "123". Typed nulls, booleans, and numbers remain unquoted. Templates that intentionally store JSON text can decode it with parse_json before serialization. Closes #11
  • calc, round, and length now return numbers instead of numeric text. Downstream assignments and serializers preserve that type, so YAML such as price: "42.57" becomes price: 42.57. number_format continues to return text.
  • Numeric parsing is stricter. Blank calc input and partially numeric round input such as "42abc" are preserved with a warning instead of being coerced. Non-finite arithmetic results preserve the original input rather than emitting Infinity or null.
  • round preserves collection structure and converts successfully rounded numeric-string members to numbers.
  • length counts singleton arrays as collections, so [42] | length changes from 2 to 1.
  • first and last preserve the selected value's type. Selected objects and nested arrays now render as JSON, and empty arrays return null instead of [].
  • nth returns a typed subset array. A singleton primitive result now unwraps during interpolation and before downstream text filters, so [1, 2] | nth:2 renders as 2 instead of [2].
  • The exported applyFiltersWithRegistry helper now renders a final null result as empty text instead of "null", matching template interpolation.

0.5.1

Choose a tag to compare

@github-actions github-actions released this 14 Sep 13:37

Attach VS Code and Sublime Text syntax packages to tagged GitHub releases.

0.5.0

Choose a tag to compare

@github-actions github-actions released this 13 Sep 21:44
  • 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

Choose a tag to compare

@github-actions github-actions released this 11 Sep 14:45

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

Choose a tag to compare

@github-actions github-actions released this 10 Sep 22:27

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 validate to check template syntax and static filter arguments without data or rendering.

0.4.0

Choose a tag to compare

@github-actions github-actions released this 09 Sep 23:00
  • Add CLI with knap render and knap batch.
  • Add configurable limits for template size, output size, intermediate values, work operations, and nesting.
  • Add allowRegex: false to make split use literal separators and disable regex searches in replace. 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:, and data: 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

Choose a tag to compare

@github-actions github-actions released this 08 Sep 20:16
  • Support dot property access after array indexing, including chained paths such as cast[0].details.name and keys that share a keyword name.
  • Merge through merge using 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 \s in 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 if tag when an elseif or else branch is taken.

0.3.0

Choose a tag to compare

@github-actions github-actions released this 07 Sep 02:10

Adds Markdown formatting, collection transformations, and YAML frontmatter generation, with typed arguments and consistent collection chaining.

New filters

Markdown

  • h1 through h6 for headings.
  • bold and italic, with optional underscore delimiters; strike and highlight, including named highlight colors.
  • hr with before, after, and both placement.
  • code for inline code or automatic multiline code blocks, and code_block for explicit fenced blocks. Both accept an optional language.
  • math for inline or automatic multiline math, and math_block for explicit blocks.
  • comment, escape_md, hard_break, and indent.
  • embed for embedded wikilinks.
  • table_pretty for padded Markdown tables, using the same UTF-16 string-length padding as Obsidian's table editor.
  • yaml_property for complete YAML properties with automatic indentation.

Text and collections

  • compact removes null and blank-string values while retaining 0 and false.
  • encode_uri encodes URI components.
  • parse_json converts JSON text into typed values.
  • sort supports ascending or descending order and nested property selection.
  • truncate uses grapheme-aware character limits, with the suffix counting toward the limit.
  • truncate_words limits the number of words and accepts a configurable suffix.
  • where filters arrays by an exact typed property value.
  • sum totals 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, and map:"name" | reverse.
  • Add property shorthand to map, including nested paths such as map:"author.name", while retaining the existing arrow syntax.
  • Preserve selected value types and use null for missing properties. Use own-property lookup for map, where, and sum paths.
  • 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.rawArguments in template rendering and applyFiltersWithRegistry.
  • 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.Segmenter when character truncation is used, so importing Knap and using unrelated filters does not require it.

YAML formatting

  • Extend yaml with block formatting for arrays and objects, and yaml:flow for 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

Choose a tag to compare

@github-actions github-actions released this 04 Sep 01:00
  • Fix parsing of nth offset expressions such as n+3.

0.2.2

Choose a tag to compare

@github-actions github-actions released this 25 Aug 20:37

Add yaml filter