Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse markdown inside HTML #14

Open
tonai opened this issue Jan 10, 2023 · 5 comments
Open

Parse markdown inside HTML #14

tonai opened this issue Jan 10, 2023 · 5 comments

Comments

@tonai
Copy link

tonai commented Jan 10, 2023

It would be great if markdown inside HTML could be parsed (like for MDX2).

Regarding this markdown (Alert being a custom vue component with a slot):

<div>Hello `div`</div>
<Alert>Hello `alert`</Alert>

I would expect:

<div>Hello <code>div</code></div>
<Alert>Hello <code>alert</code></Alert>

Current result:

<div>Hello `div`</div>
<Alert>Hello `alert`</Alert>

The case with the custom Vue component was working (markdown inside the component was parsed) in version 0.1.0 but removed in version 0.1.1 with the addition of the componentPlugin .

@meteorlxy
Copy link
Collaborator

Hi, sorry for delay.

The reason is that before 0.1.0 we were not strictly followed the markdown-it spec to handle html tags/vue components.

If you try it on raw markdown-it, any markdown syntax inside a html tag in a single line will be kept as is.

That might not be intuitive, but that's the commonmark spec defines how to treat HTML tags inside markdown.

@tonai
Copy link
Author

tonai commented Jan 19, 2023

No problem.
It is kind of a shame because MDX2 syntax is really handy.

The only workaround is to add additional blank spaces:

<Alert>

Hello `alert`

</Alert>

But in that case there will be an additionnal <p> tag:

<Alert>

<p>Hello <code>alert</code></p>

</Alert>

Is there any other option ?

@meteorlxy
Copy link
Collaborator

Maybe we could add a loose mode for that.

@meteorlxy
Copy link
Collaborator

meteorlxy commented Feb 3, 2023

Alternatively, to make it looks more markdown-like, you can also make use of some plugins like markdown-it-container to render the component.

There are some sample usage for the container plugin:

@tonai
Copy link
Author

tonai commented Feb 13, 2023

Thanks for the feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants