# TeX annotation in MathML output mode should be XML escaped #935

Closed
opened this issue Oct 14, 2014 · 9 comments

Projects
None yet
4 participants
Contributor

### physikerwelt commented Oct 14, 2014

 It would be nice if the TeX annotation generted in the MathML output would be XML escaped. Otherwise, XML validation tools might cosinder the characters & < >... to be invalid. In https://gerrit.wikimedia.org/r/#/c/166556/ provides a workaround for most cases, but if the TeX string contains "" we could have a problem with the woraround. As far as I know this is a MathJax and not a MathJax node bug, but feel free to move the bug if I'm wrong.
Contributor Author

### physikerwelt commented Oct 14, 2014

 I think it sould be fixed here. https://github.com/physikerwelt/MathJax/blob/master/unpacked/extensions/toMathML.js#L164 However, I don't know how if there is already an XML escaping methoid build into mathjax that could be used. @dpvc: Is there a method for XML escaping?
Member

### pkra commented Oct 14, 2014

 The reason is probably that we didn't expect MathJax-node, i.e., the only application would be "Show Source" in the menu. Here's what it's doing https://github.com/physikerwelt/MathJax/blob/master/unpacked/extensions/MathMenu.js#L760-L761 IIUC the best practice within XML is to use CDATA (e.g., http://jats.nlm.nih.gov/archiving/tag-library/1.1d1/n-skz0.html) but that wouldn't work in an HTML settings -- and I think we'd need both. So yes, I'd say that's reasonable but I'm not sure whether we need an XML / CDATA option.

### davidcarlisle commented Oct 14, 2014

 On 14 October 2014 17:06, Peter Krautzberger notifications@github.com wrote: The reason is probably that we didn't expect MathJax-node, i.e., the only application would be "Show Source" in the menu. Here's what it's doing https://github.com/physikerwelt/MathJax/blob/master/unpacked/extensions/MathMenu.js#L760-L761 IIUC the best practice within XML is to use CDATA (e.g., http://jats.nlm.nih.gov/archiving/tag-library/1.1d1/n-skz0.html) but that wouldn't work in an HTML settings -- and I think we'd need both. So yes, I'd say that's reasonable but I'm not sure whether we need an XML / CDATA option. I think even in a pure xml context it's better to quote <>& rather than use CDATA, apart from anything else it ensures ]]> is made safe David
Contributor Author

### physikerwelt commented Oct 14, 2014

 I have a fix that works for me. I'll create a pull request soon. https://github.com/physikerwelt/MathJax/tree/mathoid
Member

### pkra commented Oct 15, 2014

 Thanks, @davidcarlisle and thanks @physikerwelt for working on a pull request.

Closed

### dpvc pushed a commit that referenced this issue Nov 20, 2014

 Merge pull request #959 from physikerwelt/TeXML 
XML-escape TeX annotation (Resolves issue #935)
 7b5596f 

Member

### pkra commented Dec 4, 2014

 Is a treeReftest sufficient? E.g., $$&<>$$ with  &<> &<> 
Member

### pkra commented Dec 4, 2014

 Oh nevermind. I should remember my TeX...
Member

### dpvc commented Dec 4, 2014

 Is a treeReftest sufficient? No, you will need to use a script test, because the change is in toMathML(), not the NativeMML output. So you need to check the results of toMathML() to see that the annotation contains the escaped characters.

### pkra added a commit to mathjax/MathJax-test that referenced this issue Jan 15, 2015

 add test for mathjax/MathJax#935 
 00a3a69 

### dpvc pushed a commit to mathjax/MathJax-test that referenced this issue Jan 15, 2015

 Merge pull request #2 from mathjax/issue935 
add test for mathjax/MathJax#935
 01af1e5 

Member

### dpvc commented Jan 15, 2015

 ==> In Testsuite UI/issue935.html

### physikerwelt added a commit to wikimedia/mathoid that referenced this issue Jul 31, 2015

 Add TeX annotation to MathML again 
* for some reason the TeX annotation was removed
again by accident
* reintroduce this feature originally fixed in
Change-Id: I5b05e6d7c1947755c7715396468137fe6a0d56f7
 786473b