Opened 9 years ago

Closed 7 years ago

#1209 closed enhancement (fixed)

Equation Editor should be updated to use a newer version of asciimathml.js

Reported by: guest Owned by:
Priority: normal Milestone: 0.97
Component: Plugins Version: trunk
Severity: major Keywords:
Cc: marc@…, mharrisonline, ray, gocher

Description

I am using xinha in moodle with Equation Editor.

Things seem to work fine with the version published here. However, because the plugin was using version 1.4 of asciimathml.js, I tried to use the plugin with the current version of asciimathml.

While I initially thought that Equation was working fine with the current version of asciimathml.js (packaged as version 2.0.2 on sourceforge) there are at least two problems.

1) There is no preview available
2) returning to a document to re-edit results in prior equations being converted into mathml

My guess is that it would not take a great deal of effort to resolve the problem, but at this point it looks like it is beyond me.

As there may be some additional improvements to asciimathml.js forthcoming this summer, addressing the change from versin 1 to version 2 before then would be helpful.

Attachments (1)

dialog.html (17.6 KB) - added by guest 7 years ago.
popups/dialog.html of Xinha 0.95 with all my changes applied

Download all attachments as: .zip

Change History (7)

comment:1 Changed 8 years ago by douglas

  • Milestone changed from 0.96 to 0.97
  • Summary changed from Equation Editor has issues with updated asciimathml.js to Equation Editor should be updated to use a newer version of asciimathml.js
  • Type changed from defect to enhancement

comment:2 Changed 7 years ago by gogo

  • Cc mharrisonline ray gocher added

comment:3 Changed 7 years ago by gogo

Original development was in #877

I see the new ASCIIMathML is LGPL from the get-go, so just needs somebody familiar with this to bring it across.

Changed 7 years ago by guest

popups/dialog.html of Xinha 0.95 with all my changes applied

comment:4 Changed 7 years ago by guest

I have worked on this too, and have gotten it working with ASCIIMathML 2.0.2. Here's the changes I had to make:

  1. Replace xinha/plugins/Equation/ASCIIMathML.js with the official 2.0.2 version from http://mathcs.chapman.edu/~jipsen/mathml/ASCIIMathML.js
  2. Add this just below the script tag in popups/dialog.html:
    // START - Added for compatibility with ASCIIMathML 2.0
    var AMtranslated = false;
    // Next 2 functions copied from ASCIIMathML 1.4.7
    function AMcreateElementXHTML(t) {
      if (isIE) return document.createElement(t);
      else return document.createElementNS("http://www.w3.org/1999/xhtml", t);
    }
    function AMinitSymbols() {
      var texsymbols = [], i;
      for (i=0; i<AMsymbols.length; i++)
        if (AMsymbols[i].tex) 
          texsymbols[texsymbols.length] = {input:AMsymbols[i].tex, 
            tag:AMsymbols[i].tag, output:AMsymbols[i].output, ttype:AMsymbols[i].ttype};
      AMsymbols = AMsymbols.concat(texsymbols);
      AMsymbols.sort(compareNames);
      for (i=0; i<AMsymbols.length; i++) AMnames[i] = AMsymbols[i].input;
    }
    // END - Added for compatibility with ASCIIMathML 2.0
    
  3. In the same file, in the preview() function, change:
          outnode.appendChild(document.createComment("`"+str+"`"));
    

to:

      outnode.appendChild(document.createTextNode("`"+str+"`"));
  1. Optionally, in ASCIIMathML.js, change var mathcolor = "blue"; to var mathcolor = ""; unless you prefer seeing your formulas in blue.

Everything appears to be working as it was with the older version of ASCIIMathML except that in the live preview the trailing and preceeding $$ are not ignored and are visible in the equation now. So if you're entering LaTeX equations then don't enter the $. In the old version it would break if you entered an odd number of $ but work if you entered an even (or no) $s. Pretty wierd.. I think this new behavior is better.

I've also attached a modified dialog.html from Xinha 0.95 slightly before this post if anyone wants to quickly give it a run.

Niraj Bhawnani
Research Assistant
University of New South Wales.

comment:5 Changed 7 years ago by guest

  • Component changed from Xinha Core to Plugins
  • Owner gogo deleted

comment:6 Changed 7 years ago by gogo

  • Resolution set to fixed
  • Status changed from new to closed

Thank you for your submission, this is committed in changeset:1254

Note: See TracTickets for help on using tickets.