frontarm / mdx-util

Utilities for working with MDX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Paragraph are not joined by spaces

JuanCaicedo opened this issue · comments

Hi there!

My impression with markdown is that you can split a paragraph of text into many lines and they will be joined together by spaces:

# header
a
b

c
d

should become

<h1>Header</h1>
<p>a b</p>
<p>c d</p>

However, I think mdxc instead returns this (no spaces)

<h1>Header</h1>
<p>ab</p>
<p>cd</p>

Not sure if that's coming from here or from markdown-it, but I'm willing to help identify/fix 😀

I've managed to reproduce this, and it is definitely a problem. I guess I've never really used newline mid paragraph so I hadn't noticed it.

The problem is that MDX currently treats each text line as a string child of a React element, but React doesn't put any spaces between these. I'm going to try adding a newline character at the end of every text line and see how it goes.