Skip to content

Commit ad1b3e6

Browse files
committed
Fix trailing whitespace around broken data
Closes GH-13. Closes GH-14.
1 parent 2cd3e65 commit ad1b3e6

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/construct/partial_data.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ pub fn inside(tokenizer: &mut Tokenizer) -> State {
7474

7575
/// Merge adjacent data events.
7676
pub fn resolve(tokenizer: &mut Tokenizer) -> Option<Subresult> {
77+
tokenizer.map.consume(&mut tokenizer.events);
78+
7779
let mut index = 0;
7880

7981
// Loop through events and merge adjacent data events.

src/construct/partial_whitespace.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ use alloc::vec;
6767

6868
/// Resolve whitespace.
6969
pub fn resolve_whitespace(tokenizer: &mut Tokenizer, hard_break: bool, trim_whole: bool) {
70+
tokenizer.map.consume(&mut tokenizer.events);
71+
7072
let mut index = 0;
7173

7274
while index < tokenizer.events.len() {

tests/fuzz.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,23 @@ fn fuzz() -> Result<(), String> {
3030
"3-b: containers should not pierce into indented code"
3131
);
3232

33+
assert_eq!(
34+
to_html("a * "),
35+
"<p>a *</p>",
36+
"4-a: trailing whitespace and broken data"
37+
);
38+
39+
assert_eq!(
40+
to_html("_ "),
41+
"<p>_</p>",
42+
"4-b: trailing whitespace and broken data"
43+
);
44+
45+
assert_eq!(
46+
to_html_with_options("a ~ ", &Options::gfm())?,
47+
"<p>a ~</p>",
48+
"4-c: trailing whitespace and broken data"
49+
);
50+
3351
Ok(())
3452
}

0 commit comments

Comments
 (0)