8000 Add MathJax v3 support to existed math plugin by yhatt · Pull Request #166 · marp-team/marp-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add MathJax v3 support to existed math plugin #166

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

Merged
merged 12 commits into from
Jun 8, 2020
Merged

Conversation

yhatt
Copy link
Member
@yhatt yhatt commented Jun 6, 2020

It's based on #165 but it has better interface and better rendering. Resolves #164.

  • Can enable MathJax by math: 'mathjax' or math: { lib: 'mathjax' }.
  • Math typesettings in $$ block will be centered as same as KaTeX rendering.
  • MathJax math block can scale-down automatically, powered by inline SVG. It does not need to use fitting plugin!

For compatibillity, KaTeX math rendering would be default during Marp Core v1.x. However, we might adopt MathJax as primary math renderer in future version.

@yhatt yhatt changed the title Add MathJax v3 support to exist math plugin Add MathJax v3 support to existed math plugin Jun 6, 2020
@@ -98,7 +98,7 @@ function fittingHeader(md): void {

function fittingMathBlock(md): void {
const { marp_math_block } = md.renderer.rules
if (!marp_math_block) return
if (!marp_math_block || marp_math_block.scaled) return
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When marp_math_block renderer has marked the output is already scaled, fitting plugin won't override existed plugin.

md.block.ruler.enable('marp_math_block')
md.inline.ruler.enable('marp_math_inline')
} else {
md.block.ruler.disable('marp_math_block')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marp specific options are frozen by Marpit so we will no longer consider changed options when rendering.

Comment on lines +54 to +58
adaptor.setStyle(converted, 'margin', '0')
adaptor.setStyle(svg, 'display', 'block')
adaptor.setStyle(svg, 'width', '100%')
adaptor.setStyle(svg, 'height', 'auto')
adaptor.setStyle(svg, 'max-height', svgHeight)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated inline style for MathJax math block for keeping compatible rendering with KaTeX.

By re-assigning max-height from the value of height attribute, the rendered SVG can scale-down to suit to width, without using fitting plugin.

@@ -7,6 +7,8 @@
"noImplicitAny": false,
"resolveJsonModule": true,
"rootDir": ".",
// TODO: Marp team does not allow to enable "skipLibCheck". Please revert when improved MathJax typing.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope so. However, It perhaps will be unsolved forever. mathjax/MathJax-src#169
If marp team want to avoid it, we should open new issue with enough reason.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In marp-team/marp-react#22 (comment) we could fix upstream and there was a workaround (downgrade), but in this case skipLibCheck is just a only workaround. To get MathJax integration for now, we have no other choices but to enable.

There is no member of Marp team to interest in math libs, so would difficult to contribute into upstream.

@tani tani mentioned this pull request Jun 7, 2020
@yhatt yhatt merged commit af5bcea into master Jun 8, 2020
@yhatt yhatt deleted the hybrid-math-plugin branch June 8, 2020 00:19
@tani
Copy link
tani commented Jun 8, 2020

Thank you for great improvement. Additionally, I'd like to use this option in marp-cli and vscode-map. Would you mind being modified according to these changes? Could I help you anything?

@yhatt
Copy link
Member Author
yhatt commented Jun 8, 2020

Please wait for bumping version. Marp CLI can use MathJax as soon as released new minor version of Marp Core by install the latest manually.

@tani
Copy link
tani commented Jun 8, 2020

I got it. I cannot wait for new version of marp-cli, and vscode-marp too :)

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

Successfully merging this pull request may close these issues.

MathJaX v3 support
2 participants
0