MarkdownKit icon indicating copy to clipboard operation
MarkdownKit copied to clipboard

Assertion fails for some content

Open haldun opened this issue 5 years ago • 4 comments

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

haldun avatar Dec 08 '20 10:12 haldun

@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?

soffes avatar Dec 08 '20 16:12 soffes

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.

haldun avatar Dec 08 '20 16:12 haldun

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!

soffes avatar Dec 08 '20 16:12 soffes

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

haldun avatar Dec 08 '20 16:12 haldun