diff --git a/rivet-core/src/markdown.rs b/rivet-core/src/markdown.rs index 2b0202da..6745fad8 100644 --- a/rivet-core/src/markdown.rs +++ b/rivet-core/src/markdown.rs @@ -128,9 +128,15 @@ pub fn render_markdown(input: &str) -> String { in_mermaid = false; Some(Event::Html(MERMAID_CLOSE.into())) } - // Inside a mermaid block, pass text through as-is (pulldown-cmark - // emits the fenced body as Event::Text segments). - Event::Text(_) if in_mermaid => Some(event), + // Inside a mermaid block, emit the fenced body verbatim. pulldown-cmark + // delivers it as Event::Text segments, but `html::push_html` HTML-entity- + // escapes Text events — turning mermaid's core `-->` arrow into `-->` + // and `<|--` into `<|--`, which mermaid.js then rejects with "Syntax + // error in text". Re-tag the segments as Event::Html so they pass through + // unescaped (mermaid diagram source contains no HTML tags; a `` + // smuggled inside a ```mermaid block would at worst end the block early, + // and `