Forum Bugs

MathML unwanted spacings and square root merge

rainhallikas
Converting MathML, I get unwanted spacings and square root merging with other elements. See attachment. The square root is also always in 2 pieces.
  1. InputAndResult.zip68.8 kB
mikeday
We hope to improve MathML rendering quality in the future, in the meantime I would recommend converting it to SVG with MathJax or a similar library.
rainhallikas
Okay. I used MathJax. In browser, it works - browser runs JavaScript and converts MathML to SVG.

But does not work in Prince HTML-PDF transformation. I referenced the same script.
Error: https://cdn.jsdelivr.net/npm/mathjax@3/es5/mml-svg.js:1 ReferenceError: no such property: Map
mikeday
Unfortunately Prince does not support Map, which is not in ES5. In the meantime it may be necessary to run MathJax via PhantomJS first.
hubprince
I've been making some progress by adding polyfills for Map and Promise:

--script='https://polyfill.io/v3/polyfill.min.js?features=Map%2CPromise'


Might it be possible to get MathJax v3 running in this way?
hallvord
Hi, I've been investigating this question but it's not quite running yet. I have found a bug in the Polyfill library where its setPrototypeOf() emulation doesn't quite support what MathJax needs.. Specifically it uses Object.create() and then Object.getOwnPropertyNames() to copy over properties - this misses out on methods MathJax defines as static. Consider:

function test(){}
test.method = function(){ return 'useful "static" method defined on the function' }

Object.create(test).method(); // works
Object.create(test).hasOwnProperty('method') // false, not the newly created object's own property
Object.getOwnPropertyNames(Object.create(test)) // does not list 'method'


Prince does what it is supposed to, and the polyfill library fails to carry over those references. Note how create() is called here:
https://github.com/Financial-Times/polyfill-library/blob/master/polyfills/Object/setPrototypeOf/polyfill.js#L42

Announcement: repos for tests/utils

mikeday
Today we have released a new latest build that supports the Object.setPrototypeOf method, I hope it helps!
hallvord
It does help but does not get us all the way to a working MathJax. There are a couple of other bits an pieces missing - right now with some compat hacks I've gotten it to render the input, but the output still looks too messy - to be continued :)

Announcement: repos for tests/utils