Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathJax not working properly with speaker notes #1726

Open
DL6ER opened this issue Oct 13, 2016 · 5 comments
Open

MathJax not working properly with speaker notes #1726

DL6ER opened this issue Oct 13, 2016 · 5 comments

Comments

@DL6ER
Copy link

DL6ER commented Oct 13, 2016

Whenever I try to use LaTeX on speaker notes, the output is different from what I expect: The "raw" input is always shown next to the (correctly) rendered math although it should be hidden.

Example 1 (single $):

<aside class="notes">
 <ul>
  <li>Continuous level</li>
  <li>Discrete level. $m,n > 0$, scheme-dependent.</li>
 </ul>
</aside>

screenshot_speakernotes

Example 2 (double $):

<aside class="notes">
 <ul>
  <li>Continuous level</li>
  <li>Discrete level. $$m,n > 0$$, scheme-dependent.</li>
 </ul>
</aside>

screenshot_speakernotes2

@DL6ER
Copy link
Author

DL6ER commented Oct 20, 2016

Update: The generated HTML source reads:

<span class="MathJax" id="MathJax-Element-9-Frame" tabindex="0" data-mathml="<math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;><mi>m</mi><mo>,</mo><mi>n</mi><mo>&amp;gt;</mo><mn>0</mn></math>" role="presentation" style="position: relative;">
<nobr aria-hidden="true"><span class="math" id="MathJax-Span-223" role="math" style="width: 4.071em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.835em; height: 0px; font-size: 106%;"><span style="position: absolute; clip: rect(1.359em 1003.78em 2.538em -999.997em); top: -2.179em; left: 0.003em;"><span class="mrow" id="MathJax-Span-224"><span class="mi" id="MathJax-Span-225" style="font-family: MathJax_Math; font-style: italic;">m</span><span class="mo" id="MathJax-Span-226" style="font-family: MathJax_Main;">,</span><span class="mi" id="MathJax-Span-227" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.18em;">n</span><span class="mo" id="MathJax-Span-228" style="font-family: MathJax_Main; padding-left: 0.298em;">&gt;</span><span class="mn" id="MathJax-Span-229" style="font-family: MathJax_Main; padding-left: 0.298em;">0</span></span><span style="display: inline-block; width: 0px; height: 2.185em;"></span></span></span><span style="display: inline-block; overflow: hidden; vertical-align: -0.247em; border-left-width: 0px; border-left-style: solid; width: 0px; height: 1.066em;"></span></span></nobr>

<span class="MJX_Assistive_MathML" role="presentation"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>m</mi><mo>,</mo><mi>n</mi><mo>&gt;</mo><mn>0</mn></math></span></span>

So, the MJX_Assistive_MathML is not hidden as it should be (and is within the presentation itself).

@Elliot2560
Copy link

Elliot2560 commented Apr 13, 2017

I am experiencing the same issue, except that the math is not even correctly rendered in my case.

benni336 added a commit to benni336/reveal.js that referenced this issue Jun 19, 2017
Mathjax-Assist- span was not hidden in Notes.

CSS-style from main part was inserted.
Fixes Issue hakimel#1726.
@benni336
Copy link

@DL6ER Pointed it already out. Maybe not a nice solution. But it works.

@rschmehl
Copy link
Contributor

rschmehl commented Feb 7, 2018

The described procedure does not work for me.
What does work is placing this code in the file plugin/math/math.js:

"AssistiveMML": {
	disabled: true,    
},

See also http://docs.mathjax.org/en/latest/options/extensions/assistive-mml.html

mbotsch pushed a commit to mbotsch/reveal.js that referenced this issue Apr 20, 2019
Switch to MathJax' CommonHTML renderer, involving these changes:
- switch to latest mathjax version (2.7.5) and use
  TeX-AMS_CHTML-full as default configuration
- disable mathing of font height, as it causes problems both in
  the new CommonHTML and the previous HTML-CSS (issue hakimel#2105)
- disable AssistiveMML, since it duplicated math equations in
  speaker notes (issue hakimel#1726)
- use the new Promise mechanism to ensure that equations are
  properly typeset before emitting 'ready' in PDF export (issue hakimel#2256)
@mitchnegus
Copy link

mitchnegus commented Jan 20, 2021

I just ran into this problem again; duplicate math text still seems to be present in speaker notes. As an update for anyone finding this from now on, it should be noted that @rschmehl's solution disabling AssistiveMML should now be placed in plugin/math/plugin.js.

Given that math config options can now be set within the Reveal.initialize method, an even better solution would probably be just to set AssistiveMML : {disabled: true} there. Perhaps a note about this should be added to the docs (with the caveat that by disabling "AssistiveMML" screen readers will no longer see the MML text)?

I was a bit curious about where this artifact orginated from, and it seems to be due to the fact that speaker notes written in an <aside class="notes"> block are captured using the innerHTML property in the notes plugin:

/* plugin/notes/plugin.js */

// Look for notes defined in an aside element
if( notesElement ) {
  messageData.notes = notesElement.innerHTML;
  messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string';
}

It seems like this may be stripping the normal formatting that MathJax uses to hide the "AssistiveMML" text (suggested by this StackOverflow discussion). A workaround could be to reconfigure the notes plugin to import the DOM elements straight from the original document, rather than just piping the HTML text into the speaker notes pop-up. (Unfortunately, it seems like the nodes themselves can't just be sent through the existing postMessage method, due to restrictions on the structured clone algorithm... I'm no JS expert, so maybe there is an obvious fix for this.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants