Restore » in docs and allow it in highlighter

This commit is contained in:
Richard Feldman 2024-01-18 21:51:59 -05:00
parent 09c0453fc9
commit e7c93bad75
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
2 changed files with 32 additions and 8 deletions

View file

@ -18,6 +18,18 @@ pub fn highlight(code: &str) -> Vec<String> {
let mut buf: Vec<String> = Vec::new();
let mut offset = 0;
// Sometimes code snippets start with "»" in order to show that they're in the repl.
// Special-case that even though it's normally not a valid highlight.
const REPL_PROMPT: &str = "»";
let code = if code.starts_with(REPL_PROMPT) {
buf = push_html_span(buf, REPL_PROMPT, "kw");
&code[REPL_PROMPT.len()..]
} else {
code
};
for location in locations {
let current_text = &code[offset..location.byte_range().end];