pngwn / MDsveX

A markdown preprocessor for Svelte.
https://mdsvex.pngwn.io
MIT License
2.27k stars 96 forks source link

How do I group inline components in a paragraph? #430

Open eight04 opened 2 years ago

eight04 commented 2 years ago

Currently, mdsvex compiles

<Count count="{number}"/>
<Count count="{number}"/>

into

<Count count="{number}"/>
<Count count="{number}"/>

If the component looks like an inline element, it adds a paragraph:

a <Count count="{number}"/>
<Count count="{number}"/>

->

<p>a <Count count="{number}"/></p>
<Count count="{number}"/>

Also:

a <Count count="{number}"/>
b <Count count="{number}"/>

->

<p>a <Count count="{number}"/> b <Count count="{number}"/></p>

Is there a setting telling mdsvex that some components/HTML tags should be treated like inline elements? I lost all paragraphs after replacing images with svelte components.

pngwn commented 2 years ago

Currently there isn't, and I'm not sure what a good API or syntax for this looks like. Currently markdown semantics are very important, although these semantics will be tweaked in 1.0 to make things like this simpler. Will revisit this issue when I have had time to think about what a good solution might look like.

phenomen commented 2 years ago

@pngwn Check MDC inline components https://content.nuxtjs.org/guide/writing/mdc#inline-components

eight04 commented 2 years ago

@pngwn Check MDC inline components https://content.nuxtjs.org/guide/writing/mdc#inline-components

It doesn't solve this issue. We are discussing how to make the compiler group multiple components into a single paragraph.

jgrieger commented 1 year ago

Having inline components would be great. In MD you simply mix text and a link, in the resulting HTML the link would be in a different paragraph than the text which is very weird to read.