mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-06 11:48:41 +00:00
Remove double encoding in MathML via Unicode MathML spaces (#1813)
* Remove double encoding in MathML via Unicode MathML spaces We used to have a complex mechanic for escaping strings, marking them as `needsEscape = false`, and then not escaping those strings (for combining strings in `\operatorname`). But this doesn't really work with `render`ing directly to a node, as `document.createTextNode` can't be stopped from escaping. I've thus removed this mechanic, which required the following changes: * Switch MathML "smart space" encoding to use Unicode instead of `&LongNames;` (which weren't working with `render` for the same reason). * Hack our HTML/MathML serializer to not use `String.trim`, which wrecks havoc with emitted Unicode spaces. Now `toText()` doesn't escape, so strings concatenate in unescaped form, and `toHTML()` only does the necessary escaping. Thus fix #1782. * Fix src/utils.js Co-Authored-By: edemaine <edemaine@mit.edu> * Fix src/mathMLTree.js documentation Co-Authored-By: edemaine <edemaine@mit.edu> * Remove trim hack thanks to diffable-html@4.0.0 * Switch back to jest-serializer-html * Update mathMLTree.js
This commit is contained in:
@@ -46,6 +46,7 @@ exports[`A MathML builder \\text fonts become mathvariant 1`] = `
|
||||
bold
|
||||
</mtext>
|
||||
<mtext>
|
||||
|
||||
</mtext>
|
||||
<mtext mathvariant="bold-italic">
|
||||
italic
|
||||
@@ -68,6 +69,7 @@ exports[`A MathML builder \\text fonts become mathvariant 1`] = `
|
||||
bold
|
||||
</mtext>
|
||||
<mtext>
|
||||
|
||||
</mtext>
|
||||
<mtext mathvariant="sans-serif-bold-italic">
|
||||
italic
|
||||
@@ -91,6 +93,7 @@ exports[`A MathML builder \\text fonts become mathvariant 1`] = `
|
||||
bold
|
||||
</mtext>
|
||||
<mtext>
|
||||
|
||||
</mtext>
|
||||
<mtext mathvariant="monospace">
|
||||
italic
|
||||
@@ -300,7 +303,7 @@ exports[`A MathML builder should generate the right types of nodes 1`] = `
|
||||
1
|
||||
</mn>
|
||||
<mtext>
|
||||
  
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
a
|
||||
@@ -344,7 +347,7 @@ exports[`A MathML builder should output \\limsup_{x \\rightarrow \\infty} correc
|
||||
<msub>
|
||||
<mo>
|
||||
<mi mathvariant="normal">
|
||||
lim sup
|
||||
lim sup
|
||||
</mi>
|
||||
<mo>
|
||||
|
||||
@@ -379,7 +382,7 @@ exports[`A MathML builder should output \\limsup_{x \\rightarrow \\infty} in dis
|
||||
<munder>
|
||||
<mo>
|
||||
<mi mathvariant="normal">
|
||||
lim sup
|
||||
lim sup
|
||||
</mi>
|
||||
<mo>
|
||||
|
||||
@@ -702,61 +705,61 @@ exports[`A MathML builder special spaces render specially 1`] = `
|
||||
<semantics>
|
||||
<mrow>
|
||||
<mtext>
|
||||
 
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
 
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
 
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
 
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
 
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
  
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
  
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
​
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
​
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
​
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
​
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
 
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
 
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
 
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
  
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
​
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
​
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
​
|
||||
|
||||
</mtext>
|
||||
<mtext>
|
||||
​
|
||||
|
||||
</mtext>
|
||||
</mrow>
|
||||
<annotation encoding="application/x-tex">
|
||||
|
@@ -8,7 +8,7 @@ import {
|
||||
expectKaTeX, expectEquivalent,
|
||||
} from "./helpers";
|
||||
|
||||
// Serializer support
|
||||
// JSON serializer
|
||||
|
||||
const typeFirstCompare = (a, b) => {
|
||||
if (a.key === 'type') {
|
||||
|
Reference in New Issue
Block a user