Open EldarAgalarov opened 1 year ago
Hi @EldarAgalarov have you given this plugin a try to add a MathML block?
https://wordpress.org/plugins/mathml-block/
I'm not sure enough people would use this block for it to be considered for inclusion in Core; the plugin has only 900 active installs.
@kathrynwp Yes, I know about such plugins, but I prefer to be plugin-independent as much as possible, so i'm using just Custom HTML block at this moment :) MathML is part of HTML 5 standard so it sounds logical that Math ML Block should exists in the Gutenberg, like Heading, Paragraph, Table, Image blocks.
Having poked around on a math typesetting block myself, I'll share where I kind of left it off, and unfortunately why I think "MathML" isn't well-suited for core (hopefully "yet").
In short, MathML support in browsers is still somewhat abysmal. @adamsilverstein's block loads after page render to handle this by rendering the MathML via JavaScript; mine did the same thing but stored the generated rendered XML as a data URI to avoid a flash on initial page load (and to avoid pushing the cost of rendering to the client).
I would love a core formula block, but I think it'll be complicated by needing to serve a lot of different needs, which is good! Some people want to see a formula-builder UI so all they need to do is click buttons to generate a formula; others want LaTex syntax to quickly enter formulas as text. All that is fine I think, but needs people to do the work, plus it involves pulling in third-party libraries to parse the input formulas or present the UI (unless we want to write and maintain our own formula entry and rendering code).
So with the plugin space at least for now it's possible to choose your poison, so to speak, which might be much easier in the meantime than finding something that works for everyone. As I have a personal interest in this I'd be happy to review any code submissions or help guide along the project, but at the moment I'm not likely able to dedicate my time to creating such a block.
One great feature of the block inserter is the plugin search. If you type in /mathml the inserter will offer up the plugin and let you use it immediately. So using mathml currently is very low friction, although I support the idea of using native mathml support - and browser support is improving.
In short, MathML support in browsers is still somewhat abysmal
Firefox supporting MathML for a long time Chromium added MathML back since 109
Agreed that Firefox's support looks pretty good, but a couple examples from Mozilla's test page shows some significant problems for Safari and for the Chrome version I have installed, which is 107.
In the following screenshots we have a LaTeX render on the left, an image of Firefox render in the middle, and the actual browser render on the right.
Essentially nothing in Chrome
Less severe problems here but still not a good experience, and these aren't exposed on particularly complicated formulas either.
So even though Chrome has finally added support back in for MathML in their latest release (which was released just a week ago), that still leaves a pretty large group of readers behind and will for some time.
Chrome version I have installed, which is 107
You should install version 109 and then you will get following:
Still worse than Firefox rendering, but much better than "rendering" of previous versions of Chromium :)
Somewhat related Trac ticket: https://core.trac.wordpress.org/ticket/13340
See also #35005. I think this would be interesting inline as well.
Hi. It would be nice to have support for MathML blocks with basic functionality such as formula size, centering, etc. Now to insert MathML code the Custom HTML block should be used.