docs: Ensure macOS and Linux keybindings are escaped in HTML (#39802)

Closes #39654

Release Notes:

- Fixed the formatting of macOS and Linux keybindings in the Zed docs to
escape the backslash character when templating.
This commit is contained in:
Sean Hagstrom 2025-10-23 11:13:35 -07:00 committed by GitHub
parent 6aaf19f276
commit 55bc679c19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -203,6 +203,10 @@ fn template_big_table_of_actions(book: &mut Book) {
});
}
fn format_binding(binding: String) -> String {
binding.replace("\\", "\\\\")
}
fn template_and_validate_keybindings(book: &mut Book, errors: &mut HashSet<PreprocessorError>) {
let regex = Regex::new(r"\{#kb (.*?)\}").unwrap();
@ -223,7 +227,10 @@ fn template_and_validate_keybindings(book: &mut Book, errors: &mut HashSet<Prepr
return "<div>No default binding</div>".to_string();
}
format!("<kbd class=\"keybinding\">{macos_binding}|{linux_binding}</kbd>")
let formatted_macos_binding = format_binding(macos_binding);
let formatted_linux_binding = format_binding(linux_binding);
format!("<kbd class=\"keybinding\">{formatted_macos_binding}|{formatted_linux_binding}</kbd>")
})
.into_owned()
});