SwiftDocOrg / CommonMark

Create, parse, and render Markdown text according to the CommonMark specification
MIT License
179 stars 10 forks source link

Can't form Range with upperBound < lowerBound #1

Closed andrewconlan closed 4 years ago

andrewconlan commented 4 years ago

Seem to be running into an issue when adding a header to a list "* #" or quote "> #", then checking the range for that header:

Fatal error: Can't form Range with upperBound < lowerBound

I've added a test project, to show it happening test.zip

mattt commented 4 years ago

Thanks so much for opening this issue and providing a reproducible test case, @andrewconlan. This looks to be a bug in cmark, as cmark_node_get_start_column is reporting a position after cmark_node_get_end_column. I'll investigate this some more and open some issues / PRs in that project.

In the meantime, I can think of a few possible workarounds:

Of these options, I'm leaning on #3, because that would provide a fix without changing the public API. Do you have any strong feelings about the best way to resolve this?

andrewconlan commented 4 years ago

Yep I think number #3 sounds like a good solution until it's resolved in cmark, I'm using the project to add attributes to a UITextView as the user types and it's working really well, thanks again for the project, it's excellent

mattt commented 4 years ago

Thanks again for reporting this, @andrewconlan. The fix in #2 is now merged and available in version 0.2.2.