Skip to content

Commit e00c9e8

Browse files
authored
Merge pull request #646 from Martin005/escaped-character-span-sourcepos
fix: Incorrect `sourcepos` for escaped character spans
2 parents fdb17fc + 38f7b4b commit e00c9e8

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/parser/inlines.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<'a, 'r, 'o, 'd, 'c, 'p> Subject<'a, 'r, 'o, 'd, 'c, 'p> {
392392

393393
let inline_text = self.make_inline(
394394
NodeValue::Text(self.input[self.pos - 1..self.pos].to_string().into()),
395-
self.pos - 2,
395+
self.pos - 1,
396396
self.pos - 1,
397397
);
398398

src/tests/escaped_char_spans.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,24 @@ fn escaped_char_spans(markdown: &str, html: &str) {
1212
fn disabled_escaped_char_spans(markdown: &str, expected: &str) {
1313
html(markdown, expected);
1414
}
15+
16+
#[test]
17+
fn escaped_char_span_sourcepos() {
18+
assert_ast_match!(
19+
[render.escaped_char_spans],
20+
"Test \\`hello world\\` here.",
21+
(document (1:1-1:26) [
22+
(paragraph (1:1-1:26) [
23+
(text (1:1-1:5) "Test ")
24+
(escaped (1:6-1:7) [
25+
(text (1:7-1:7) "`")
26+
])
27+
(text (1:8-1:18) "hello world")
28+
(escaped (1:19-1:20) [
29+
(text (1:20-1:20) "`")
30+
])
31+
(text (1:21-1:26) " here.")
32+
])
33+
])
34+
);
35+
}

src/tests/sourcepos.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,12 @@ const TEXT: TestCase = (
246246
sourcepos!((11:3-11:8)),
247247
sourcepos!((12:3-12:9)),
248248
sourcepos!((12:12-12:15)),
249-
sourcepos!((14:7-14:14)),
249+
sourcepos!((14:1-14:5)),
250+
sourcepos!((14:7-14:7)),
251+
sourcepos!((14:8-14:18)),
252+
sourcepos!((14:20-14:20)),
253+
sourcepos!((14:21-14:26)),
254+
sourcepos!((16:7-16:14)),
250255
],
251256
r#"stuff before
252257
@@ -261,6 +266,8 @@ hello world
261266
- item 1[^1]
262267
- item 2 **bold**
263268
269+
Test \`hello world\` here.
270+
264271
[^1]: The end.
265272
"#,
266273
);

0 commit comments

Comments
 (0)