Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect sourcepos for a html comment of HtmlBlock #507

Open
akiomik opened this issue Dec 14, 2024 · 1 comment
Open

Incorrect sourcepos for a html comment of HtmlBlock #507

akiomik opened this issue Dec 14, 2024 · 1 comment

Comments

@akiomik
Copy link

akiomik commented Dec 14, 2024

  • expected: 1:1-1:21
  • actual: 1:1-0:0

source:

let text = "<!-- A html block -->";
let arena = Arena::new();
let ast = parse_document(&arena, text, &Options::default());
println!("{:?}", ast);

output:

Node {
  data: RefCell { value: Ast { value: Document, sourcepos: Sourcepos { start: LineColumn { line: 1, column: 1 }, end: LineColumn { line: 1, column: 21 } }, internal_offset: 0, content: "", open: false, last_line_blank: false, table_visited: false, line_offsets: [] } },
  children: [
    Node {
      data: RefCell { value: Ast { value: HtmlBlock(NodeHtmlBlock { block_type: 2, literal: "<!-- A html block -->\n" }), sourcepos: Sourcepos { start: LineColumn { line: 1, column: 1 }, end: LineColumn { line: 0, column: 0 } }, internal_offset: 0, content: "", open: false, last_line_blank: false, table_visited: false, line_offsets: [0] } },
      children: []
    }
  ]
}

environment:

  • rustc 1.83.0 (90b35a623 2024-11-26)
  • comrak 0.31.0
@akiomik akiomik changed the title Incorrect sourcepos for HtmlBlock of a html comment Incorrect sourcepos for a html comment of HtmlBlock Dec 14, 2024
@akiomik
Copy link
Author

akiomik commented Dec 19, 2024

<pre> (block_type: 1) may have the same issue.

source:

let text = "<pre>foo</pre>";
let arena = Arena::new();
let ast = parse_document(&arena, text, &Options::default());
println!("{:#?}", ast);

output:

Node {
    data: RefCell {
        value: Ast {
            value: Document,
            sourcepos: Sourcepos {
                start: LineColumn {
                    line: 1,
                    column: 1,
                },
                end: LineColumn {
                    line: 1,
                    column: 14,
                },
            },
            internal_offset: 0,
            content: "",
            open: false,
            last_line_blank: false,
            table_visited: false,
            line_offsets: [],
        },
    },
    children: [
        Node {
            data: RefCell {
                value: Ast {
                    value: HtmlBlock(
                        NodeHtmlBlock {
                            block_type: 1,
                            literal: "<pre>foo</pre>\n",
                        },
                    ),
                    sourcepos: Sourcepos {
                        start: LineColumn {
                            line: 1,
                            column: 1,
                        },
                        end: LineColumn {
                            line: 0,
                            column: 0,
                        },
                    },
                    internal_offset: 0,
                    content: "",
                    open: false,
                    last_line_blank: false,
                    table_visited: false,
                    line_offsets: [
                        0,
                    ],
                },
            },
            children: [],
        },
    ],
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants