-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Markdown] $ is escaped as \$ if encountered once #6213
Comments
But it does seem a bit excessive to me. Maybe we can do this better. |
Uncertain if this is related or a new issue. |
If we know we're not using math syntax, can this behavior be disabled? UPDATE I tried prettier-ignore for markdown but it actually formatted the comment (indented it) and re-added the \ too. UPDATE 2 |
This is bad when the markdown target (e.g. static site generator) doesn't support math syntax so will render literal |
I am also getting a blackslash rendered into the html output, which as far as I see it is a major bug in prettier's markdown formatting. I would be happy to put in a PR to help fix/remove this given some sort of direction or signoff from a maintainer. @ikatyang - any thoughts here? |
The behavior you mentioned sounds like a bug, but the backslash in escaped dollar sign should not be rendered into the html output according to the CommonMark spec. Since this issue (#6213) is about code style while yours sounds like a formatting bug, could you open a new issue with steps to reproduce? |
@ikatyang I'm not sure what do you mean by "this issue is about code style "? This issue is exactly about formatting: if author writes |
It looks like the Markdown renderer you used is not spec-compliant, I'm not sure what should we do in this case. |
Maybe we can avoid printing a But we don’t want to end up in a situtation where this edit: -A gift of $14 million
+A gift of $14 million from John and $20 million from Jane ... suddenly results in accidental inline math that could have been avoided if Prettier had printed |
True, To be precise this is bug in Marked prior to version 0.4.0. My plan for this issue is to upgrade renderer. But I argue that his behavior violates Prettier correctness rule:
In this case Prettier indeed outputs a valid code (both |
I don't know either. That's the trickiest part, there is no formal definition for the math syntax in markdown. As far as I can tell, its definition is simply "content between dollar signs", the rest detail is up to implementers, which we followed the rules from But it seems
Given that this new rule won't be that easy to be triggered, we should be able to avoid those unnecessary backslashes if we apply the same rule here. |
I am also seeing prettier escape |
I think this is getting worse when updating remark-math |
I'm seeing this as well. Are there any workarounds for the time being? I don't want to disable the entire file (MDX in my case). |
any workarounds? |
I'm having this same issue using MDX in Gatsby. |
…ent $ being changed to \$ prettier/prettier#6213
I'm also seeing this in a markdown file where I'm trying to bold some stuff… I can't imagine I'm the only one? 🤔 Not sure if I should open another issue or…? I there's an open issue or solution out there, can you point me in the right direction? I haven't found it. |
@minimaldesign Does |
Well, the first issue is that it's not standard markdown format, so it creates potential compatibility issues down the line. Thanks! |
@minimaldesign What do you mean it’s not standard markdown? It’s supported in the original markdown implementation (https://daringfireball.net/projects/markdown/dingus) and in the CommonMark Spec: https://spec.commonmark.org/0.29/#backslash-escapes |
I mean it in the dictionary sense: normal, usual, typical, common, ordinary, customary, conventional, etc. John Gruber:
I don't think it's right to add unnecessary Maybe it's only important to me? But as I also mentioned initially, there are also tech ramifications like broken output and misleading diffs. Thanks! |
I personally like
Where? |
Hmm, maybe I wasn't clear enough. I write:
And Prettier changes it to:
I had to turn off Prettier on that page… |
@minimaldesign If Prettier indeed breaks your code, please open a new issue with a proper bug report. To do that, reproduce the problem on Prettier's Playground and click the Report issue button there. |
Is there a way to disable math syntax interpolation through Prettier config? These are the only workarounds I found:
None of which are ideal. I would argue that there are more plain text users than those that need inline math. Could we make this kind of interpolation optional through Prettier's configuration file? |
Hi, Has there been any concluded outcome of this issue? Would definitely agree with options to disable math syntax through Prettier. We're getting plenty of $ in mdx while we still wish to be using Prettier on our files. |
is the +1 |
+1 @muescha |
🙏🏼 thank you so much for getting this fixed! |
As prettier has finally been fixed to not re-add it. See: * prettier/prettier#6213 * mdx-js/mdx#606
Prettier 1.18.2
Playground link
Input:
Output:
Pagagraph with \$14 million. Pagagraph with $14 million. But if more $dollars on the same line...
Expected behavior:
No escaping of dollar sign is expected:
The text was updated successfully, but these errors were encountered: