# bhollis/maruku

### Subversion checkout URL

You can clone with HTTPS or Subversion.

# MathJax support and "block" equations#36

Closed
opened this Issue · 12 comments

### 4 participants

The current verison of MaRuKu has a few small issues or debatable preferences with respect to math parsing.

• One is that there is no option to output MathJax instead of MathML or PNGs.
• Another is that displayed equations should be treated as span elements instead of block elements.
This latter point is necessary to get proper paragraph indentation.

I have a prototype fix for these two issues in my fork dgleich/maruku:mathjax -- dgleich@a5869a0. Currently, the MathJax option will not work with equation numbering properly. I can probably fix that if that would be desirable.

I'd appreciate any feedback on the fork before submitting a pull request. I think both of these features will make MaRuKu more attractive.

(For the curious, I was hoping to use Jekyll to manage a math-heavy site. It seems that none of the default MarkDown parsers play nicely with MathJax. Hence, my patch -- it was also an excuse to start learning more about Ruby.)

Collaborator

You might want to look at how Instiki and Heterotic beast handle the integration of Maruku and MathJax.

Please Please add this feature to Maruku. It is otherwise extremely annoying to use latex in markdown and especially for making sites in jekyll. A simple google search will tell that a lot of people are annoyed by this and the work arounds are complicated. Pandoc already has support for mathjax, and for this reason some people has made a pandoc ruby branch(https://groups.google.com/forum/?fromgroups#!topic/jekyll-rb/Fk4O7JF8Bcc).

Geevi, do you want to see if you can massage my fork and update it so that it could be integrated into the current Maruku?

Collaborator

MathJax can render either embedded MathML or embedded LaTeX pseudo-code.

Why is embedding LaTeX pseudo-code preferable to embedding MathML (which Maruku already does)?

@dgleich I am a newbie to ruby programming, but i can try. Especially if there is some hope that it will get in the original maruku branch. I would like to host my site using github pages which only supports maruku.

@distler MathML is not a format in which a human being can write. Latex is much simpler and familiar for most people in theoretical sciences. I also dont want to write elsewhere in latex and then do a conversion to MathML. If that was the case, i could have sticked to good old latex itself.

Currently i use dsanson's jekyll fork that uses pandoc-ruby, generate the html on my local machine and push the generated html to github. Not a bad arrangement, but not perfect. If this was directly supported, you can expect a lot of people starting to author documents in Markdown(and websites in jekyll) instead of latex which is very verbose and technical for the non-math formatting part.

MathJax also supports creating new latex commands. This makes it easier to abstract common formatting elements. It's possible you can get these with blahtex or itex... but it doesn't seem like there is any need for these other programs to recode the latex as mathml.

Currently, I utilize maruku (with my patch) and jekyll to generate html and pdf files from a single markdown source.

For instance the page:
http://www.cs.purdue.edu/homes/dgleich/compopt/homeworks/homework-4.html and http://www.cs.purdue.edu/homes/dgleich/compopt/homeworks/homework-4.pdf
both come from one markdown file.

Collaborator

MathML is not a format in which a human being can write.

But itex is. And Maruku already converts itex to MathML.

For clients which support native rendering of MathML, that's much faster than MathJax rendering.

Moreover, it allows you to mix MathML and SVG in interesting and useful ways that you cannot do if you are sending pidgin LaTeX over the wire. See, e.g. this page for some examples. (Visit the page both in Firefox and in Safari or Chrome, to see both the native and MathJax renderings. Then check out the Markdown source ...)

MathJax also supports creating new latex commands.

Only (if I understand correctly) locally: on a per-equation basis. Which strikes me as kinda useless (as well as being vulnerable to billion-laughs attacks, etc).

Are there other features that you see as missing from itex?

@distler Sorry i mistook your earlier comment about MathML. I agree with you about the tex to mathml conversion, and the mathjax rendering being slow. But the problem i have with it is exactly that it is not supported in most existing browsers. Also the math ml rendering in most existing browser doesn't look as good as what mathjax give me. Its quite possible that this gets sorted out in a few years, but i want to have a blog now.

Collaborator

I'll explain this one more time, and then go away.

MathJax supports rendering of MathML. On the page I linked to MathJax is configured to do the rendering for all browsers except Gecko-based browsers (Firefox et al) and IE with the MathPlayer plugin.

If you really prefer the MathJax rendering (despite its being dog-slow, not supporting mixed MathML/SVG content, ...) , it would be even more trivial to configure it to do the rendering for all browsers.

What does the rendering is a completely independent issue from what you send over the wire. And I am unconvinced that sending pidgin LaTeX over the wire is a good idea.

Hi @distler, i see your point now. Actually my problem is with jekyll not supporting itex2mml with maruku. Is there a config for jekyll which runs maruku with itex2mml?

Thanks a lot for helping out. :-)

Collaborator

There is a configuration file, lib/maruku/defaults.rb. The lines you want say

:html_math_output_mathml => true, # also set :html_math_engine
:html_math_engine => 'itex2mml' # none, ritex, itex2mml

This is enabled by default on my branch (and requires you to have done a gem install itextomml).

Then Maruku will digest itex (pidgin LaTeX) equations and spit out MathML.

You can use MathJax to render that MathML, or you can let (some) browsers render it natively. The choice is yours ....

closed this
to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.