Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
markdown preview: Ignore inline HTML tags in text (#19804)
Bennet Bo Fennerb13940720a90
diff --git a/crates/markdown_preview/src/markdown_parser.rs b/crates/markdown_preview/src/markdown_parser.rsindex 0b3c361fd26..d514b89e52c 100644--- a/crates/markdown_preview/src/markdown_parser.rs+++ b/crates/markdown_preview/src/markdown_parser.rs@@ -234,6 +234,10 @@ impl<'a> MarkdownParser<'a> {text.push('\n');}+ // We want to ignore any inline HTML tags in the text but keep+ // the text between them+ Event::InlineHtml(_) => {}+Event::Text(t) => {text.push_str(t.as_ref());@@ -849,6 +853,16 @@ mod tests {);}+ #[gpui::test]+ async fn test_text_with_inline_html() {+ let parsed = parse("This is a paragraph with an inline HTML <sometag>tag</sometag>.").await;++ assert_eq!(+ parsed.children,+ vec![p("This is a paragraph with an inline HTML tag.", 0..63),],+ );+ }+#[gpui::test]async fn test_raw_links_detection() {let parsed = parse("Checkout this https://zed.dev link").await;@@ -1092,6 +1106,26 @@ Some other content);}+ #[gpui::test]+ async fn test_list_item_with_inline_html() {+ let parsed = parse(+ "\+* This is a list item with an inline HTML <sometag>tag</sometag>.+",+ )+ .await;++ assert_eq!(+ parsed.children,+ vec![list_item(+ 0..67,+ 1,+ Unordered,+ vec![p("This is a list item with an inline HTML tag.", 4..44),],+ ),],+ );+ }+#[gpui::test]async fn test_nested_list_with_paragraph_inside() {let parsed = parse(