Skip to content

sourcepos broken for tables and inlines and confusing CMARK_OPT_SOURCEPOS behavior #222

@martincizek

Description

@martincizek

We've implemented an automated GFM editor, which depends heavily on sourcepos, which is currently widely broken. I will sum app all the issues here and then will link a pull request with the fixes.

I wanted to wait until the overlapping upstream pull request commonmark#298 is merged, but nothing happens for more than a year, although the objections against performance turned out to be negligible.

I kindly ask you to review this, as the GfmEditor is one of exciting use cases enabled by sourcepos. That means, incorrect sourcepos is not just a cosmetic bug affecting rendering appearance. It prevents whole category of automatic processing that would be possible with it.

  1. Sourcepos is incorrect on tables with preceding table-like paragraph:
    | paragraph |
    | header |
    | --- |
    | row |
    
  2. CMARK_OPT_SOURCEPOS is very confusing in terms how it affects the parser:
    • when it is not set on the parser, sourcepos is currently broken on all inlines
    • when it is set on the parser, sourcepos gets improved, but it is still far from correct
  3. Sourcepos is broken on strikethrough with softbreak:
    Hi ~~friend~~ and ~~other
    friend~~.
    
  4. Sourcepos is missing on softbreaks and linebrekas (at least we missed it a lot :))
  5. Sourcepos is broken for things mentioned in upstream PR Fix source positions for inlines. commonmark/cmark#298, i.e.:
    • Inlines inside inconsistently indented blocks.
    • Links/images.
    • Autolinks.
    • Escaped newlines.
    • Non-matched backticks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions