Skip to content

Commit

Permalink
Fix GFM tables interfering with other constructs
Browse files Browse the repository at this point in the history
Closes GH-19.

Co-authored-by: Christian Murphy <christian.murphy.42@gmail.com>
  • Loading branch information
wooorm and ChristianMurphy committed Oct 26, 2022
1 parent ccf6775 commit db3c46a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/construct/gfm_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ pub fn head_row_break(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
None => {
tokenizer.tokenize_state.seen = false;
tokenizer.tokenize_state.size = 0;
State::Nok
}
Some(b'\n') => {
Expand Down Expand Up @@ -427,6 +428,7 @@ pub fn head_delimiter_start(tokenizer: &mut Tokenizer) -> State {
tokenizer.interrupt = false;

if tokenizer.lazy || tokenizer.pierce {
tokenizer.tokenize_state.size = 0;
State::Nok
} else {
tokenizer.enter(Name::GfmTableDelimiterRow);
Expand Down
6 changes: 6 additions & 0 deletions tests/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,11 @@ fn fuzz() -> Result<(), String> {
"6-b: container close after unclosed fenced code, with eol (list, GH-16)"
);

assert_eq!(
to_html_with_options("> x\n``", &Options::gfm()),
Ok("<blockquote>\n<p>x</p>\n</blockquote>\n<p>``</p>".into()),
"7: lazy container lines almost starting fenced code (GH-19)"
);

Ok(())
}

0 comments on commit db3c46a

Please sign in to comment.