Skip to content

Commit e139a80

Browse files
Fix GFM autolink literals after tabs
Closes GH-18. Co-authored-by: Christian Murphy <[email protected]>
1 parent db3c46a commit e139a80

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/event.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3512,8 +3512,11 @@ impl Point {
35123512
b'\n' | b'\r' => unreachable!("cannot move past line endings"),
35133513
b'\t' => {
35143514
let remainder = next.column % TAB_SIZE;
3515-
debug_assert_ne!(remainder, 0, "expected remainder larger than `0`");
3516-
let vs = TAB_SIZE - remainder;
3515+
let vs = if remainder == 0 {
3516+
0
3517+
} else {
3518+
TAB_SIZE - remainder
3519+
};
35173520
next.index += 1;
35183521
next.column += 1 + vs;
35193522
}

tests/fuzz.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,29 @@ fn fuzz() -> Result<(), String> {
7474
"7: lazy container lines almost starting fenced code (GH-19)"
7575
);
7676

77+
assert_eq!(
78+
to_html_with_options("a\t[email protected]", &Options::gfm()),
79+
Ok("<p>a\t<a href=\"mailto:[email protected]\">[email protected]</a></p>".into()),
80+
"8-a: autolink literals after tabs (GH-18)"
81+
);
82+
83+
assert_eq!(
84+
to_html_with_options("aa\t[email protected]", &Options::gfm()),
85+
Ok("<p>aa\t<a href=\"mailto:[email protected]\">[email protected]</a></p>".into()),
86+
"8-b: autolink literals after tabs (GH-18)"
87+
);
88+
89+
assert_eq!(
90+
to_html_with_options("aaa\t[email protected]", &Options::gfm()),
91+
Ok("<p>aaa\t<a href=\"mailto:[email protected]\">[email protected]</a></p>".into()),
92+
"8-c: autolink literals after tabs (GH-18)"
93+
);
94+
95+
assert_eq!(
96+
to_html_with_options("aaaa\t[email protected]", &Options::gfm()),
97+
Ok("<p>aaaa\t<a href=\"mailto:[email protected]\">[email protected]</a></p>".into()),
98+
"8-d: autolink literals after tabs (GH-18)"
99+
);
100+
77101
Ok(())
78102
}

0 commit comments

Comments
 (0)