marianoguerra / rst2html5

transform restructuredtext documents to html5 + twitter's bootstrap css, deck.js or reveal.js
http://marianoguerra.github.com/rst2html5
MIT License
177 stars 51 forks source link

No math support at all? #42

Closed bk322 closed 8 years ago

bk322 commented 10 years ago

rst2html supports math:

.. math::

   x^2

divs get some math processing depending on the command line options of the rst2html. However rst2html5 just leaves plain divs.

marianoguerra commented 10 years ago

I just added support for mathjax:

https://github.com/marianoguerra/rst2html5/blob/master/examples/mathjax.rst

check if it's ok for you

I don't know a lot about mathjax (or maths :P) so let me know how it works for you

bk322 commented 10 years ago

Thank You.

I got

rst2html5: error: no such option: --mathjax

I use the latest version:

~/cmp/blds/misc3/rst2html5: git log
commit d7d211ba671b2f0ae98071bccc18593a593d523c
Author: Mariano Guerra <luismarianoguerra@gmail.com>
Date:   Fri Feb 7 01:49:26 2014 +0100

    mention mathjax on the readme

commit 1bdba5aa2223ee09ca0e1e87a154d8d9792a2048
Author: Mariano Guerra <luismarianoguerra@gmail.com>
Date:   Fri Feb 7 01:45:48 2014 +0100

    initial attempt at math support

Does it work for You? Actually MathML is more important for me. Math works fine in the vanillay rst2html. I just thought maybe You can leave the math as it is there.

torfsen commented 8 years ago

It seems that non-MathJax math support was removed in 2b667c46e38dc285a7953f1a19a1195018af8e7d when a new Writer was introduced. It looks like MathML and other options were supported before that. I'd also prefer to have more choices than just MathJax, and, more important, I'd like to use RST markup for declaring math (i.e. the :math: role and the .. math:: directive). With the current MathJax support, on the other hand, it seems that I need to use MathJax markup in my RST files. That's rather contrary to the idea of keeping semantics (RST) and display (HTML, CSS, MathJax) separate.

In my opinion, the ideal solution would be to have an option for selecting the math output variant (MathML, MathJax, etc.) and the :math: role and .. math:: directive would then be translated into appropriate code. That would allow users to switch from MathML to MathJax (and vice versa) by simply changing the options they use to call rst2html5. If I understand things correctly that is also the approach that was used in the old writer.

@marianoguerra: Is that something that would be OK for you? If so I would try to implement that and create a PR.

marianoguerra commented 8 years ago

hi, thanks for the comment, I don't use math myself so you seem to know more than I do, please create a PR and I will merge it, I guess it's better than the current state of things :)

torfsen commented 8 years ago

I'll prepare PR, although it may take me time since things are pretty busy here at the moment.

torfsen commented 8 years ago

I'm working on this. Most of it is done, but some small issues still need to be fixed. Basically I took the code from the original docutils, refactored it and adapted it to our architecture.

@marianoguerra: Once everything works I would remove the current MathJax-postprocessor, is that OK with you?

marianoguerra commented 8 years ago

@torfsen if the replacement works, I'm ok with it.

torfsen commented 8 years ago

This should be ready to go. Documentation (well ,the README) and tests have been updated.

I've added new configuration options (--mathjax-url, --mathjax-config, --math-css) to get away from previous means (--math-output "mathjax foo" and --mathjax-opts url=foo,config=bar) which I find not very user friendly (and harder to handle in the code, too). The old approaches are still supported (but not documented), though.

I've also decided to keep the MathJax postprocessor to make sure that we stay backwards-compatible. However I removed its detailed documentation and marked it as deprecated instead.