From 24786022cd916ff3d406ab47d4687a7b2692ee81 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 22 Jun 2025 16:25:08 -0700 Subject: [PATCH] Fix smart punctuation inside grammar terminals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Smart punctuation was converting `...` to `…`. This fixes it so that it will be escaped to avoid the conversion. This normally doesn't happen inside a backtick code block, but since we are using spans for terminals, pulldown-cmark is accidentally picking them up. This also includes hyphen to handle en-dash and em-dash, though we don't have those. Fixes https://github.com/rust-lang/reference/issues/1867 --- mdbook-spec/src/grammar/render_markdown.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mdbook-spec/src/grammar/render_markdown.rs b/mdbook-spec/src/grammar/render_markdown.rs index 625eaea51..1aacc9e86 100644 --- a/mdbook-spec/src/grammar/render_markdown.rs +++ b/mdbook-spec/src/grammar/render_markdown.rs @@ -223,6 +223,7 @@ impl Characters { /// Escapes characters that markdown would otherwise interpret. fn markdown_escape(s: &str) -> Cow<'_, str> { - static ESC_RE: LazyLock = LazyLock::new(|| Regex::new(r#"[\\`_*\[\](){}'"]"#).unwrap()); + static ESC_RE: LazyLock = + LazyLock::new(|| Regex::new(r#"[\\`_*\[\](){}'".-]"#).unwrap()); ESC_RE.replace_all(s, r"\$0") }