Inline comment directly after jsx block fails to parse.
See original GitHub issueSubject of the issue
Adding an inline md comment directly after an inline html/jsx block in a markdown file causes mdx to fail to parse.
Similar to this issue: https://github.com/mdx-js/mdx/issues/243
Your environment
- OS: macos
- Packages: “@mdx-js/react”: “^1.4.5”,
Steps to reproduce
ON the sample site, add an inline comment to the in html example.
# Below is a JSX block
<div style={{ padding: '10px 30px', backgroundColor: 'tomato' }}>
<h2>Try making this heading have the color green</h2>
</div>
<!-- AUTO-GENERATED-CONTENT:END -->
🎉 BONUS POINTS for creating a minimal reproduction and uploading it to GitHub. This will get you the fastest support. 🎉
Expected behaviour
The comment is ignored.
Actual behaviour
Parsing fails.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to use comments in React - Stack Overflow
My comments are showing up in the UI. What would be the right approach to apply single and multiple line comments inside a...
Read more >React Native Comments - 2 Ways to Add Comments in JSX
Regular JavaScript comments in JSX get parsed as Text. ... If you want to comment in render block where we use JSX you...
Read more >How to comment in React JSX - Wes Bos
Regular JavaScript comments in JSX get parsed as Text and show up in your app. Comments in JSX are weird and when searching...
Read more >JavaScript Comments - W3Schools
Any text between /* and */ will be ignored by JavaScript. This example uses a multi-line comment (a comment block) to explain the...
Read more >React Building Comments Application - YouTube
Comments system is a popular feature for any React project but it's not easy. In this video we will build comments section from...
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
@wooorm Good question. I reckon MD doesn’t have a syntax for comments, so we were left with HTML comment. Nor does JSX have comments, really.
I’m not sure about
<>{/* comments like this */}<>
since:{}
syntax inside JSX inside MDX.But I reckon that, if we, in fact, stop treating HTML as a valid MDX, in favour of JSX as a valid MDX, then yes, indeed JS comment in JSX syntax is more “proper” than HTML comment, yes.
(just not sure whether we do xd)
Hi all! I’m going to close this as it landed on the
main
, the (now default) branch we’re using to gear up to the MDX@2 release.The reason is so that it’s more clear which issues still need to be solved already and don’t require further work.
Expect another
next
release soonish, which might include it, or maybe it’s already released as a beta!For more info, see https://github.com/mdx-js/mdx/issues/1041.