Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-43856

Add a mathjax filter

XMLWordPrintable

    • MOODLE_27_STABLE
    • MOODLE_27_STABLE
    • MDL-43856-master
    • Hide
      • Enable this filter and put some tex commands between $$ markers in some content.
      • Make sure the tex is processed into a nice equation.
      • Try the Atto equation editor with this filter enabled instead of the tex one.
      • Verify it looks much better with this filter.
      • Change your site to use https
      • Verify the filter keeps working
      • Test the filter in some browsers (ie 9-11 + firefox + chrome + android)
      • Make sure the texfiltercompatibility flag is turned on in the filter
      • Manually enter some text using some delimiters supported by the tex filter:

         \[ fdsa \]
         [tex] blafdas [tex]
         <tex> blah </tex>
        

      • Make sure they are replaced in a page and can be edited in the equation editor (the delimiters should be preserved when editing an equation - except <tex> gets mapped to [tex] - thats intended).
      • Make sure the texfiltercompatibility flag is turned off in the filter

        Test that \[ blah \] is shown as a "display" equation (like block)
        Test that \( blah \) is shown as a "inline" equation (like span)
        

      • Setup the glossary auto link filter
      • Create a glossary entry with an equation in it
      • Create another entry with a word that will link to the first entry
      • Check that when the autolink filter runs, the popup displays the equation typeset with mathjax
      • View only the second glossary entry (the one that auto links to the first). Make sure there are no other equations in the page. Verify (using browser dev tools) that the external mathjax library only loads when the popup is opened and that the equation in the popup displays correctly.
      • Download a local copy of mathjax and unzip it to a folder in your webroot.
      • Update the filter settings to point to your local copy of the library.
      • Verify the filter still works.
      • Change your language to hebrew
      • Open the right click menu on an equation and verify it's in hebrew

      Test that AsciiMath can be enabled in this filter.

      • Edit the MathJax configuration to this:

        MathJax.Hub.Config({
        config: ["MMLorHTML.js", "Safe.js"],
        jax: ["input/TeX","input/MathML","input/AsciiMath","output/HTML-CSS","output/NativeMML"],
        extensions: ["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js","asciimath2jax.js"],
        TeX: {
        extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
        },
        menuSettings: {
        zoom: "Double-Click",
        mpContext: true,
        mpMouse: true
        },
        errorSettings: { message: ["!"] },
        skipStartupTypeset: true,
        messageStyle: "none"
        });
        

      • Add ` as an additionaldelimiter
      • Put an asciimath equation in a page

        My equation is `int_0^1f(x)dx`
        

      • Verify it is rendered nicely
      Show
      Enable this filter and put some tex commands between $$ markers in some content. Make sure the tex is processed into a nice equation. Try the Atto equation editor with this filter enabled instead of the tex one. Verify it looks much better with this filter. Change your site to use https Verify the filter keeps working Test the filter in some browsers (ie 9-11 + firefox + chrome + android) Make sure the texfiltercompatibility flag is turned on in the filter Manually enter some text using some delimiters supported by the tex filter: \[ fdsa \] [tex] blafdas [tex] <tex> blah </tex> Make sure they are replaced in a page and can be edited in the equation editor (the delimiters should be preserved when editing an equation - except <tex> gets mapped to [tex] - thats intended). Make sure the texfiltercompatibility flag is turned off in the filter Test that \[ blah \] is shown as a "display" equation (like block) Test that \( blah \) is shown as a "inline" equation (like span) Setup the glossary auto link filter Create a glossary entry with an equation in it Create another entry with a word that will link to the first entry Check that when the autolink filter runs, the popup displays the equation typeset with mathjax View only the second glossary entry (the one that auto links to the first). Make sure there are no other equations in the page. Verify (using browser dev tools) that the external mathjax library only loads when the popup is opened and that the equation in the popup displays correctly. Download a local copy of mathjax and unzip it to a folder in your webroot. Update the filter settings to point to your local copy of the library. Verify the filter still works. Change your language to hebrew Open the right click menu on an equation and verify it's in hebrew Test that AsciiMath can be enabled in this filter. Edit the MathJax configuration to this: MathJax.Hub.Config({ config: ["MMLorHTML.js", "Safe.js"], jax: ["input/TeX","input/MathML","input/AsciiMath","output/HTML-CSS","output/NativeMML"], extensions: ["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js","asciimath2jax.js"], TeX: { extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"] }, menuSettings: { zoom: "Double-Click", mpContext: true, mpMouse: true }, errorSettings: { message: ["!"] }, skipStartupTypeset: true, messageStyle: "none" }); Add ` as an additionaldelimiter Put an asciimath equation in a page My equation is `int_0^1f(x)dx` Verify it is rendered nicely
    • 40
    • FRONTEND Sprint 11

      A demo mathjax filter was added to the prototype.moodle.net text editor demo. This is a pretty good implementation, but there are 2 problems with it.

      1/ The full mathjax library is hundreds of megabytes (fonts) - it's just too big to include the whole thing in Moodle. So - some fonts were stripped etc to keep the size of that one down - and it was still over 30MB. An alternative is to use the CDN mathjax library by default - and provide a method to download and install the full version into moodledata for people who require it (firewall/proxy etc).

      2/ It does things properly (moodley) by wrapping the mathjax library a yui module and including it from the footer. This means that the loading of mathjax does not block the rest of the page displaying. The downside is that the alternative method of installing mathjax is to link to it in additionalhtmlhead. This includes mathjax earlier, so the equations on the page are rendered earlier - and some people prefer that option. Maybe there is an alternative way of including it that will load it earlier.

      3/ However it is loaded/linked etc. In the forum samples I have seen, it is linked to from the head with almost a default configuration. This is a XSS risk - the tex allows some tokens which can produce e.g. javascript after rendering. MathJax has an option specifically for disabling those dangerous commands and this needs to be enabled.

            Votes:
            2 Vote for this issue
            Watchers:
            20 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.