-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Handle backslash escaping in template literals #366
Handle backslash escaping in template literals #366
Conversation
This pull request is automatically deployed with Now. |
It looks like changing renderWithReact to replace all
Seems like the solution is to scope it down to happen just inside of code blocks and inline code, but for every |
I had similar problem in my case I used <MDXTag>{`Some text `}{`\`}{` other text`}</MDXTag> which obviously breaks because the const visit = require('unist-util-visit')
// custom plugin to fix mdx->jsx backslask escape {`\`} issue
function fixBasckslashMdPlugin() {
return tree => visit(tree, 'text', node => {
if (node.value === '\\') {
node.value = '\\\\'
}
})
} and put it in my mdx-js/loader in webpack {
test: /.mdx?$/,
use: [
'babel-loader',
{
loader: '@mdx-js/loader',
options: {
mdPlugins: [
fixBasckslashMdPlugin
]
}
}
]
}, |
this is looking good to me. I've been unable to get it to fail so far. |
There's a bug that exists when
<code>
children end in\
or have "unicode escape sequence-looking" values like\unlikely\
.I haven't been able to fix it yet, but here's a test that throws when these values are used in code blocks or inline.
It looks like these are the issue-causing sequences, which have been changed since ES2016, but only for tagged template literals. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates_and_escape_sequences