From 55bc679c196e0622449471bf2233ff935ab2b1d4 Mon Sep 17 00:00:00 2001 From: Sean Hagstrom Date: Thu, 23 Oct 2025 11:13:35 -0700 Subject: [PATCH] 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. --- crates/docs_preprocessor/src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/docs_preprocessor/src/main.rs b/crates/docs_preprocessor/src/main.rs index 747cb2ecdd..b614a82511 100644 --- a/crates/docs_preprocessor/src/main.rs +++ b/crates/docs_preprocessor/src/main.rs @@ -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) { let regex = Regex::new(r"\{#kb (.*?)\}").unwrap(); @@ -223,7 +227,10 @@ fn template_and_validate_keybindings(book: &mut Book, errors: &mut HashSetNo default binding".to_string(); } - format!("{macos_binding}|{linux_binding}") + let formatted_macos_binding = format_binding(macos_binding); + let formatted_linux_binding = format_binding(linux_binding); + + format!("{formatted_macos_binding}|{formatted_linux_binding}") }) .into_owned() });