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

Mathjaxloader filter breaks nested Latex math environments

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Moodle filters are used in most places in which users may add formatted text, for example, in the course section summary.

      Initial setup

      1. The MathJax filter must be active in the site with the default settings (Site administration -> Plugins -> Filters)

      Testing

      1. Start editing a course section summary
      2. We will try different kinds of math inputs and check that they are rendered correctly in the course page. The Moodle HTML editor should be switched to the HTML mode so that you can copy-paste the examples directly into the editor. (The HTML </> button shows in the editor toolbar when the second row of tools is also shown.) For each case, save the changes and check that the course page looks correct.
        1. Inline \( x_2 = y \) and display \[ h = t^2 \]
          

          Ensure that one inline and one display formula are rendered.

        2. Display $$ h = t^2 $$ and inline \( x_2 = y \)
          

          Ensure that one display and one inline formula are rendered.

        3. Nested

          \[ 
          \newcommand{\False}{\mathsf{F}} 
          \newcommand{\NullF}{\fbox{\(\False\)}} 
          \]
          Text with inline formula using the custom LaTex macro \( a = \NullF \)
          

          Ensure that one inline formula is rendered and the letter F is inside a box. The display formula leaves some visible vertical whitespace on the screen.

        4. Nested and some more content

          \[ 
          \newcommand{\False}{\mathsf{F}} 
          \newcommand{\NullF}{\fbox{\(\False\)}} 
          \]
          Text with inline formula using the custom LaTex macro \( a = \NullF \). Now we add a display formula: $$ b = \NullF $$
          

          Ensure that one inline formula is rendered and the letter F is inside a box. The first display formula leaves some visible vertical whitespace on the screen. Ensure that the second display formula (at the end of the text) renders "b equals F-box".

        5. Complex content

          Testing math. Simple inline math first: \( x_2 = y^3 \).
          \[ 
          \newcommand{\False}{\mathsf{F}} 
          \newcommand{\NullF}{\fbox{\(\False\)}} 
          \newcommand{\Fp}{\fbox{\(\False_p\)}}
          \]
          Writing some content with math. Inline formula \( a = \NullF \).
          Display math next:
          $$ b = \NullF $$
          Simple inline math again \( k = a * x_i \).
          Display math \[ c = \Fp \]
          

          Ensure that the formulas are rendered correctly: one basic inline, empty display formula (whitespace), inline a equals F-box, display b equals F-box, simple inline, and display c equals Fp-box.

      Show
      Moodle filters are used in most places in which users may add formatted text, for example, in the course section summary. Initial setup The MathJax filter must be active in the site with the default settings (Site administration -> Plugins -> Filters) Testing Start editing a course section summary We will try different kinds of math inputs and check that they are rendered correctly in the course page. The Moodle HTML editor should be switched to the HTML mode so that you can copy-paste the examples directly into the editor. (The HTML </> button shows in the editor toolbar when the second row of tools is also shown.) For each case, save the changes and check that the course page looks correct. Inline \( x_2 = y \) and display \[ h = t^2 \] Ensure that one inline and one display formula are rendered. Display $$ h = t^2 $$ and inline \( x_2 = y \) Ensure that one display and one inline formula are rendered. Nested \[ \newcommand{\False}{\mathsf{F}} \newcommand{\NullF}{\fbox{\(\False\)}} \] Text with inline formula using the custom LaTex macro \( a = \NullF \) Ensure that one inline formula is rendered and the letter F is inside a box. The display formula leaves some visible vertical whitespace on the screen. Nested and some more content \[ \newcommand{\False}{\mathsf{F}} \newcommand{\NullF}{\fbox{\(\False\)}} \] Text with inline formula using the custom LaTex macro \( a = \NullF \). Now we add a display formula: $$ b = \NullF $$ Ensure that one inline formula is rendered and the letter F is inside a box. The first display formula leaves some visible vertical whitespace on the screen. Ensure that the second display formula (at the end of the text) renders "b equals F-box". Complex content Testing math. Simple inline math first: \( x_2 = y^3 \). \[ \newcommand{\False}{\mathsf{F}} \newcommand{\NullF}{\fbox{\(\False\)}} \newcommand{\Fp}{\fbox{\(\False_p\)}} \] Writing some content with math. Inline formula \( a = \NullF \). Display math next: $$ b = \NullF $$ Simple inline math again \( k = a * x_i \). Display math \[ c = \Fp \] Ensure that the formulas are rendered correctly: one basic inline, empty display formula (whitespace), inline a equals F-box, display b equals F-box, simple inline, and display c equals Fp-box.
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE
    • Pull from Repository:
    • Pull 3.5 Branch:
      MDL-61981-35_nestedmath
    • Pull Master Branch:
      MDL-61981-master_nestedmath

      Description

      Normally in Latex and MathJax, it is possible to use nested math environments, i.e., \( inside a \[ block. The Moodle filter mathjaxloader breaks that usecase by adding <span class="nolink"> elements around the inner math environment, which is not allowed since it is still inside the outer math environment and HTML markup does not work there.

      Example: write text in a Moodle course section

      Testing math.
       
      \[
      \newcommand{\False}{\mathsf{F}}
      \newcommand{\NullF}{\fbox{\(\False\)}}
      \]
       
      Writing some content with math. Inline formula \( a = \NullF \)
      

      The Latex macro definitions are broken since Moodle adds span HTML elements inside it.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                12/Nov/18

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m