soffes / MarkdownKit

Fancy Markdown input with TextKit powered by CommonMark
MIT License
45 stars 6 forks source link

Assertion fails for some content #13

Open haldun opened 3 years ago

haldun commented 3 years ago

The following inputs create an assertion failure at https://github.com/soffes/MarkdownKit/blob/769ec26ac46fe9cd249c1fd6133b225102efa7ed/Sources/MarkdownKitObjC/BaseTextStorage.m#L27

This one has a [line
break].

[line break]: /foo
* List item _ending_
with _emphasis_.

* List item
with **strong emphasis**.

* List item
with [a link](http://google.com).
This one has a [line
break].

[line break]: /foo
soffes commented 3 years ago

@haldun Hmm. Any ideas? Without that assertion, TextKit will access things out of bounds.

Do you think we should just disable the assertion and return instead?

haldun commented 3 years ago

TBH I didn't dig deeper to these issues yet, so I think it would be better to understand why the assertion fails for these inputs at the first place.

soffes commented 3 years ago

I ran into something similar in the past. It was a bug in cmark. Had to make a make some small changes to it to get it to work reliably. Maybe start with adding these strings in tests and asserting where you think the ranges should be then work backwards from there.

I don't have time today to look at this. I can try to help later this week though if you can't figure it out!

haldun commented 3 years ago

Oh this is not urgent at all! I just wanted to document these edge cases.