ASCIIMathML as filter - CONTRIB-384

ASCIIMathML as filter - CONTRIB-384

by Marc Grober -
Number of replies: 14
Just wanted to note that there is a tracker item here: http://tracker.moodle.org/browse/CONTRIB-384
regarding implementation of asciimathml as a core filter and your comments (and votes??) would be helpful.

ASCIIMathML is available in in javascript, php and other formats; parses tex as well as its own simplified text expressions as well as graphs using d.svg; is extensible (and I am hopinh that it will soon do OpenOffice Math text expressions); and asciimathml text expressions can be created, saved and inserted via dragmath. Additionally, asciimathml can use words instead of symbols as tokens so as to avoid compatibility problems with other applications.

Most importantly, asciimathml converts to mathml on the fly so there are no gif issues.
Average of ratings: -
In reply to Marc Grober

Re: ASCIIMathML as filter - CONTRIB-384

by Andy Kemp -
I have been using JS_Math for the last couple of months but came across this and a couple of other references to the ASCIIMathML filter...

There are somethings I really like about it, the fact that you can use both Latex and the simpler asciimath syntax to generate the display , and the fact that it is using MathML...

However this is also the problem whilst MathML is the standard for displaying maths in a browser it is still badly supported. To use it in IE you need to install a plugin, for firefox you need extra fonts and don't even try to run it in Safari as it doesn't work...

I would love to see something replace the TexFilter in core, but I would like it to be something that supports a wider range of browsers. Otherwise I can see my students using the excuse that it didn't look right on the screen for why they didn't do their homework!?!

Would it be possible to add some image rendering so that in the event that MathML is not present it falls back to generating gifs?

If this is not possible then at the moment I would rather see JS_Math and DragMath added to core to give us system which works on all browsers (even if it is a little slower and not quite as simple to use)...

However if anyone has any idea how I can get this to work in Safari, I would happily support this tracker item.

Cheers
Andy
In reply to Andy Kemp

Re: ASCIIMathML as filter - CONTRIB-384

by Mauno Korpelainen -

Nice that you told about JSMath, Andy. Jsmath looks cleaner than Tex but the size of filter folder is 6 MB and Tex takes less than 2 MB

Attached a small example of difference between Tex and JSMath equations. I made only one change to javascript.php  (otherwise each equation is shown in separate rows)

    doubleDollarsAreInLine: 1,  // make $$...$$ be in-line math?

I am sure that Dragmath will be in core moodle soon - in fact it is already included to moodle 2.0 inside tinymce folder (not used yet) and the best part of Dragmath is that it works in all normal browsers that support javascript and Java + we have a plugin ready for htmlarea, tinymce, xinha and fckeditor.

As Marc has mentioned in many posts Asciimathml.js does some such things that other filters do not - graphs are extremely nice - I agree this lack of cross browser support is not good. But since you know it you may tell the students to use firefox (or IE with plugins) in such courses where asciimathml or asciisvg graphs are used...I really like all of these tools and could take a dozens more tools to my moodles.

Attachment math.gif
In reply to Mauno Korpelainen

Re: ASCIIMathML as filter - CONTRIB-384

by Mauno Korpelainen -

Attached some examples of the graphs and maths of asciimathml.js

Examples

In reply to Mauno Korpelainen

Re: ASCIIMathML as filter - CONTRIB-384

by Marc Grober -
[expletive deleted], I should never have shown you what asciimathml can do, Mauno.... you are like a kid in a candy shop ;=}

I would like to see moodle.org enable asciimathml and d.svg. The tex filter would still work and it would allow us a greater opportunity to discuss these issues.

However, one thing you can't see from Mauno's field trip is that if you double click any of the graphs (not here, these are just images) you can dynamically change the graph and cursor in the graph area provides you with coordinates.

In reply to Mauno Korpelainen

Re: ASCIIMathML as filter - CONTRIB-384

by Andy Kemp -
I agree there is a lot to like about asciimathml, it just the lack of cross browser compatibility that worries me...If I am honest it's probably because I use safari as my main browser and I don't want to switch!?!

I was particularly impressed with the graphs however and would love to swap but for now I think JSMath offers me a little more than I get from asciimathml.

The rough edges on the Tex plugin and the fact that it required installing Latex on the server made the core Tex plugin a non-starter for me...

In an ideal world I would love to see asciimathml render mathml where available but fall back to images where this is not available... This however would require adding in a mathml to image engine...

I had a quick hunt around and this looks a possibilty:
http://www.pierce.ctc.edu/dlippman/asciimathtex/AMT.html

So it could then be setup to use mathml where it can or fallback to either a server-based tex filter or maybe jsMath...

I guess the concern is that we then end up with a much bigger filter...

Maybe it could be modular, so that you can add in the fallback filter seperately?

If we could add this kind of thing in then I think we have an excellent solution for everyone!


In reply to Andy Kemp

Re: ASCIIMathML as filter - CONTRIB-384

by Mauno Korpelainen -

Things may change - it was only some time ago when html editors started to work with Safari and Opera and if we have multilang feature in editor (made with span tags) we could probably have some kind of browser specific math spans too - or wait some news from Webkit team...

In theory we would need to have only one line of code for browser check and one line to produce mathematics or images... in practice it may be a little more difficult.big grin

In reply to Andy Kemp

Re: ASCIIMathML as filter - CONTRIB-384

by Marc Grober -
I'm familiar with the work that Dave Lippman has done (you mentioned the fallback replacement for asciimatmljs). The last published version David did was based on asciimathml.js v 1.4.7. Peter indicated he was going to try to find some time this summer to address some changes in asciimathml.js (it is currently at 2.0.3) and something along those lines might be possible.

I think it might be easiest to use mathtran.js as a fallback. The present limitation would be the conversion of asciimathml text expressions to tex if no MathMl is available and the expression is not dollarsign delimited (if it was it would just need to be betokened and passed through.) I think the barrier then is just time on task so to speak..... the ability to do the conversion is there, as is the ability to check for the browser.... and we could reference mathtrans.js remotely (at least for the short term... and hopefully all browsers will do mathML shortly.

These issues have to be resolved in html5 or things generally are going to start getting very sticky on the web. webkit has indicated that it would be nice if they could support w3c technology recommended in 2001. http://webkit.org/projects/mathml/index.html I am sympathetic to cries regarding proprietary extensions and am no friend of IE, but if you are going to have a standards organization at some point can't we agree that folks responsible for software that is compliant have some responsibility to step up??

In reply to Marc Grober

Re: ASCIIMathML as filter - CONTRIB-384

by Andy Kemp -
This sounds promising if we can get it to work...

I don't think we will see MathML in webkit any time soon that project page has been around for a while and nothing seems to be forthcoming... Someone offered to do it for this years GSoC but it didn't make the cut...

I think we have to assume that at least for the next year or two that MathML will not be supported by WebKit. And given WebKit is used in lots of mobile browsers as well as Safari it is important that we provide an alternative rendering system when mathml is unavailable...

I would rather not rely on the current Tex filter as a fall back as is isn't particularly clear, and would like to see the JSMAth module used for that part...

So are we looking at a 3 part solution:
asciimathml in the first instance
where MathML is unavailable the string is passed through mathtrans and then passed onto another Latex rendering engine...

How likely is it that we could put something like this in place? I would be happy to help out a bit but I am not a proper coder I mostly just hack other people's php to suit my needs!
In reply to Andy Kemp

Re: ASCIIMathML as filter - CONTRIB-384

by Mauno Korpelainen -
I can try and it may be easier than it sounds to write that code. Getting the whole browser sensitive math filter system to core moodle is not so likely anymore.wink
In reply to Andy Kemp

Re: ASCIIMathML as filter - CONTRIB-384

by Marc Grober -
I share your doubts about webkit, but "soon" is relative and this is just one of many issues in the current xhtml->html5 debate. I recommend firefox because it is NOT tightly coupled with the OS and appears to provide added functionality in virtually all environments. Student wise it means that every student can use th same client no matter the hardware or OS and that I can provide a students with a complete computing platform for less than I spend on coffee in a year. On the otherhand, when I am forced to use Windows I use IEtab with firefox-maybe webkit should look at a SafariTab for firefox ;=}

However, back to practicalities....
I can't speak for Peter or David, but it looks like between them they have already developed most of the prerequisites for such a solution (the initial translation to MathML as well as a decent subset for tex translation ). This would all have to be updated, let's say into an asciimathml.js version 3.0 as David's code is based on the old version of asciimathml. Then we would need some function to pass asciimathml2tex expressions to a tex image engine (jsMath or mathtrans)
In reply to Marc Grober

Re: ASCIIMathML as filter - CONTRIB-384

by Andy Kemp -
You have persuaded me that this can work and have my vote!

The graphs that can be produced with asciiMathML are particularly impressive and add a lot more functionality then just rendering mathematical notation...
In reply to Andy Kemp

Re: ASCIIMathML as filter - CONTRIB-384

by Marc Grober -
David and I just exchanged notes. In his CMS he still uses the asciimathml configured to fallback to mimetex as posted and the files as Andy noted are all still posted at http://www.pierce.ctc.edu/dlippman/asciimathtex/AMT.html, I just need to figure out whats what and update functions to 2.x and test, and then look at piping stream to optional server side tex engines.

I am still thinking that the reason Mauno saw asciimathml work though filter was turned off is that require_js is including js files in filter directory, so what may be an eventual target is to update the Chan->Lippman php filter or do the js files via site/course themes as Mauno demod

I asked David if he minds us fiddling with his code and for suggestions as to implementation and I am sure he will be helpful (in fact he offered to do some work but doesn't have the time right now....) I am a bit concerned about identifying and employing a fallback tex server side engine that is not easily deployed in moodle core if we are going to argue that this should become moodle core (and I think the discussion so far is ample reason to support this.)

I am wondering what mathtran folk have to say to such a thing.....
In reply to Mauno Korpelainen

Re: ASCIIMathML as filter - CONTRIB-384

by Marc Grober -
Hey Mauno,

I have just noticed that limit in my installation of asciimathml is working correctly, while yours is coming out as a subscript. I had noted that elsewhere when working on your test site as well.... Something may have gone amiss somewhere.... can you log into schmoodle and compare what you are doing on your site with what shows up on mine?
Below a text expression and attached is the rendering using asciimathml.js I see both in your xinareplay I installed and in my production 1.8.2 moodle
Test:
`frac{df}{dx}=lim_(h->0) frac{f(x+h)-f(x)}{h}=lim_(\Deltax->0) frac{f(x+\Deltax)-f(x)}{\Deltax}`
I do prefer the asciimathml rendering, but that is undoubtedly helped by the use of appropriate fonts..... but I can also easily change the color and font, though instance by instance only if I can insert js script tags....
Attachment asciimathlimit.PNG
In reply to Andy Kemp

Re: ASCIIMathML as filter - CONTRIB-384

by Marc Grober -
Andy et al.

David Lippman already sent me a quick rewrite on a fallback to mimetex and some comments on using other engines and I have started a new thread to focus on development and deployment here:
http://moodle.org/mod/forum/discuss.php?d=99167

One of the subjects I think we will have to address is how best to address use of a fallback server side tex engine....