Skip to content
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] Space removed before dollar sign #5483

Closed
BPScott opened this issue Nov 14, 2018 · 3 comments
Closed

[Markdown] Space removed before dollar sign #5483

BPScott opened this issue Nov 14, 2018 · 3 comments
Labels
lang:markdown Issues affecting Markdown locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. priority:high Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent! status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! type:bug Issues identifying ugly output, or a defect in the program
Milestone

Comments

@BPScott
Copy link
Member

BPScott commented Nov 14, 2018

In markdown a dollar sign seems to swallow all spaces before it when there is another one on the same line.

I think this is related to mathjax stuff and I think the solution is I need to escape all dollar signs but I wonder if there is some way that prettier can be smarter about how it treats these dollar signs pairings

//cc @ikatyang

Prettier 1.15.2
Playground link

Input:

$10 - $20
$10.00 and $40.00

Output:

$10 -$20
$10.00 and$40.00

Expected behavior:

As input

OR

\$10 - \$20
\$10.00 and \$40.00
@j-f1 j-f1 added lang:markdown Issues affecting Markdown priority:high Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent! type:bug Issues identifying ugly output, or a defect in the program labels Nov 15, 2018
@ikatyang ikatyang added the status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! label Nov 15, 2018
@alexandernanberg
Copy link

Is Prettier meant to escape all $ from now on or just the ones in "math-syntax"?

For an example

Input

$5/month

Output

\$5/month

This still occurs on the preview of the #5485 PR

@ikatyang
Copy link
Member

The math syntax is quite easy to be triggered, for example:

<!-- input -->
hello world $something __hi__ foo bar $baz
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this is parsed as math, which means
                                        its content will be preserved.
                                        `__hi__` is not considered a strong here.

<!-- output -->
hello world $something __hi__ foo bar $baz

So we escape all non-math dollar signs to reduce false positives (this rule is also applied to * and _):

<!-- input -->
hello world \$something __hi__ foo bar $baz
                        ^^^^^^ this is be parsed as strong

<!-- output -->
hello world \$something **hi** foo bar \$baz

If you saw a dollar sign that is not escaped, it's probably recognized as math syntax.

@alexandernanberg
Copy link

Ah I get it, thanks!

@ikatyang ikatyang added this to the 1.15.3 milestone Nov 23, 2018
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Feb 21, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:markdown Issues affecting Markdown locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. priority:high Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent! status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

4 participants