Skip to content

Commit

Permalink
Fix GFM autolink literals that end in in GFM table pipes
Browse files Browse the repository at this point in the history
Closes GH-20.

Co-authored-by: Christian Murphy <christian.murphy.42@gmail.com>
  • Loading branch information
wooorm and ChristianMurphy committed Oct 28, 2022
1 parent e485745 commit 5d5e945
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/construct/gfm_autolink_literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,9 @@ pub fn path_inside(tokenizer: &mut Tokenizer) -> State {
}
_ => {
// Source: <https://github.com/github/cmark-gfm/blob/ef1cfcb/extensions/autolink.c#L12>.
if kind_after_index(tokenizer.parse_state.bytes, tokenizer.point.index)
== CharacterKind::Whitespace
if tokenizer.current.is_none()
|| kind_after_index(tokenizer.parse_state.bytes, tokenizer.point.index)
== CharacterKind::Whitespace
{
State::Retry(StateName::GfmAutolinkLiteralPathAfter)
} else {
Expand Down
6 changes: 6 additions & 0 deletions tests/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,11 @@ fn fuzz() -> Result<(), String> {
"8-d: autolink literals after tabs (GH-18)"
);

assert_eq!(
to_html_with_options("| a |\n| - |\n| www.a|", &Options::gfm()),
Ok("<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><a href=\"http://www.a\">www.a</a></td>\n</tr>\n</tbody>\n</table>".into()),
"9: autolink literals that end in table cell delimiter (GH-20)"
);

Ok(())
}

0 comments on commit 5d5e945

Please sign in to comment.