question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline comment directly after jsx block fails to parse.

See original GitHub issue

Subject 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

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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Danoncommented, Apr 18, 2020

@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:

  • that’s 10 characters of comment syntax (pragmatic? not sure)
  • That’s not a JSX comment, actually. That’s actually JS comment, inside {} 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)

0reactions
wooormcommented, Dec 18, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found