Backslash doesn't insert a br
See original GitHub issueSubject of the issue
I’ve been using \
for new lines in my markdown files and it worked great with rehype etc. Migrated to MDX and noticed it didn’t work the same way. Not 100% sure if this is a standard way of inserting new lines or not.
Your environment
- MacOS 10.14.1
@mdx-js/mdx
@0.18.1
- Node @
v10.15.0
Steps to reproduce
(async () => {
const result = await mdx(`
# Hello, MDX
**Hello**\
I <3 Markdown and JSX
`)
console.log(result)
})()
Expected behaviour
Backslash (\
) should be converted to a <br/>
element
Actual behaviour
It’s just omitted
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to insert a line break <br> in markdown - Stack Overflow
Try adding 2 spaces (or a backslash \ ) after the first line: [Name of link](url) My line of text\. Visually: [Name of...
Read more >Automatic line break with backslash in listings - TeX
I have found two answers to my question, both of which allow backslashes to be correctly styled when used for automatic line-breaking with ......
Read more >HTML Line Break – How to Break a Line with the HTML <br ...
You can insert line breaks in HTML with the <br> tag, which is equivalent to a carriage return on a keyboard. Be aware...
Read more >Make line breaks work when you render text in a React or Vue ...
... if you were to put it into a React (or Vue) component, like this: ... is split up the string and then...
Read more >How to Get Line Breaks In Markdown
If you do not use spaces or backslashes, your line break will not render in the HTML output even though you have a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh my bad, had no idea that backslash didn’t work in template strings. Adding
commonmark: true
in mygatsby-mdx
options solved it for me!That could be it!
Or maybe because you use a slash in a template literal: