fix(export): emit one CSS class per keyword for independent colouring
CI / cargo fmt --check (push) Successful in 22s
CI / cargo clippy (push) Successful in 39s
CI / cargo test (push) Successful in 30s
CI / editor keymaps (push) Successful in 1m17s

All keywords previously shared `class="todo"`, so a stylesheet couldn't
distinguish e.g. red TODO from green DONE. Emit a distinct class per keyword
(todo/done/started/fixme/fixed/xxx); TODO keeps the vimwiki `todo` class so
stock vimwiki CSS still styles it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 21:43:11 -03:00
parent 9a751037ce
commit e0f97a5caf
2 changed files with 23 additions and 8 deletions
+9 -6
View File
@@ -492,13 +492,16 @@ impl HtmlRenderer {
}
fn render_keyword(&self, n: &KeywordNode, w: &mut dyn Write) -> io::Result<()> {
// One class per keyword so stylesheets can colour them independently
// (e.g. red TODO/FIXME/XXX vs green DONE/FIXED/STARTED). TODO keeps the
// vimwiki `todo` class so stock vimwiki CSS still styles it.
let (label, class) = match n.keyword {
Keyword::Todo => ("TODO", "keyword keyword-todo"),
Keyword::Done => ("DONE", "keyword keyword-done"),
Keyword::Started => ("STARTED", "keyword keyword-started"),
Keyword::Fixme => ("FIXME", "keyword keyword-fixme"),
Keyword::Fixed => ("FIXED", "keyword keyword-fixed"),
Keyword::Xxx => ("XXX", "keyword keyword-xxx"),
Keyword::Todo => ("TODO", "todo"),
Keyword::Done => ("DONE", "done"),
Keyword::Started => ("STARTED", "started"),
Keyword::Fixme => ("FIXME", "fixme"),
Keyword::Fixed => ("FIXED", "fixed"),
Keyword::Xxx => ("XXX", "xxx"),
};
write!(w, "<span class=\"{class}\">{label}</span>")
}
+14 -2
View File
@@ -196,8 +196,20 @@ fn inline_code_is_escaped() {
#[test]
fn keyword_spans() {
let out = render("TODO write tests\n");
assert!(out.contains("<span class=\"keyword keyword-todo\">TODO</span>"));
// One class per keyword so a stylesheet can colour groups differently.
// TODO keeps the vimwiki `todo` class.
let cases = [
("TODO x\n", "<span class=\"todo\">TODO</span>"),
("DONE x\n", "<span class=\"done\">DONE</span>"),
("STARTED x\n", "<span class=\"started\">STARTED</span>"),
("FIXME x\n", "<span class=\"fixme\">FIXME</span>"),
("FIXED x\n", "<span class=\"fixed\">FIXED</span>"),
("XXX x\n", "<span class=\"xxx\">XXX</span>"),
];
for (src, expected) in cases {
let out = render(src);
assert!(out.contains(expected), "src {src:?} -> {out}");
}
}
#[test]