mity / md4c

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

Whitespace is removed after leave_span #126

Closed conorwsullivan closed 3 years ago

conorwsullivan commented 3 years ago

When parsing text that is underlined, in a latex code block, has a strikethrough, etc, the next call MD_PARSER.text() has missing whitespace at the beginning of the text. This happens no matter the setting of MD_FLAG_COLLAPSEWHITESPACE. It seems to happen after any span, that is, after any call to MD_PARSER.leave_span().

Image showing the issue. Look for the red markings.

mity commented 3 years ago

I am confused: There are only latex math inline spans, no such blocks. So, maybe it's leave_span() and not leave_block() what could be relevant? But furthermore the image does not show any latex math syntax construction at all.

And I failed to reproduce when tried these:

$ printf '_foo_ bar\n' | ./md2html/md2html --funderline
<p><u>foo</u> bar</p>

$ printf '_foo_  bar\n' | ./md2html/md2html --funderline    # two spaces
<p><u>foo</u>  bar</p>                 

$ printf '_foo_  bar\n' | ./md2html/md2html --funderline --fcollapse-whitespace
<p><u>foo</u> bar</p>

So, can you please provide a small input in a textual form, which can be fed into md2html utility (and any options required to reproduce), output you get, and output you expect to get?

conorwsullivan commented 3 years ago

Apologies, I meant leave_span

mity commented 3 years ago

Ok. But I cannot see how that changes that "cannot reproduce" state.

So, could you provide the instructions for reproducing it, as asked for? Or if you implement your own callbacks instead of using the provided HTML renderer, the issue might be in your callback implementation?

conorwsullivan commented 3 years ago

I've determined the issue isn't with md4c, apologies for any trouble.