LaTeX in prologuehtml not processed by MathJax

LaTeX in prologuehtml not processed by MathJax

by Neil Strickland -
Number of replies: 2

I have a question using a combinator template grader where the question statement contains some LaTeX (enclosed in round brackets with backslashes) and the prologuehtml element in the grader return value also contains LaTeX.  I have the MathJax filter enabled, and this converts the LaTeX code in the question statement to mathematical notation.  However, the LaTeX code in the prologuehtml is not converted.   This seems to be because the question text somehow automagically gets wrapped in <span class="filter_mathjaxloader_equation">...</span>, whereas the prologuehtml does not.  This wrapping seems to be done by the filter() method of the class filter_mathjaxloader defined in moodle/filter/mathjaxloader/filter.php.  However, I have not been able to understand what controls the application of that method.  On the other hand, I have other questions using the STACK plugin where the specific feedback field contains LaTeX and MathJax processes it, so there is apparently no fundamental obstruction there.  Does anyone have any ideas about this?  

In reply to Neil Strickland

Moved to Github issue tracker

by Neil Strickland -

I have reported this (with additional details) at https://github.com/trampgeek/moodle-qtype_coderunner/issues/182 which I now think is a better place for it.

In reply to Neil Strickland

Re: Moved to Github issue tracker

by Richard Lobb -

I'll answer in both places as I think people searching for the issue are more likely to land up here.

Thanks for reporting. It is a bug in CodeRunner, exactly as your github posting identifies. I have a tentative fix, but I want to see if it creates any new problems before releasing it.

In the meantime, here's a workaround (slightly ugly).

  1. Make sure that the JavaScript mathjax filter code is loaded on the page by including a hidden span with some mathjax code in it. For example (editing in raw HTML mode):
    <span style="display: none;">\(x = 1\)</span>
  2. Wrap your LaTeX equation in the MathJax span you identified above: <span class="filter_mathjaxloader_equation">...</span>

Alternatively, if you want to live on the bleeding edge, you could checkout the development branch on github. Probably you'd only want the latest commit (to renderer.php) addressing this bug as some of the other changes are work-in-progress.