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

Issues with inline $$44 + x$$ #330

Closed
bcm-at-zama opened this issue Jun 24, 2022 · 6 comments
Closed

Issues with inline $$44 + x$$ #330

bcm-at-zama opened this issue Jun 24, 2022 · 6 comments
Labels
question Further information is requested

Comments

@bcm-at-zama
Copy link

bcm-at-zama commented Jun 24, 2022

Describe the bug

context

I use this kind of .md:

$$42 + x$$

This is $43 + x$.

This is $$44 + x$$.

The important line is the 3rd one (with 44). I am using $$ instead one $ because my .md is going to be used by GitBook, and it looks this later does not like simple $ . But I also want to use this .md with Sphinx.

Sphinx supports inline $$ .

expectation

I would hope to have an .md after formatting which is still readable.

bug
But instead this is what I get:

$$42 + x$$

This is $43 + x$.

This is \$$44 + x$\$.

Once again, the important thing is the third line. And so, when I sphinx my doc, I get wrong output. Sphinx does not like \$$.

problem

This is a problem for people doing markdowns which are both used by Sphinx and GitBook. Not sure it is a mistake of mdformat, but at least, I was able to have a file mostly usable by both Sphinx and GitBook before using mdformat.

Reproduce the bug

  1. Create foo.md with
$$42 + x$$

This is $43 + x$.

This is $$44 + x$$.
  1. (optional) Try to sphinx this: it is readable

  2. mdformat it

  3. You get

$$42 + x$$

This is $43 + x$.

This is \$$44 + x$\$.
  1. (optional) Try to sphinx this: it is ugly.

List your environment

mdformat --version
mdformat 0.7.14 (mdformat_tables: 0.4.1, mdformat_myst: 0.1.4, mdformat_toc: 0.3.0, mdformat_frontmatter: 0.4.1)

sw_vers
ProductName: macOS
ProductVersion: 11.6
BuildVersion: 20G165

@bcm-at-zama bcm-at-zama added the bug Something isn't working label Jun 24, 2022
@welcome
Copy link

welcome bot commented Jun 24, 2022

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@hukkin hukkin added question Further information is requested and removed bug Something isn't working labels Jun 26, 2022
@hukkin
Copy link
Member

hukkin commented Jun 26, 2022

Thanks for the issue!

CommonMark doesn't know about the dollar math syntax you're using. It seems you want MyST support which you get with pip install mdformat-myst. Does this fix your issue?

@bcm-at-zama
Copy link
Author

Thanks for considering my issue.

On your advice, I have tried with mdformat --version mdformat 0.7.14 (mdformat_tables: 0.4.1, mdformat_myst: 0.1.4, mdformat_toc: 0.3.0, mdformat_frontmatter: 0.4.1), but it creates

\$$42+x$\$

as well. If you think it is not mdformat problem,. no worries, I can think of a workaround on my side.

Thanks a lot guys for what you do with all these open source tools which make dev easier + better.

@hukkin
Copy link
Member

hukkin commented Jun 27, 2022

OK now I see what the problem is. Mdformat-myst attempts to be able to format whatever syntax is enabled by default in MyST. Originally MyST didn't default to allowing inline double dollar math like

This is $$44 + x$$.

It did however allow block level double dollar math

This is

$$
44 + x
$$
.

If you convert your double dollar math to this (separate from previous paragraph with an empty line) then mdformat-myst will format it just fine.

Note that MyST has recently removed all dollar math syntax from its enabled by default syntax, so it is possible that mdformat-myst decides to drop formatting support for it as well. Your safest bet at keeping formatting support and building new support for double dollar inline math would be to create another plugin e.g. mdformat-dollarmath.

@bcm-at-zama
Copy link
Author

bcm-at-zama commented Jun 27, 2022

I used inlined $$ 42 $$ because of some problems with other tools (namely, GitBook which doesn't accept single $'s). So, I really needed to have inlined double dollars ' s, unfortunately. But yes, I can understand it is not mdformat's fault.

I have never tried doing a plug-in but maybe it will be the road I have to take.

Thanks guys

@hukkin
Copy link
Member

hukkin commented Jun 27, 2022

As long as mdformat-myst still supports dollarmath, IMO a PR to support inline double dollars should be accepted there too. But according to its current policy, removing support would be the correct long term move.

Note that this policy may change, there's discussion here executablebooks/mdformat-myst#5 and here executablebooks/mdformat-myst#9

I'm closing this now since this certainly isn't an issue with mdformat "core" which is very clear about only supporting CommonMark syntax.

@hukkin hukkin closed this as completed Jun 27, 2022
@hukkin hukkin mentioned this issue Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants