Mathematics tools

Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.
Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Two weeks to go before holidays and new maths stuff is looking really good now, Marc...

If you want to play your self with these proto type plugins (10000 examples and all possible symbols still need to be placed to final entry lists of plugins) you can download a "clean testing package" from http://korpelainen.net/mathplugins.zip or visit http://korpelainen.net/plugindemo with test account ( test - test ).

I should be able to write the needed documentation and fixes within one week and will be happy to spend my holidays free of all alphas and betas for a while - at least first weeks in England...

For other possible testers - in addition to Marc - here brief instructions:

Image fallback is now almost perfect - for supported commands of latex in latexmathml, supported graph types in asciisvg and supported asciimathml commands. New features can be added and possible bugs fixed... if you find them.

Download the package from http://korpelainen.net/mathplugins.zip and unzip the files to subfolders lang, lib and theme of your moodle 1.9.x. These files should work with all versions of moodle 1.7-1.9 and customized versions for moodle 2.x will be available later when moodle 2.0 is stable for production sites. No core files of moodle will be overwritten and all parts can be cleanly removed if scripts are not needed after testing. Only one thing worries me - after the latest update of Safari today dragmath plugins suddenly started to stop responding - other plugins and browsers are working ok. I try to check error logs to see what is wrong with latest update of Safari, other code ...or java/Dragmath?

Folder lang contains "pre versions" of language files of 6 experimental tinymce plugins: asciisvg, asciimath, asciimaths, latexmaths, dragmaths and draglatex with tinymce 3.2.3 - preview plugin is modified version and moodleimage and moodlelink plugins by Glen Davies are used for course files of moodle. Default editor HTMLArea is disabled in theme Math config.php - footer.html of that theme selects different integration files for teachers and students according to capability to manage course files and the actual init code is in files theme/math/editor1t.php (teachers) and editor1s.php (students). Meta.php calls script /lib/editor/common/AM.js that is the "motor primus" of all maths - it renderes asciimathml, latexmathml and asciisvg for you using external image fallback renderer if browser does not support MathML (FF does...). YUI tabview is used for tabs and one css file added to skins of YUI.

So you simply need to either use theme "math" as site, user or course theme or copy the changes from theme config.php, meta.php, footer.php and extra files to be able to use these scripts with any theme - it's not too complex anyway. The easiest way to test the files is just to download/upload the files to correct place and change theme to math. TinyMCE pops up instead of HTMLArea and new plugins should be visible. In full screen mode also table controls area available - new code for media plugin (embedding old style asciisvg) and new unicode picker (keyboard) might be avilable in July/August.

You can change all main settings from AM.js itself or in theme (meta.php again) with tags like

<script type="text/javascript">

var AScgiloc = "<?php echo $CFG->wwwroot ?>/lib/editor/common/php/svgimg.php"; var AMTcgiloc = "http://korpelainen.net/cgi-bin/mathtex.cgi?\\png\\gammacorrection{1.4}"; var JeMTcgiloc = "http://korpelainen.net/cgi-bin/mathtex.cgi?\\png\\gammacorrection{1.4}"; </script> Usually these are the only settings you might want to change - my test server has a very limited capacity (about 10 GB) to render images and maths for millions of moodlers so if you know some public server that can use some distribution of LaTeX (TeX Live etc) and even better a great renderer like mathtex.cgi ( http://www.forkosh.dreamhost.com/source_mathtex.html ) use it - in fact these scripts can be modified to use any latex renderer - also traditional Mimetex or texfilter of moodle with tiny extra script but for clean image fallback it is most reasonable to configure a fully functional Latex to use png files with scalable density and gammacorrection. You will notice the difference between mimetex images and asciimathml/latexmathml as ascii/unicode characters when you print your maths and when you load large equations for the first time. Mathtex is using a log file to save the location of png files which makes rendering of fallback images faster. For Asciisvg plugin you need to read instructions from http://moodle.org/mod/forum/discuss.php?d=121738 first. Javascript file AM.js may change to a php file after holidays but right now it is easier to use mainly javascripts untill all code is cleaned and re-re-re-checked... That script works nicely with Mediawiki so writing some good new examples using current latex wiki pages and available pdf documentation should make the my "literal work" easier... if you have any comments, new ideas etc send me email - I'll be back next week. Average of ratings: Useful (1) Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Just a short comment - if you happened to download that package within 5 minutes of my post I had left some unnecessary files (copies of old copies of copies) to folder lib/editor/common and uploaded a new package without those files to my test server... Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG It is also good to note that we can use asciimathml as included javascript file in any web pages with one line like: <script type="text/javascript" src="http://korpelainen.net/plugindemo/lib/editor/common/AM.js"></script> for example in theme header.html, meta.php, footer.html of theme - or attachments to translate maths (see attached file) Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG You caught me flatfooted, as I was counting days and wanted to set up a separate experimental moodle for testing - LOL I am still concerned that the eventual results do not go too far afield common asciimathml functionality so am hoping all this and SA's new efforts will result in a common core script and shared plugins.... Please share with asciimath google group Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG These plugins are using some lang strings for moodle and yui tabs inside moodle but it is as well possible to modify the plugins to use common yui tabs ( http://developer.yahoo.com/yui/tabview/ ) or some other applets or tools in addition to Dragmath. I placed Dragmath to folder dragmath2 mainly to avoid overwriting existing versions of dragmath in lib/editor/common because I tested changing <Initial> <output1></output1> <output2></output2> </Initial> to <Initial> <output1></output1> <output2></output2> </Initial> for format ASCIIMathML.xml like it is for Latex.xml because in those 2 plugins I want to use dragmath more than once to add equations for temporary textarea and paste the combined equations to editor. I noticed too that moodle changes \\ to \ in resources (some filter?) so I changed the matrix code to produce 2 line feeds in Latex format with <!-- Matrix --> <Matrix> <matrixStart> \left( \begin{array}{ccc} </matrixStart> <rowStart></rowStart> <elementStart></elementStart> <elementEnd></elementEnd> <elementSeparator><![CDATA[ & ]]></elementSeparator> <rowEnd>\\\\</rowEnd> <rowSeparator></rowSeparator> <matrixEnd> \end{array} \right) </matrixEnd> </Matrix> to make array type matrices functional in resources of moodle (pasted from Dragmath) and also changed asciimathml to produce array code for image fallback instead of matrix that works in mimetex but does not work in mathtex. This way you can enter matrices in two both ways (see plugin code for exaples) I have here 2 dragmath plugins with different default settings to be able to directly combine each format to possible examples and symbols - it is also possible to use one and only plugin for all this ( the original SEE idea ) but it may be less user friendly with more optional selection boxes and possible confusion of different code formats. Personally I like more the latexmathml part - asciimathml has some prolems with short tags like "in" which is translated from all otherwise non translated words inside ... - everythINg - latexmathml does not do this ( and \in inside words is otherwise rare too... but I commented some tags that I originally included from latexmathml too: like \i, \L, \l, \O, \o, \S and did not include similar combining characters of latex like \u or \v. It is of course possible to add any latex tags with some output code for MathML but I added JeM image fallback for cases that can't be done with MathML (for example macro based latex commands that produce different output according to parameters given for those tags). I can use latex directly with tex filter and change/add \usepackage tags for latex but it does not produce mathML which needs to be separately produced for unicode/ascii output. I will share the code (these links) for asciimath group - file http://korpelainen.net/plugindemo/lib/editor/common/AM.js may be the most useful part for people using other environments than moodle. This is certainly not the "final version" - I tried to use separate files for asciimathml, latexmathml and asciisvg, separate files for mathtex and mimetex, separate files with old asciisvg and plugin based asciisvg but soon I had 20 different scripts and it was hard to remember which was doing what... It would be easier to use just one format with latex commands like \alpha everywhere and allow changing the meaning/output of tags like \\newtag or newtag using similar input tags for both asciimathml and latexmathml, both mimetex and mathtex... do we really need two almost similar input arrays if for most cases the only difference is backslash \ ? Current tags like {input:"Heart", tag:"mo", output:"\u2661", tex:"heartsuit", ttype:CONST}, in asciimath part might be as well {input:"\\Heart", tag:"mo", output:"\u2661", tex:"heartsuit", ttype:CONST}, (different distributions of LaTeX have different commands - Mimetex/Mathtex...) It is easy to understand why Peter originally started to use commands like {input:"<=>", tag:"mo", output:"\u21D4", tex:"Leftrightarrow", ttype:CONST}, because it is so much faster to write A<=>B than A \Leftrightarrow B (if you need to remember latex commands). If you have a plugin that produces latex tags with one button click you don't need to remember commands any more but you still need to be able to change tags... For a "normal" teacher a simple plugin like Dragmath is in my opinion the best choice - java is just slow and extending Dragmath with new commands should be possible without Netbeans. Javascript based plugins can be easily changed but they miss pure WYSIWYG - preview window helps but you still need to change some latex tags... no option is perfect but if you remember the situation two years ago... we had no free tools available then. Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Arghh - just tested the plugins with IE6 and surprise, surprise - IE6 can't of course show those fine looking transparent png images so I need to add extra tags for IE6 to render all fallback images for IE6 as gif files and for other browsers as png Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG MK, You know how I feel about IE, but you are right-it should be as transparent as possible as far as browser usage. I preferred to customize insertion strings in dragmath XML as that makes both moodle code maintenance easier and keeps dragmath usage consistent and that was why i moved dollar sig s to dragmath xml file. Things like extra slashes remind me of my first attempt fiddling with asciimath over tokenisation - and increasing complexity in any system will increase liklihood of system failure-if you are concerned for complexity of current structure, heaven help the rest of us - LOL Therein lies the rub; try to address every possible exception infirst release versus focusing on simplification Anyway, this looks GREAT and I am very excited by your progress. Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Well I just changed png to gif and it does not look any worse... If IE likes gif let it be gif: The easiest solution is to drop pngs away from AMTcgiloc and JeMTcgiloc If you use my server for fallback change in file lib/editor/common/AM.js var AMTcgiloc = "http://korpelainen.net/cgi-bin/mathtex.cgi?\\png\\gammacorrection{1.4}"; var JeMTcgiloc = "http://korpelainen.net/cgi-bin/mathtex.cgi?\\png\\gammacorrection{1.4}"; to var AMTcgiloc = http://korpelainen.net/cgi-bin/mathtex.cgi?\\gammacorrection{1.4}; var JeMTcgiloc = "http://korpelainen.net/cgi-bin/mathtex.cgi?\\gammacorrection{1.4}"; Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Here's an gif example with dpi 500: $\dpi{500}\gammacorrection{1.2}\alpha$ and png image with same settings: $\png\dpi{500}\gammacorrection{1.2}\alpha$ Can you see any difference? I can't... so I will use gifs in the future to avoid double amount of images. Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Mauno, In your test site please check out the quiz question I added to the quiz "test": http://korpelainen.net/plugindemo/mod/quiz/attempt.php?q=1 Notice that when you click on drop down you see correctly displayed equations, but not unless you click on drop down. You see the equation in its text expression form, then the js finishes rendering and then the equation disappears. Is this a spacing location issue as far as dropdown? Also notice that feedback is not correctly displayed.... Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG I did an agraph page for a test for when you get that functioning <hugegrin>in the near future</hugegrin> One thing I want to mention. When I did the quiz question you put in (graphed simultaneous equations) I went to click on the intersection to get the coordinates and realized that this functionality is not available in this format, and that is really unfortunate..... Your presentation is great though... and I will beat on it some more vis-a-vis dragmath As far as gif vs png, while I am no Edward Lear, The biggest issue with gif vs png Is picturing the spat o'er the copyright thing so...... Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Missing coordinates come from the changed code by David... but they can be taken back. It's a part of the bigger AsciiSVG issue (old / new function drawPictures) I have not used/tested how drop down lists get code in those quizzes but it looks like MathML works and FF renders asciimathml correct but fallback images are not rendered inside dropdown lists in IE/Opera/Safari - so the next question is: do drop down lists support images or is there some other reason (extra spaces etc) that might cause failed images in drop down lists...? Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Interesting extra note is that latexmathml does not render fractions like 3/2 correct like asciimathml does - one line more to check in input/output lists. Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Marc, the answer is that normal drop down lists do not support images in IE, Opera or Safari, they work ok in FF. It should be the same for tex filter that produces images and therefore they are not shown in drop down lists for IE, Opera or Safari. We should use for example jQuery to transform dropdown lists to lists that support images - see http://www.marghoobsuleman.com/jquery-image-dropdown ... but I am not yet sure if this can be done in theme level or should such changes be done in site level (or quiz module) to allow any use of images in drop down lists Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Mmmm........ I was looking at the dropdowns using FF and am assuming that I was seeing mathml, not image fallback... The size of the dropdown changed to accommodate the spacing of the dropdown content Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Ah - we were talking about different thing - this looks like some kind of CSS issue or filter issue in Multichoice question type. The answer (option of selection list) shown in list under correct selection is not the same as correct selection itself shown at first .... and if you have only asciimath in correct answer you get empty box. It's not caused by asciimathml or my scripts - otherwise you would not see the answers at all. In addition to this some content may be filtered by this special question type because it uses {...} and some characters to recognize different parts of question to create drop down lists and for example$\frac{2}{3}$might break such code. Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Yes, Mauno, we are on same page now. I figured it was CSS and had not even thought about the fact that it could be an issue with the question type. Who is the quizpert? Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG I think I found the final obstacle between old and new asciisvg (agraph) code: - I must still clean the code but the different plot function caused the main trouble so I changed old function to ASplot and old drawing function to ASdrawPictures. Coordinates are visible in FF when you move mouse (they can't be in IE) and Adobe SVG viewer is currently disabled for IE (IE shows images no matter if you use SVG viewer or not) - and now Opera replace agarph-endagraph with embedded asciisvg but I suppose we can get both old and new code to work at the same time. IE shows blank image instead of svg and we could add an optional tag for agraph/embed (class="OLDASCIIsvg") to show some image for IE... Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Do you mutter js in your sleep, LOL? Great work. Note that the bb{F_(hydr)} broke - we had discussion in asciimath group that this is asciisvg Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG I found some additional issues with respect to agraph that I hilighted on your test site (http://korpelainen.net/plugindemo/mod/resource/view.php?id=16) • Pointer coordinates are not independently reset at origin in each graph, and I suspect that this may pre-date your experiments, so I will have to double check. • ASCIIsvg ability to parse backticks now gone • Not including ymax and ymin will skew all graphs on same page using agraph • Chrome shows an arc even where strokewidth=0 Options are beginning to make this very powerful but very easily a confusing interface because of the levels at which various items are parsed, as we have discussed before.... Docs for regular users willl have to be carefully crafted ;=} Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG Well this is a natural effect when you try to combine two scripts that use different code for same thing - old ASCIIsvg.js and David's plugin based ASCIIsvg. I used some hours in testing what function or variable with " or ' should do what with or without endpoints, angle or whatsoever... those different asciisvg features are now in two separate files and if I change the order different things work ( ASCIISVG.js has for example that ShowButton feature that does not work in agraph version of asciimathml /AM.js ) - it just takes more time to a) learn all those features b) find them in code and c) find out how to combine all these features so that they work similarily with old/new/combined code I think I won't use now too much time for asciisvg - I checked the scripts by SA but I must have missed some info because I got mostly error messages from the test files that were of course made for different version of asciimathml ( ) My test site has now also one script example (Testing scripts) but you can't edit those scripts, because script tags are commented for normal users and I can't allow any visitors to be able to add scripts with test account. Still it's good to know that they can be used too as interactive demos. Do you need an administrator account, Marc? Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG As I have said before, one could a lifetime playing with this ;=} need to focus on some core elements for which we can provide technical docs and how-tos for now and consider that SEE rc 0.1, LOL, and get in people's hands. Regarding svg, I want to see a product that a US public school teacher could use to plot simultaneous equations or the area under an integral as well as the graphing calculator features and I think you are very close to living up to the SUPER in SEE But the docs for this will be substantial, and if moodle doesn't support it we will have to host this elsewhere- I can do this with my DH accts and even set up a separate domain for it or we can have SA host it at asciimath.com Average of ratings: - Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG I believe that the reason for missing asciimath inside asciisvg is the order of parsing different code. Current order is: function generic() { if(!JeMinit()) return; JeMtranslate(); //parses double @:s (forced image fallback to Mathtex) if(!AMinit()) return; if (translateOnLoad) { var nd = document.getElementById("processasciimathinmoodle"); if (nd!=null || !checkforprocessasciimathinmoodle) { AMtranslate();//parses asciimathml and latexmathml (  and$ ) and changes agraphs to embed code
}
}
drawPictures();// draws plugin based graphs
};

and then finally in ASCIIsvg.js:

function generic()
{
if (isIE) {return;} else {ASdrawPictures();}//draws old style ASCIIsvg and renders translated agraphs
};

Maybe some function is used twice with the same name etc - I just need to add the code of ASCIIsvg.js to correct place in AM.js - ASCIIsvg.js does not have any code for parsing asciimathml...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Chrome has improved a lot since the first beta versions and it has a nice inspector that can be rendered with mouse right click - and you can double click each object and test how it changes if you change values. In this case 1px red line vanishes if I set stroke-opacity to 0 instead of current default value 1.

We should check the meaning of each default value in asciisvg and different types of graphs and all default values should be changable for each graph like that coordinate font size.

After holidays I could try to modify the graph plugin (or media plugin) to add most common old style graph types with parameters like xmax, xmin, ymax, ymin etc - the ideal plugin should be able to add classic asciisvg (or controlled svg) for FF, Opera, Safari and Chrome but it should allow also some type of image fallback with php and GD (if it is just possible to produce those images for IE - GD supports those functions but somebody like David should be capable to write the code for other functions than plot). There are so many interesting things that could be done but time to do them is too limited...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Anyway - it is a Chrome bug - FF and Safari show them correct, Opera renders embed tags correct but does not change agraph...endagraph to embed tags (Opera does things somehow forehand and it is still one step too late for example in equation preview in rendering characters  )

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Marc, about this "ASCIIsvg ability to parse backticks now gone" - do you actually have any version of asciimathml or asciisvg that can do this - I am totally confused because I have tried all my versions and none have been able to parse asciimathml backticks inside asciisvg in tags like

<p>agraph width=300; height=300; xmin=-6; xmax=6; axes(7, 7, "labels", 6, 6); stroke="red"; strokewidth=2; fill="lightgreen"; ellipse([0,0],5,3); text([0,1], "ASCIIsvg is the coolest thing"); text([0,-1], "alpha - since peanut butter!"); text([4,5], "Quadrant I"); text([-4,5], "Quadrant II"); text([-4,-5], "Quadrant III"); text([4,-5], "Quadrant V"); endagraph</p>

The latest file I tried was ASCIIMathMLwFallback2.js

Are you sure that those asciimath tags were not outside the graph? The only related page I found was http://math.chapman.edu/cgi-bin/math.pl?ASCIIsvg_FAQ

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

I don't think you can use asciimathml translated to MathML (or fallback images) inside SVG (translated asciisvg) but a workaround is to use asciimathml outside the graph and use relative or absolute positioning to place asciimathml over the graph with tags like

<div style="position: relative; left: 0pt; top: 0pt;">agraph width=300; height=300; xmin=-6; xmax=6; axes(7, 7, "labels", 6, 6); stroke="red"; strokewidth=2; fill="lightgreen"; ellipse([0,0],5,3); text([0,1], "ASCIIsvg is the coolest thing"); text([0,-1], "since peanut butter!"); text([4,5], "Quadrant I"); text([-4,5], "Quadrant II"); text([-4,-5], "Quadrant III"); text([4,-5], "Quadrant V"); endagraph</div>
<div style="position: relative; left: 65px; top: -145px;">alpha beta</div>

See the last example in http://korpelainen.net/plugindemo/mod/resource/view.php?id=16

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

And this MathML looks pretty only in Firefox - Opera can do it if you use embed tags and for Safari, Opera and Chrome the fallback image is not so cool anymore as transparent gif file over green background. I suppose it's better to use just text inside graphs (A, B, ...) and give those equations with asciimathml outside the graphs.

I will do only some tiny fixes to files during the next week and start writing that documentation on Monday...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Mauno,

I created a demonstration page for this issue here:

This is an example of one reason I like the idea of Moodle for asciimath general support (general and not just Moodle based usage) in that it can support multiple scripts easily via different themes.... and the themes are user selectable....

The clue to this was the fact that the embedded version was producing the implied multiplication dot, while the plain asciimath was not.....

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

I got it functional yesterday but noticed too how changing one property of scripts easily drops another property - and when I got a functional calculator and asciimathml inside asciisvg I somehow lost plugin based graphs for IE...

It is possible to use different output for IE and maybe the ideal solution should use totally different file/script for IE from the beginning. My test site does not use all features right now - I try to change the scripts once more to give IE at least a tiny smiley instead of big empty box for those features that IE can't handle. After holidays I'll try to test some sort of script selector / activity that could allow you to select in a resource which scripts/properties are used and for which browsers.

In some cases IE could even code of google charts like this http://code.google.com/apis/chart/

(it would be interesting to create one plugin for these chart types too)

and if we need a solution for graphs that supports all browsers GD may be the only way to go - unless IE some day starts to support svg or have a functional plugin as a successor of Adobe svg player that is no longer maintained http://www.w3.org/Graphics/SVG/IG/wiki/SVG_Plugin_for_IE

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

By the way, I see the same dropdown issue using Moodle 1.9.3 and David's first version of asciimath2w/fallback, so this is not something introduced in pursuing SEE....

BTW, what are you thinking as far as debugging messages? Initially I wanted to include session cookies which would advise the user once that this or that needed to be fixed, but then would be totally transparent.... maybe we should stick with turning the kind of messaging david did on or off and just add call here and there to help figure out what is or is not running properly??

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Just experimenting with this plugin on my site and whilst it basically works it seems there is some CSS missing that is used in the Dragmath etx pop-up window as the buttons don't render the same as on your test site...

Any ideas?

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

The plugins are using yui tabs for tabs and custom css file inside plugin files and folders - I might have missed some file from the latest zip file - can you send some link, screenshot, environment etc.

I have been testing new code during the last days on my test site so it is not necessarely the same code as in that zip file - I can check it and update to my server tomorrow if something essential is missing.

The symbols in plugins can also render something else than the image map shows - it is possible to add any files with any symbols or examples to those tabs but I have been busy with the latest tests of using the features of asciimathml and asciisvg that are not supported by IE (and partly Opera).

I think I'll nail the basic functions today and will use experimental parts only with extra scripts in the future so that main plugins are cross browser compatible but you can still extend them in some themes or resourses with extra scripts that are separately loaded for FF and Webkit browsers & IE6-8

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Attached are a couple of screenshots of what I am seeing... It seems to work, but the interface is all over the shot...

http://twitpic.com/5y8m7/full
http://twitpic.com/5y8nm/full

Also noticed that whist the graphs display fine in the TinyMCE window they do not appear in the resulting page - Not sure if TinyMCE is istripping them out somehow as there is nothing left in the source for the page...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Looks strange - like language files from lang/en_utf8/ and css from /lib/yui/tabview/assets/skins/sam/tabviewdrag.css were not rendered at all...
and tinymce should read also XHTML rule set (/lib/editor/common/fullrule.php) from init code of theme/math/ ( editor1t.php ) that allows using of embed tags  like

<embed type="image/svg+xml" src="http://127.0.0.1/moodle195/lib/editor/common/d.svg" style="width: 300px; height: 200px; vertical-align: middle; float: none;" sscr="-7.5,7.5,-5,5,1,1,1,1,1,300,200,func,2sin(x)/x^2,null,0,0,,,red,1,none" class="ASplugin" />

which is the translated separately to IE and other browsers using sscr attribute

One reason could be broken javascript - if you have edited the files... I really have not seen this - my test environments are Windows Vista/local PC and Debian Lenny (linux) and I have tried IE6-7-8, FF2-3 and latest Windows versions of Safari, Opera and Chrome. But if you see the plugins correct on my test site it sounds like some local problem - is it Mac?

Marc,

one thing in calculator image fallback is sometimes annoying and slow - failures to render some button... I think I'll replace the basic button code with nice looking images and add some css to calculator... adding asciisvg is possible with normal ...tags but in resources you need to add \\\\ to get backslash inside ALO-tags to get fully functional latexmathml inside asciisvg - sounds complex but check the code of example resource. And in Opera you should not add html tags like <p>...</p> inside agraph and endagraph or Opera somehow can't render maths - otherwise Opera seems to work pretty well but it can't render asciimathml inside acsiisvg at all - I wonder why (some browser specific thing again  )

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Seems like it might be an issue with my shared hosting as I have intalled it on an WAMP install and the CSS all looks fine...

However I still can't get the graphs to display... Any ideas?

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

If you don't see graphs you might need to check first these settings either in AM.js (or corresponing file) or in theme meta.php if you have those variables there

var AScgiloc = "http://korpelainen.net/plugindemo/lib/editor/common/php/svgimg.php";//TeX Live and compile Mathtex to use it - see the links above

var dsvglocation = "http://korpelainen.net/"; // path to d.svg (blank if same as ASCIIMathML.js loc)

I have made some modifications to the latest files so that only emped tags with class="ASplugin" are checked - and IE will always show images. If you have Adobe SVG plugin installed images may fail to render as svg - that plugin is far from perfect and it accepts only certain tags (you should see white box then - that's why I force in latest versions IE to use always images - if you see the images in preview mode in plugin this might be the cause)

Next you could check if any images are stored to your local install /lib/editor/common/php/imgs or the folder you have named in lib/editor/common/php/svgimg.php to be the image folder - if there are no images you might need to change the permissions of that folder (unless you leave these two variables to store images to my test server...)

Third possible problem might be that something is really cutting embed tags - site setting, other plugin etc or tinymce is not using the init code from my files - I should see the code to be sure...

I will make only a couple of changes to files before June and try to get tomorrow the documentation and updated package to my site. Calculator looks better now with some "styling"  - it will be in the next package available. Otherwise these plugins can be modified used to create other kinds of plugins for adding something else than asciimathml, latexmathml or latex to moodle - stickers or stamps, unicode, some preformatted tags etc. My Safari is still having problems with dragmath plugins (stops responding while I add content) - it's mysterious but I guess I will find the cause if it does not come from latest Safari itself (some problems with Java?)

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Graphs display in the TinyMCE window and are stored in the php/imgs, so I'm guessing something is stripping out the embedd tags... I'll have an explore ans see what I can find...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Right found the culprit!
In Security > Site Policies > allowobjectembed

This setting needs to be enabled otherwise it won't work!

Final problem from my end is that whenever I try to submit something (e.g. forum post) susing the tinymce editor (even if it just contains text) it highlights it in red and says required...

Pressing post again works but it is a little odd...

Any thoughts on this one?

Thanks for all the help!

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Yes - it's a known effect/problem with theme based integrations and tinymce... I have not done any changes to core files of moodle but if you want to get this tiny effect away you should edit

/lib/formslib.php

find and change the line

var ret = true;

to

tinyMCE.triggerSave();
var ret = true;

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Thanks!

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

For those people who want to modify tinymce or use theme based integration without these plugins some more info:

Current (latest) version of TinyMCE included to http://korpelainen.net/mathplugins.zip is Version: 3.2.4.1

Modified plugins of tinymce:

asciimath
asciimaths
asciisvg
draglatex
dragmaths
latexmaths
moodleimage
preview (loads AM.js from lib/editor/common to preview mode)

and other standard plugins of tinymce included:

directionality
emotions
fullscreen
inlinepopups
nonbreaking
paste
safari
searchreplace
spellchecker
style
table

This is a sort of minimal package of latest tinymce - I have also taken files editor_plugin_src.js from each plugin away because they are just "work copies" of files editor_plugin.js that are the actual javascript files that tinymce uses

There is one tiny change to core tinymce code in lib/editor/tinymath/themes/advanced/js/source_editor.js where var "cleaning" replaces &amp; with & in source editor - otherwise source editor would mess matrix tags containing & - characters ( &amp; would become &amp;amp; and next &amp;amp;amp;... when you edit source code with tinymce )

tinyMCEPopup.resizeToInnerSize();

// Remove Gecko spellchecking
if (tinymce.isGecko)
document.body.spellcheck = tinyMCEPopup.editor.getParam("gecko_spellcheck");
var cleaning = tinyMCEPopup.editor.getContent({source_view : true});
cleaning = cleaning.replace(/&amp;/g,"&");
document.getElementById('htmlSource').value = cleaning;

setWrap('soft');
document.getElementById('wraped').checked = true;
}

resizeInputs();
}

TinyMCE of moodle 2.0 has some (youtube) modifications for media plugin if you want to use media plugin - I will add the media plugin to mathplugins package later but it is not included now because current code would cut embed tags that are used for graphs in asciisvg plugin and elsewhere in old style asciisvg.

And I will continue these discussions in "metapost"

http://moodle.org/mod/forum/discuss.php?d=124352

that will have the latest info about all these plugins.

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

I tried to upgrade to the latest version as our school machines have IE7 with the annoying AdobeSVG plugin (which cannot be disabled), but IE is still trying to display the graphs through AdobeSVG...

Did I need to change something other than replace AM.js?

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Find the problem, TinyMCE was stripping out the class tag that you added - not sure why as fullrule.php had it included...

extended_valid_elements : 'embed[class]',

and now it seems fine, have also got SVG script and mathtex installed locall now as well...

Thanks for all your hard work...

I have also done a basic nanogong integration with your tinymce editor if it's of any use to anyone...

Average of ratings: Useful (1)
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Thanks Andy. Mauno is on vacation and I am sure will address this when he gets back.... Other than that, what do you think is SEE? Too much? Too little? Usability? Functionality? Kitchen sink approach?

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

I like it, would probably not include 4 different ways to enter maths - but give each institution the choice is excellent (some admin page to select which tinymce plugins to enable or better yet a user setting!)

Love the SVG graphs! Brilliantly simple but really powerful!

All in a very impressive solution which works well across all the platforms I have tried it on...

With the dragmath-esc windows it needs to either not include the /alpha /beta or replace it when your first add something... afew times I have ended up with an extra alpha and beta at the start of whatever I was trying to write!

Next on my list of Mathematical integration is to try my hand at STACK, but I will carefully follow this project as it is a brilliant addition to Moodle and I hope we can get it in core...

I continue to maintain my concerns (as I did a year or so ago when we spoke about it) about doing the integration via themes rather than through a plugin/filter - I would really prefer a cleaner way to integrate it and the ability to easily turn it on/off for testing purposes...

But don't let that take away from what you have achieved!

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

well, I just discovered that petr is "fixing" dragmath as moodle core without apparently discussing what he us doing with anyone else, so I haven't a clue if any of this will see the light of day, and frankly I have been involved largely because the last guy took a pill (perhaps for the same reasons I am)

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG
I was not fixing DragMath originally, I ended up implementing full support for pluggable editors. Unfortunately there were several previous failed attempts all over the Moodle code base. At first I have to remove all obsolete and non working code, help with integration of repository file picker, fix language pack handling and solving many other issue along the way.

I did not expect I will need to rewrite everything, well I did and I am still not finished. There is not much to discuss now in relation to editors, I need to finish the integration with new formslib and file API and describe everything. Then we need to discuss handling of text formats and after that reimplement text format support in Moodle completely.

Any feedback is welcome, I will try to keep you more informed in future

Petr

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Mauno has been a veritable super man on this, marrying some new developments in asciimath with editors via an extensive plugin system..... Hopefully this will be the interface seen in moodle 2 ( without the $$alpha beta$$ LOL )

While I think Mauno agrees with you vis-a-vis a proper filter, and changes to usage of require_js may help address some of what suggested using asciimath via themes, I still like the just in time display as it does not result in filter conflicts and different flavors can easily be user selected via theme.

Of course, the more integrated the technology is, the more likely it will require modification and that is something we need to be careful of.

But, I have to agree that compared to how things are now, SEE presents a huge step forward, and with the use of something like Imathas, stack, or webworks takes moodle to a new level as far as math instruction....

I am hoping to find some high school kids needing community service cred for their college apps to do our state demo exit exam all in asciimath as a demonstration project.... We shall see whether I can close the deal. ;=}

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Hi Hauno.

I would like to install the AsciiMathML in my moodle site but I do not understand well which has to be the process to do it in an existing theme. I think that I have to upload the folders lib and lang, this is ok but, which files of my theme do I have to change and how? Is it difficult? Could you write a few lines helping me about this?

Thank you

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

- If you just want to use some version of ASCIIMathML for rendering maths all you need to do is to add tags like

<script type="text/javascript" src="pathtoyourscript/ASCIIMathML.js"></script>

- If you want to test my version with image fallback using Mathtex on my test server try to add to your theme meta.php

the following line

<script type="text/javascript" src="http://korpelainen.net/plugindemo/lib/editor/common/AM.js"></script>

alpha beta gamma you should see those characters or try corresponding tags using

$\alpha \beta \gamma$ (latexmathml)

or

$$\\$$ \alpha \beta \gamma $$\\$$ (latex) with and without tex filter to see the different results.

--------------------------

http://korpelainen.net/mediawiki/ has some examples about different renderers and test integration that allows you to use normal HTMLArea on your moodle site but also use tinymce in custom themes - compare the files of normal standard theme and math theme - theme config.php, meta.php and footer.html & editor*** files have the changes for editor integration. This whole system may change a lot during the next months - I have already made a different test version for moodle 2.0 that allows pluggable editors by default (thanks to Petr Skoda) and many new theme based things (thanks to Tim Hunt) which are not possible in moodle 1.9 but will be possible in moodle 2.0 after some months.

Read once all instructions from my test site mediawiki and if you need help in adding those tags to your theme send me email (it's in my profile) and a zipped copy of your custom theme - I can send you a package back with demo changes and better explanation...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Hi Mauno and Marc.

Thank you very much for yout help.

Best Regards

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Noticed some issues with latex today in this package... Was trying to draw a 4th root, which is written as $$\sqrt[4]{x}$$ in latex and renders fine in the fallback image script but doesn't render in mathml in FF...

Any ideas?

Also having a lot of issues with importing questions in Aiken format into moodle that involve latex, as when I edit it is loses all the answers that were previous entered... Anyone seen anything similar?

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Sorry forgot that it would change my code to tex!

\sqrt[4]{x}

Also quiz issues isn't just with imported questions, whenever I try to edit a question that uses latex in answers the answers get stripped out when saving...

It seems that AM.js is replacing the code with 'p align=' then the image outside the textbox so when you save it is changing all the answers to be 'p align='

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Andy,

asciimath does not use same syntax for nth roots, so are you saying that you are not getting correct results via the included latexmathml?

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Yep. I'm entering all my maths as Latex as I know that quite well...#

If I enter the code as  \sqrt[4]{x}  in the fallback image I get the forthroot of x but in FF where it is using MML it is displaying wrong...

So I assume the error is in latexmathml... Where should I look?

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

We are talking SEE right? I think Mauno stayed with dbldollars for latex, single dollars for latexmathml via asciimath and back ticks for straight asciimath and there addition spans that could be used as well

nth root has been a pain, perhaps that's why it's othen done $$x^1/n$$ but all tables for asciimath/asciimathml are in the actual js files; you can't miss them....

If I can get a bit more on on what you are actually using I may be able to nail it down, but Mauno was working on several things and in some he backed latexmathml out of asciimathml I think......

Almost best way to check things out is to do it on his test server, which is open for this purpose.... I will try and get on their and see what I can see....

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Yep we are talking SEE...

I've put my example in topic 6 of the testcourse mentioned in the first post so you can see what I mean... The problem with double dollars being strictly latex is that it forces the image to the centre and on to it's own line, so is no good for inline maths...

Also do you have any thoughts on the quiz problem I mentioned?

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Andy,

This has been a problem for some time, and I think it was discussed in the asciimath group because of wiki issues with square brackets as well, but I can't recall it was ever "fixed" (what I do recall is that we changed dragmath somehow and I will have to dig through the xml file to see what I did at the time.... - so I created some further explorations at http://korpelainen.net/plugindemo/mod/resource/view.php?id=23 and posted to the list as far as what David might recall about a solution.... asciimathml itself renders root(x) and LatexMathML will render x^1/n

As soon as I am sure where the parsing error is I will see abuot getting it tweaked....

As far as webworks, I have to wait for the Sears appliance repair man on Tuesday (they graciously provide a nine hour window.....) and so will have some time to look at conversion of a test bank I downloaded, but I do encourage you to download the wwmqt code from the svn in the link I provided and try the install, as that makes everything impossibly simple.... there was only one hitch and I think Michael Rich fixed that in March... I will also download the wwmqt and do a new install on one of my moodles....

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Yes Marc,

there are several problems involved: FF2 fonts, replacement of (square) brackets, different code/syntax for asciimathML/latexmathml/latex etc

On my test server TeX filter is enabled so tex works ok inside double dollars and renders $$\sqrt[4]{x}$$ (with Tex Live) and "forced image fallback" with double @:s works ok using

JeMTcgiloc (external image fallback which produces http://korpelainen.net/cgi-bin/mathtex.cgi?\gammacorrection{1.4}\sqrt[4]{x}  as $\gammacorrection{1.4}\sqrt[4]{x}$ )

Asciimathml root( 4 ) ( x ) works ok like you said but FF2 can have difficulties with fonts in MathML and I suppose latexmathml can't handle brackets correctly in this case...

Andy,

for the code produced by plugins I can only say that those plugins are really experimental test plugins that have several output options but the output choices given on my demo site are far from perfect. Those two plugins that have DragMath included should probably have only one output format available and all output from buttons should be preset... that's one of the tasks to be done during the coming months - I have just enjoyed too much about sunny weather and summer vacation...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Thanks! I can live with using @@ @@ when I need to do roots for now!

Not sure what was going on with the quiz as that seems to behaving itself now... Porbably an extra  somewhere causing it to try and render stuff!

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

I was testing a little more both old AsciiMathML and LatexMathML scripts and it looks like Nth roots with sqrt tags  ( other than tags like sqrt{2} ) have not worked correct in any previous version of those scripts.

I guess the original reason was that Peter J et al used sqrt for cases like sqrt{2} and other roots were ment to be done with root tags. I can change my code to parse also sqrt[4]{x} and $\sqrt[4]{x}$ correct but we would need to have some standard code for all versions of asciimathml and latexmathml - which is the best way/syntax to input roots like  \sqrt{2} - $$\sqrt{2}$$ and  \sqrt[4]{2} - $$\sqrt[4]{2}$$ ?

For root output root{4}{x} and \root{4}{x} work correct both in MathML and image fallback... and root will be replaced with \sqrt[4]{x} in image fallback.

root(4)(x) does work in asciimathml but \root(4)(x) does not work in latexmathml.

NOTE: I edited this post because the change I made to AM.js was not the proper one...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

I think it is best to rewrite different scripts for AsciiMathML, LatexMathML, AsciiSVG and Latex rendering - there are too many such issues that work differently in IE / FF vs AsciimathML / LatexMathML / Latex and inside AMATH/AGRAPH tags. Every time you change one thing you may loose another thing...

LatexMathML should use as pure LaTeX syntax as possible and if possible all those tags should work the same way in Mimetex and Mathtex fallbacks. I could try to turn everything upsidedown and try to build a system that uses TeX either with a new filter (modified TeX filter) or external TeX renderer for IE and translates the same tags only for FF as MathML. IE and FF could use different scripts all the time.

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Hi Any and Marc,

I was travelling 3 days in the eastern Finland so sorry for a late answer...

If you use AM.js or AsciiMathML.js to render TeX between double dollars and you don't want it to be aligned to center change lines

function simpleLaTeXformatting(st) {
st = st.replace(/\$\$((.|\n)*?)\$\$/g,"<p align=\"center\">$\\displaystyle{$1}$</p>"); ... to function simpleLaTeXformatting(st) { st = st.replace(/\$\$((.|\n)*?)\$\$/g,"${$1}$");

...

It's original code from AsciiMathML.js - not my code.

Roots have been problematic all the time and it's one of those reasons why I added double @:s (and disabled algebra filter) to force FF to use image fallback for roots - FF2 has those font issues with MathML and some parts of original LatexMathML are using different code than corresponding AsciiMathML parts...

PS. You can also use (enable) normal TeX filter to render TeX (notations inside double dollars) in cases like this and use latexmathml with dollars or asciimathml with ... for most parts. The main problem with LatexmathML and AsciiMathML is that neither one of these is rendering all Latex or all MathML tags perfectly so if you need perfect TeX you need to use TeX filter or external Tex for example with my mathtex/Tex Live combnation ( var JeMTcgiloc in script ) and to render perfect MathML you would need to render MathML as MathML - not translate it with parser scripts like asciimathml.js

Average of ratings: -
ASCIIMathML, LatexMathML and \sqrt[n]{x}

Andy,

LatexMathML's syntax does not support the optional argument syntax employed by Tex, so \root[n]{x} won't work. Instead, it deploys a "new" command which is consistent with the asciimathml syntax (which uses root(x)): \rootn(x)

See http://www.maths.nottingham.ac.uk/personal/drw/lm.html Item #6

Personally I think the root command makes more sense, but there ya go.....

Thanks to Paul Soares for helping me relocate the detail on this!

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

Well... it's not that simple...

It really depends on settings of the script and that version of latexmathml does not use image fallback. What works with one script does not work with another and in this case latexmathml of AM.js will fail with image fallback (IE)... or matrices will stop working...

In my opinion it does not matter if we use

\sqrt[ 4 ] { x } or \root4x or \root { 4 } { x } or \root ( 4 )( x ) or...

as long as we can handle the difference between roots like

$$\sqrt[4]{x}$$ and $$\sqrt[4x]{ }$$ and $$\sqrt{4x}$$ etc

In AM.js latexmathml part can understand any combination of root/sqrt tags with numbers, (...), {...} or [...] with and without image fallback if we just write the correct code for this but we can't do similar parsing for all of these bracket tags or can we?

Scripts should know without testing when and how to parse brackets in roots like $$\sqrt[3]{(x+4)}$$ or it is just simpler to use that syntax that you know best... or plugins should produce similar code for all cases.

So in my opinion latexmathml should render ( limited set of ) TeX syntax as TeX for IE and as MathML for FF (if possible) and we can use any kind of modified code in asciimathml to produce different input/output to make the syntax more user friendly or pure TeX for such cases that can't be rendered as MathML.

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

I don't disagree with you Mauno, just pointing out the history of the artifact....
However, use of square brackets by tex for this purpose has always been a problem when using in wiki, especially where nowiki code not implemented..... which in part brings one back to when anything is parsed.

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

It is important if possible that we allow correct rendering of Tex - as if people import tex or use MathType etc to create their code then it should correctly render...

However I can live with the odd hack as long as we can find a way to document it so people know!

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

I will test some new code for sqrt[n]{x} in latexmathml and asciimathml tomorrow - we may just need to check what we have after sqrt and add some new lines of code to AM.js for latexmathml part together with some additional replacement code... although the traditional asciimathml and latexmathml have used sqrt only for square root.

For image fallback pure TeX is perfect - you just output latex as it is but for MathML you need to create the new tags using standard rules and functions. On the other hand it is as well possible to replace root tags with sqrt tags for image fallback - when you know what to replace with what...

I agree with you Andy - particularly if we want to use AM.js to render also tex inside double dollars instead of TeX filter because in that case double dollars will be replaced with single dollars by function simpleLaTeXformatting and that function should at the latest parse all non latex tags to proper latex or image fallback will fail. Like the name says LatexMathML should use in input/output Latex and MathML...

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

Documentation has always been a bit of a nightmare, especially as there are so many flavors of this and that here and there.....

I think at the core we are always looking at bang for the buck as it were - how much functionality out for how much development in....

In the best of all worlds one would hope for total transparency based on syntax tables created with a consistent standard (one of the reason I like the effort by Alex vis-a-vis the xml tables for DragMath)

Mauno has really jumped into asciimath and I am sure will find a fix, but the flip side is that every tweak now echos through this and that as asciimath is a collage of a different code and there is no "HEAD" for asciimath yet, though there has been some discussion on the asciimath google group over this and SA has attemnpted a complete collection on his fullxml site.

To me there are a number of objectives possibly facing asciimath including implementing MathML and providing a simpler syntax than tex for math notation - an argument could be made that former would be more effectively done via LatexML (not to be confused with LatexMathML) and the latter via the webworks algebra syntax..... but I am not convinced..

We will have multiple syntax no matter what we do, so the best answer is to design a notational system for representing MathML that can parse any syntax based on tables created in a common system, and I think that is probably the best locus for development effort (though I would hate to see Mauno drop SEE to play with that - LOL)

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

Yes - and for me documentation has been the worst nightmare ( I barely remember myself what I have done during the past months... )

While testing the current script with IE8 Developer tools this morning (and getting errors with MathML node code) I thought again the possible separation of code right from the beginning and simply using different scripts for FF, IE and other browsers.

So no matter what the original AsciiMathML.js or LatexMathML.js does I will most likely split the AM javascript to editable variables (with administration menu and php), non editable functions, and smaller parts of code (separate code for different browsers and separate code for AsciiMathML, LatexMathML and AsciiSVG). In ideal case the end users should be able to select which syntax they want to use for their commands and fallback...and finally we have these MathPlayers, Wikis, exceptions in Resources ( \\ ), plugin settings, automathmodes and different filters that can mess up the whole thing...

And I really need to clean all unnecessary code from AM.js as well - and moodle 2.0 might need a new kind of AsciiMathML filter (based on TeX filter)

OK - back to work - LOL

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

Marc and Andy,

my demo site has now a little different version of AM.js that can parse \sqrt[]{x} correct and all nth roots with \sqrt[n]{x} correct both in asciimathml/latexmathml with or without image fallback but I still need to find out how to render plain square roots in MathML without that [] correct. The main problem is that MathML uses msqrt tag for square roots and mroot tag for nth roots and for some reason my code leaves one extra pair of {...} inside normal square root in latexmathml...it's hidden there somewhere...

I will update the whole package after some weeks - also Dragmath needs to be upgraded to mathplugins.zip

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

And attached AM.js for Andy (AM.zip) has a fix for rendering \sqrt[n]{x} and \sqrt{x} correct both in asciimathml and latexmathml (I had missed one line)

The only tiny problem left (that I noticed) with sqrt tags was in situations where you have syntax like

sqrt[4]{sqrt[4]{2x+3}} in asciimathml and current code fails to parse inner root correct in IE.

If you use \sqrt[4]{\sqrt[4]{2x+3}} it is parsed correct like $\sqrt[4]{\sqrt[4]{2x+3}}$ in latexmathml or latex as

$$\sqrt[4]{\sqrt[4]{2x+3}}$$

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

I created a wiki on the same topic in your demo site Mauno to demonstrate the issues that use of square brackets introduces (http://korpelainen.net/plugindemo/mod/wiki/view.php?id=25) - I had posted about this to Ludo vis-a-vis how nWiki might address such matters, but don;t know if this was ever considered (though my guess is that nowiki will be implemented in the nWiki - but my attempts to get nWiki running with Moodle 1.9.x all ran into trouble.....)

My perspective is that it makes much more sense to abandon use of sqrt root for nth roots in Tex, and for that matter even for square roots, as this is one of the only circumstances I believe where tex requires use of square bracket...... But I know that won;t happen any time soon..... but I do know that while I agree that usage should be seamless, this will result in forum postings as it has in the past - LOL

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

All good points, Marc.

I have not used Wiki of moodle for maths and the only tags that really worked in Wiki were those root tags of asciimathml:

root{4}{root{4}{2x+3}} wíthout square brackets - just like you said before.

In my opinion it is however much easier to require that new Wiki of moodle 2.0 should handle square brackets than require that all TeX users and distributions should start using root{n}{x} instead of sqrt[n]{x} because Wiki of moodle can't render square brackets correct...  ( at least the first versions of NWiki were capable to do this - I haven't tested the latest NWikis or Wiki of moodle 2 yet )

I guess we can allow parallel syntax to do the same things and change the code of these scripts so that both roots and sqrts work with certain extra tags.

The main release for all these math plugins will be moodle 2.0 (next year?) anyway and we will have workarounds for all this kind of special cases, right?

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

In mediawiki square brackets cause no problems and both sqrts and roots work ok with ..., dollars, double dollars or double @:s - a quick test

http://korpelainen.net/mediawiki/index.php/Roots

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

Mediawiki uses doubled square brackets for a link as opposed to erfurtwiki version used in moodle. I am hopeful that nwiki markup will be the same as
mediawiki markup, so that export from openoffice and other apps can be uniformly entered in both, but I am not holding my breath.

Initial nwiki rollout had template features I have not seen back, which would allow a teacher to create a multipage math workbook for each student, a process which us presently complicated by inability to export to erfurtwiki markup (though for anyone interested - Ian?? - I think I have an example I could share).

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

When you talk about IE are you referencing IE8 or prior versions?

Average of ratings: -
Re: ASCIIMathML, LatexMathML and \sqrt[n]{x}

IE8 - I haven't tested IE6 for a while but basicly it is possible to change mode in IE8 developer tools to test IE7 and IE6/5.5 with IE8...

In addition to Wiki special cases in moodle are resources that may strip one backslash and other filters & smileys...

I was testing today again that tiny modification in filter/tex/flter.php:

function tex_filter ($courseid,$text) {

global $CFG; if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox'))
{        return \$text;
} else {...old filter code...}

}

that uses enabled TeX filter for other browsers than Firefox together with AM.js (translateLaTeX = true;) and the whole system could be really simple if latexmathml would use normal TeX. Tex filter produces Tex for all other browsers than Firefox and AM.js translates the same code for MathML.

About week ago I tested also using HotEqn java applet as universal image fallback - the good point is that it works everywhere, even off line (with limited set of latex tags) but the bad point is that you need to set height and width for each applet tag and first applet is always rendered slowly in java.

Because external image fallback should be the last option to render maths if no other option is available advanced internal math filter ( = modified tex filter ) together with editable variables and input/output tables in moodle (with php) and MathML translation & Asciisvg scripts for FF in separately loaded scripts might be the next step forward.

I don't like the current code that checks everywhere if (isIE)...or if (!isIE)... I could as well let IE to use TeX filter directly with better/more complete LateXMathML and let Firefox to use MathML with LatexMathML. It still allows us to use different code for AsciiMathML inside ...` or two TeX filters with separate delimiters...

And we will still have many other open issues left with other browsers like Chrome, Opera or Safari but the main pain has always been and will always be IE

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

I am hoping to be able to use some of these mathml generating scripts in moodle for my course this fall. I am used to writing mathematical text using latex and I might also be interested in presenting graphs written in asciisvg.

I would use the university-wide moodle server so I can only ask the administrators of the server for things which I am sure will not break anything for other courses.

So, my idea is to ask the administrators to add a theme which is identical to the university moodle theme except that in meta.php a link to AM.js is added.

As for image fallback, I believe I can force my students to use firefox and install the STIX fonts so fallback is not needed and I would like to turn it off.

So, I have three questions:

1. Am I right in assuming that this will not change anything for users who don't use my theme?

2. The idea is to use AM.js rather than the other variants of asciimathml since it seems most actively updated and tuned to moodle. So even if I don't want the image fallback, AM.js would be the best choice. Is this wrong?

3. How can I turn of image fallback in AM.js?

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

My demo file AM.js is in an experimental state right now. It has many nice features combined but if you want to use a stable version with a little less functions and symbols select one of Peter Jibsen's or David Lippman's latest versions that you should find from this discussion:

If you use asciimathml in theme it does not change behaviour of moodle for those users that do not use that theme. So if you use asciimathml through course theme asciimathml javascript will render maths only on those courses that use this theme and it renders code in browser. Fallback images are saved to fallback server if you use MathTex with cache - cgi mimetex does not save any images to any server. In my demo site I have given custom smileys in theme config.php to avoid smiley conflicts - otherwise you would see sometimes smileys inside mathematical notations...

If you use an image fallback version and don't give value for variable AMTcgiloc fallback script can't work because it does not find any external fallback server or address. I am still planning to rewrite the whole script so that it would use directly Tex filter for latex fallback if possible and as second option some external image fallback like cgi mimetex, mathtex or MathTran from OU and directly different scripts for Firefox and MathML/SVG capable browsers but filter approach has some other issues for example with full screen editor so this option is not yet available...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG
Hi Stefan,

1. Am I right in assuming that this will not change anything for users who don't use my theme?

Correct.

2. The idea is to use AM.js rather than the other variants of asciimathml since it seems most actively updated and tuned to moodle. So even if I don't want the image fallback, AM.js would be the best choice. Is this wrong?

Not sure why you would want to turn off fallback. Wouldn't you want fallback just in case javascript is turned off in the browser? If nothing else, it's standard practice to have fallback.

3. How can I turn of image fallback in AM.js?

Again, I'm not sure why you would be worried about needing this turned off.

Hope this helps,

Ian.

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Or you can visit any "public page" using asciisvg examples, check the source to find out the address of that particular version of asciisvg.js or asciimathml.js, download, edit settings from the beginning of that script and test

For example if you need graphs like (note: use Firefox!)

http://www1.chapman.edu/~jipsen/svg/graphs/lines.html

or

http://www1.chapman.edu/~jipsen/svg/graphs/exponentials.html

visit

http://www1.chapman.edu/~jipsen/svg/ASCIIsvg.js

and you can see both source of those examples and the script rendering graphs from source. All versions of asciisvg need file d.svg to render svg (or corresponding file) or dsvglocation for that file if it is not in the same folder as asciisvg.js itself.

The main problem with all these scripts is that there are too many different versions available and they don't all use same tags or settings - some have image fallback some don't...

The best advantage of using themes is that even if scripts may be different you can use different versions of asciisvg or asciimathml for different courses through themes and can use old and new style asciisvg separately if they don't use same syntax...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

I was going to tell you that AM.js was still being tweaked, but Mauno got their first (and he is doing the tweaking - lol). There have been some very exciting developments (you can check out some of what has been done at asciimathml.com and asciimath googlegroup - the english version of the URL for the group is http://groups.google.com/group/asciimath) but I think it safest, especially considering your precatory remarks, that you stick with a version that is older but more stable, and I think that will help you convince your admin that subsequent upgrades will pose no further threat....

I put a URL for the asciimathml.js with fallback that I am currently using in production in the moodle docs which will work for you pending a more stable release. It is based on David's version with some incremental tweaks which means it is a bit newer than the last version that Peter posted. Just be sure to change the fallback if you will be using it. The URL is just to the one file, so you would have to download the current asciimath zip from sourceforge and then replace the asciimathml with the new file.

If you want, I could also zip you a complete package, as I had been working on that, that your admin can just place in your moodle root and unzip....

As Ian indicates, asciimathml is all client side and it won't have any impact on your site, though I would recommend turning off Tex if you will not be using it otherwise as there would be no need to run the page through the tex filter, though you can run the tex filter and asciimathml at the same time (you can experiment with the diffs between using single dollars, double dollars and backticks)

Average of ratings: -
Svar: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

First of all, I am really impressed by the possibilities of these scripts. I would like to contribute what I think is a bug report although I don't know if this is the right forum.

I set up a local moodle server using moodle4mac and installed the mathplugins.zip scripts. Playing around with it I wanted to create a graph using the asciisvg button in the tinymce editor. I entered two functions, "y=0.5x" and "y=0.8 x" (note the space between 0.8 and x). This worked well and I can view the html source in tinymce and it is

&lt;embed type="image/svg+xml" src="http://localhost:8888/moodle19/lib/editor/common/d.svg" style="width: 300px; height: 200px; vertical-align: middle; float: none;" sscr="-7.5,7.5,-5,5,1,1,1,1,1,300,200,func,0.5x,null,0,0,-7,7,black,1,none,func,0.8 x,null,0,0,-7,7,black,1,none" class="ASplugin" /&gt;

So I save it, do something else and come back to it to edit it except now the "y=0.8 x" line is gone from the picture in tinymce and the html source looks like this:

&lt;embed type="image/svg+xml" src="http://localhost:8888/moodle19/lib/editor/common/d.svg" style="width: 300px; height: 200px; vertical-align: middle; float: none;" sscr="-7.5,7.5,-5,5,1,1,1,1,1,300,200,func,0.5x,null,0,0,-7,7,black,1,none,func,0.8" class="ASplugin" /&gt;

Clearly everything after the space in the "sscr" variable has disappeared. As a workaround I can probably avoid spaces but I thought I might still report it.

Average of ratings: -
Re: Svar: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Yes it could be called a tiny bug. Plugin should probably either check allowed output format for functions ( y=0.8x is ok but y=0.8 x is not just like you said ) or spaces could be parsed as a part of notation

And spaces should be easy to remove from equations using javascript - when the plugin is next time upgraded...

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Hi just wondering is your demo site still open to the public because I used the test-test combination for login and it no longer works. Would love to take a look at it again

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Some "tester" from Salvador - Brazil had changed the test password ( Thu 23 July 2009, 10:02 PM ip ... ) and it should work again

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Hello Mauno, Hello all,

I visidet you site and was pleased to check and test googletex, geonext and all the tools implemented over there.

I am interested to  implement them on moodle 2.1. As the procedure outlined in the post is for moodle 1.9 could u please give an advice and help as to how we can adapt it for a moodle 2.1 or at least 2.0. It seems like the directories structure and files are very differents in the two versions.

Best regards

khaled

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Most of moodle 2 implementations are "ready" for - some bugs still exist and I could in fact publish the moodle 2 plugins pretty soon.

Since moodle 1.9 plugins I have made some modifications - for example asciisvg now works in IE9 - and I have been testing the optional way to use all the math tools together with filters, filter settings, editors, editor settings, themes, theme settings and al those various browsers that allways do something in some personal way. For example JSXGraphs need to use IE8 compatibility mode so if you want to use both asciisvg and jsxgraphs you can't get svg in ie9 because IE9 can't use current VML renderer of Jsxgraphs in IE9 mode... and IE9 can't use Geonext plugin in IE9 mode so I had to force IE9 to IE8 mode and let IE9 show images instead of svg in asciisvg scripts.

I have also tested recently a flash based editor plugin (FMath) in a mathML plugin and was able to create a filter that can render mathml in all activities a little same way as Wiris but with MathJax (cross browser compatible and does not require any images unless you want to see mathml in editor content...) and I created a new way to select image fallback for different renderers as a site wide filter setting so for example asciimath is now running from a php file which takes settings from math filter...

I am still spending my vacation (and my wife is busy to give me new tasks in garden...) so it may take still some time to collect all the pieces to documented packages but they are coming in the near future... ( I thing I have promised this now so many times that I have no other option than publish current files within 3 days - no matter if they are finished or not - so I will send the links to new files at the latest on Friday, 5th of this month )

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Hei Mauno,

Thanks for Mathplugin.

I have installed and number of renderer i got.

But it is not included in 'Module and Plugin' database.

Such nice thing should be included.

OK

Could we include MathJax in this Plugin ?

----------------

Happy Vaction.

Definitely we are waiting for MathPlugin for Moodle 2.x

Best Regards,

Ravi

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Well...so far most of my plugins have been a sort of demo plugins and "under development (for years, I know )"...

In new moodle 2 demo plugins I do have a couple of plugins using MathJax - you will see them tomorrow - some surprises will be included

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

Hi Mauno,

Can I integrate google drawing in this test plugin editor (http://korpelainen.net/plugindemo/mod/quiz/attempt.php?q=1)? I found this test plugin url in your previous post. So Please guide me to solve this problem.

My previous post url http://moodle.org/mod/forum/discuss.php?d=197446 plz have look

Thanks

Average of ratings: -
Re: Plugins for AsciiMathML, Latex(MathML) and AsciiSVG

You replied to an old post and I upgraded the 1.9 plugins last time about 2 years ago ... and also the plugins for moodle 2 have been upgraded since http://moodle.org/mod/forum/discuss.php?d=182627

I don't really know what kind of drawings you expect the students to draw but several tools / plugins can draw graphs if you need them. Both that old 1.9 package and the latest 2.X packages have a plugin that creates JSXGraphs with a Geonext applet and show them in any content if JSXGraph filter is enabled and the necessary scripts are in source or on page. Moodle 2 package in http://moodle.org/mod/forum/discuss.php?d=182627 has also a plugin for drawing graphs with asciisvg, wizard (plugin) for getting Google Charts code and Wiris CAS with graph option included (disabled by default since it requires a lisence after 1000 calculations but you can as well enable the Wiris filter and plugins if you plan to use them)