objecthub / swift-markdownkit

A framework for parsing and transforming text in Markdown format written in Swift 5 for macOS, iOS, and Linux. The syntax is based on the CommonMark specification. The framework defines an abstract syntax for Markdown, provides a parser for parsing strings into abstract syntax trees, and comes with generators for HTML and attributed strings.
Apache License 2.0
154 stars 23 forks source link

Parsing/generating errors #14

Open AlvaroBro opened 3 weeks ago

AlvaroBro commented 3 weeks ago

Hi @objecthub !

First, thanks for this awesome library, I've started using it as I want to have enriched messages in my instant messaging app.

I've been trying several options, but none has been optimal. For example I need tables support, and yours is the only one I've found that provides this.

But testing it, I've found several cases where the result is not correct. I'm am currently debugging and I'm able to provide, for example:

If you could help me solving these cases it would be great! I think I will test you library to extreme cases as I plan to create complicated messages.

So, should I go ahead and start providing examples???

Thank you!

objecthub commented 3 weeks ago

Thanks for your message, @AlvaroBro ! If you found issues with the table support in MarkdownKit, then I definitely want to fix them. If you have some examples where the results are not as expected, then it would be great if you could share them.

AlvaroBro commented 3 weeks ago

Ok! In fact, for the moment all the problems I've had were not in tables but in other elements. I still have not started testing tables but for a very basic case. Ok then, I'll start posting cases here :)

AlvaroBro commented 3 weeks ago

Please let me know if you need any more details!

Nested lists

Nested unordered list.

Problem: always adds an empty extra list item

Input text

- Manzana
    - Banana

I get the same result if I use 2 spaces instead of tab.

I use ExtendedMarkdownParser, which I extended as shown in you example to support underlined and strike-through text.

Debug info

Input text and parser's result:

Captura de pantalla 2024-10-14 a las 19 08 35

Generated HTML body:

Captura de pantalla 2024-10-14 a las 18 59 24

Generated attributed string:

Captura de pantalla 2024-10-14 a las 19 06 17

Which looks like this in a TextView:

Simulator Screenshot - iPhone 15 - 2024-10-14 at 19 06 29