Skip to content

incorrect sourcepos for list node between code blocks #703

@akiomik

Description

@akiomik

Description

When a list is positioned between fenced code blocks, the List node's sourcepos incorrectly ends at the list marker position instead of spanning to the end of the list content.

```
code
```
- list
```
code
```
  • expected: List sourcepos should be 4:1-4:6
  • actual: List sourcepos is 4:1-4:3

NOTE: The Item node and its children appear to have correct sourcepos (4:1-4:6, 4:3-4:6).

Test Case

#[test]
fn test_list_sourcepos_bug_between_code_blocks() {
    let markdown_input = r#"```
code
```
- list
```
code
```"#;

    let arena = Arena::new();
    let options = Options::default();
    let root = parse_document(&arena, markdown_input, &options);

    let list_node = root.descendants()
        .find(|d| matches!(d.data().value, NodeValue::List(_)))
        .unwrap();

    let actual_sourcepos = list_node.data().sourcepos;

    // This fails: expected 4:1-4:6, got 4:1-4:3
    assert_eq!(actual_sourcepos, sourcepos!((4:1-4:6)));
}

Environment

  • comrak: 0.48.0

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions