Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: A header directly after a JSX opening tag will not render as an <h1> #136

Closed
Flaque opened this issue May 7, 2018 · 4 comments
Closed

Comments

@Flaque
Copy link

Flaque commented May 7, 2018

Overview

Markdown headers don't render correctly when there's no space in between the JSX opening tag.

Example failure

Take the following code:

import Styles from "./styles.js";

<Styles>
# hello, world!

</Styles>

This will render without an H1:
bad code

Example success

If we add a space, like in the following:

import Styles from "./styles.js";

<Styles>

# hello, world!

</Styles>

This will render an h1 version:

good code

@timneutkens
Copy link
Member

So actually writing markdown in between jsx tags is not supported. You've actually ran into an edge case with the compiler 😄

So the output of this is correct:

import Styles from "./styles.js";

<Styles>
# hello, world!

</Styles>

And this isn't, even though it's hard for us to actually parse it out, this is an edge case:

import Styles from "./styles.js";

<Styles>

# hello, world!

</Styles>

So what happens when you add an extra line is that every line becomes a paragraph, it's also wrapped as such, but since we don't touch any content of a jsx tag, the result will be wrapped between the tags.

@Flaque
Copy link
Author

Flaque commented May 7, 2018

Ohhhh interesting! :O

writing markdown in between jsx is not supported

Could it be? Would there be an issue with it?

@timneutkens
Copy link
Member

Could it be? Would there be an issue with it?

It's very complex and out of scope for mdx imho. Basically what we do now is turn html nodes into jsx nodes, and then just render the "raw" jsx inside the transpiled jsx document.

Also the markdown cheatsheet is mentioning: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#inline-html

Markdown in HTML
Does *not* work **very** well. Use HTML tags.

@silvenon
Copy link
Contributor

Closing this because we're tracking a similar issue #241. I would like this to work in the future somehow, but we could use some API suggestion. 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants