Backslash sometimes inserted when using $ in text
See original GitHub issueI noticed that on some parts of my portfolio site (made with gatsby and gatsby-mdx), there are extra backslashes being inserted in some places where dollar signs are used. For example:
- Go to https://descioli.design/grove and Find for
\$
— there are 6 occurrences on the page. There are 12 usages of$
, though — not every $ is preceded by a backslash. - The MDX source for that page is here. Note: no backslashes.
- The rendering of the page is here. Pretty standard AFAIK.
It only started happening when I switched from Remark to MDX. I didn’t notice it when I did the initial switch.
Environment
- macOS and ubuntu, latest version
- @mdx-js/mdx@1.0.20, gatsby-mdx@0.6.3
- node@10.1.0, yarn@1.13.0
Steps to reproduce
Clone my portfolio repo, https://github.com/lourd/descioli-design, and run it. No additional configuration needed.
Expected behaviour
No extra backslashes.
Actual behaviour
Extra backslashes
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:15 (6 by maintainers)
Top Results From Across the Web
Slash Symbols in Writing: When to Use a Backslash vs. a ...
The forward slash should be placed directly between two words when used ... Forwards slashes are often used when an abbreviation involves shortening...
Read more >Backslash inserted when pressing o, u, h at the same time
When I press the letters o, u, and h at the same time, a backslash \ ends up being inserted before the h....
Read more >How does one insert a backslash or a tilde (~) into LaTeX? - TeX
I believe \backslash may be used in math formulae, but not into text itself. Lamport's, Kopka's, and Mittelbach's texts have said as much...
Read more >JavaScript backslash (\) in variables is causing an error
The backslash ( \ ) is an escape character in Javascript (along with a lot of other C-like languages). This means that when...
Read more >Punctuation Tips: The Backslash and Forward Slash - Proofed
The backslash (\) is mostly used in computing and isn't a punctuation mark. · The forward slash (/) can be used in place...
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
Sorry to comment on a closed issue but I’m still seeing MDX render
\$
in the HTML if the dollar sign is escaped in the MDX. It’s a Next.js project, and here are my dependencies:Is there a dependency I need to explicitly add that I’m missing, to make sure I’m actually grabbing a recent enough version to get this fix?
If anyone else runs into this problem like I did today, here’s how I fixed it. I needed prettier to stop adding in the backslash. I first started looking in the prettier settings to see if I could turn off the math portion but that ended up being a dead end. I realized that I needed to tell prettier to simply ignore it.
I first tried to my prettier ignore file: https://media.lauraleeflores.com/llu5D48j that works however it will ignore the page completely and that was not ideal for me.
The solution that worked was to simply ignore a portion of the file. You can learn more about that here: https://prettier.io/docs/en/ignore.html
Mine is an mdx file so this is how I ignored it: https://media.lauraleeflores.com/YEuR1dYj
I hope that helps someone who runs into the same problem.