Closed meteorlxy closed 3 years ago
Works as expected. That's markdown terms, see spec.
Inline elements will be force-wrapped by paragraph: https://markdown-it.github.io/#md3=%7B%22source%22%3A%22%3Cb%3Etest%3C%2Fb%3E%22%2C%22defaults%22%3A%7B%22html%22%3Atrue%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22src%22%7D%7D
@puzrin ??? That's what I reported. img tag does not work like that!
https://spec.commonmark.org/dingus/?text=%3Cimg%20src%3D%22foo.png%22%3E%0A%0A%3Cb%3Etest%3C%2Fb%3E
That works exactly as reference parser. Issues like "your parser should work not as reference one" are not welcome.
I see, so this should be reported to commonmark
Alright, found the related issue: https://github.com/commonmark/commonmark-spec/issues/492
As far as i understand, tags are wrapped with paragraph only if followed with something AND are not in list of "block tags". I don't remember details "why". But there were long forum discussions if anyone wish to dive inside.
@puzrin Thanks for your explanation!
Although it's a little weird, we have to follow the "implicit" spec. (I could not find the related description in commonmark spec... 😅 )
Although it's a little weird, we have to follow the "implicit" spec.
https://spec.commonmark.org/0.30/#html-blocks
4.6, condition 7:
Start condition: line begins with a complete open tag (with any tag name other than pre, script, style, or textarea) or a complete closing tag, followed by zero or more spaces and tabs, followed by the end of the line. End condition: line is followed by a blank line.
The spec is very much explicit about this, standalone <img>
on its own line is a block tag.
<img>
tag should be ahtml_inline
token, but it seems to be parsed ashtml_block
token.https://markdown-it.github.io/#md3=%7B%22source%22%3A%22%3Cimg%20src%3D%5C%22foo.png%5C%22%3E%5Cn%22%2C%22defaults%22%3A%7B%22html%22%3Atrue%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22debug%22%7D%7D