marp-team / marp-core

The core of Marp converter
MIT License
775 stars 130 forks source link

Trouble rendering HTML and Markdown in the same line #341

Closed sorousherafat closed 1 year ago

sorousherafat commented 1 year ago

Version of Marp Tool

Marp VS Code v2.6.0

Operating System

Linux

Environment

How to reproduce

write down the following markdown and HTML:

<div>
**Hello**
</div>

<div>

**Hello**

</div>

Expected behavior

both of the divs should be rendered bold.

Actual behavior

only the second div is rendered bold.

image

Additional information

I am willing to contribute to the project and perhaps fix the bug, but I will need some guidance regarding the source code.

yhatt commented 1 year ago

This is the result of following the CommonMark specification. It is not really a bug. The first <div> block, without blank lines around contents, should not parse as Markdown text.

Second, it provides a very simple and flexible way of including Markdown content inside HTML tags: simply separate the Markdown from the HTML using blank lines:

Compare:

https://spec.commonmark.org/0.30/#example-188

See also https://github.com/orgs/marp-team/discussions/192#discussioncomment-3375932.