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

math global directive #243

Closed
yhatt opened this issue Jul 11, 2021 · 1 comment · Fixed by #246
Closed

math global directive #243

yhatt opened this issue Jul 11, 2021 · 1 comment · Fixed by #246
Labels
enhancement New feature or request

Comments

@yhatt
Copy link
Member

yhatt commented Jul 11, 2021

We are considering to change the default math rendering library in Marp Core to MathJax, to avoid many rendering bugs in KaTeX due to auto-scaling (#159, #236) and network access via CDN (marp-team/marp-vscode#170 (comment)).

For keeping nice rendering of exist slides that are expected to use KaTeX, we are planning to add math global directive to fix the math library used in Markdown. Even if broke slides, user can declare to use KaTeX per Markdown just by adding math: katex definition.

---
math: katex
---

math global directive accepts "katex", "mathjax", and boolean.

  • katex: Use KaTeX.
  • mathjax: Use MathJax.
  • true: Use the default library. (default: KaTeX in v2, and MathJax in the future version)
  • false: Disable math.
    • It would bring a troublesome problem if math global directive let to disable: math global directive #243 (comment). Even if just supported to choice the math library, we would achieve an original purpose.
@yhatt yhatt added the enhancement New feature or request label Jul 11, 2021
@yhatt
Copy link
Member Author

yhatt commented Jul 13, 2021

Technical issue

Marpit parser recognizes global directive after parsing the whole of Markdown so currently we should certainly assume the syntax $...$ and $$...$$ as math before parsing global directive. In this case, supporting math: false in the global directive makes a troublesome in below:

---
math: false
---

te*st$y=x*2$

It means:

<p>te<em>st$y=x</em>2$</p>

But we cannot recognize * as the syntax for emphasis because $y=x*2$ have already consumed as the math token.

We have to save superposition state in tokens for keeping compatibility with Markdown and some external Marpit/markdown-it plugins. Bluntly it's too complex.

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

Successfully merging a pull request may close this issue.

1 participant