Skip to content

Commit

Permalink
Fix double setext heading underlines
Browse files Browse the repository at this point in the history
Related-to: GH-22.
  • Loading branch information
wooorm committed Nov 25, 2022
1 parent 4f77634 commit eea185e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/construct/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ pub fn flow_end(tokenizer: &mut Tokenizer) -> State {
if !document_lazy_continuation_current && !child.events.is_empty() {
let before = skip::opt_back(&child.events, child.events.len() - 1, &[Name::LineEnding]);
let name = &child.events[before].name;
if name == &Name::Content {
if name == &Name::Content || name == &Name::HeadingSetextUnderline {
document_lazy_continuation_current = true;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/construct/heading_setext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,12 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
&& !tokenizer.pierce
// Require a paragraph before.
&& (!tokenizer.events.is_empty()
&& tokenizer.events[skip::opt_back(
&& matches!(tokenizer.events[skip::opt_back(
&tokenizer.events,
tokenizer.events.len() - 1,
&[Name::LineEnding, Name::SpaceOrTab],
)]
.name
== Name::Content)
.name, Name::Content | Name::HeadingSetextUnderline))
{
tokenizer.enter(Name::HeadingSetextUnderline);

Expand Down
6 changes: 6 additions & 0 deletions tests/heading_setext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ fn heading_setext() -> Result<(), String> {
"should prefer a setext heading over an interrupting list"
);

assert_eq!(
to_html("[a]: b\n=\n="),
"<h1>=</h1>",
"should support a two setext heading underlines after a definition, as a setext heading"
);

assert_eq!(
to_html("> ===\na"),
"<blockquote>\n<p>===\na</p>\n</blockquote>",
Expand Down

0 comments on commit eea185e

Please sign in to comment.