-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Add MathJax v3 support to existed math plugin #166 8000 span>
Conversation
@@ -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 |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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.
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) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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? |
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. |
I got it. I cannot wait for new version of marp-cli, and vscode-marp too :) |
It's based on #165 but it has better interface and better rendering. Resolves #164.
math: 'mathjax'
ormath: { lib: 'mathjax' }
.$$
block will be centered as same as KaTeX rendering.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.