Initial checklist
Affected package
react-markdown@10.1.0, rehype-raw@7.0.0
Steps to reproduce
When starting a markdown content string with <br/>\n, the markdown parsing of the remaining content is skipped and displayed as raw text. Only this exact sequence triggers the behavior, <br/>, \n, \n<br/>, A<br/>\n, etc. cause no issues.
I use the ReactMarkdown component with rehype-raw to properly enable HTML content, but I was able to reproduce this behavior with your vite stackblitz template linked above.
https://stackblitz.com/edit/github-8swqiz1q?file=src%2Fapp.tsx
This is the segment that is relevant:
import Markdown from 'react-markdown';
import rehypeRaw from 'rehype-raw';
const markdown = '<br/>\n[test](https://example.com)';
function App() {
return <Markdown rehypePlugins={[rehypeRaw]}>{markdown}</Markdown>;
}
It displays the following (including the newline):
[test](https://example.com)
For now, I simply replace the <br/>\n at the start of the string with a simple <br/> which fixes the issue, but I would like have a proper solution to this. Am I misunderstanding some markdown spec or is this an issue of the library?
I tried this exact string with several other local and online renderers and none of these showed this behavior.
Actual behavior
The rendered content is:
[test](https://example.com)
Expected behavior
I would expect the content to be:
<a href="https://example.com">test</a>
(or something related).
Runtime
Firefox 142.0.1 (64-bit)
Package manager
npm@10.8.2 on your stackblitz and npm@6.14.13 locally
Operating system
macOS 15.4.1 (24E263)
Build and bundle tools
CRA (Create React App), Vite
Initial checklist
Affected package
react-markdown@10.1.0, rehype-raw@7.0.0
Steps to reproduce
When starting a markdown content string with
<br/>\n, the markdown parsing of the remaining content is skipped and displayed as raw text. Only this exact sequence triggers the behavior,<br/>,\n,\n<br/>,A<br/>\n, etc. cause no issues.I use the
ReactMarkdowncomponent withrehype-rawto properly enable HTML content, but I was able to reproduce this behavior with your vite stackblitz template linked above.https://stackblitz.com/edit/github-8swqiz1q?file=src%2Fapp.tsx
This is the segment that is relevant:
It displays the following (including the newline):
For now, I simply replace the
<br/>\nat the start of the string with a simple<br/>which fixes the issue, but I would like have a proper solution to this. Am I misunderstanding some markdown spec or is this an issue of the library?I tried this exact string with several other local and online renderers and none of these showed this behavior.
Actual behavior
The rendered content is:
Expected behavior
I would expect the content to be:
(or something related).
Runtime
Firefox 142.0.1 (64-bit)
Package manager
npm@10.8.2 on your stackblitz and npm@6.14.13 locally
Operating system
macOS 15.4.1 (24E263)
Build and bundle tools
CRA (Create React App), Vite