fix(client): colour-span conceal must skip unallocatable colours
CI / cargo fmt --check (push) Successful in 34s
CI / cargo clippy (push) Successful in 42s
CI / cargo test (push) Successful in 35s
CI / editor keymaps (push) Successful in 1m36s

A literal `<span style="color:…">` in prose (the sample wiki's own colorize
instructions used one, with a `…` ellipsis as the colour) was matched by the
scanner and fed to `highlight guifg=…`, which raised E254 on the un-silenced
guifg line. That aborted the whole nuwiki#colors#refresh(), so on the Vim
clients NO spans got concealed (start-vim) and follow-link crashed mid
FileType autocmd (start-vim-coc). Neovim happened to dodge it depending on
which buffer was scanned.

s:define() now:
- validates the colour (only #hex or an alphabetic name) and skips anything
  else — rgb()/hsl() functions and prose examples no longer create bogus
  conceal regions or errors;
- runs both `highlight` calls under `silent!`, so a valid-format but unknown
  name can't abort the refresh either (tags still conceal, text just isn't
  recoloured).

Also reworded the sample wiki's colorize note so it no longer embeds a
literal span tag.

Test: colorize.skips_unallocatable_colour (vim) — an rgb() span before a real
one: refresh doesn't error, the rgb span isn't concealed, the real span still
is. nvim 269, vim 260+18, all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 16:09:15 +00:00
parent 15ba774a28
commit 9de8543385
3 changed files with 32 additions and 6 deletions
+3 -3
View File
@@ -97,9 +97,9 @@ super^script^ and sub,,script,,, and inline math $e^{i\pi} + 1 = 0$.
Put the cursor on a word and run `:VimwikiColorize red` (or press
`<Leader>wc` and type a colour); or visually select a phrase and press
`<Leader>wc`. Each wraps the target in `<span style="color:…">…</span>` —
the tags are concealed, so you see just the word painted in that colour
(move the cursor onto it to reveal the raw markup).
`<Leader>wc`. Each wraps the target in an inline colour-span tag whose
markup is concealed, so you see just the word painted in that colour (move
the cursor onto it to reveal the raw markup).
- colorize this important word
- now select and colour this whole phrase