Also add highlighting for paths.

This commit is contained in:
Tom Alexander 2025-02-22 16:55:53 -05:00
parent 3245e830d2
commit c4cf814f8d
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 18 additions and 3 deletions

View File

@ -3,6 +3,7 @@
--srclg-nix-srchl-comment-color: #048a81;
--srclg-nix-srchl-property-color: #bfbccb;
--srclg-nix-srchl-string-color: #ecc30b;
--srclg-nix-srchl-string-special-path-color: #067bc2;
}
@media (prefers-color-scheme: light) {
@ -11,6 +12,7 @@
--srclg-nix-srchl-comment-color: #fb757e;
--srclg-nix-srchl-property-color: #404334;
--srclg-nix-srchl-string-color: #133cf4;
--srclg-nix-srchl-string-special-path-color: #f9843d;
}
}
@ -29,6 +31,9 @@
.srchl_string {
color: var(--srclg-nix-srchl-string-color);
}
.srchl_string_special_path {
color: var(--srclg-nix-srchl-string-special-path-color);
}
}
}
}

View File

@ -47,7 +47,7 @@ render!(RenderSrcBlock, ISrcBlock, original, _render_context, {
content: body.to_owned(),
},
ISrcSegment::HighlightStart { name } => RenderSrcSegment::HighlightStart {
name: name.to_owned(),
name: css_safe_name(name),
},
ISrcSegment::HighlightEnd => RenderSrcSegment::HighlightEnd,
})
@ -61,3 +61,11 @@ render!(RenderSrcBlock, ISrcBlock, original, _render_context, {
post_blank: original.post_blank,
})
});
fn css_safe_name<S>(inp: S) -> String
where
std::string::String: From<S>,
{
let inp: String = inp.into();
inp.replace(".", "_")
}

View File

@ -138,9 +138,11 @@ where
L: Borrow<str>,
{
let highlight_names = [
"comment", "keyword", "property",
"comment",
"keyword",
"property",
"string",
// "string.special.path",
"string.special.path",
// "string.special.uri",
];
// Need 1 highlighter per thread