baudren / NoteOrganiser

Scientific Note Taking
MIT License
13 stars 6 forks source link

Add math support with KaTeX #36

Open baudren opened 9 years ago

baudren commented 9 years ago

KaTeX seems pretty easy to set up, and is faster than MathJax. This would be nice to have on the long term.

baudren commented 9 years ago

Actually, pandoc supports it out of the box, though my tests so far are not working. It seems that pypandoc does not transmit the --katex flag. Will test tonight on a Linux

baudren commented 9 years ago

So, after more tinkering, it looks like actually windows support is not so good with KaTeX... pandoc is working fine, but the display is just plain wrong. I have been putting up a minimal working example, and will probably end up asking on their repo or on Stack Overflow. I will try tonight on Linux.

baudren commented 9 years ago

Ok, so there is a small problem of dependency. The version of pandoc shipped with the latest Ubuntu, 15.04, is too old to support KaTeX (it uses 1.12.4.2, whereas it was introduced in 1.13.2).

How should we handle that? We could try to detect the version through pypandoc, and if there is not the right one, simply remove the --katex call. We should somehow show people that the math display could be improved...

What do you think?

baudren commented 9 years ago

There was also a problem with not using html 5 type declaration at the beginning of the html, so I had to changed the pandoc headers to <!DOCTYPE html>. I will check if this solves the issue on Windows (or you can tell me, @egolus )

egolus commented 9 years ago

I'm no expert in math rendering, but at least the example from http://khan.github.io/KaTeX/ looks good

about the version issue.. I don't know, if there's an easy check for the pandoc version, removing the --katex parameter sounds reasonable. I'm not sure, we should at least add a log-entry, but maybe even show a note in the client .. with the option to not show it again

baudren commented 9 years ago

It looks like it is Qt html rendering that fails, on windows (or the PySide bindings, but that would be weird). When rendered through Firefox, I get the good display for inline math, good_katex But when rendered inside Note Organiser, the lower infinity sign is far too high. I get a warning, QFont::setPixelSize: Pixel size <= 0 (0), but from searching for it, it seems to be a non problematic warning. wrong_katex.

Don't you get the same on your machine?

baudren commented 9 years ago

For the version issue, our wish has already been fulfilled. I am implementing it now.

baudren commented 9 years ago

I added the check for the version - and had to rebase (I had branched out of another branch than devel, sorry for that). Please be sure to delete your local KaTeX branch before pulling, or pain will follow...

egolus commented 9 years ago

you're right, I've got the same issue