mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
785 stars 146 forks source link

issue with 2 lists, separated with a new line ? #164

Closed vtorri closed 3 years ago

vtorri commented 3 years ago

Hello,

I am using a toolkit to render markdown files. For debug, i have printed the description of each callbacks (entering or leaving block or span, and text)

with this file :

- first
- second

the terminal output is

_md_enter_block : body
_md_enter_block : ul
_md_enter_block : li (indent : 1)
text (0) normal : 'first'
_md_leave_block : li
_md_enter_block : li (indent : 1)
text (0) normal : 'second'
_md_leave_block : li
_md_leave_block : ul
_md_leave_block : body

But with this file :

- first
- second

- Type some Markdown on the left
- See HTML in the right

the terminal output is

_md_enter_block : body
_md_enter_block : ul
_md_enter_block : li (indent : 1)
_md_enter_block : p
text (0) normal : 'first'
_md_leave_block : p
_md_leave_block : li
_md_enter_block : li (indent : 1)
_md_enter_block : p
text (0) normal : 'second'
_md_leave_block : p
_md_leave_block : li
_md_enter_block : li (indent : 1)
_md_enter_block : p
text (0) normal : 'Type some Markdown on the left'
_md_leave_block : p
_md_leave_block : li
_md_enter_block : li (indent : 1)
_md_enter_block : p
text (0) normal : 'See HTML in the right'
_md_leave_block : p
_md_leave_block : li
_md_leave_block : ul
_md_leave_block : body

As you can see, 'P' blocks are. added

If I add text between the 2 lists, no 'P' block is added.

Is this behavior normal , or is this an issue ?

thank you

vtorri commented 3 years ago

i've tried with https://spec.commonmark.org/dingus/ and indeed, a paragraph is added

so md4c is correct. I have to adapt a bit my rendering, then

closing

mity commented 3 years ago

Yes, the blank line switches the list into what the specification calls a loose list.