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

Support for LaTeX math environments like in Jupyter notebooks? #380

Closed
mgeier opened this issue May 10, 2021 · 12 comments
Closed

Support for LaTeX math environments like in Jupyter notebooks? #380

mgeier opened this issue May 10, 2021 · 12 comments
Labels
enhancement New feature or request

Comments

@mgeier
Copy link

mgeier commented May 10, 2021

I was trying to use MyST-Parser with nbsphinx in spatialaudio/nbsphinx#560, but it doesn't seem to support math environments like

\begin{equation*}
a
\end{equation*}

Describe the solution you'd like

It would be great if that worked just like in Jupyter notebooks.

Is there an extension I can enable to get this?

@mgeier mgeier added the enhancement New feature or request label May 10, 2021
@chrisjsewell
Copy link
Member

Is there an extension I can enable to get this?

See https://myst-parser.readthedocs.io/en/latest/using/syntax-optional.html#direct-latex-math,
which uses the amsmath_plugin: https://mdit-py-plugins.readthedocs.io/en/latest/#math

@mgeier
Copy link
Author

mgeier commented May 10, 2021

Cool, that seems to be it!

Is there by any chance a Python package that has the same extensions enabled that are also used in the Jupyter project?

If not, I guess I'll have to create my own ...

@chrisjsewell
Copy link
Member

Is there by any chance a Python package that has the same extensions enabled that are also used in the Jupyter project?

I'm not sure I understand what you mean by this. What is the goal you want to achieve with the python package?

@mgeier
Copy link
Author

mgeier commented May 10, 2021

What is the goal you want to achieve with the python package?

I would like to make it easy for people to use Markdown files in Sphinx which support the same (or at least a very similar) syntax to what they are used to from Jupyter notebooks.

And with "easy" I mean: one Python package, one entry in extensions in conf.py, nothing else.

@chrisjsewell
Copy link
Member

And with "easy" I mean: one Python package, one entry in extensions in conf.py, nothing else.

So basically myst-parser with hard-coded configuration 🤷

@mgeier
Copy link
Author

mgeier commented May 10, 2021

Exactly. Sorry that I wasn't clearer about that.

@choldgraf
Copy link
Member

To generalize this a bit: it feels like we are talking about distributions of markdown-it-py. This also feels related to #348.

Is there a graceful way to let people bundle up markdown-it-py + some specific extensions enabled? Or is the best practice just to roll your own python package / sphinx extension and push it to pip?

@mgeier - assuming that you're doing this at the nbsphinx level, could you also just automatically activate those extensions under the hood (similar to what Jupyter Book does) in order to recreate that markdown experience by default?

@chrisjsewell
Copy link
Member

chrisjsewell commented May 10, 2021

I mean obviously it is entirely up to you if you want to re-write myst-parser in your own package.
But it would seem better to me, to break up myst-parser into one "simpler" core package, and then one (or more) packages that use it as the base implementation to extend on (including myst-parser itself).
This is a somewhat similar proposal to #347

@choldgraf
Copy link
Member

But it would seem better to me, to break up myst-parser into one "simpler" core package, and then one (or more) packages that use it as the base implementation to extend on (including myst-parser itself).

Yep - that's what I imagined too re: "distributions". I think that we should be careful that we don't dilute the meaning of "MyST" in the process (e.g., we may want to consider that a distribution of MyST must be a strict superset of MyST syntax, it cannot disable any core MyST syntax) but it'd be a useful extension point to be able to have myst, myst-jupyter, etc.

@mgeier
Copy link
Author

mgeier commented May 10, 2021

I'm not planning to re-write MyST-Parser in the short term (I'm still sitting on a half-finished but dormant CommonMark parser project, but currently I'm not working on it), I was indeed talking about something like #342 (comment).

Ideally I'd like to use an existing package, but if it's only a few lines I can also make my own.

@chrisjsewell
Copy link
Member

ok well I will close this anyhow 👍

@mgeier
Copy link
Author

mgeier commented May 10, 2021

I just had an epiphany: nbsphinx already has Markdown support via Jupytext! I should have thought about this earlier, it's actually quite obvious.

Everything already works as expected, I just had to document it: spatialaudio/nbsphinx#561

So I won't have to create my own MyST-based Python package after all!

I will not need anything that we just discussed in this issue, but it might still be interesting for other people who might want to use MyST-Parser with Jupyter-like Markdown extensions.

But I'm fine with closing this, I won't be needing it anymore.

Thanks for your help, though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants