DXsmiley / mathbot

Discord bot for mathematics
https://dxsmiley.github.io/mathbot/
GNU General Public License v3.0
278 stars 53 forks source link

Adding Asciimath #45

Open saivan opened 5 years ago

saivan commented 5 years ago

So it would be super awesome if we let the user input asciimath which is just a lot easier than latex (especially for younger students), I don't how how hard that would be based on the way you've designed it. But I was thinking a simple asciimath to latex converter would be cool, then users could just do:

This is some $$\LaTeX$$ and this is some $$+text(AsciiMath)+$

The asciimath would just get converted to latex and sent to your current renderer. Thoughts?

DXsmiley commented 5 years ago

AsciiMath sounds like a good idea. There's multiple ways to potentially go about it though.

There may be other approaches that I haven't considered though.

saivan commented 5 years ago

Actually, I think they are just using the converter in the main repo :P

https://github.com/asciimath/asciimathml/blob/master/asciimath-based/ASCIIMath2TeX.php

DXsmiley commented 5 years ago

Hmmmm... 800 lines of PHP. Not really something I want to tackle. I'll try searching for something more usable.

saivan commented 5 years ago

Any updates here?

DXsmiley commented 5 years ago

Life got bad for a bit, and now I'm working full time. So apologies for being slow on this.

I did find a JS script to convert AsciiMath into LaTeX, so we could use that, but bringing all of node.js into the system for such a feature seems like overkill. The script, modified to be run from the command line, is here.

saivan commented 5 years ago

No problem. I am not sure, maybe it is slightly overkill :P Doubt it will be efficient, but this code is just creating an ast and replacing some symbols, so something like this https://github.com/PiotrDabkowski/Js2Py could work.

DXsmiley commented 5 years ago

The official ASCIImath page has a description of the grammar on it: http://asciimath.org/#syntax There's BNF down the bottom of the page. It doesn't look TOO bad to implement, but maybe there's something I'm missing.

saivan commented 5 years ago

No it isn't so crazy. But why do that when you can just run the javascript in python 😎 I suppose its up to you though. Another implementation would probably be interesting to the folks over at asciimath though.