Skip to content

Commit 8964f32

Browse files
committed
parser: deal with 
 and missing content.
1 parent 6f1649e commit 8964f32

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/parser/mod.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -3067,15 +3067,22 @@ where
30673067
return;
30683068
}
30693069

3070-
text.drain(..end);
3071-
30723070
// These are sound only because the exact text that we've matched and
30733071
// the count thereof (i.e. "end") will precisely map to characters in
30743072
// the source document.
3075-
sourcepos.start.column += end;
3076-
let reference = spx.consume(end) + 1;
3077-
assert_eq!(reference, sourcepos.start.column);
3078-
parent.data.borrow_mut().sourcepos.start.column += end;
3073+
text.drain(..end);
3074+
3075+
let adjust = spx.consume(end) + 1;
3076+
// Do we need to account separately for the parent? I _think_ it always
3077+
// has the same start col to begin with as `sourcepos` itself.
3078+
assert_eq!(
3079+
sourcepos.start.column,
3080+
parent.data.borrow().sourcepos.start.column
3081+
);
3082+
3083+
// HACK: See tests::fuzz::echaw9. The paragraph doesn't exist in the source!
3084+
sourcepos.start.column = usize::min(sourcepos.end.column, adjust);
3085+
parent.data.borrow_mut().sourcepos.start.column = sourcepos.start.column;
30793086

30803087
grandparent.data.borrow_mut().value =
30813088
NodeValue::TaskItem(if symbol == ' ' { None } else { Some(symbol) });

src/tests/fuzz.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -346,17 +346,12 @@ fn echaw8() {
346346
fn echaw9() {
347347
// fuzz/artifacts/all_options/minimized-from-8a07a44ba1f971ec39d0c14d377c78c2535c6fd5
348348
assert_ast_match!(
349-
[extension.autolink, extension.tasklist],
349+
[extension.tasklist],
350350
"-\t[ ]
",
351-
(document (1:1-1:15) [
352-
(list (1:1-1:15) [
353-
(taskitem (1:1-1:15) [
354-
(paragraph (1:7-1:17) [
355-
(text (1:7-1:13) "𝔛-<")
356-
(link (1:14-1:17) "mailto:[email protected]" [
357-
(text (1:14-1:17) "[email protected]")
358-
])
359-
])
351+
(document (1:1-1:14) [
352+
(list (1:1-1:14) [
353+
(taskitem (1:1-1:14) [
354+
(paragraph (1:14-1:14)) // Unsatisfying. See parser::process_tasklist.
360355
])
361356
])
362357
]),

0 commit comments

Comments
 (0)