-
-
Notifications
You must be signed in to change notification settings - Fork 916
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and discussions and couldn’t find anything (or linked relevant results below)
Affected package
[email protected], [email protected]
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
[email protected] on your stackblitz and [email protected] locally
Operating system
macOS 15.4.1 (24E263)
Build and bundle tools
CRA (Create React App), Vite