mdx-js / mdx

Markdown for the component era
https://mdxjs.com
MIT License
17.76k stars 1.14k forks source link

Can't escape a single quote with \ #2332

Closed NickHeiner closed 1 year ago

NickHeiner commented 1 year ago

Initial checklist

Affected packages and versions

mdx-loader@3.0.2, mdx.macro@0.2.9

Link to runnable example

No response

Steps to reproduce

https://codesandbox.io/s/mdx-forked-kmcqc5

Expected behavior

I would have expected that this would have worked to escape a single quote:

<FullConversation contents='Today\'s Issue:' />

I checked https://mdxjs.com/docs/troubleshooting-mdx/ but didn't find anything about this.

I also tried this, and it also didn't work:

<FullConversation contents='Today''s Issue:' />

Actual behavior

I get this error:

SyntaxError
unknown: Unterminated string constant (7:43)

   5 |       {...props}
   6 |       components={components}>
>  7 | <FullConversation contents='Today\'s Issue:' />
     |                                            ^
   8 |     </MDXLayout>
   9 |   )
  10 | };

Runtime

Other (please specify in steps to reproduce)

Package manager

Other (please specify in steps to reproduce)

OS

Other (please specify in steps to reproduce)

Build and bundle tools

Other (please specify in steps to reproduce)

ChristianMurphy commented 1 year ago

Welcome @NickHeiner! 👋 MDX is JSX in Markdown. Your example isn't valid JSX

Trying out the same code in Babel as JSX fails: https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=DwMQrgNhDCD2B2A3ApgJwM4EMAuBLBABAMYLbLzboC8A5ACqwAmmAngDo3oECS66YyAFw0CAegB8QA&debug=false&forceAllTransforms=false&modules=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env%2Creact%2Cstage-2&prettier=false&targets=&version=7.22.9&externalPlugins=&assumptions=%7B%7D

Some options which are valid:

<FullConversation contents="Today's Issue:" />

or

<FullConversation contents={'Today\'s Issue:'} />
NickHeiner commented 1 year ago

Whoops! Thanks.

On Thu, Aug 3, 2023 at 10:56 Christian Murphy @.***> wrote:

Welcome @NickHeiner https://github.com/NickHeiner! 👋 MDX is JSX in Markdown. Your example isn't valid JSX

Trying out the same code in Babel as JSX fails: https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=DwMQrgNhDCD2B2A3ApgJwM4EMAuBLBABAMYLbLzboC8A5ACqwAmmAngDo3oECS66YyAFw0CAegB8QA&debug=false&forceAllTransforms=false&modules=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env%2Creact%2Cstage-2&prettier=false&targets=&version=7.22.9&externalPlugins=&assumptions=%7B%7D

Some options which are valid:

or

<FullConversation contents={'Today\'s Issue:'} />

— Reply to this email directly, view it on GitHub https://github.com/mdx-js/mdx/issues/2332#issuecomment-1664143796, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGKTA3OJXG4LWISQKRXQO3XTO3YXANCNFSM6AAAAAA3C3ZGQ4 . You are receiving this because you were mentioned.Message ID: @.***>