Skip to content

v0.6.0 — block anchors render as badges

Choose a tag to compare

@verveguy verveguy released this 11 Sep 03:04
· 102 commits to main since this release
40c24f2

Writing ^id at the end of a line marks that block with an anchor, and the editor now renders it as a badge rather than raw text. This is the definition site for the block-scoped links and transclusion added in 0.5.0 — [[file#^id]] and ![[file#^id]] address exactly these anchors.

Issues: #122, #124, #126, #127.

The id is an opaque token

ULIDs, raw-decimal snowflakes, NanoIDs (including _ and -), UUID-shaped ids, base62 and short alphanumeric ids (^a1b2c3) all badge. There is no length or charset rule to satisfy.

Position is the disambiguator, not the id's shape: the caret must start a token (line start, or preceded by whitespace) and the id must run to end of line. Ordinary prose is left alone — 2^10, 10^100, mc^2 and a ^ b are never badged, mid-line or at a line's end. Carets inside inline code, fenced blocks and MathJax are untouched by construction, not by special-casing.

An anchor may be wrapped in symmetric emphasis — **^id**, __^id__, *^id*, _^id_ — badging the id without the wrapper characters.

A reference written mid-sentence (![[file#^id]]) is a wiki-link and has always resolved independently of position. Unchanged.

Requires a matching host resolver

This is half a change. For ![[file#^id]] to resolve an anchor this editor badges, the embedding application's resolveTransclusion() must use an agreeing anchor rule. The Liminis app's resolver was widened in step (shadoworg/liminis-notes#1114). Other hosts should match:

/(?:^|\s)(?:(\*\*|__|\*|_)\^([^\s\]#*]+?)\1|\^([^\s\]#*]+))\s*$/

Both sides are pinned against a shared case table (src/markdown/__tests__/blockAnchorCases.ts) so they cannot drift silently. A host on an older resolver will show badges it cannot resolve.

Known limitations

  • A bare number alone at end of line preceded by whitespace (^100), or wrapped in emphasis (*^2*), is badged. Accepted rather than filtered: any minimum-length rule excluding it would also exclude legitimate short ids like ^a1b2c3. Real mathematics is written in MathJax ($x^2$) and excluded structurally.
  • Asymmetric wrappers (**^id_) and non-emphasis wrappers (~~…~~, backticks, parentheses) are not recognised.

Why 0.6.0 and not 0.5.1

Nothing here has ever been published — 0.5.0's dist contains no blockAnchor at all — so nothing can break. The minor is deliberate: every feature release in this repo has been one, and more importantly ^0.5.0 would let a routine lockfile refresh adopt this without anyone choosing to. Editor and resolver need to move together.