comrak icon indicating copy to clipboard operation
comrak copied to clipboard

`sourcepos` is incorrect for `<script>` tags

Open GabeIsman opened this issue 6 months ago • 4 comments

I've encountered an odd issue. I'm using the Ruby wrapper (Commonmarker) and inspecting the AST shows some strange behavior around the sourcepos of <script> tags. AFAICT this is only related to script tags, and only ones that appear all on one line at that.

Commonmarker.parse("<script></script>")
=> #<Commonmarker::Node(document):
  source_position={:start_line=>1, :start_column=>1, :end_line=>1, :end_column=>17}
  children=[#<Commonmarker::Node(html_block):
       source_position={:start_line=>1,
        :start_column=>1,
        :end_line=>0,
        :end_column=>0}>]>

note the end_line and end_column are both zero. In general I've observed that end_line is start_line - 1, and end_column is always zero.

Let me know if I should open an issue on Commonmarker instead, but I don't see how this could be caused by the wrapper. I just lack the rust expertise to test it directly in rust, sorry!

GabeIsman avatar Jul 29 '24 16:07 GabeIsman