Skip to content

Commit

Permalink
fix: handle tags in nested blockquotes
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin1887 committed Mar 30, 2024
1 parent 147c1bb commit 45281bc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
10 changes: 10 additions & 0 deletions pulldown-cmark/specs/blockquotes_tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,13 @@ And consecutive blockquotes too:
.
<blockquote class="markdown-alert-caution"><p>Line 1.</p></blockquote><blockquote class="markdown-alert-tip"><p>Line 2.</p></blockquote>
````````````````````````````````

Tags also work in inner blockquotes:
```````````````````````````````` example
> > [!CAUTION]
> > Line 1.
> Line 2.
.
<blockquote><blockquote class="markdown-alert-caution"><p>Line 1.
Line 2.</p></blockquote></blockquote>
````````````````````````````````
4 changes: 2 additions & 2 deletions pulldown-cmark/src/scanners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ impl<'a> LineStart<'a> {
self.ix += scan_nextline(&self.bytes[self.ix..]);
// Go to the next line of the blockquote if any
// omitting the '> ' to not create a nested blockquote
if self.scan_ch(b'>') {
let _ = self.scan_space(1);
while self.scan_ch(b'>') {
self.scan_space(1);
}
}
match tag {
Expand Down
13 changes: 13 additions & 0 deletions pulldown-cmark/tests/suite/blockquotes_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,16 @@ fn blockquotes_tags_test_11() {

test_markdown_html(original, expected, false, false, false);
}

#[test]
fn blockquotes_tags_test_12() {
let original = r##"> > [!CAUTION]
> > Line 1.
> Line 2.
"##;
let expected = r##"<blockquote><blockquote class="markdown-alert-caution"><p>Line 1.
Line 2.</p></blockquote></blockquote>
"##;

test_markdown_html(original, expected, false, false, false);
}

0 comments on commit 45281bc

Please sign in to comment.