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:
Erik Demaine
2019-01-01 11:55:44 -05:00
committed by ylemkimon
parent f5234a2f01
commit 647c661db0
6 changed files with 53 additions and 53 deletions

View File

@@ -2803,10 +2803,10 @@ diff@^3.2.0:
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
diffable-html@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/diffable-html/-/diffable-html-3.0.0.tgz#3766be8bcf6e90e061bdc321e04e14fc0630853f"
integrity sha512-lUxHiU00DexR/wKcY56OiJZmB0D66ghidYfU4VxUMG09TDx+1jjO7/dFrZKI2p9z00tWY/7ZeO9BBEi6n0jUYQ==
diffable-html@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/diffable-html/-/diffable-html-4.0.0.tgz#eb44a189785115bacd04829f31658fcd3c0ce590"
integrity sha512-keJdgy2qBkdrrnwP1YE6e834d4Y+mV0aRFzk8w7WzyAJVbQVfcJltSmUWB3r/NOoO/0jt7RdJlvy5ioyqvmQcw==
dependencies:
htmlparser2 "^3.9.2"
@@ -5197,12 +5197,12 @@ jest-runtime@^23.5.0:
write-file-atomic "^2.1.0"
yargs "^11.0.0"
jest-serializer-html@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/jest-serializer-html/-/jest-serializer-html-5.0.0.tgz#6848c4d8fb0f6c6dcb1e26a05e46d66c7ff9edb9"
integrity sha512-WfBvUnFdcZNJZMHuOWQFry+5qScsLhoaPxUOzXTqxGIp7BzWMEgr2sG/GKdLTIIfyNviAVp3k4jcqHtBkG18Lg==
jest-serializer-html@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/jest-serializer-html/-/jest-serializer-html-6.0.0.tgz#39ce49a42b3937d1687f93923814d21b47ae9a85"
integrity sha512-S855oT9Yt1T07I45+uRaLsH22TR5lAvgqBxKreqDKs6QmcaxzapGgKamc4J2KxMrPc2uDdWcuOaprcjIuVUxvQ==
dependencies:
diffable-html "^3.0.0"
diffable-html "^4.0.0"
jest-serializer@^23.0.1:
version "23.0.1"