Skip to content

Commit 2478602

Browse files
committed
Fix smart punctuation inside grammar terminals
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 #1867
1 parent 50fc162 commit 2478602

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mdbook-spec/src/grammar/render_markdown.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ impl Characters {
223223

224224
/// Escapes characters that markdown would otherwise interpret.
225225
fn markdown_escape(s: &str) -> Cow<'_, str> {
226-
static ESC_RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r#"[\\`_*\[\](){}'"]"#).unwrap());
226+
static ESC_RE: LazyLock<Regex> =
227+
LazyLock::new(|| Regex::new(r#"[\\`_*\[\](){}'".-]"#).unwrap());
227228
ESC_RE.replace_all(s, r"\$0")
228229
}

0 commit comments

Comments
 (0)