Skip to content

Commit 5d5e945

Browse files
Fix GFM autolink literals that end in in GFM table pipes
Closes GH-20. Co-authored-by: Christian Murphy <[email protected]>
1 parent e485745 commit 5d5e945

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/construct/gfm_autolink_literal.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,9 @@ pub fn path_inside(tokenizer: &mut Tokenizer) -> State {
470470
}
471471
_ => {
472472
// Source: <https://github.com/github/cmark-gfm/blob/ef1cfcb/extensions/autolink.c#L12>.
473-
if kind_after_index(tokenizer.parse_state.bytes, tokenizer.point.index)
474-
== CharacterKind::Whitespace
473+
if tokenizer.current.is_none()
474+
|| kind_after_index(tokenizer.parse_state.bytes, tokenizer.point.index)
475+
== CharacterKind::Whitespace
475476
{
476477
State::Retry(StateName::GfmAutolinkLiteralPathAfter)
477478
} else {

tests/fuzz.rs

+6
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,11 @@ fn fuzz() -> Result<(), String> {
9898
"8-d: autolink literals after tabs (GH-18)"
9999
);
100100

101+
assert_eq!(
102+
to_html_with_options("| a |\n| - |\n| www.a|", &Options::gfm()),
103+
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()),
104+
"9: autolink literals that end in table cell delimiter (GH-20)"
105+
);
106+
101107
Ok(())
102108
}

0 commit comments

Comments
 (0)