Forum Bugs

setTimeout support

anandthakker
Hello,

I'm trying to use MathJax (javascript library) for equations. I'm using 9.0r5 on Mac OS X. Currently, I'm getting message, "prince: warning: setTimeout is not yet supported".

I noticed that setTimeout support is marked as done in the roadmap. Should this actually be working in the 9.0r5 release? If not, will it be shipped in a release in the near future?

Thanks!
-Anand



mikeday
setTimeout is not supported in Prince 9 rev 5. It will be supported in future releases, but at this time it's not clear if that will be sufficient to run MathJax, as further JavaScript DOM support is still needed.
anandthakker
Thanks for your response.

FYI, in case anyone else stumbles onto this thread in the future: I'm now investigating using Prerender (http://prerender.io) to grab a post-JS-processing version of each page, and then running Prince on that.

Initial tests look promising, although there seem to be some issues with STIX fonts that I'm still investigating.
medeek
I am also currently using MathJax to generate mathematical expressions with my snow load calculator here:

http://design.medeek.com/resources/snow/snow_calculator.pl

I am planning on using Prince to generate a PDF version of the report that users can download. I'm not really familiar with MathML but maybe that will be the route I have to go unless someone has a better method of generating math expressions that would be compatible with Prince.
mikeday
I think there are external tools that can convert MathML into SVG, perhaps that would also work for you?
medeek
For the symbolic equations the SVG or GIF images will work fine however in some cases I liked to show the equations with the actual values, this is where it would be nice to incorporate the MathJax.
mn4367
@anandthakker, you may look here for a similar solution (pre-rendering math and post-processing).
skycaptain
I'm using slimerjs to prerender every javascript, since prince does not support some other scripts as well. Since slimerjs is just a headless Firefox browser every script is just rendered as in a normal Firefox installation. And the good thing is, slimerjs is scriptable. So I just convert my daily markdown to html, a file watcher script catches up the html file and calls slimerjs. Rendering mathjax takes some time, so I've hooked into MathJax.Hub.Queue, which notifies slimerjs when all equations are prerendered. Afterwards I delete all script-tags to prevend javascript executation in prince and finally slimerjs sends the prerendered html to prince.
It requires some scripting, but it works very well - see the attached file. Another good point is, that you don't need mathjax to render you equations into SVGs, as they render badly on Screens. Instead you can just the default HTML-CSS or even the new Fast Renderer for the output.

EDIT: mn4367 already posted the same solution for phantomjs. Two people, same thought :D
  1. mathjax.pdf362.6 kB

Edited by skycaptain

mikeday
The latest build of Prince now supports MathJax 3, as demonstrated here. :)