How to disable mathjax preview in atto?

How to disable mathjax preview in atto?

by Éva Rácz -
Number of replies: 10

Hello All,

I am upgrading from 2.2 to 3.0, and experiencing some problems with atto and formulas.

There are no problems if I simply create a new question and include some formula (by simply typing the equation and not with the eq editor) and then save it.
If, however, I reopen that same question for editing later, the previous formula doesn't appear as a tex code but a pretty preview and the html source contains a very long span starting with <span class="MathJax_Preview">. When I try to add another formula to the question text it becomes completely messed up, and even the original formula is changed (font type and size) if this new version is saved.

I'm not sure whether this is an issue with atto. Is there a way to disable equation preview in the editor? So basically when I am editing I'd like to see the tex code but no html code. (In 2.2 there were no problems with this, although there were problems with tinyMCE messing up multilang content. In any case, I think it's not reasonable to expect that every teacher/question creator should resort to using "plain text area" as their text editor).

I attached the text files containing the html source of the question and screen shots of the results (and in case it is the actual culprit, my mathjax config). I created the original question using the plain text area editor to make sure that nothing is modified at the first save, then changed the editor to atto when I reopened the question.

Thank you for any insight into this problem.
Average of ratings: -
In reply to Éva Rácz

Re: How to disable mathjax preview in atto?

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers
Are you using the MathJaxfilter that is part of Moodle 2.7+ or do you have MathJax include in the header using the Site administration->Appearance->Additional HTML setting?
In reply to Daniel Thies

Re: How to disable mathjax preview in atto?

by Robert Northcutt -

I am having the same issue when editing questions. This is only an issue when the Atto Equation Editor has been added to the editing menu. If I remove the equation editor (and type LaTex directly) there is no issue. This is fine for me but will be an issue for my students who do not know LaTex and need the equation editor when creating posts involving mathematics.

I am currently using the MathJax filter in Moodle 3.1. Can the MathJax preview be disabled in the editor?

In reply to Robert Northcutt

Re: How to disable mathjax preview in atto?

by Robert Northcutt -
I updated to  3.1+ (Build: 20160701) this morning and the issue I was having with the Atto Equation Editor while editing Questions seems to have been resolved.


Now, when I edit a question I see the LaTex embedded in the question (not a preview). Additionally, if I select the LaTex and then click on the Atto Equation Editor, it opens the editor and displays the LaTex and the preview. When I exit the Equation Editor, the updated LaTex is embedded in the question. Perfect!


Thank you.

In reply to Robert Northcutt

Re: How to disable mathjax preview in atto?

by Robert Northcutt -

Sorry. I was overly optimistic. If the Atto Equation Editor is used when editing an existing question the equation is shown as a preview and you are unable to edit the equation (unless you want to go into the HTML and wade through the MathJax tags). The only real solution is delete the equation and reenter - which is very annoying if you only want to make simple LaTex updates.

It would be really nice to be able to disable the MathJax preview and edit he LaTex directly OR be able to select the MathJax preview and open in the Atto Equation Editor for editing. I can do neither at this point.

In reply to Robert Northcutt

Re: How to disable mathjax preview in atto?

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

Robert,

There is not suppose to be a preview of mathematics within the Atto editor field. It is only supposed to be previewed within the equation editor. I have had this happen on occasion, and it usually has something to do with a misconfiguration of MathJax. MathJax is rendering the TeX expression in the editor when it is not suppose to.

Are you using the MathJax filter that came with Moodle or are you including MathJax in the headers so how? If you are using the filter, have you changed the default configuration? Does this happen everywhere in Moodle or just editing questions? or even a particular question type?

You may try configuring and using the TeX notation filter instead of MathJax. This is compatible with the Atto equatiion editor and will not process the editor content accidentally. You may also try adding tex2jax: {ignoreClass: "editor_atto_content"} to your MathJax configuration. (see MathJax Documentation)

Average of ratings: Useful (1)
In reply to Daniel Thies

Re: How to disable mathjax preview in atto?

by Robert Northcutt -

Daniel, thank you for your response. I ended getting things to work but not sure that I fully understand what I have done. Additionally, I needed to include the MathJax included in Additional HTML to get formatted equations to appear in multiple choice question answers. I needed to have the MathJax filter enabled in order to get the Atto Equation editor to appear in the editing window.

Here are the final version of the configurations that seem to work for me.

MathJax Configuration

Average of ratings: Useful (1)
In reply to Robert Northcutt

Re: How to disable mathjax preview in atto?

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

The Additional HTML is what is causing the problem with the editor. A better solution might be using the embedded answer (cloze) question using MULTICHOICE_V subquestion. This question type is compatible with the MathJax filter.

In reply to Daniel Thies

Re: How to disable mathjax preview in atto?

by Robert Northcutt -

All of my multi-choice questions are "calculated" multi-choice questions with multiple variants. So, I do not think the cloze question is a workable alternative (I don't want to create 20 versions of the same question).

This configuration WORKS (the Atto Equation Editor is behaving correctly and the answers for the calculated multi-choice questions are being properly formatted with MathJax) . Originally, when it was not working, I was trying one or the other. So, for now, my problem seems to be solved.

In reply to Daniel Thies

Re: How to disable mathjax preview in atto?

by Björn Bettzüche -

I had the same Problem with Atto and the MathJax filter. I configured the filter as proposed by the Stack Documentation for theire question type plugin. But instead of using additional HTML, like propesed by doc, I used the filter settings:

MathJax.Hub.Config({
    MMLorHTML: { prefer: "HTML" },
    tex2jax: {
        displayMath: \[', '\\]'">'\\[', '\\]',
        inlineMath:  \(', '\\)'">'\\(', '\\)',
        processEscapes: true
    },
    TeX: { extensions: ['enclose.js'] }
});

Thanks Daniel, your suggestion fixes the problem, except that the preview of the equation editor doesnt work anymore:

MathJax.Hub.Config({
    MMLorHTML: { prefer: "HTML" },
    tex2jax: {
        displayMath: \[', '\\]'">'\\[', '\\]',
        inlineMath:  \(', '\\)'">'\\(', '\\)',
        processEscapes: true,
        ignoreClass: "editor_atto_content"
    },
    TeX: { extensions: ['enclose.js'] }
});

In reply to Björn Bettzüche

Re: How to disable mathjax preview in atto?

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

I believe that Robert configured MathJax in the header and also in the filter. There is some code in the equation editor that tells MathJax to update that may not work if the filter is not configured.

Alternatively one could configure the TeX notation filter for use in the equation editor. One could also try Mathslate for Atto if  you can install a plugin. It is compatible with MathJax in additional HTML. No filter is required.