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

[BUG] Incorrect position of one-line HTML comment tags #23

Open
Sereja313 opened this issue Sep 20, 2022 · 3 comments
Open

[BUG] Incorrect position of one-line HTML comment tags #23

Sereja313 opened this issue Sep 20, 2022 · 3 comments

Comments

@Sereja313
Copy link

Sereja313 commented Sep 20, 2022

There seems to be some kind of bug with the single-line HTML comment tags. The values ​​of the endLine and endColumn fields are always incorrect for them.

Here is an example:

commonmarkToNode [] [] $ fromString "<!-- comment -->"

produces

Node (Just (PosInfo {startLine = 1, startColumn = 1, endLine = 1, endColumn = 16})) DOCUMENT [Node (Just (PosInfo {startLine = 1, startColumn = 1, endLine = 0, endColumn = 0})) (HTML_BLOCK "<!-- comment -->\n") []]
@kivikakk
Copy link
Owner

Heya! This library doesn't do much more than wrap, so I suspected this might come from the underlying cmark-gfm, which does seem to be the case:

$ printf '<!-- comment -->' | cmark-gfm --unsafe -t xml --sourcepos
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "CommonMark.dtd">
<document sourcepos="1:1-1:16" xmlns="http://commonmark.org/xml/1.0">
  <html_block sourcepos="1:1-0:0" xml:space="preserve">&lt;!-- comment --&gt;
</html_block>
</document>

I suspect this case is getting hit here and it's not correctly adjusting for the free-content nature of inline HTML blocks. There's a possibly related bug mentioned upstream: commonmark/cmark#298

@kivikakk
Copy link
Owner

This PR also looks promising (see item number 2 in the PR body): github/cmark-gfm#210

@Sereja313
Copy link
Author

Oh I see. Thank you very much for your response!

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

No branches or pull requests

2 participants