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

dollarmath matches aggressively #305

Closed
jpmckinney opened this issue Feb 6, 2021 · 7 comments
Closed

dollarmath matches aggressively #305

jpmckinney opened this issue Feb 6, 2021 · 7 comments
Labels
discussion no fixed close condition

Comments

@jpmckinney
Copy link
Contributor

Describe the bug

If the Markdown document contains:

If Alice gives Bob $10, and Bob gives Eve $10, how much money does Bob have?

Then, unless myst_enable_extensions = [] is set in conf.py, the HTML output is:

<p>If Alice gives Bob <span class="math notranslate nohighlight">\(10, and Bob gives Eve \)</span>10, how much money does Bob have?</p>

To Reproduce

  1. Clone https://github.com/jpmckinney/myst-parser-tests
  2. Run instructions at https://github.com/jpmckinney/myst-parser-tests/blob/master/index.md

Expected behavior

A less surprising result would be:

<p>If Alice gives Bob $10, and Bob gives Eve $10, how much money does Bob have?</p>

I don't know MathJax as I've never used it. Maybe it's impossible to determine that $10, and Bob gives Eve $ is not a math string. If that's the case, it might be a good idea to not include dollarmath by default.

@jpmckinney jpmckinney added the bug Something isn't working label Feb 6, 2021
@choldgraf
Copy link
Member

I think this is gonna be a tricky one depending on the use-case. In scientific fields it is super common to use dollar math for equations, which is why this is turned on by default (since MyST grew out of Jupyter Book, and that is a data science-specific use-case).

To get around this, you can just "escape" the dollar signs. Can you try the following:

If Alice gives Bob \$10, and Bob gives Eve \$10, how much money does Bob have?

?

@chrisjsewell
Copy link
Member

chrisjsewell commented Feb 6, 2021

I suggest you re-read https://myst-parser.readthedocs.io/en/latest/using/syntax.html#dollar-delimited-math 😉: This is exactly what myst_dmath_allow_space=False and myst_dmath_allow_digits=False are for

I'm open to discussion, as to whether or not these should be False by default

@chrisjsewell chrisjsewell added discussion no fixed close condition and removed bug Something isn't working labels Feb 6, 2021
@jpmckinney
Copy link
Contributor Author

For my use case, I'm fine with just setting myst_enable_extensions = [], to guarantee that dollarmath is never run. I don't know how changing the defaults of those two other variables will affect users who do want dollarmath to run sometimes, so I'll leave it to you to consider appropriate defaults.

@chrisjsewell
Copy link
Member

to guarantee that dollarmath is never run

yeh no worries, it obviously just a bit problematic to remove dollarmath completely as a default now, which might break a lot of peoples docs

@choldgraf
Copy link
Member

Hmmm, should we close this one? I don't think it's actionable since we're not going to change the default. Do we need to document something more clearly?

@jpmckinney
Copy link
Contributor Author

All good for me - just wanted to check the defaults :)

@jpmckinney
Copy link
Contributor Author

🙏 Fixed by #505

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion no fixed close condition
Projects
None yet
Development

No branches or pull requests

3 participants