Add TeX to MathML conversion via ritex#169
Add TeX to MathML conversion via ritex#169tmthrgd wants to merge 1 commit intogettalong:masterfrom tmthrgd:mathml
Conversation
|
Thanks for this pull request! I have looked at the ritex gem and it doesn't seem to be actively developed anymore. Is it more or less feature complete and are therefore no updates anymore? Nonetheless, there are still some things that would need to be done:
|
|
The :display option for the parser is representative of whether the math is inline or block (not the clearest option name). Ritex indeed seems seldom updated now but it has the benefit of being pure ruby. There is another parser, ietex2mml, that is actively developed that I discovered since submitting this request. My concern with this parser is that it relies on a native binary, this may or may not be acceptable to you. I'll add the options, tests and docs or I'm happy to rewrite it to use ietex2mml. It could even be written to use either ietex2mml or ritex, either as a fallback or another option. |
|
In terms of nicer formatted html, neither ritex nor ietex2mml support that. If it is essential the best I could suggest would be to pass the output through a HTML parser (probably the kramdown HTML parser) and then output the HTML nodes. |
|
Thanks for the clarifications! The nicer formatting is not necessary, I just wanted to know if this would be possible. I would prefer a pure Ruby solution to one that depends on a binary. However, if you want to implement both solution it would be fine with me. I had a short look at itextomml and it seems it doesn't actually depend on a binary but is just using the code that is also used in the binary. So if the gem is available on the platform, it should also just work. Additionally, it would possibly make sense to introduce a general option like |
|
I'll admit my Ruby knowledge is very fresh and I couldn't quite work out how itextomml worked. So it may well be 'binary free', I was simply working off the description on the website. I personally love the idea of a generic math_engine option as you described it. My only concern (if you can call it that) is consistency. Should code blocks also have a similar setup, that might allow pygments or other highlighters? I'd suggest closing this pull request and spiking it off into an issue until a decision is reached. Which I'll happily do when it's not 5:21am... |
|
Oh hell it's only 5:21am! |
|
Thanks for all your input! As for code blocks and syntax highlighting this is already on my TODO list. |
This allows math environments to be output as MathML instead of MathJax script tags when using the Html converter. This allows browsers to natively display mathematics without the need for any javascript library (MathJax).
It has been provided conditionally similarly to coderay, with a
enable_ritexoption that defaults to false. It supports both inline and block math.It relies on the ritex package (
[sudo] gem install ritex). I have done my best to keep to the syntax as I could determine it and have not made any changes to the tests or manuals/docs which might be necessary to accept this pull request.TeX such as
$$f(x) = a{x^3} + b{x^2} + cx + d$$(a cubic function) would be rendered as:which renders as