gjtorikian / commonmarker

Ruby wrapper for the comrak (CommonMark parser) Rust crate
MIT License
429 stars 82 forks source link

Incorrect processing of list and next block of code #146

Closed amshkv closed 3 years ago

amshkv commented 3 years ago

Hi. i have next sample:

* simple list item
* simple list item

```java
import

and i get
```=> "  - simple list item\n  - simple list item\n\n<!-- end list -->\n\n``` java\nimport\n```\n"```

![image](https://user-images.githubusercontent.com/23584933/131799238-b37f991c-6d05-4ee7-86a0-acc320db0461.png)

if you insert any text or separator the problem goes away

asdf

import


````"  - simple list item\n  - simple list item\n\nasdf\n\n``` java\nimport\n```\n"````

can be removed somehow `<!-- end list -->` coment without adding other blocks?
gjtorikian commented 3 years ago

I can't reproduce this at all:

irb(main):002:0" str = <<~DOC
irb(main):003:0" * simple list item
irb(main):004:0" * simple list item
irb(main):005:0" 
irb(main):006:0" ```java
irb(main):007:0" import
irb(main):008:0" ```
irb(main):009:0> DOC
irb(main):011:0> CommonMarker.render_html(str, :DEFAULT)
=> "<ul>\n<li>simple list item</li>\n<li>simple list item</li>\n</ul>\n<pre><code class=\"language-java\">import\n</code></pre>\n"

How are you calling Commonmarker?

amshkv commented 3 years ago

CommonMarker.render_doc(str, :DEFAULT).to_commonmark we use render_doc to preprocess images

test with CommonMarker.render_html(str, :DEFAULT) does not contain end list

kivikakk commented 3 years ago

See here:

https://github.com/commonmark/cmark/blob/6fcf869337a125f784ee7bd4f1c50ac1af9d5715/src/commonmark.c#L217-L223

This is hard to avoid.

gjtorikian commented 3 years ago

Given that this is an issue in the core Commonmark, I would suggest you work with them to address it, @amshkv. Since this is only a Ruby wrapper to that C library there's not much we can do, as we don't want to deviate from their implementation.