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

Allow empty lines in JS blocks in MDX? #555

Closed
Paul-Hebert opened this issue Mar 18, 2020 · 5 comments
Closed

Allow empty lines in JS blocks in MDX? #555

Paul-Hebert opened this issue Mar 18, 2020 · 5 comments
Labels
✨ enhancement New feature or request 👷 environment Setup, build tools, configuration, etc. ⁉️ question Further information is requested

Comments

@Paul-Hebert
Copy link
Member

It's possible to insert JS blocks at the top of our MDX files. However, if you introduce any empty lines within JS blocks for code organization then they're treated as markdown instead of JS.

There are a few relevant issues that may be worth tracking:

mdx-js/mdx#787
mdx-js/mdx#195

In the meantime I'm curious if anyone has any clever ideas to help handle this.

@Paul-Hebert Paul-Hebert added ✨ enhancement New feature or request ⁉️ question Further information is requested 👷 environment Setup, build tools, configuration, etc. labels Mar 18, 2020
@Paul-Hebert
Copy link
Member Author

Paul-Hebert commented Mar 18, 2020

Screen Shot 2020-03-18 at 12 15 00 PM

Note how the console.log() line is treated as markdown.

@calebeby
Copy link
Member

Here is a fun hack:

You can put export {} on the line before a line you want mdx to interpret as JS

export {}
console.log('hello')

Even more hacky (or equally hacky?)

export console.log('hello')

Not sure if webpack will allow that one though

@Paul-Hebert
Copy link
Member Author

Oh... interesting... I'm not sure how I feel about actually using that but it's good to know!

@spaceninja
Copy link
Member

@Paul-Hebert since this is a limitation of MDX with no easy answer beside the workarounds Caleb posted, would you be okay closing this issue?

@Paul-Hebert
Copy link
Member Author

Sure 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request 👷 environment Setup, build tools, configuration, etc. ⁉️ question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants