Hacker Newsnew | comments | show | ask | jobs | submit | xymostech's comments login

Woah, awesome. I've used the http://dnstunnel.de/ tunneling scripts before, and they're a bit of a pain to setup (mostly because of the perl library requirements).

-----


I remember using these scripts years ago when wifi hotspots used to charge obscene amounts of money...

-----


There's no real "secret sauce", it's mostly just "do things smart". For example, while MathJax tends to do a bunch of calculations about exact positions of where different characters should go, KaTeX manages to get away with offloading most of that into the CSS, so the native CSS renderer can handle it.

MathJax also does strange things involving inserting elements into the DOM to look at metrics that it uses in its calculations, then removing them, which takes a lot of time. We make sure that the same input is rendered the same every time, and try to make sure it looks good everywhere (there are a couple cases where we aren't the best at this, mostly because browser font rendering isn't great).

We also support less environments than MathJax, for example we only support HTML+CSS output (for now, though MathML is in the works for accessibility reasons), whereas MathJax supports HTML+CSS, SVG, MathML, and older browsers like IE 6. This means it can't rely on things like good CSS rendering like we do. It's a worthwhile tradeoff for us, because we can make ours so much faster, but it is a tradeoff.

-----


Hey! We're planning on adding environments (everything that uses \begin and \end) sometime soon. There's a couple github issues touching on this point; if you want to know how development's going, you can follow one of the issues.

-----


I see: https://github.com/Khan/KaTeX/issues/43

:)

-----


There's a lot of choices. We support a smaller subset of browsers and outputs (only IE8+, only HTML+CSS, no SVG), so we gain some speed there. We also try to push as much of the calculation into CSS as possible, so that the native browser does as much work as possible, instead of the javascript. MathJax does a lot more manual positioning.

-----


This is definitely a goal for the future. Eventually we'd like to support everything that MathJax does (and maybe more!) Equation numbering involves more work than some of the other features (we've managed to get away with never calculating widths of elemnts, but we'd have to do that to get horizontal alignment working, we think), so we're pushing it back for now.

-----


There aren't any plans at the moment. We've struggled with this problem before, and wrote something similar with https://github.com/khan/KAS/ but we've never worked at doing something inline. We use MathQuill in a couple places, which does the input decently (writing works, but typing something like x^2_2 gives you x^{2_2} not x^2_2), but the output doesn't look great. It's hard to do what the user wants, have clickable bits, and still have good looking output.

-----


I recently made this little tool for writing latex macros: http://kasperpeulen.github.io/PressAndHold/ It works the same as the OSX press and hold accent picker. I have also a unicode version which I think is much more appealing for young mathematicians: http://kasperpeulen.github.io/PressAndHold/Unicode/

All MIT licensed if you are interested in using it.

-----


I agree that it's a very difficult problem. I think that it's a major missing piece for online math learning right now (actually interacting with math symbols in a non ASCII/textbox way). Thanks for all of the hard work you guys do!

-----


We never do any unsafe dom manipulations, like using .innerHTML, only createElement and appendChild, so things should be fairly safe. Also, if you do server-side rendering, we escape code that users type in, so that should work well also.

-----


We won't support ASCIIMath yet. There's a lot of content on the web already in LaTeX syntax (and on our own website), and a lot of people already know it. It is difficult to use and read, but it gets the job done. Maybe once we've gotten all of the core LaTeX features done, we'll start looking to this. Thanks for the info, though!

-----


yes, would love asciimath support. most of the math that'll exist on the web isn't there yet, and it'll be so much easier to the next billion internet users than learning latex.

katex looks great though. we (socratic.org) might start using it if we can find a good asciimath=>latex converter.

-----


Check out https://github.com/mathjax/asciimathml/blob/master/asciimath.... It uses the AsciiMath parser to generate latex to be fed into mimetex for rendering, but it could probably be daisy-chained with katex. I keep it current with the latest AsciiMath revisions.

-----


I created such a daisy-chained page that uses ASCIIMathML input with KaTeX rendering where possible, and it falls back to MathJax when KaTeX can't handle the expression. See

http://www.intmath.com/cg5/asciimathml-katex-mathjax.php

-----


I've never heard of this before, could you let me know what it is?

-----


Probably: http://www.ctan.org/pkg/xypic

Support for tikz would be great, too.

More broadly: great project! Looks to bring us closer to the day when math on the web is easy and just works.

If you don't mind me asking, can you say why you didn't work with MathJax, and decided to start over?

-----


Ah. Yes, the diagram generating libraries are harder to implement. Since we don't actually implement the primitives that TeX uses, we can't just import libraries like xypic or tikz wholesale, we'd have to rewrite them from scratch. Maybe a project for when we've got most of the actual math working.

As for why we didn't work with MathJax, this started out as more of an internal project for making our own math fast, and has slowly built up to what we have today.

We also didn't think that we could get the speed we wanted while still supporting all of the obscure features MathJax does (like SVG rendering).

-----


We don't use features like this at Khan Academy. However, most of the time the problems with MathJax were with the inital problem load, not with changing expressions later. It might be interesting to support something like that eventually! Let me know how it works for you.

-----

More

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: