-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Blocks: Add formula typesetting block. #58912
base: trunk
Are you sure you want to change the base?
Conversation
This patch introduces a new block type meant for typesetting mathematical formulae. This block renders TeX formula input and produces an SVG output via the MathJax external library.
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/blocks.php |
Size Change: +849 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
That could be a good fit for: |
A Formula block is nice, but the second part of math typesetting are inline formulas, in the paragraph text. I'm not even sure how to implement this. It should be a new Format Type for rich text, but is the current API capable of doing this? |
@jsnajdr this would fit well as a Bit, and as we're currently exploring Bits in the editor it could be an interesting motivating case. |
Status
This is a working demo that's barely constructed.
Todo
npm
, or custom-built with only the parts needed for Gutenberg.wp-core-block-image
instead ofwp-core-block-figure
and I can't figure out where this comes from.a + 2 &= x\nx &= x - 2
Related work
What?
This patch introduces a new block type meant for typesetting mathematical formulae. This block renders TeX formula input and produces an SVG output via the MathJax external library.
Screen.Recording.2024-02-10.at.1.49.04.PM.mov
Why?
For posts interacting with mathematical concepts it's important to be able to conveniently and cleanly represent mathematical formulae. The editor doesn't directly support this, yet a well-known and near-universal format exists for describing those formulae. This format is the TeX mathematical syntax.
How?
This patch draws in the MathJax project as a dependency to render formula in the editor as they are typed. It creates an SVG output, which is stored as a data URI in the block's HTML, and requests a textual description of the formula for those who won't be able to see or read it.
Testing Instructions
This is not yet ready to test, however you can try adding a formula block in the Playground