vitepress
vitepress copied to clipboard
dup component with <img>+<p> in markdown (SSR)
Describe the bug
Thanks for creating vitepress, we are loving it!
In markdown w/ SSR, placing a <p> tag directly below an image breaks rendering of the next component. The component is duplicated for some reason. Note that this bug only occurs with SSR (not vitepress dev).
Reproduction
Here is some markdown to try:

<p>sometext</p>
<MyComponent/>
MyComponent.vue:
<template>
<div style="width: 10rem; height: 10rem; background: red" />
</template>
On dev it renders as one red box, with SSR it renders as two. The SSR HTML is strange:
<p><img src="..." alt=""></p>
<div style="width: 10rem; height: 10rem; background: red;"></div>
<p></p>
<div style="width:10rem;height:10rem;background:red;"></div>

Expected behavior
Component would render properly, or at least identically, in both dev and SSR.
System Info
System:
OS: macOS 12.4
CPU: (8) arm64 Apple M1
Memory: 135.58 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.13.2 - ~/.asdf/installs/nodejs/16.13.2/bin/node
Yarn: 1.22.18 - ~/.asdf/installs/nodejs/16.13.2/.npm/bin/yarn
npm: 8.1.2 - ~/.asdf/plugins/nodejs/shims/npm
Browsers:
Chrome: 102.0.5005.115
Firefox: 97.0.1
Safari: 15.5
npmPackages:
vitepress: ^1.0.0-alpha.1 => 1.0.0-alpha.1
Additional context
To workaround the issue, place a newline between the image and the <p> tag, like so:

<p>sometext</p>
<MyComponent/>
Then everything renders properly.
Validations
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Hi! This is actually the commonmark standard. You need to separate markdown and html/vue by at least a blank line. I'm not sure why the content is being duplicated. But giving no space between md and html will generally cause issues with rendering.
I am fine with this. But shouldn't it work the same between dev and SSR? That seems like an issue.
Hmmm, yeah if this doesn't happen in dev, it would surely be hard to catch this... It would be cool if we can have same behaviour in dev too.
Closing as I can no longer reproduce this in latest (1.0.0-alpha.54)