diff --git a/v2/fuzz/fuzz_targets/parse_markdown.rs b/v2/fuzz/fuzz_targets/parse_markdown.rs index b81a9d5..2591dac 100644 --- a/v2/fuzz/fuzz_targets/parse_markdown.rs +++ b/v2/fuzz/fuzz_targets/parse_markdown.rs @@ -11,6 +11,7 @@ fuzz_target!(|data: &[u8]| { else { return; }; + dbg!(&source); let target = MarkdownContent::new(source, None); let parser = MarkdownParser::new(&target, offset, ()); let mut buf = Vec::new(); diff --git a/v2/src/markdown/parser.rs b/v2/src/markdown/parser.rs index a1b62df..7a09e29 100644 --- a/v2/src/markdown/parser.rs +++ b/v2/src/markdown/parser.rs @@ -762,8 +762,12 @@ impl<'input, W: Write, V: TextVisitor, T: TextTokenizer> RenderTreeEncoder<'inpu self.text(&text, inner_range)?; self.tag_end()?; } - Event::Html(_) => unreachable!(), // This event is handled in `Tag::HtmlBlock` event using `HtmlBlockReader` - Event::InlineHtml(html) => { + // Inline HTML inside blockquote is emitted as Event::Html event wrongly. Uncomment the below line when + // the following issue is fixed and the fix is released. + // https://github.com/pulldown-cmark/pulldown-cmark/issues/960 + // + // Event::Html(_) => unreachable!(), // This event is handled in `Tag::HtmlBlock` event using `HtmlBlockReader` + Event::Html(html) | Event::InlineHtml(html) => { self.tag("html")?; self.out.write_all(br#","raw":""#)?; @@ -1053,6 +1057,7 @@ mod tests { snapshot_test!(escaped_chars_in_text); snapshot_test!(alert); snapshot_test!(url_inside_link); + snapshot_test!(inline_html_inside_blockquote); // Offset snapshot_test!(offset_block, Some(30)); diff --git a/v2/src/markdown/snapshots/shiba_preview__markdown__parser__tests__inline_html_inside_blockquote.snap b/v2/src/markdown/snapshots/shiba_preview__markdown__parser__tests__inline_html_inside_blockquote.snap new file mode 100644 index 0000000..0918cee --- /dev/null +++ b/v2/src/markdown/snapshots/shiba_preview__markdown__parser__tests__inline_html_inside_blockquote.snap @@ -0,0 +1,23 @@ +--- +source: src/markdown/parser.rs +expression: json +--- +{ + "kind": "render_tree", + "tree": [ + { + "c": [ + { + "c": [ + { + "raw": "", + "t": "html" + } + ], + "t": "p" + } + ], + "t": "blockquote" + } + ] +} diff --git a/v2/src/markdown/testdata/inline_html_inside_blockquote.md b/v2/src/markdown/testdata/inline_html_inside_blockquote.md new file mode 100644 index 0000000..c8fbdfa --- /dev/null +++ b/v2/src/markdown/testdata/inline_html_inside_blockquote.md @@ -0,0 +1,2 @@ +> bar>