Skip to content

swatches: add a match mode and extra delimiters, per site, language and block - #6

Merged
ewels merged 2 commits into
mainfrom
feat/swatch-match-modes
Oct 5, 2026
Merged

ewels merged 2 commits into
mainfrom
feat/swatch-match-modes

Conversation

@ewels

@ewels ewels commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Closes #4

Outside stylesheets, a colour gets a swatch only when it looks like a value: after :, =, ,, ( or a quote, and before ,, ;, ), }, ] or the end of the line. That misses colours in syntaxes such as nf-metro's %%metro line: main | Main | #4CAF50, and a site had no way to fix it.

New swatches options:

  • match: 'value' | 'all' (default 'value'). 'all' gives every hex colour and colour function in a block a swatch, as in stylesheets. The guards stay on: #123 / #1234 and short all-letter hex such as #add still get no swatch outside quotes, and named colours still need quotes.
  • delimiters: { before?: string[]; after?: string[] } (default {}). Extra text allowed before and after a colour that looks like a value. It adds to the built-in delimiters.
  • byLanguage: Record<string, { match?, delimiters? }> (default {}). Per-language settings, which replace the site match and delimiters for that language. languages stays as it is (it picks which blocks are scanned), because a map there could not say "all languages, plus these settings".
  • Fence attribute swatches.match="all" / swatches.match="value" for one block. A bad value warns and the block uses the site or language setting.

Defaults are unchanged. The decision and the rejected shapes are in .agents/DECISIONS.md. The docs page, the options and attributes reference and the skill are updated.

pnpm lint, pnpm test, pnpm lint:docs and pnpm docs:build pass with no warnings.

🤖 Generated with Claude Code

ewels and others added 2 commits October 5, 2026 12:29
…nd block

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…s no swatch

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ewels
ewels force-pushed the feat/swatch-match-modes branch from 1bcf8ee to 2396233 Compare October 5, 2026 10:30
@ewels
ewels merged commit 09d1c63 into main Oct 5, 2026
3 checks passed
@ewels
ewels deleted the feat/swatch-match-modes branch October 5, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swatches: configurable delimiters and an "everywhere" mode

1 participant