diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-12-11 22:35:27 +0300 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-12-21 21:08:31 +0300 |
commit | 16de14ea980aec9da2b6960adff6d08597bd88b0 (patch) | |
tree | 9070a2b41c91b9da9a33661139d7b816aeaa7436 | |
parent | 563a801c6ab7e6cb9d1481eb3fdc7c82d7942983 (diff) |
Updated katex library
83 files changed, 10717 insertions, 4778 deletions
diff --git a/changelogs/unreleased/jivl-update-katex.yml b/changelogs/unreleased/jivl-update-katex.yml new file mode 100644 index 00000000000..99b5fe49620 --- /dev/null +++ b/changelogs/unreleased/jivl-update-katex.yml @@ -0,0 +1,5 @@ +--- +title: Updated the katex library +merge_request: 15864 +author: +type: other diff --git a/vendor/assets/fonts/KaTeX_AMS-Regular.eot b/vendor/assets/fonts/KaTeX_AMS-Regular.eot Binary files differindex 784276a3cbf..97fd899ab05 100644..100755 --- a/vendor/assets/fonts/KaTeX_AMS-Regular.eot +++ b/vendor/assets/fonts/KaTeX_AMS-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_AMS-Regular.ttf b/vendor/assets/fonts/KaTeX_AMS-Regular.ttf Binary files differindex 6f1e0be2028..001c30f2f43 100644..100755 --- a/vendor/assets/fonts/KaTeX_AMS-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_AMS-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_AMS-Regular.woff b/vendor/assets/fonts/KaTeX_AMS-Regular.woff Binary files differindex 4dded4733b3..c6376aeac46 100644..100755 --- a/vendor/assets/fonts/KaTeX_AMS-Regular.woff +++ b/vendor/assets/fonts/KaTeX_AMS-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_AMS-Regular.woff2 b/vendor/assets/fonts/KaTeX_AMS-Regular.woff2 Binary files differindex ea81079c4e2..6b43fd937ab 100644..100755 --- a/vendor/assets/fonts/KaTeX_AMS-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_AMS-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_Caligraphic-Bold.eot b/vendor/assets/fonts/KaTeX_Caligraphic-Bold.eot Binary files differindex 1a0db0c568e..f4613bc7c39 100644..100755 --- a/vendor/assets/fonts/KaTeX_Caligraphic-Bold.eot +++ b/vendor/assets/fonts/KaTeX_Caligraphic-Bold.eot diff --git a/vendor/assets/fonts/KaTeX_Caligraphic-Bold.ttf b/vendor/assets/fonts/KaTeX_Caligraphic-Bold.ttf Binary files differindex b94907dad11..e92c81860c5 100644..100755 --- a/vendor/assets/fonts/KaTeX_Caligraphic-Bold.ttf +++ b/vendor/assets/fonts/KaTeX_Caligraphic-Bold.ttf diff --git a/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff b/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff Binary files differindex 799fa8122ca..a27cd773c62 100644..100755 --- a/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff +++ b/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff diff --git a/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff2 b/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff2 Binary files differindex 73bb5422878..d9ababd7685 100644..100755 --- a/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff2 +++ b/vendor/assets/fonts/KaTeX_Caligraphic-Bold.woff2 diff --git a/vendor/assets/fonts/KaTeX_Caligraphic-Regular.eot b/vendor/assets/fonts/KaTeX_Caligraphic-Regular.eot Binary files differindex 6cc83d0922c..b7f66c8e206 100644..100755 --- a/vendor/assets/fonts/KaTeX_Caligraphic-Regular.eot +++ b/vendor/assets/fonts/KaTeX_Caligraphic-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_Caligraphic-Regular.ttf b/vendor/assets/fonts/KaTeX_Caligraphic-Regular.ttf Binary files differindex cf51e2021e4..e7736624028 100644..100755 --- a/vendor/assets/fonts/KaTeX_Caligraphic-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_Caligraphic-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff b/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff Binary files differindex f5e5c623577..c6df9639e16 100644..100755 --- a/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff +++ b/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff2 b/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff2 Binary files differindex dd76d3488d5..d762739df6d 100644..100755 --- a/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_Caligraphic-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_Fraktur-Bold.eot b/vendor/assets/fonts/KaTeX_Fraktur-Bold.eot Binary files differindex 1960b106656..ffade5ea4ae 100644..100755 --- a/vendor/assets/fonts/KaTeX_Fraktur-Bold.eot +++ b/vendor/assets/fonts/KaTeX_Fraktur-Bold.eot diff --git a/vendor/assets/fonts/KaTeX_Fraktur-Bold.ttf b/vendor/assets/fonts/KaTeX_Fraktur-Bold.ttf Binary files differindex 7b0790f1ae8..977b2f9a8f8 100644..100755 --- a/vendor/assets/fonts/KaTeX_Fraktur-Bold.ttf +++ b/vendor/assets/fonts/KaTeX_Fraktur-Bold.ttf diff --git a/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff b/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff Binary files differindex dc325713291..fd2d1be5547 100644..100755 --- a/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff +++ b/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff diff --git a/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff2 b/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff2 Binary files differindex fdc429227ad..f5b9bc4611b 100644..100755 --- a/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff2 +++ b/vendor/assets/fonts/KaTeX_Fraktur-Bold.woff2 diff --git a/vendor/assets/fonts/KaTeX_Fraktur-Regular.eot b/vendor/assets/fonts/KaTeX_Fraktur-Regular.eot Binary files differindex e4e73796aea..1676056a3e3 100644..100755 --- a/vendor/assets/fonts/KaTeX_Fraktur-Regular.eot +++ b/vendor/assets/fonts/KaTeX_Fraktur-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_Fraktur-Regular.ttf b/vendor/assets/fonts/KaTeX_Fraktur-Regular.ttf Binary files differindex 063bc0263eb..a2b86fcf0f0 100644..100755 --- a/vendor/assets/fonts/KaTeX_Fraktur-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_Fraktur-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff b/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff Binary files differindex c4b18d863f3..9088fcd1da8 100644..100755 --- a/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff +++ b/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff2 b/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff2 Binary files differindex 4318d938e26..748ed0e0688 100644..100755 --- a/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_Fraktur-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_Main-Bold.eot b/vendor/assets/fonts/KaTeX_Main-Bold.eot Binary files differindex 80fbd022363..3af6f51c107 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Bold.eot +++ b/vendor/assets/fonts/KaTeX_Main-Bold.eot diff --git a/vendor/assets/fonts/KaTeX_Main-Bold.ttf b/vendor/assets/fonts/KaTeX_Main-Bold.ttf Binary files differindex 8e10722afae..0a9434d1ed3 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Bold.ttf +++ b/vendor/assets/fonts/KaTeX_Main-Bold.ttf diff --git a/vendor/assets/fonts/KaTeX_Main-Bold.woff b/vendor/assets/fonts/KaTeX_Main-Bold.woff Binary files differindex 43b361a6005..42e687ed86a 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Bold.woff +++ b/vendor/assets/fonts/KaTeX_Main-Bold.woff diff --git a/vendor/assets/fonts/KaTeX_Main-Bold.woff2 b/vendor/assets/fonts/KaTeX_Main-Bold.woff2 Binary files differindex af57a96c148..ad0487c9c3c 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Bold.woff2 +++ b/vendor/assets/fonts/KaTeX_Main-Bold.woff2 diff --git a/vendor/assets/fonts/KaTeX_Main-Italic.eot b/vendor/assets/fonts/KaTeX_Main-Italic.eot Binary files differindex fc770166b5e..0c2537ba89c 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Italic.eot +++ b/vendor/assets/fonts/KaTeX_Main-Italic.eot diff --git a/vendor/assets/fonts/KaTeX_Main-Italic.ttf b/vendor/assets/fonts/KaTeX_Main-Italic.ttf Binary files differindex d124495d7b6..a8142a7fe34 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Italic.ttf +++ b/vendor/assets/fonts/KaTeX_Main-Italic.ttf diff --git a/vendor/assets/fonts/KaTeX_Main-Italic.woff b/vendor/assets/fonts/KaTeX_Main-Italic.woff Binary files differindex e623236bc44..0c301bd6787 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Italic.woff +++ b/vendor/assets/fonts/KaTeX_Main-Italic.woff diff --git a/vendor/assets/fonts/KaTeX_Main-Italic.woff2 b/vendor/assets/fonts/KaTeX_Main-Italic.woff2 Binary files differindex 944e9740bdf..9ea376e0986 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Italic.woff2 +++ b/vendor/assets/fonts/KaTeX_Main-Italic.woff2 diff --git a/vendor/assets/fonts/KaTeX_Main-Regular.eot b/vendor/assets/fonts/KaTeX_Main-Regular.eot Binary files differindex dc60c090c7a..5c3387fd668 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Regular.eot +++ b/vendor/assets/fonts/KaTeX_Main-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_Main-Regular.ttf b/vendor/assets/fonts/KaTeX_Main-Regular.ttf Binary files differindex da5797ffcce..43145ee90cd 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_Main-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_Main-Regular.woff b/vendor/assets/fonts/KaTeX_Main-Regular.woff Binary files differindex 37db672e821..4956dc62d35 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Regular.woff +++ b/vendor/assets/fonts/KaTeX_Main-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_Main-Regular.woff2 b/vendor/assets/fonts/KaTeX_Main-Regular.woff2 Binary files differindex 48820424893..89b01e44c46 100644..100755 --- a/vendor/assets/fonts/KaTeX_Main-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_Main-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_Math-BoldItalic.eot b/vendor/assets/fonts/KaTeX_Math-BoldItalic.eot Binary files differindex 52c8b8c6b40..4209732a5dc 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-BoldItalic.eot +++ b/vendor/assets/fonts/KaTeX_Math-BoldItalic.eot diff --git a/vendor/assets/fonts/KaTeX_Math-BoldItalic.ttf b/vendor/assets/fonts/KaTeX_Math-BoldItalic.ttf Binary files differindex a8b527c7ef6..c40c1003a35 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-BoldItalic.ttf +++ b/vendor/assets/fonts/KaTeX_Math-BoldItalic.ttf diff --git a/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff b/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff Binary files differindex 8940e0b5801..38c9cf2959a 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff +++ b/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff diff --git a/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff2 b/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff2 Binary files differindex 15cf56d3408..9d33f144720 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff2 +++ b/vendor/assets/fonts/KaTeX_Math-BoldItalic.woff2 diff --git a/vendor/assets/fonts/KaTeX_Math-Italic.eot b/vendor/assets/fonts/KaTeX_Math-Italic.eot Binary files differindex 64c8992c477..b6f8cbe8ce1 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-Italic.eot +++ b/vendor/assets/fonts/KaTeX_Math-Italic.eot diff --git a/vendor/assets/fonts/KaTeX_Math-Italic.ttf b/vendor/assets/fonts/KaTeX_Math-Italic.ttf Binary files differindex 06f39d3a299..a61089b2258 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-Italic.ttf +++ b/vendor/assets/fonts/KaTeX_Math-Italic.ttf diff --git a/vendor/assets/fonts/KaTeX_Math-Italic.woff b/vendor/assets/fonts/KaTeX_Math-Italic.woff Binary files differindex cf3b4b79e5b..465a41f359f 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-Italic.woff +++ b/vendor/assets/fonts/KaTeX_Math-Italic.woff diff --git a/vendor/assets/fonts/KaTeX_Math-Italic.woff2 b/vendor/assets/fonts/KaTeX_Math-Italic.woff2 Binary files differindex 5f8c4bfa455..3f945bee400 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-Italic.woff2 +++ b/vendor/assets/fonts/KaTeX_Math-Italic.woff2 diff --git a/vendor/assets/fonts/KaTeX_Math-Regular.eot b/vendor/assets/fonts/KaTeX_Math-Regular.eot Binary files differindex 5521e6a564d..3408ad26bad 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-Regular.eot +++ b/vendor/assets/fonts/KaTeX_Math-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_Math-Regular.ttf b/vendor/assets/fonts/KaTeX_Math-Regular.ttf Binary files differindex 73127082370..5a5788a58db 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_Math-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_Math-Regular.woff b/vendor/assets/fonts/KaTeX_Math-Regular.woff Binary files differindex 0e2ebdf18af..34b0e3618b5 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-Regular.woff +++ b/vendor/assets/fonts/KaTeX_Math-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_Math-Regular.woff2 b/vendor/assets/fonts/KaTeX_Math-Regular.woff2 Binary files differindex ebe3d028a34..2385fbeb8e6 100644..100755 --- a/vendor/assets/fonts/KaTeX_Math-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_Math-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Bold.eot b/vendor/assets/fonts/KaTeX_SansSerif-Bold.eot Binary files differindex 1660e76a2b6..2104d2aa29b 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Bold.eot +++ b/vendor/assets/fonts/KaTeX_SansSerif-Bold.eot diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Bold.ttf b/vendor/assets/fonts/KaTeX_SansSerif-Bold.ttf Binary files differindex dbeb7b92ab5..644e8aa3c4d 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Bold.ttf +++ b/vendor/assets/fonts/KaTeX_SansSerif-Bold.ttf diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff b/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff Binary files differindex 8f144a8bb31..126fd8e4b42 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff +++ b/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff2 b/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff2 Binary files differindex 329e85557fa..f042002876c 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff2 +++ b/vendor/assets/fonts/KaTeX_SansSerif-Bold.woff2 diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Italic.eot b/vendor/assets/fonts/KaTeX_SansSerif-Italic.eot Binary files differindex 289ae3ff8b7..d9633ff5865 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Italic.eot +++ b/vendor/assets/fonts/KaTeX_SansSerif-Italic.eot diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Italic.ttf b/vendor/assets/fonts/KaTeX_SansSerif-Italic.ttf Binary files differindex b3a2f38f224..9eb9d8f0ce6 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Italic.ttf +++ b/vendor/assets/fonts/KaTeX_SansSerif-Italic.ttf diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff b/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff Binary files differindex bddf7ea6579..0fb184ce0ab 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff +++ b/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff2 b/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff2 Binary files differindex 5fa767bddd6..cf87ba55541 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff2 +++ b/vendor/assets/fonts/KaTeX_SansSerif-Italic.woff2 diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Regular.eot b/vendor/assets/fonts/KaTeX_SansSerif-Regular.eot Binary files differindex 1b38b98a180..190015bf812 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Regular.eot +++ b/vendor/assets/fonts/KaTeX_SansSerif-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Regular.ttf b/vendor/assets/fonts/KaTeX_SansSerif-Regular.ttf Binary files differindex e4712f84775..4d27eba24b7 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_SansSerif-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff b/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff Binary files differindex 33be368048f..bcaae2cbd1e 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff +++ b/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff2 b/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff2 Binary files differindex 4fcb2e29a05..aa1eefc0930 100644..100755 --- a/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_SansSerif-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_Script-Regular.eot b/vendor/assets/fonts/KaTeX_Script-Regular.eot Binary files differindex 7870d7f319b..c41bad3038c 100644..100755 --- a/vendor/assets/fonts/KaTeX_Script-Regular.eot +++ b/vendor/assets/fonts/KaTeX_Script-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_Script-Regular.ttf b/vendor/assets/fonts/KaTeX_Script-Regular.ttf Binary files differindex da4d11308ae..11700094b79 100644..100755 --- a/vendor/assets/fonts/KaTeX_Script-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_Script-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_Script-Regular.woff b/vendor/assets/fonts/KaTeX_Script-Regular.woff Binary files differindex d6ae79f998a..03df046d859 100644..100755 --- a/vendor/assets/fonts/KaTeX_Script-Regular.woff +++ b/vendor/assets/fonts/KaTeX_Script-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_Script-Regular.woff2 b/vendor/assets/fonts/KaTeX_Script-Regular.woff2 Binary files differindex 1b43deb45a8..a6fc2a96b7d 100644..100755 --- a/vendor/assets/fonts/KaTeX_Script-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_Script-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_Size1-Regular.eot b/vendor/assets/fonts/KaTeX_Size1-Regular.eot Binary files differindex 29950f95ff6..ebe463e4a3f 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size1-Regular.eot +++ b/vendor/assets/fonts/KaTeX_Size1-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_Size1-Regular.ttf b/vendor/assets/fonts/KaTeX_Size1-Regular.ttf Binary files differindex 194466a655d..7d0a7c5825e 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size1-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_Size1-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_Size1-Regular.woff b/vendor/assets/fonts/KaTeX_Size1-Regular.woff Binary files differindex 237f271edd1..c1838b2927c 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size1-Regular.woff +++ b/vendor/assets/fonts/KaTeX_Size1-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_Size1-Regular.woff2 b/vendor/assets/fonts/KaTeX_Size1-Regular.woff2 Binary files differindex 39b6f8f746c..450cd7b3866 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size1-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_Size1-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_Size2-Regular.eot b/vendor/assets/fonts/KaTeX_Size2-Regular.eot Binary files differindex b8b0536f967..c0fdba72c89 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size2-Regular.eot +++ b/vendor/assets/fonts/KaTeX_Size2-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_Size2-Regular.ttf b/vendor/assets/fonts/KaTeX_Size2-Regular.ttf Binary files differindex b41b66a638f..fcff9e13239 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size2-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_Size2-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_Size2-Regular.woff b/vendor/assets/fonts/KaTeX_Size2-Regular.woff Binary files differindex 4a3055854ed..5b421fb6f83 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size2-Regular.woff +++ b/vendor/assets/fonts/KaTeX_Size2-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_Size2-Regular.woff2 b/vendor/assets/fonts/KaTeX_Size2-Regular.woff2 Binary files differindex 3facec1ab89..a0df638b81b 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size2-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_Size2-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_Size3-Regular.eot b/vendor/assets/fonts/KaTeX_Size3-Regular.eot Binary files differindex 576b864fae6..a28ebc892c3 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size3-Regular.eot +++ b/vendor/assets/fonts/KaTeX_Size3-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_Size3-Regular.ttf b/vendor/assets/fonts/KaTeX_Size3-Regular.ttf Binary files differindex 790ddbbc55f..af36ae23ee9 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size3-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_Size3-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_Size3-Regular.woff b/vendor/assets/fonts/KaTeX_Size3-Regular.woff Binary files differindex 3a6d062e660..d0d195539e2 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size3-Regular.woff +++ b/vendor/assets/fonts/KaTeX_Size3-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_Size3-Regular.woff2 b/vendor/assets/fonts/KaTeX_Size3-Regular.woff2 Binary files differindex 2cffafe5018..226186ae5fc 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size3-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_Size3-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_Size4-Regular.eot b/vendor/assets/fonts/KaTeX_Size4-Regular.eot Binary files differindex c2b045fc3db..a6753252675 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size4-Regular.eot +++ b/vendor/assets/fonts/KaTeX_Size4-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_Size4-Regular.ttf b/vendor/assets/fonts/KaTeX_Size4-Regular.ttf Binary files differindex ce660aa7ff9..979a449915d 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size4-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_Size4-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_Size4-Regular.woff b/vendor/assets/fonts/KaTeX_Size4-Regular.woff Binary files differindex 7826c6c97a1..185e575d6e3 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size4-Regular.woff +++ b/vendor/assets/fonts/KaTeX_Size4-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_Size4-Regular.woff2 b/vendor/assets/fonts/KaTeX_Size4-Regular.woff2 Binary files differindex c92189812d9..292513c0e09 100644..100755 --- a/vendor/assets/fonts/KaTeX_Size4-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_Size4-Regular.woff2 diff --git a/vendor/assets/fonts/KaTeX_Typewriter-Regular.eot b/vendor/assets/fonts/KaTeX_Typewriter-Regular.eot Binary files differindex 4c178f484a8..b713e4cc0e4 100644..100755 --- a/vendor/assets/fonts/KaTeX_Typewriter-Regular.eot +++ b/vendor/assets/fonts/KaTeX_Typewriter-Regular.eot diff --git a/vendor/assets/fonts/KaTeX_Typewriter-Regular.ttf b/vendor/assets/fonts/KaTeX_Typewriter-Regular.ttf Binary files differindex b0427ad0a56..78640734c50 100644..100755 --- a/vendor/assets/fonts/KaTeX_Typewriter-Regular.ttf +++ b/vendor/assets/fonts/KaTeX_Typewriter-Regular.ttf diff --git a/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff b/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff Binary files differindex 78e990488a9..c572bf5073f 100644..100755 --- a/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff +++ b/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff diff --git a/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff2 b/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff2 Binary files differindex 618de99d480..eddad58f060 100644..100755 --- a/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff2 +++ b/vendor/assets/fonts/KaTeX_Typewriter-Regular.woff2 diff --git a/vendor/assets/javascripts/katex.js b/vendor/assets/javascripts/katex.js index 6b59a3477a7..92936bb247f 100644 --- a/vendor/assets/javascripts/katex.js +++ b/vendor/assets/javascripts/katex.js @@ -42,47 +42,63 @@ */ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.katex = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ -/* eslint no-console:0 */ -/** - * This is the main entry point for KaTeX. Here, we expose functions for - * rendering expressions either to DOM nodes or to markup strings. - * - * We also expose the ParseError class to check if errors thrown from KaTeX are - * errors in the expression, or errors in javascript handling. - */ +"use strict"; + +var _ParseError = require("./src/ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +var _Settings = require("./src/Settings"); + +var _Settings2 = _interopRequireDefault(_Settings); + +var _buildTree = require("./src/buildTree"); + +var _buildTree2 = _interopRequireDefault(_buildTree); -var ParseError = require("./src/ParseError"); -var Settings = require("./src/Settings"); +var _parseTree = require("./src/parseTree"); -var buildTree = require("./src/buildTree"); -var parseTree = require("./src/parseTree"); -var utils = require("./src/utils"); +var _parseTree2 = _interopRequireDefault(_parseTree); + +var _utils = require("./src/utils"); + +var _utils2 = _interopRequireDefault(_utils); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Parse and build an expression, and place that expression in the DOM node * given. */ -var render = function(expression, baseNode, options) { - utils.clearNode(baseNode); +var render = function render(expression, baseNode, options) { + _utils2.default.clearNode(baseNode); - var settings = new Settings(options); + var settings = new _Settings2.default(options); - var tree = parseTree(expression, settings); - var node = buildTree(tree, expression, settings).toNode(); + var tree = (0, _parseTree2.default)(expression, settings); + var node = (0, _buildTree2.default)(tree, expression, settings).toNode(); baseNode.appendChild(node); }; // KaTeX's styles don't work properly in quirks mode. Print out an error, and // disable rendering. + +/* eslint no-console:0 */ +/** + * This is the main entry point for KaTeX. Here, we expose functions for + * rendering expressions either to DOM nodes or to markup strings. + * + * We also expose the ParseError class to check if errors thrown from KaTeX are + * errors in the expression, or errors in javascript handling. + */ + if (typeof document !== "undefined") { if (document.compatMode !== "CSS1Compat") { - typeof console !== "undefined" && console.warn( - "Warning: KaTeX doesn't work in quirks mode. Make sure your " + - "website has a suitable doctype."); + typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype."); - render = function() { - throw new ParseError("KaTeX doesn't work in quirks mode."); + render = function render() { + throw new _ParseError2.default("KaTeX doesn't work in quirks mode."); }; } } @@ -90,19 +106,19 @@ if (typeof document !== "undefined") { /** * Parse and build an expression, and return the markup for that. */ -var renderToString = function(expression, options) { - var settings = new Settings(options); +var renderToString = function renderToString(expression, options) { + var settings = new _Settings2.default(options); - var tree = parseTree(expression, settings); - return buildTree(tree, expression, settings).toMarkup(); + var tree = (0, _parseTree2.default)(expression, settings); + return (0, _buildTree2.default)(tree, expression, settings).toMarkup(); }; /** * Parse an expression and return the parse tree. */ -var generateParseTree = function(expression, options) { - var settings = new Settings(options); - return parseTree(expression, settings); +var generateParseTree = function generateParseTree(expression, options) { + var settings = new _Settings2.default(options); + return (0, _parseTree2.default)(expression, settings); }; module.exports = { @@ -114,24 +130,1056 @@ module.exports = { * to change. Use at your own risk. */ __parse: generateParseTree, - ParseError: ParseError, + ParseError: _ParseError2.default +}; + +},{"./src/ParseError":84,"./src/Settings":87,"./src/buildTree":94,"./src/parseTree":122,"./src/utils":128}],2:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true }; +},{"core-js/library/fn/array/from":12}],3:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/get-iterator"), __esModule: true }; +},{"core-js/library/fn/get-iterator":13}],4:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/is-iterable"), __esModule: true }; +},{"core-js/library/fn/is-iterable":14}],5:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/json/stringify"), __esModule: true }; +},{"core-js/library/fn/json/stringify":15}],6:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/object/define-property"), __esModule: true }; +},{"core-js/library/fn/object/define-property":16}],7:[function(require,module,exports){ +module.exports = { "default": require("core-js/library/fn/object/freeze"), __esModule: true }; +},{"core-js/library/fn/object/freeze":17}],8:[function(require,module,exports){ +"use strict"; + +exports.__esModule = true; + +exports.default = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } }; +},{}],9:[function(require,module,exports){ +"use strict"; + +exports.__esModule = true; + +var _defineProperty = require("../core-js/object/define-property"); + +var _defineProperty2 = _interopRequireDefault(_defineProperty); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + (0, _defineProperty2.default)(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); +},{"../core-js/object/define-property":6}],10:[function(require,module,exports){ +"use strict"; -},{"./src/ParseError":6,"./src/Settings":8,"./src/buildTree":13,"./src/parseTree":22,"./src/utils":25}],2:[function(require,module,exports){ -/** @flow */ +exports.__esModule = true; +var _isIterable2 = require("../core-js/is-iterable"); + +var _isIterable3 = _interopRequireDefault(_isIterable2); + +var _getIterator2 = require("../core-js/get-iterator"); + +var _getIterator3 = _interopRequireDefault(_getIterator2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if ((0, _isIterable3.default)(Object(arr))) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; +}(); +},{"../core-js/get-iterator":3,"../core-js/is-iterable":4}],11:[function(require,module,exports){ "use strict"; +exports.__esModule = true; + +var _from = require("../core-js/array/from"); + +var _from2 = _interopRequireDefault(_from); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { + arr2[i] = arr[i]; + } + + return arr2; + } else { + return (0, _from2.default)(arr); + } +}; +},{"../core-js/array/from":2}],12:[function(require,module,exports){ +require('../../modules/es6.string.iterator'); +require('../../modules/es6.array.from'); +module.exports = require('../../modules/_core').Array.from; + +},{"../../modules/_core":24,"../../modules/es6.array.from":73,"../../modules/es6.string.iterator":77}],13:[function(require,module,exports){ +require('../modules/web.dom.iterable'); +require('../modules/es6.string.iterator'); +module.exports = require('../modules/core.get-iterator'); + +},{"../modules/core.get-iterator":71,"../modules/es6.string.iterator":77,"../modules/web.dom.iterable":78}],14:[function(require,module,exports){ +require('../modules/web.dom.iterable'); +require('../modules/es6.string.iterator'); +module.exports = require('../modules/core.is-iterable'); + +},{"../modules/core.is-iterable":72,"../modules/es6.string.iterator":77,"../modules/web.dom.iterable":78}],15:[function(require,module,exports){ +var core = require('../../modules/_core'); +var $JSON = core.JSON || (core.JSON = { stringify: JSON.stringify }); +module.exports = function stringify(it) { // eslint-disable-line no-unused-vars + return $JSON.stringify.apply($JSON, arguments); +}; + +},{"../../modules/_core":24}],16:[function(require,module,exports){ +require('../../modules/es6.object.define-property'); +var $Object = require('../../modules/_core').Object; +module.exports = function defineProperty(it, key, desc) { + return $Object.defineProperty(it, key, desc); +}; + +},{"../../modules/_core":24,"../../modules/es6.object.define-property":75}],17:[function(require,module,exports){ +require('../../modules/es6.object.freeze'); +module.exports = require('../../modules/_core').Object.freeze; + +},{"../../modules/_core":24,"../../modules/es6.object.freeze":76}],18:[function(require,module,exports){ +module.exports = function (it) { + if (typeof it != 'function') throw TypeError(it + ' is not a function!'); + return it; +}; + +},{}],19:[function(require,module,exports){ +module.exports = function () { /* empty */ }; + +},{}],20:[function(require,module,exports){ +var isObject = require('./_is-object'); +module.exports = function (it) { + if (!isObject(it)) throw TypeError(it + ' is not an object!'); + return it; +}; + +},{"./_is-object":40}],21:[function(require,module,exports){ +// false -> Array#indexOf +// true -> Array#includes +var toIObject = require('./_to-iobject'); +var toLength = require('./_to-length'); +var toAbsoluteIndex = require('./_to-absolute-index'); +module.exports = function (IS_INCLUDES) { + return function ($this, el, fromIndex) { + var O = toIObject($this); + var length = toLength(O.length); + var index = toAbsoluteIndex(fromIndex, length); + var value; + // Array#includes uses SameValueZero equality algorithm + // eslint-disable-next-line no-self-compare + if (IS_INCLUDES && el != el) while (length > index) { + value = O[index++]; + // eslint-disable-next-line no-self-compare + if (value != value) return true; + // Array#indexOf ignores holes, Array#includes - not + } else for (;length > index; index++) if (IS_INCLUDES || index in O) { + if (O[index] === el) return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; + }; +}; + +},{"./_to-absolute-index":62,"./_to-iobject":64,"./_to-length":65}],22:[function(require,module,exports){ +// getting tag from 19.1.3.6 Object.prototype.toString() +var cof = require('./_cof'); +var TAG = require('./_wks')('toStringTag'); +// ES3 wrong here +var ARG = cof(function () { return arguments; }()) == 'Arguments'; + +// fallback for IE11 Script Access Denied error +var tryGet = function (it, key) { + try { + return it[key]; + } catch (e) { /* empty */ } +}; + +module.exports = function (it) { + var O, T, B; + return it === undefined ? 'Undefined' : it === null ? 'Null' + // @@toStringTag case + : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T + // builtinTag case + : ARG ? cof(O) + // ES3 arguments fallback + : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; +}; + +},{"./_cof":23,"./_wks":69}],23:[function(require,module,exports){ +var toString = {}.toString; + +module.exports = function (it) { + return toString.call(it).slice(8, -1); +}; + +},{}],24:[function(require,module,exports){ +var core = module.exports = { version: '2.5.1' }; +if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef + +},{}],25:[function(require,module,exports){ +'use strict'; +var $defineProperty = require('./_object-dp'); +var createDesc = require('./_property-desc'); + +module.exports = function (object, index, value) { + if (index in object) $defineProperty.f(object, index, createDesc(0, value)); + else object[index] = value; +}; + +},{"./_object-dp":50,"./_property-desc":56}],26:[function(require,module,exports){ +// optional / simple context binding +var aFunction = require('./_a-function'); +module.exports = function (fn, that, length) { + aFunction(fn); + if (that === undefined) return fn; + switch (length) { + case 1: return function (a) { + return fn.call(that, a); + }; + case 2: return function (a, b) { + return fn.call(that, a, b); + }; + case 3: return function (a, b, c) { + return fn.call(that, a, b, c); + }; + } + return function (/* ...args */) { + return fn.apply(that, arguments); + }; +}; + +},{"./_a-function":18}],27:[function(require,module,exports){ +// 7.2.1 RequireObjectCoercible(argument) +module.exports = function (it) { + if (it == undefined) throw TypeError("Can't call method on " + it); + return it; +}; + +},{}],28:[function(require,module,exports){ +// Thank's IE8 for his funny defineProperty +module.exports = !require('./_fails')(function () { + return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; +}); + +},{"./_fails":32}],29:[function(require,module,exports){ +var isObject = require('./_is-object'); +var document = require('./_global').document; +// typeof document.createElement is 'object' in old IE +var is = isObject(document) && isObject(document.createElement); +module.exports = function (it) { + return is ? document.createElement(it) : {}; +}; + +},{"./_global":33,"./_is-object":40}],30:[function(require,module,exports){ +// IE 8- don't enum bug keys +module.exports = ( + 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' +).split(','); + +},{}],31:[function(require,module,exports){ +var global = require('./_global'); +var core = require('./_core'); +var ctx = require('./_ctx'); +var hide = require('./_hide'); +var PROTOTYPE = 'prototype'; + +var $export = function (type, name, source) { + var IS_FORCED = type & $export.F; + var IS_GLOBAL = type & $export.G; + var IS_STATIC = type & $export.S; + var IS_PROTO = type & $export.P; + var IS_BIND = type & $export.B; + var IS_WRAP = type & $export.W; + var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); + var expProto = exports[PROTOTYPE]; + var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]; + var key, own, out; + if (IS_GLOBAL) source = name; + for (key in source) { + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + if (own && key in exports) continue; + // export native or passed + out = own ? target[key] : source[key]; + // prevent global pollution for namespaces + exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] + // bind timers to global for call from export context + : IS_BIND && own ? ctx(out, global) + // wrap global constructors for prevent change them in library + : IS_WRAP && target[key] == out ? (function (C) { + var F = function (a, b, c) { + if (this instanceof C) { + switch (arguments.length) { + case 0: return new C(); + case 1: return new C(a); + case 2: return new C(a, b); + } return new C(a, b, c); + } return C.apply(this, arguments); + }; + F[PROTOTYPE] = C[PROTOTYPE]; + return F; + // make static versions for prototype methods + })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; + // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% + if (IS_PROTO) { + (exports.virtual || (exports.virtual = {}))[key] = out; + // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% + if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out); + } + } +}; +// type bitmap +$export.F = 1; // forced +$export.G = 2; // global +$export.S = 4; // static +$export.P = 8; // proto +$export.B = 16; // bind +$export.W = 32; // wrap +$export.U = 64; // safe +$export.R = 128; // real proto method for `library` +module.exports = $export; + +},{"./_core":24,"./_ctx":26,"./_global":33,"./_hide":35}],32:[function(require,module,exports){ +module.exports = function (exec) { + try { + return !!exec(); + } catch (e) { + return true; + } +}; + +},{}],33:[function(require,module,exports){ +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self + // eslint-disable-next-line no-new-func + : Function('return this')(); +if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef + +},{}],34:[function(require,module,exports){ +var hasOwnProperty = {}.hasOwnProperty; +module.exports = function (it, key) { + return hasOwnProperty.call(it, key); +}; + +},{}],35:[function(require,module,exports){ +var dP = require('./_object-dp'); +var createDesc = require('./_property-desc'); +module.exports = require('./_descriptors') ? function (object, key, value) { + return dP.f(object, key, createDesc(1, value)); +} : function (object, key, value) { + object[key] = value; + return object; +}; + +},{"./_descriptors":28,"./_object-dp":50,"./_property-desc":56}],36:[function(require,module,exports){ +var document = require('./_global').document; +module.exports = document && document.documentElement; + +},{"./_global":33}],37:[function(require,module,exports){ +module.exports = !require('./_descriptors') && !require('./_fails')(function () { + return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7; +}); + +},{"./_descriptors":28,"./_dom-create":29,"./_fails":32}],38:[function(require,module,exports){ +// fallback for non-array-like ES3 and non-enumerable old V8 strings +var cof = require('./_cof'); +// eslint-disable-next-line no-prototype-builtins +module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { + return cof(it) == 'String' ? it.split('') : Object(it); +}; + +},{"./_cof":23}],39:[function(require,module,exports){ +// check on default Array iterator +var Iterators = require('./_iterators'); +var ITERATOR = require('./_wks')('iterator'); +var ArrayProto = Array.prototype; + +module.exports = function (it) { + return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); +}; + +},{"./_iterators":46,"./_wks":69}],40:[function(require,module,exports){ +module.exports = function (it) { + return typeof it === 'object' ? it !== null : typeof it === 'function'; +}; + +},{}],41:[function(require,module,exports){ +// call something on iterator step with safe closing on error +var anObject = require('./_an-object'); +module.exports = function (iterator, fn, value, entries) { + try { + return entries ? fn(anObject(value)[0], value[1]) : fn(value); + // 7.4.6 IteratorClose(iterator, completion) + } catch (e) { + var ret = iterator['return']; + if (ret !== undefined) anObject(ret.call(iterator)); + throw e; + } +}; + +},{"./_an-object":20}],42:[function(require,module,exports){ +'use strict'; +var create = require('./_object-create'); +var descriptor = require('./_property-desc'); +var setToStringTag = require('./_set-to-string-tag'); +var IteratorPrototype = {}; + +// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() +require('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function () { return this; }); + +module.exports = function (Constructor, NAME, next) { + Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) }); + setToStringTag(Constructor, NAME + ' Iterator'); +}; + +},{"./_hide":35,"./_object-create":49,"./_property-desc":56,"./_set-to-string-tag":58,"./_wks":69}],43:[function(require,module,exports){ +'use strict'; +var LIBRARY = require('./_library'); +var $export = require('./_export'); +var redefine = require('./_redefine'); +var hide = require('./_hide'); +var has = require('./_has'); +var Iterators = require('./_iterators'); +var $iterCreate = require('./_iter-create'); +var setToStringTag = require('./_set-to-string-tag'); +var getPrototypeOf = require('./_object-gpo'); +var ITERATOR = require('./_wks')('iterator'); +var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` +var FF_ITERATOR = '@@iterator'; +var KEYS = 'keys'; +var VALUES = 'values'; + +var returnThis = function () { return this; }; + +module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { + $iterCreate(Constructor, NAME, next); + var getMethod = function (kind) { + if (!BUGGY && kind in proto) return proto[kind]; + switch (kind) { + case KEYS: return function keys() { return new Constructor(this, kind); }; + case VALUES: return function values() { return new Constructor(this, kind); }; + } return function entries() { return new Constructor(this, kind); }; + }; + var TAG = NAME + ' Iterator'; + var DEF_VALUES = DEFAULT == VALUES; + var VALUES_BUG = false; + var proto = Base.prototype; + var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; + var $default = $native || getMethod(DEFAULT); + var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; + var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; + var methods, key, IteratorPrototype; + // Fix native + if ($anyNative) { + IteratorPrototype = getPrototypeOf($anyNative.call(new Base())); + if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { + // Set @@toStringTag to native iterators + setToStringTag(IteratorPrototype, TAG, true); + // fix for some old engines + if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis); + } + } + // fix Array#{values, @@iterator}.name in V8 / FF + if (DEF_VALUES && $native && $native.name !== VALUES) { + VALUES_BUG = true; + $default = function values() { return $native.call(this); }; + } + // Define iterator + if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { + hide(proto, ITERATOR, $default); + } + // Plug for library + Iterators[NAME] = $default; + Iterators[TAG] = returnThis; + if (DEFAULT) { + methods = { + values: DEF_VALUES ? $default : getMethod(VALUES), + keys: IS_SET ? $default : getMethod(KEYS), + entries: $entries + }; + if (FORCED) for (key in methods) { + if (!(key in proto)) redefine(proto, key, methods[key]); + } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); + } + return methods; +}; + +},{"./_export":31,"./_has":34,"./_hide":35,"./_iter-create":42,"./_iterators":46,"./_library":47,"./_object-gpo":52,"./_redefine":57,"./_set-to-string-tag":58,"./_wks":69}],44:[function(require,module,exports){ +var ITERATOR = require('./_wks')('iterator'); +var SAFE_CLOSING = false; + +try { + var riter = [7][ITERATOR](); + riter['return'] = function () { SAFE_CLOSING = true; }; + // eslint-disable-next-line no-throw-literal + Array.from(riter, function () { throw 2; }); +} catch (e) { /* empty */ } + +module.exports = function (exec, skipClosing) { + if (!skipClosing && !SAFE_CLOSING) return false; + var safe = false; + try { + var arr = [7]; + var iter = arr[ITERATOR](); + iter.next = function () { return { done: safe = true }; }; + arr[ITERATOR] = function () { return iter; }; + exec(arr); + } catch (e) { /* empty */ } + return safe; +}; + +},{"./_wks":69}],45:[function(require,module,exports){ +module.exports = function (done, value) { + return { value: value, done: !!done }; +}; + +},{}],46:[function(require,module,exports){ +module.exports = {}; + +},{}],47:[function(require,module,exports){ +module.exports = true; + +},{}],48:[function(require,module,exports){ +var META = require('./_uid')('meta'); +var isObject = require('./_is-object'); +var has = require('./_has'); +var setDesc = require('./_object-dp').f; +var id = 0; +var isExtensible = Object.isExtensible || function () { + return true; +}; +var FREEZE = !require('./_fails')(function () { + return isExtensible(Object.preventExtensions({})); +}); +var setMeta = function (it) { + setDesc(it, META, { value: { + i: 'O' + ++id, // object ID + w: {} // weak collections IDs + } }); +}; +var fastKey = function (it, create) { + // return primitive with prefix + if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; + if (!has(it, META)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return 'F'; + // not necessary to add metadata + if (!create) return 'E'; + // add missing metadata + setMeta(it); + // return object ID + } return it[META].i; +}; +var getWeak = function (it, create) { + if (!has(it, META)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return true; + // not necessary to add metadata + if (!create) return false; + // add missing metadata + setMeta(it); + // return hash weak collections IDs + } return it[META].w; +}; +// add metadata on freeze-family methods calling +var onFreeze = function (it) { + if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it); + return it; +}; +var meta = module.exports = { + KEY: META, + NEED: false, + fastKey: fastKey, + getWeak: getWeak, + onFreeze: onFreeze +}; + +},{"./_fails":32,"./_has":34,"./_is-object":40,"./_object-dp":50,"./_uid":68}],49:[function(require,module,exports){ +// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) +var anObject = require('./_an-object'); +var dPs = require('./_object-dps'); +var enumBugKeys = require('./_enum-bug-keys'); +var IE_PROTO = require('./_shared-key')('IE_PROTO'); +var Empty = function () { /* empty */ }; +var PROTOTYPE = 'prototype'; + +// Create object with fake `null` prototype: use iframe Object with cleared prototype +var createDict = function () { + // Thrash, waste and sodomy: IE GC bug + var iframe = require('./_dom-create')('iframe'); + var i = enumBugKeys.length; + var lt = '<'; + var gt = '>'; + var iframeDocument; + iframe.style.display = 'none'; + require('./_html').appendChild(iframe); + iframe.src = 'javascript:'; // eslint-disable-line no-script-url + // createDict = iframe.contentWindow.Object; + // html.removeChild(iframe); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); + iframeDocument.close(); + createDict = iframeDocument.F; + while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]]; + return createDict(); +}; + +module.exports = Object.create || function create(O, Properties) { + var result; + if (O !== null) { + Empty[PROTOTYPE] = anObject(O); + result = new Empty(); + Empty[PROTOTYPE] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO] = O; + } else result = createDict(); + return Properties === undefined ? result : dPs(result, Properties); +}; + +},{"./_an-object":20,"./_dom-create":29,"./_enum-bug-keys":30,"./_html":36,"./_object-dps":51,"./_shared-key":59}],50:[function(require,module,exports){ +var anObject = require('./_an-object'); +var IE8_DOM_DEFINE = require('./_ie8-dom-define'); +var toPrimitive = require('./_to-primitive'); +var dP = Object.defineProperty; + +exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) { + anObject(O); + P = toPrimitive(P, true); + anObject(Attributes); + if (IE8_DOM_DEFINE) try { + return dP(O, P, Attributes); + } catch (e) { /* empty */ } + if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); + if ('value' in Attributes) O[P] = Attributes.value; + return O; +}; + +},{"./_an-object":20,"./_descriptors":28,"./_ie8-dom-define":37,"./_to-primitive":67}],51:[function(require,module,exports){ +var dP = require('./_object-dp'); +var anObject = require('./_an-object'); +var getKeys = require('./_object-keys'); + +module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) { + anObject(O); + var keys = getKeys(Properties); + var length = keys.length; + var i = 0; + var P; + while (length > i) dP.f(O, P = keys[i++], Properties[P]); + return O; +}; + +},{"./_an-object":20,"./_descriptors":28,"./_object-dp":50,"./_object-keys":54}],52:[function(require,module,exports){ +// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) +var has = require('./_has'); +var toObject = require('./_to-object'); +var IE_PROTO = require('./_shared-key')('IE_PROTO'); +var ObjectProto = Object.prototype; + +module.exports = Object.getPrototypeOf || function (O) { + O = toObject(O); + if (has(O, IE_PROTO)) return O[IE_PROTO]; + if (typeof O.constructor == 'function' && O instanceof O.constructor) { + return O.constructor.prototype; + } return O instanceof Object ? ObjectProto : null; +}; + +},{"./_has":34,"./_shared-key":59,"./_to-object":66}],53:[function(require,module,exports){ +var has = require('./_has'); +var toIObject = require('./_to-iobject'); +var arrayIndexOf = require('./_array-includes')(false); +var IE_PROTO = require('./_shared-key')('IE_PROTO'); + +module.exports = function (object, names) { + var O = toIObject(object); + var i = 0; + var result = []; + var key; + for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key); + // Don't enum bug & hidden keys + while (names.length > i) if (has(O, key = names[i++])) { + ~arrayIndexOf(result, key) || result.push(key); + } + return result; +}; + +},{"./_array-includes":21,"./_has":34,"./_shared-key":59,"./_to-iobject":64}],54:[function(require,module,exports){ +// 19.1.2.14 / 15.2.3.14 Object.keys(O) +var $keys = require('./_object-keys-internal'); +var enumBugKeys = require('./_enum-bug-keys'); + +module.exports = Object.keys || function keys(O) { + return $keys(O, enumBugKeys); +}; + +},{"./_enum-bug-keys":30,"./_object-keys-internal":53}],55:[function(require,module,exports){ +// most Object methods by ES6 should accept primitives +var $export = require('./_export'); +var core = require('./_core'); +var fails = require('./_fails'); +module.exports = function (KEY, exec) { + var fn = (core.Object || {})[KEY] || Object[KEY]; + var exp = {}; + exp[KEY] = exec(fn); + $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp); +}; + +},{"./_core":24,"./_export":31,"./_fails":32}],56:[function(require,module,exports){ +module.exports = function (bitmap, value) { + return { + enumerable: !(bitmap & 1), + configurable: !(bitmap & 2), + writable: !(bitmap & 4), + value: value + }; +}; + +},{}],57:[function(require,module,exports){ +module.exports = require('./_hide'); + +},{"./_hide":35}],58:[function(require,module,exports){ +var def = require('./_object-dp').f; +var has = require('./_has'); +var TAG = require('./_wks')('toStringTag'); + +module.exports = function (it, tag, stat) { + if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); +}; + +},{"./_has":34,"./_object-dp":50,"./_wks":69}],59:[function(require,module,exports){ +var shared = require('./_shared')('keys'); +var uid = require('./_uid'); +module.exports = function (key) { + return shared[key] || (shared[key] = uid(key)); +}; + +},{"./_shared":60,"./_uid":68}],60:[function(require,module,exports){ +var global = require('./_global'); +var SHARED = '__core-js_shared__'; +var store = global[SHARED] || (global[SHARED] = {}); +module.exports = function (key) { + return store[key] || (store[key] = {}); +}; + +},{"./_global":33}],61:[function(require,module,exports){ +var toInteger = require('./_to-integer'); +var defined = require('./_defined'); +// true -> String#at +// false -> String#codePointAt +module.exports = function (TO_STRING) { + return function (that, pos) { + var s = String(defined(that)); + var i = toInteger(pos); + var l = s.length; + var a, b; + if (i < 0 || i >= l) return TO_STRING ? '' : undefined; + a = s.charCodeAt(i); + return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff + ? TO_STRING ? s.charAt(i) : a + : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; + }; +}; + +},{"./_defined":27,"./_to-integer":63}],62:[function(require,module,exports){ +var toInteger = require('./_to-integer'); +var max = Math.max; +var min = Math.min; +module.exports = function (index, length) { + index = toInteger(index); + return index < 0 ? max(index + length, 0) : min(index, length); +}; + +},{"./_to-integer":63}],63:[function(require,module,exports){ +// 7.1.4 ToInteger +var ceil = Math.ceil; +var floor = Math.floor; +module.exports = function (it) { + return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); +}; + +},{}],64:[function(require,module,exports){ +// to indexed object, toObject with fallback for non-array-like ES3 strings +var IObject = require('./_iobject'); +var defined = require('./_defined'); +module.exports = function (it) { + return IObject(defined(it)); +}; + +},{"./_defined":27,"./_iobject":38}],65:[function(require,module,exports){ +// 7.1.15 ToLength +var toInteger = require('./_to-integer'); +var min = Math.min; +module.exports = function (it) { + return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 +}; + +},{"./_to-integer":63}],66:[function(require,module,exports){ +// 7.1.13 ToObject(argument) +var defined = require('./_defined'); +module.exports = function (it) { + return Object(defined(it)); +}; + +},{"./_defined":27}],67:[function(require,module,exports){ +// 7.1.1 ToPrimitive(input [, PreferredType]) +var isObject = require('./_is-object'); +// instead of the ES6 spec version, we didn't implement @@toPrimitive case +// and the second argument - flag - preferred type is a string +module.exports = function (it, S) { + if (!isObject(it)) return it; + var fn, val; + if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; + if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; + if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; + throw TypeError("Can't convert object to primitive value"); +}; + +},{"./_is-object":40}],68:[function(require,module,exports){ +var id = 0; +var px = Math.random(); +module.exports = function (key) { + return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); +}; + +},{}],69:[function(require,module,exports){ +var store = require('./_shared')('wks'); +var uid = require('./_uid'); +var Symbol = require('./_global').Symbol; +var USE_SYMBOL = typeof Symbol == 'function'; + +var $exports = module.exports = function (name) { + return store[name] || (store[name] = + USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); +}; + +$exports.store = store; + +},{"./_global":33,"./_shared":60,"./_uid":68}],70:[function(require,module,exports){ +var classof = require('./_classof'); +var ITERATOR = require('./_wks')('iterator'); +var Iterators = require('./_iterators'); +module.exports = require('./_core').getIteratorMethod = function (it) { + if (it != undefined) return it[ITERATOR] + || it['@@iterator'] + || Iterators[classof(it)]; +}; + +},{"./_classof":22,"./_core":24,"./_iterators":46,"./_wks":69}],71:[function(require,module,exports){ +var anObject = require('./_an-object'); +var get = require('./core.get-iterator-method'); +module.exports = require('./_core').getIterator = function (it) { + var iterFn = get(it); + if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!'); + return anObject(iterFn.call(it)); +}; + +},{"./_an-object":20,"./_core":24,"./core.get-iterator-method":70}],72:[function(require,module,exports){ +var classof = require('./_classof'); +var ITERATOR = require('./_wks')('iterator'); +var Iterators = require('./_iterators'); +module.exports = require('./_core').isIterable = function (it) { + var O = Object(it); + return O[ITERATOR] !== undefined + || '@@iterator' in O + // eslint-disable-next-line no-prototype-builtins + || Iterators.hasOwnProperty(classof(O)); +}; + +},{"./_classof":22,"./_core":24,"./_iterators":46,"./_wks":69}],73:[function(require,module,exports){ +'use strict'; +var ctx = require('./_ctx'); +var $export = require('./_export'); +var toObject = require('./_to-object'); +var call = require('./_iter-call'); +var isArrayIter = require('./_is-array-iter'); +var toLength = require('./_to-length'); +var createProperty = require('./_create-property'); +var getIterFn = require('./core.get-iterator-method'); + +$export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Array.from(iter); }), 'Array', { + // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) + from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { + var O = toObject(arrayLike); + var C = typeof this == 'function' ? this : Array; + var aLen = arguments.length; + var mapfn = aLen > 1 ? arguments[1] : undefined; + var mapping = mapfn !== undefined; + var index = 0; + var iterFn = getIterFn(O); + var length, result, step, iterator; + if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); + // if object isn't iterable or it's array with default iterator - use simple case + if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) { + for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) { + createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value); + } + } else { + length = toLength(O.length); + for (result = new C(length); length > index; index++) { + createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); + } + } + result.length = index; + return result; + } +}); + +},{"./_create-property":25,"./_ctx":26,"./_export":31,"./_is-array-iter":39,"./_iter-call":41,"./_iter-detect":44,"./_to-length":65,"./_to-object":66,"./core.get-iterator-method":70}],74:[function(require,module,exports){ +'use strict'; +var addToUnscopables = require('./_add-to-unscopables'); +var step = require('./_iter-step'); +var Iterators = require('./_iterators'); +var toIObject = require('./_to-iobject'); + +// 22.1.3.4 Array.prototype.entries() +// 22.1.3.13 Array.prototype.keys() +// 22.1.3.29 Array.prototype.values() +// 22.1.3.30 Array.prototype[@@iterator]() +module.exports = require('./_iter-define')(Array, 'Array', function (iterated, kind) { + this._t = toIObject(iterated); // target + this._i = 0; // next index + this._k = kind; // kind +// 22.1.5.2.1 %ArrayIteratorPrototype%.next() +}, function () { + var O = this._t; + var kind = this._k; + var index = this._i++; + if (!O || index >= O.length) { + this._t = undefined; + return step(1); + } + if (kind == 'keys') return step(0, index); + if (kind == 'values') return step(0, O[index]); + return step(0, [index, O[index]]); +}, 'values'); + +// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) +Iterators.Arguments = Iterators.Array; + +addToUnscopables('keys'); +addToUnscopables('values'); +addToUnscopables('entries'); + +},{"./_add-to-unscopables":19,"./_iter-define":43,"./_iter-step":45,"./_iterators":46,"./_to-iobject":64}],75:[function(require,module,exports){ +var $export = require('./_export'); +// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) +$export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f }); + +},{"./_descriptors":28,"./_export":31,"./_object-dp":50}],76:[function(require,module,exports){ +// 19.1.2.5 Object.freeze(O) +var isObject = require('./_is-object'); +var meta = require('./_meta').onFreeze; + +require('./_object-sap')('freeze', function ($freeze) { + return function freeze(it) { + return $freeze && isObject(it) ? $freeze(meta(it)) : it; + }; +}); + +},{"./_is-object":40,"./_meta":48,"./_object-sap":55}],77:[function(require,module,exports){ +'use strict'; +var $at = require('./_string-at')(true); + +// 21.1.3.27 String.prototype[@@iterator]() +require('./_iter-define')(String, 'String', function (iterated) { + this._t = String(iterated); // target + this._i = 0; // next index +// 21.1.5.2.1 %StringIteratorPrototype%.next() +}, function () { + var O = this._t; + var index = this._i; + var point; + if (index >= O.length) return { value: undefined, done: true }; + point = $at(O, index); + this._i += point.length; + return { value: point, done: false }; +}); + +},{"./_iter-define":43,"./_string-at":61}],78:[function(require,module,exports){ +require('./es6.array.iterator'); +var global = require('./_global'); +var hide = require('./_hide'); +var Iterators = require('./_iterators'); +var TO_STRING_TAG = require('./_wks')('toStringTag'); + +var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' + + 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' + + 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' + + 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' + + 'TextTrackList,TouchList').split(','); + +for (var i = 0; i < DOMIterables.length; i++) { + var NAME = DOMIterables[i]; + var Collection = global[NAME]; + var proto = Collection && Collection.prototype; + if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME); + Iterators[NAME] = Iterators.Array; +} + +},{"./_global":33,"./_hide":35,"./_iterators":46,"./_wks":69,"./es6.array.iterator":74}],79:[function(require,module,exports){ function getRelocatable(re) { // In the future, this could use a WeakMap instead of an expando. if (!re.__matchAtRelocatable) { // Disjunctions are the lowest-precedence operator, so we can make any // pattern match the empty string by appending `|()` to it: // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-patterns - var source = re.source + "|()"; + var source = re.source + '|()'; // We always make the new regex global. - var flags = "g" + (re.ignoreCase ? "i" : "") + (re.multiline ? "m" : "") + (re.unicode ? "u" : "") + var flags = 'g' + (re.ignoreCase ? 'i' : '') + (re.multiline ? 'm' : '') + (re.unicode ? 'u' : '') // sticky (/.../y) doesn't make sense in conjunction with our relocation // logic, so we ignore it here. ; @@ -143,7 +1191,7 @@ function getRelocatable(re) { function matchAt(re, str, pos) { if (re.global || re.sticky) { - throw new Error("matchAt(...): Only non-global regexes are supported"); + throw new Error('matchAt(...): Only non-global regexes are supported'); } var reloc = getRelocatable(re); reloc.lastIndex = pos; @@ -160,72 +1208,133 @@ function matchAt(re, str, pos) { } module.exports = matchAt; -},{}],3:[function(require,module,exports){ -/** - * The Lexer class handles tokenizing the input in various ways. Since our - * parser expects us to be able to backtrack, the lexer allows lexing from any - * given starting point. - * - * Its main exposed function is the `lex` function, which takes a position to - * lex from and a type of token to lex. It defers to the appropriate `_innerLex` - * function. - * - * The various `_innerLex` functions perform the actual lexing of different - * kinds. - */ +},{}],80:[function(require,module,exports){ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ -var matchAt = require("match-at"); +'use strict'; +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; -var ParseError = require("./ParseError"); +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } -// The main lexer class -function Lexer(input) { - this.input = input; - this.pos = 0; + return Object(val); } -/** - * The resulting token returned from `lex`. - * - * It consists of the token text plus some position information. - * The position information is essentially a range in an input string, - * but instead of referencing the bare input string, we refer to the lexer. - * That way it is possible to attach extra metadata to the input string, - * like for example a file name or similar. - * - * The position information (all three parameters) is optional, - * so it is OK to construct synthetic tokens if appropriate. - * Not providing available position information may lead to - * degraded error reporting, though. - * - * @param {string} text the text of this token - * @param {number=} start the start offset, zero-based inclusive - * @param {number=} end the end offset, zero-based exclusive - * @param {Lexer=} lexer the lexer which in turn holds the input string - */ -function Token(text, start, end, lexer) { - this.text = text; - this.start = start; - this.end = end; - this.lexer = lexer; +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } } -/** - * Given a pair of tokens (this and endToken), compute a “Token” encompassing - * the whole input range enclosed by these two. - * - * @param {Token} endToken last token of the range, inclusive - * @param {string} text the text of the newly constructed token - */ -Token.prototype.range = function(endToken, text) { - if (endToken.lexer !== this.lexer) { - return new Token(text); // sorry, no position information available - } - return new Token(text, this.start, endToken.end, this.lexer); +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; }; +},{}],81:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.controlWordRegex = undefined; + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require("babel-runtime/helpers/createClass"); + +var _createClass3 = _interopRequireDefault(_createClass2); + +var _matchAt = require("match-at"); + +var _matchAt2 = _interopRequireDefault(_matchAt); + +var _ParseError = require("./ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +var _SourceLocation = require("./SourceLocation"); + +var _SourceLocation2 = _interopRequireDefault(_SourceLocation); + +var _Token = require("./Token"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + /* The following tokenRegex * - matches typical whitespace (but not NBSP etc.) using its first group + * - matches comments (must have trailing newlines) * - does not match any control character \x00-\x1f except whitespace * - does not match a bare backslash * - matches any ASCII character except those just mentioned @@ -239,111 +1348,431 @@ Token.prototype.range = function(endToken, text) { * If there is no matching function or symbol definition, the Parser will * still reject the input. */ -var tokenRegex = new RegExp( - "([ \r\n\t]+)|" + // whitespace - "([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint - "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + // surrogate pair - "|\\\\(?:[a-zA-Z]+|[^\uD800-\uDFFF])" + // function name - ")" -); /** - * This function lexes a single token. + * The Lexer class handles tokenizing the input in various ways. Since our + * parser expects us to be able to backtrack, the lexer allows lexing from any + * given starting point. + * + * Its main exposed function is the `lex` function, which takes a position to + * lex from and a type of token to lex. It defers to the appropriate `_innerLex` + * function. + * + * The various `_innerLex` functions perform the actual lexing of different + * kinds. */ -Lexer.prototype.lex = function() { - var input = this.input; - var pos = this.pos; - if (pos === input.length) { - return new Token("EOF", pos, pos, this); + +var commentRegexString = "%[^\n]*[\n]"; +var controlWordRegexString = "\\\\[a-zA-Z@]+"; +var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +var tokenRegex = new RegExp("([ \r\n\t]+)|" + ( // whitespace +"(" + commentRegexString + "|") + // comments +"[!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint +"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + // surrogate pair +"|\\\\verb\\*([^]).*?\\3" + // \verb* +"|\\\\verb([^*a-zA-Z]).*?\\4" + ( // \verb unstarred +"|" + controlWordRegexString) + ( // \macroName +"|" + controlSymbolRegexString) + // \\, \', etc. +")"); + +// tokenRegex has no ^ marker, as required by matchAt. +// These regexs are for matching results from tokenRegex, +// so they do have ^ markers. +var controlWordRegex = exports.controlWordRegex = new RegExp("^" + controlWordRegexString); +var commentRegex = new RegExp("^" + commentRegexString); + +/** Main Lexer class */ + +var Lexer = function () { + function Lexer(input) { + (0, _classCallCheck3.default)(this, Lexer); + + this.input = input; + this.pos = 0; } - var match = matchAt(tokenRegex, input, pos); - if (match === null) { - throw new ParseError( - "Unexpected character: '" + input[pos] + "'", - new Token(input[pos], pos, pos + 1, this)); + + /** + * This function lexes a single token. + */ + + + (0, _createClass3.default)(Lexer, [{ + key: "lex", + value: function lex() { + var input = this.input; + var pos = this.pos; + if (pos === input.length) { + return new _Token.Token("EOF", new _SourceLocation2.default(this, pos, pos)); + } + var match = (0, _matchAt2.default)(tokenRegex, input, pos); + if (match === null) { + throw new _ParseError2.default("Unexpected character: '" + input[pos] + "'", new _Token.Token(input[pos], new _SourceLocation2.default(this, pos, pos + 1))); + } + var text = match[2] || " "; + var start = this.pos; + this.pos += match[0].length; + var end = this.pos; + + if (commentRegex.test(text)) { + return this.lex(); + } else { + return new _Token.Token(text, new _SourceLocation2.default(this, start, end)); + } + } + }]); + return Lexer; +}(); + +exports.default = Lexer; + +},{"./ParseError":84,"./SourceLocation":88,"./Token":90,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9,"match-at":79}],82:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _toConsumableArray2 = require("babel-runtime/helpers/toConsumableArray"); + +var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require("babel-runtime/helpers/createClass"); + +var _createClass3 = _interopRequireDefault(_createClass2); + +var _Lexer = require("./Lexer"); + +var _Lexer2 = _interopRequireDefault(_Lexer); + +var _Token = require("./Token"); + +var _macros = require("./macros"); + +var _macros2 = _interopRequireDefault(_macros); + +var _ParseError = require("./ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +var _objectAssign = require("object-assign"); + +var _objectAssign2 = _interopRequireDefault(_objectAssign); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var MacroExpander = function () { + function MacroExpander(input, macros) { + (0, _classCallCheck3.default)(this, MacroExpander); + + this.lexer = new _Lexer2.default(input); + this.macros = (0, _objectAssign2.default)({}, _macros2.default, macros); + this.stack = []; // contains tokens in REVERSE order } - var text = match[2] || " "; - var start = this.pos; - this.pos += match[0].length; - var end = this.pos; - return new Token(text, start, end, this); -}; -module.exports = Lexer; + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ -},{"./ParseError":6,"match-at":2}],4:[function(require,module,exports){ -/** - * This file contains the “gullet” where macros are expanded - * until only non-macro tokens remain. - */ -var Lexer = require("./Lexer"); + (0, _createClass3.default)(MacroExpander, [{ + key: "future", + value: function future() { + if (this.stack.length === 0) { + this.pushToken(this.lexer.lex()); + } + return this.stack[this.stack.length - 1]; + } -function MacroExpander(input, macros) { - this.lexer = new Lexer(input); - this.macros = macros; - this.stack = []; // contains tokens in REVERSE order - this.discardedWhiteSpace = []; -} + /** + * Remove and return the next unexpanded token. + */ -/** - * Recursively expand first token, then return first non-expandable token. - */ -MacroExpander.prototype.nextToken = function() { - for (;;) { - if (this.stack.length === 0) { - this.stack.push(this.lexer.lex()); + }, { + key: "popToken", + value: function popToken() { + this.future(); // ensure non-empty stack + return this.stack.pop(); + } + + /** + * Add a given token to the token stack. In particular, this get be used + * to put back a token returned from one of the other methods. + */ + + }, { + key: "pushToken", + value: function pushToken(token) { + this.stack.push(token); } - var topToken = this.stack.pop(); - var name = topToken.text; - if (!(name.charAt(0) === "\\" && this.macros.hasOwnProperty(name))) { - return topToken; + + /** + * Append an array of tokens to the token stack. + */ + + }, { + key: "pushTokens", + value: function pushTokens(tokens) { + var _stack; + + (_stack = this.stack).push.apply(_stack, (0, _toConsumableArray3.default)(tokens)); } - var expansion = this.macros[name]; - if (typeof expansion === "string") { - var bodyLexer = new Lexer(expansion); - expansion = []; - var tok = bodyLexer.lex(); - while (tok.text !== "EOF") { - expansion.push(tok); - tok = bodyLexer.lex(); + + /** + * Consume all following space tokens, without expansion. + */ + + }, { + key: "consumeSpaces", + value: function consumeSpaces() { + for (;;) { + var token = this.future(); + if (token.text === " ") { + this.stack.pop(); + } else { + break; + } } - expansion.reverse(); // to fit in with stack using push and pop - this.macros[name] = expansion; } - this.stack = this.stack.concat(expansion); - } -}; -MacroExpander.prototype.get = function(ignoreSpace) { - this.discardedWhiteSpace = []; - var token = this.nextToken(); - if (ignoreSpace) { - while (token.text === " ") { - this.discardedWhiteSpace.push(token); - token = this.nextToken(); + /** + * Consume the specified number of arguments from the token stream, + * and return the resulting array of arguments. + */ + + }, { + key: "consumeArgs", + value: function consumeArgs(numArgs) { + var args = []; + // obtain arguments, either single token or balanced {…} group + for (var i = 0; i < numArgs; ++i) { + this.consumeSpaces(); // ignore spaces before each argument + var startOfArg = this.popToken(); + if (startOfArg.text === "{") { + var arg = []; + var depth = 1; + while (depth !== 0) { + var tok = this.popToken(); + arg.push(tok); + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + } else if (tok.text === "EOF") { + throw new _ParseError2.default("End of input in macro argument", startOfArg); + } + } + arg.pop(); // remove last } + arg.reverse(); // like above, to fit in with stack order + args[i] = arg; + } else if (startOfArg.text === "EOF") { + throw new _ParseError2.default("End of input expecting macro argument"); + } else { + args[i] = [startOfArg]; + } + } + return args; + } + + /** + * Expand the next token only once if possible. + * + * If the token is expanded, the resulting tokens will be pushed onto + * the stack in reverse order and will be returned as an array, + * also in reverse order. + * + * If not, the next token will be returned without removing it + * from the stack. This case can be detected by a `Token` return value + * instead of an `Array` return value. + * + * In either case, the next token will be on the top of the stack, + * or the stack will be empty. + * + * Used to implement `expandAfterFuture` and `expandNextToken`. + * + * At the moment, macro expansion doesn't handle delimited macros, + * i.e. things like those defined by \def\foo#1\end{…}. + * See the TeX book page 202ff. for details on how those should behave. + */ + + }, { + key: "expandOnce", + value: function expandOnce() { + var topToken = this.popToken(); + var name = topToken.text; + var isMacro = name.charAt(0) === "\\"; + if (isMacro && _Lexer.controlWordRegex.test(name)) { + // Consume all spaces after \macro (but not \\, \', etc.) + this.consumeSpaces(); + } + if (!this.macros.hasOwnProperty(name)) { + // Fully expanded + this.pushToken(topToken); + return topToken; + } + + var _getExpansion2 = this._getExpansion(name), + tokens = _getExpansion2.tokens, + numArgs = _getExpansion2.numArgs; + + var expansion = tokens; + if (numArgs) { + var args = this.consumeArgs(numArgs); + // paste arguments in place of the placeholders + expansion = expansion.slice(); // make a shallow copy + for (var i = expansion.length - 1; i >= 0; --i) { + var tok = expansion[i]; + if (tok.text === "#") { + if (i === 0) { + throw new _ParseError2.default("Incomplete placeholder at end of macro body", tok); + } + tok = expansion[--i]; // next token on stack + if (tok.text === "#") { + // ## → # + expansion.splice(i + 1, 1); // drop first # + } else if (/^[1-9]$/.test(tok.text)) { + var _expansion; + + // replace the placeholder with the indicated argument + (_expansion = expansion).splice.apply(_expansion, [i, 2].concat((0, _toConsumableArray3.default)(args[+tok.text - 1]))); + } else { + throw new _ParseError2.default("Not a valid argument number", tok); + } + } + } + } + // Concatenate expansion onto top of stack. + this.pushTokens(expansion); + return expansion; } - } - return token; -}; + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + * Equivalent to expandOnce() followed by future(). + */ + + }, { + key: "expandAfterFuture", + value: function expandAfterFuture() { + this.expandOnce(); + return this.future(); + } + + /** + * Recursively expand first token, then return first non-expandable token. + */ + + }, { + key: "expandNextToken", + value: function expandNextToken() { + for (;;) { + var expanded = this.expandOnce(); + // expandOnce returns Token if and only if it's fully expanded. + if (expanded instanceof _Token.Token) { + // \relax stops the expansion, but shouldn't get returned (a + // null return value couldn't get implemented as a function). + if (expanded.text === "\\relax") { + this.stack.pop(); + } else { + return this.stack.pop(); // === expanded + } + } + } + + // Flow unable to figure out that this pathway is impossible. + // https://github.com/facebook/flow/issues/4808 + throw new Error(); // eslint-disable-line no-unreachable + } + + /** + * Returns the expanded macro as a reversed array of tokens and a macro + * argument count. + * Caches macro expansions for those that were defined simple TeX strings. + */ + + }, { + key: "_getExpansion", + value: function _getExpansion(name) { + var definition = this.macros[name]; + var expansion = typeof definition === "function" ? definition(this) : definition; + if (typeof expansion === "string") { + var numArgs = 0; + if (expansion.indexOf("#") !== -1) { + var stripped = expansion.replace(/##/g, ""); + while (stripped.indexOf("#" + (numArgs + 1)) !== -1) { + ++numArgs; + } + } + var bodyLexer = new _Lexer2.default(expansion); + var tokens = []; + var tok = bodyLexer.lex(); + while (tok.text !== "EOF") { + tokens.push(tok); + tok = bodyLexer.lex(); + } + tokens.reverse(); // to fit in with stack using push and pop + var expanded = { tokens: tokens, numArgs: numArgs }; + // Cannot cache a macro defined using a function since it relies on + // parser context. + if (typeof definition !== "function") { + this.macros[name] = expanded; + } + return expanded; + } + + return expansion; + } + }]); + return MacroExpander; +}(); /** - * Undo the effect of the preceding call to the get method. - * A call to this method MUST be immediately preceded and immediately followed - * by a call to get. Only used during mode switching, i.e. after one token - * was got in the old mode but should get got again in a new mode - * with possibly different whitespace handling. + * This file contains the “gullet” where macros are expanded + * until only non-macro tokens remain. */ -MacroExpander.prototype.unget = function(token) { - this.stack.push(token); - while (this.discardedWhiteSpace.length !== 0) { - this.stack.push(this.discardedWhiteSpace.pop()); - } -}; -module.exports = MacroExpander; +exports.default = MacroExpander; + +},{"./Lexer":81,"./ParseError":84,"./Token":90,"./macros":120,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9,"babel-runtime/helpers/toConsumableArray":11,"object-assign":80}],83:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require("babel-runtime/helpers/createClass"); + +var _createClass3 = _interopRequireDefault(_createClass2); + +var _fontMetrics2 = require("./fontMetrics"); + +var _fontMetrics3 = _interopRequireDefault(_fontMetrics2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -},{"./Lexer":3}],5:[function(require,module,exports){ +var sizeStyleMap = [ +// Each element contains [textsize, scriptsize, scriptscriptsize]. +// The size mappings are taken from TeX with \normalsize=10pt. +[1, 1, 1], // size1: [5, 5, 5] \tiny +[2, 1, 1], // size2: [6, 5, 5] +[3, 1, 1], // size3: [7, 5, 5] \scriptsize +[4, 2, 1], // size4: [8, 6, 5] \footnotesize +[5, 2, 1], // size5: [9, 6, 5] \small +[6, 3, 1], // size6: [10, 7, 5] \normalsize +[7, 4, 2], // size7: [12, 8, 6] \large +[8, 6, 3], // size8: [14.4, 10, 7] \Large +[9, 7, 6], // size9: [17.28, 12, 10] \LARGE +[10, 8, 7], // size10: [20.74, 14.4, 12] \huge +[11, 10, 9]]; /** * This file contains information about the options that the Parser carries * around with it while parsing. Data is held in an `Options` object, and when @@ -351,117 +1780,245 @@ module.exports = MacroExpander; * `.reset` functions. */ +var sizeMultipliers = [ +// fontMetrics.js:getFontMetrics also uses size indexes, so if +// you change size indexes, change that function. +0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; + +var sizeAtStyle = function sizeAtStyle(size, style) { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; + /** - * This is the main options class. It contains the style, size, color, and font - * of the current parse level. It also contains the style and size of the parent - * parse level, so size changes can be handled efficiently. + * This is the main options class. It contains the current style, size, color, + * and font. * - * Each of the `.with*` and `.reset` functions passes its current style and size - * as the parentStyle and parentSize of the new options class, so parent - * handling is taken care of automatically. + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. */ -function Options(data) { - this.style = data.style; - this.color = data.color; - this.size = data.size; - this.phantom = data.phantom; - this.font = data.font; - - if (data.parentStyle === undefined) { - this.parentStyle = data.style; - } else { - this.parentStyle = data.parentStyle; - } +var Options = function () { + function Options(data) { + (0, _classCallCheck3.default)(this, Options); - if (data.parentSize === undefined) { - this.parentSize = data.size; - } else { - this.parentSize = data.parentSize; + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this._fontMetrics = undefined; } -} -/** - * Returns a new options object with the same properties as "this". Properties - * from "extension" will be copied to the new options object. - */ -Options.prototype.extend = function(extension) { - var data = { - style: this.style, - size: this.size, - color: this.color, - parentStyle: this.style, - parentSize: this.size, - phantom: this.phantom, - font: this.font, - }; + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + - for (var key in extension) { - if (extension.hasOwnProperty(key)) { - data[key] = extension[key]; + /** + * The base size index. + */ + + + (0, _createClass3.default)(Options, [{ + key: "extend", + value: function extend(extension) { + var data = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + maxSize: this.maxSize + }; + + for (var key in extension) { + if (extension.hasOwnProperty(key)) { + data[key] = extension[key]; + } + } + + return new Options(data); } - } - return new Options(data); -}; + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ -/** - * Create a new options object with the given style. - */ -Options.prototype.withStyle = function(style) { - return this.extend({ - style: style, - }); -}; + }, { + key: "havingStyle", + value: function havingStyle(style) { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style) + }); + } + } -/** - * Create a new options object with the given size. - */ -Options.prototype.withSize = function(size) { - return this.extend({ - size: size, - }); -}; + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ -/** - * Create a new options object with the given color. - */ -Options.prototype.withColor = function(color) { - return this.extend({ - color: color, - }); -}; + }, { + key: "havingCrampedStyle", + value: function havingCrampedStyle() { + return this.havingStyle(this.style.cramp()); + } -/** - * Create a new options object with "phantom" set to true. - */ -Options.prototype.withPhantom = function() { - return this.extend({ - phantom: true, - }); -}; + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ -/** - * Create a new options objects with the give font. - */ -Options.prototype.withFont = function(font) { - return this.extend({ - font: font, - }); -}; + }, { + key: "havingSize", + value: function havingSize(size) { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size + }); + } + } -/** - * Create a new options object with the same style, size, and color. This is - * used so that parent style and size changes are handled correctly. - */ -Options.prototype.reset = function() { - return this.extend({}); -}; + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + + }, { + key: "havingBaseStyle", + value: function havingBaseStyle(style) { + style = style || this.style.text(); + var wantSize = sizeAtStyle(Options.BASESIZE, style); + if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize + }); + } + } -/** - * A map of color names to CSS colors. - * TODO(emily): Remove this when we have real macros - */ -var colorMap = { + /** + * Create a new options object with the given color. + */ + + }, { + key: "withColor", + value: function withColor(color) { + return this.extend({ + color: color + }); + } + + /** + * Create a new options object with "phantom" set to true. + */ + + }, { + key: "withPhantom", + value: function withPhantom() { + return this.extend({ + phantom: true + }); + } + + /** + * Create a new options objects with the give font. + */ + + }, { + key: "withFont", + value: function withFont(font) { + return this.extend({ + font: font || this.font + }); + } + + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + + }, { + key: "sizingClasses", + value: function sizingClasses(oldOptions) { + if (oldOptions.size !== this.size) { + return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; + } else { + return []; + } + } + + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + + }, { + key: "baseSizingClasses", + value: function baseSizingClasses() { + if (this.size !== Options.BASESIZE) { + return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; + } else { + return []; + } + } + + /** + * Return the font metrics for this size. + */ + + }, { + key: "fontMetrics", + value: function fontMetrics() { + if (!this._fontMetrics) { + this._fontMetrics = _fontMetrics3.default.getFontMetrics(this.size); + } + return this._fontMetrics; + } + + /** + * A map of color names to CSS colors. + * TODO(emily): Remove this when we have real macros + */ + + }, { + key: "getColor", + + + /** + * Gets the CSS color of the current options object, accounting for the + * `colorMap`. + */ + value: function getColor() { + if (this.phantom) { + return "transparent"; + } else if (this.color != null && Options.colorMap.hasOwnProperty(this.color)) { + return Options.colorMap[this.color]; + } else { + return this.color; + } + } + }]); + return Options; +}(); + +Options.BASESIZE = 6; +Options.colorMap = { "katex-blue": "#6495ed", "katex-orange": "#ffa500", "katex-pink": "#ff00af", @@ -517,24 +2074,29 @@ var colorMap = { "katex-grayH": "#3b3e40", "katex-grayI": "#21242c", "katex-kaBlue": "#314453", - "katex-kaGreen": "#71B307", + "katex-kaGreen": "#71B307" }; +exports.default = Options; -/** - * Gets the CSS color of the current options object, accounting for the - * `colorMap`. - */ -Options.prototype.getColor = function() { - if (this.phantom) { - return "transparent"; - } else { - return colorMap[this.color] || this.color; - } -}; +},{"./fontMetrics":101,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],84:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); -module.exports = Options; +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _ParseNode = require("./ParseNode"); + +var _ParseNode2 = _interopRequireDefault(_ParseNode); + +var _Token = require("./Token"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -},{}],6:[function(require,module,exports){ /** * This is the ParseError class, which is the main error thrown by KaTeX * functions when something has gone wrong. This is used to distinguish internal @@ -542,24 +2104,28 @@ module.exports = Options; * * If possible, a caller should provide a Token or ParseNode with information * about where in the source string the problem occurred. - * - * @param {string} message The error message - * @param {(Token|ParseNode)=} token An object providing position information */ -function ParseError(message, token) { +var ParseError = +// Error position based on passed-in Token or ParseNode. + +function ParseError(message, // The error message +token) // An object providing position information +{ + (0, _classCallCheck3.default)(this, ParseError); + var error = "KaTeX parse error: " + message; - var start; - var end; + var start = void 0; - if (token && token.lexer && token.start <= token.end) { + var loc = token && token.loc; + if (loc && loc.start <= loc.end) { // If we have the input and a position, make the error a bit fancier // Get the input - var input = token.lexer.input; + var input = loc.lexer.input; // Prepend some information - start = token.start; - end = token.end; + start = loc.start; + var end = loc.end; if (start === input.length) { error += " at end of input: "; } else { @@ -570,13 +2136,13 @@ function ParseError(message, token) { var underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); // Extract some context from the input and add it to the error - var left; + var left = void 0; if (start > 15) { left = "…" + input.slice(start - 15, start); } else { left = input.slice(0, start); } - var right; + var right = void 0; if (end + 15 < input.length) { right = input.slice(end, end + 15) + "…"; } else { @@ -589,28 +2155,112 @@ function ParseError(message, token) { // See http://stackoverflow.com/a/8460753 var self = new Error(error); self.name = "ParseError"; + // $FlowFixMe self.__proto__ = ParseError.prototype; - + // $FlowFixMe self.position = start; return self; -} +}; + +// $FlowFixMe More hackery + -// More hackery ParseError.prototype.__proto__ = Error.prototype; -module.exports = ParseError; +exports.default = ParseError; -},{}],7:[function(require,module,exports){ -/* eslint no-constant-condition:0 */ -var functions = require("./functions"); -var environments = require("./environments"); -var MacroExpander = require("./MacroExpander"); -var symbols = require("./symbols"); -var utils = require("./utils"); -var cjkRegex = require("./unicodeRegexes").cjkRegex; +},{"./ParseNode":85,"./Token":90,"babel-runtime/helpers/classCallCheck":8}],85:[function(require,module,exports){ +"use strict"; -var parseData = require("./parseData"); -var ParseError = require("./ParseError"); +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _Token = require("./Token"); + +var _SourceLocation = require("./SourceLocation"); + +var _SourceLocation2 = _interopRequireDefault(_SourceLocation); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * The resulting parse tree nodes of the parse tree. + * + * It is possible to provide position information, so that a `ParseNode` can + * fulfill a role similar to a `Token` in error reporting. + * For details on the corresponding properties see `Token` constructor. + * Providing such information can lead to better error reporting. + */ +var ParseNode = function ParseNode(type, // type of node, like e.g. "ordgroup" +value, // type-specific representation of the node +mode, // parse mode in action for this node, "math" or "text" +firstToken, // first token of the input for this node, +lastToken) // last token of the input for this node, +// will default to firstToken if unset +{ + (0, _classCallCheck3.default)(this, ParseNode); + + this.type = type; + this.value = value; + this.mode = mode; + this.loc = _SourceLocation2.default.range(firstToken, lastToken); +}; + +exports.default = ParseNode; + +},{"./SourceLocation":88,"./Token":90,"babel-runtime/helpers/classCallCheck":8}],86:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require("babel-runtime/helpers/createClass"); + +var _createClass3 = _interopRequireDefault(_createClass2); + +var _functions = require("./functions"); + +var _functions2 = _interopRequireDefault(_functions); + +var _environments = require("./environments"); + +var _environments2 = _interopRequireDefault(_environments); + +var _MacroExpander = require("./MacroExpander"); + +var _MacroExpander2 = _interopRequireDefault(_MacroExpander); + +var _symbols = require("./symbols"); + +var _symbols2 = _interopRequireDefault(_symbols); + +var _utils = require("./utils"); + +var _utils2 = _interopRequireDefault(_utils); + +var _units = require("./units"); + +var _unicodeRegexes = require("./unicodeRegexes"); + +var _ParseNode = require("./ParseNode"); + +var _ParseNode2 = _interopRequireDefault(_ParseNode); + +var _ParseError = require("./ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * This file contains the parser used to parse out a TeX expression from the @@ -641,809 +2291,1196 @@ var ParseError = require("./ParseError"); * * The earlier functions return ParseNodes. * The later functions (which are called deeper in the parse) sometimes return - * ParseFuncOrArgument, which contain a ParseNode as well as some data about + * ParsedFuncOrArgOrDollar, which contain a ParseNode as well as some data about * whether the parsed object is a function which is missing some arguments, or a * standalone object which can be used as an argument to another function. */ +/* TODO: Uncomment when porting to flow. +type ParsedType = "fn" | "arg" | "$" +type ParsedFunc = {| + type: "fn", + result: string, // Function name defined via defineFunction (e.g. "\\frac"). + token: Token, +|}; +type ParsedArg = {| + type: "arg", + result: ParseNode, + token: Token, +|}; +type ParsedDollar = {| + // Math mode switch + type: "$", + result: "$", + token: Token, +|}; +type ParsedFuncOrArgOrDollar = ParsedFunc | ParsedArg | ParsedDollar; +*/ + /** - * Main Parser class + * @param {ParseNode} result + * @param {Token} token + * @return {ParsedArg} */ -function Parser(input, settings) { - // Create a new macro expander (gullet) and (indirectly via that) also a - // new lexer (mouth) for this parser (stomach, in the language of TeX) - this.gullet = new MacroExpander(input, settings.macros); - // Store the settings for use in parsing - this.settings = settings; +function newArgument(result, token) { + return { type: "arg", result: result, token: token }; } -var ParseNode = parseData.ParseNode; +/** + * @param {Token} token + * @return {ParsedFunc} + */ +/* eslint no-constant-condition:0 */ +function newFunction(token) { + return { type: "fn", result: token.text, token: token }; +} /** - * An initial function (without its arguments), or an argument to a function. - * The `result` argument should be a ParseNode. + * @param {Token} token + * @return {ParsedDollar} */ -function ParseFuncOrArgument(result, isFunction, token) { - this.result = result; - // Is this a function (i.e. is it something defined in functions.js)? - this.isFunction = isFunction; - this.token = token; +function newDollar(token) { + return { type: "$", result: "$", token: token }; } /** - * Checks a result to make sure it has the right type, and throws an - * appropriate error otherwise. - * - * @param {boolean=} consume whether to consume the expected token, - * defaults to true + * @param {ParsedFuncOrArgOrDollar} parsed + * @return {ParsedFuncOrArg} */ -Parser.prototype.expect = function(text, consume) { - if (this.nextToken.text !== text) { - throw new ParseError( - "Expected '" + text + "', got '" + this.nextToken.text + "'", - this.nextToken - ); +function assertFuncOrArg(parsed) { + if (parsed.type === "$") { + throw new _ParseError2.default("Unexpected $", parsed.token); } - if (consume !== false) { - this.consume(); + return parsed; +} + +var Parser = function () { + function Parser(input, settings) { + (0, _classCallCheck3.default)(this, Parser); + + // Create a new macro expander (gullet) and (indirectly via that) also a + // new lexer (mouth) for this parser (stomach, in the language of TeX) + this.gullet = new _MacroExpander2.default(input, settings.macros); + // Use old \color behavior (same as LaTeX's \textcolor) if requested. + // We do this after the macros object has been copied by MacroExpander. + if (settings.colorIsTextColor) { + this.gullet.macros["\\color"] = "\\textcolor"; + } + // Store the settings for use in parsing + this.settings = settings; + // Count leftright depth (for \middle errors) + this.leftrightDepth = 0; } -}; -/** - * Considers the current look ahead token as consumed, - * and fetches the one after that as the new look ahead. - */ -Parser.prototype.consume = function() { - this.nextToken = this.gullet.get(this.mode === "math"); -}; + /** + * Checks a result to make sure it has the right type, and throws an + * appropriate error otherwise. + * + * @param {boolean=} consume whether to consume the expected token, + * defaults to true + */ -Parser.prototype.switchMode = function(newMode) { - this.gullet.unget(this.nextToken); - this.mode = newMode; - this.consume(); -}; -/** - * Main parsing function, which parses an entire input. - * - * @return {?Array.<ParseNode>} - */ -Parser.prototype.parse = function() { - // Try to parse the input - this.mode = "math"; - this.consume(); - var parse = this.parseInput(); - return parse; -}; + (0, _createClass3.default)(Parser, [{ + key: "expect", + value: function expect(text, consume) { + if (this.nextToken.text !== text) { + throw new _ParseError2.default("Expected '" + text + "', got '" + this.nextToken.text + "'", this.nextToken); + } + if (consume !== false) { + this.consume(); + } + } -/** - * Parses an entire input tree. - */ -Parser.prototype.parseInput = function() { - // Parse an expression - var expression = this.parseExpression(false); - // If we succeeded, make sure there's an EOF at the end - this.expect("EOF", false); - return expression; -}; + /** + * Considers the current look ahead token as consumed, + * and fetches the one after that as the new look ahead. + */ -var endOfExpression = ["}", "\\end", "\\right", "&", "\\\\", "\\cr"]; + }, { + key: "consume", + value: function consume() { + this.nextToken = this.gullet.expandNextToken(); + } -/** - * Parses an "expression", which is a list of atoms. - * - * @param {boolean} breakOnInfix Should the parsing stop when we hit infix - * nodes? This happens when functions have higher precendence - * than infix nodes in implicit parses. - * - * @param {?string} breakOnTokenText The text of the token that the expression - * should end with, or `null` if something else should end the - * expression. - * - * @return {ParseNode} - */ -Parser.prototype.parseExpression = function(breakOnInfix, breakOnTokenText) { - var body = []; - // Keep adding atoms to the body until we can't parse any more atoms (either - // we reached the end, a }, or a \right) - while (true) { - var lex = this.nextToken; - if (endOfExpression.indexOf(lex.text) !== -1) { - break; + /** + * Switches between "text" and "math" modes. + */ + + }, { + key: "switchMode", + value: function switchMode(newMode) { + this.mode = newMode; } - if (breakOnTokenText && lex.text === breakOnTokenText) { - break; + + /** + * Main parsing function, which parses an entire input. + * + * @return {Array.<ParseNode>} + */ + + }, { + key: "parse", + value: function parse() { + // Try to parse the input + this.mode = "math"; + this.consume(); + var parse = this.parseInput(); + return parse; } - if (breakOnInfix && functions[lex.text] && functions[lex.text].infix) { - break; + + /** + * Parses an entire input tree. + */ + + }, { + key: "parseInput", + value: function parseInput() { + // Parse an expression + var expression = this.parseExpression(false); + // If we succeeded, make sure there's an EOF at the end + this.expect("EOF", false); + return expression; } - var atom = this.parseAtom(); - if (!atom) { - if (!this.settings.throwOnError && lex.text[0] === "\\") { - var errorNode = this.handleUnsupportedCmd(); - body.push(errorNode); - continue; - } + }, { + key: "parseExpression", + + + /** + * Parses an "expression", which is a list of atoms. + * + * @param {boolean} breakOnInfix Should the parsing stop when we hit infix + * nodes? This happens when functions have higher precendence + * than infix nodes in implicit parses. + * + * @param {?string} breakOnTokenText The text of the token that the expression + * should end with, or `null` if something else should end the + * expression. + * + * @return {Array<ParseNode>} + */ + value: function parseExpression(breakOnInfix, breakOnTokenText) { + var body = []; + // Keep adding atoms to the body until we can't parse any more atoms (either + // we reached the end, a }, or a \right) + while (true) { + // Ignore spaces in math mode + if (this.mode === "math") { + this.consumeSpaces(); + } + var lex = this.nextToken; + if (Parser.endOfExpression.indexOf(lex.text) !== -1) { + break; + } + if (breakOnTokenText && lex.text === breakOnTokenText) { + break; + } + if (breakOnInfix && _functions2.default[lex.text] && _functions2.default[lex.text].infix) { + break; + } + var atom = this.parseAtom(breakOnTokenText); + if (!atom) { + if (!this.settings.throwOnError && lex.text[0] === "\\") { + var errorNode = this.handleUnsupportedCmd(); + body.push(errorNode); + continue; + } - break; + break; + } + body.push(atom); + } + return this.handleInfixNodes(body); } - body.push(atom); - } - return this.handleInfixNodes(body); -}; -/** - * Rewrites infix operators such as \over with corresponding commands such - * as \frac. - * - * There can only be one infix operator per group. If there's more than one - * then the expression is ambiguous. This can be resolved by adding {}. - * - * @returns {Array} - */ -Parser.prototype.handleInfixNodes = function(body) { - var overIndex = -1; - var funcName; + /** + * Rewrites infix operators such as \over with corresponding commands such + * as \frac. + * + * There can only be one infix operator per group. If there's more than one + * then the expression is ambiguous. This can be resolved by adding {}. + * + * @param {Array<ParseNode>} body + * @return {Array<ParseNode>} + */ + + }, { + key: "handleInfixNodes", + value: function handleInfixNodes(body) { + var overIndex = -1; + var funcName = void 0; + + for (var i = 0; i < body.length; i++) { + var node = body[i]; + if (node.type === "infix") { + if (overIndex !== -1) { + throw new _ParseError2.default("only one infix operator per group", node.value.token); + } + overIndex = i; + funcName = node.value.replaceWith; + } + } - for (var i = 0; i < body.length; i++) { - var node = body[i]; - if (node.type === "infix") { if (overIndex !== -1) { - throw new ParseError( - "only one infix operator per group", - node.value.token); + var numerNode = void 0; + var denomNode = void 0; + + var numerBody = body.slice(0, overIndex); + var denomBody = body.slice(overIndex + 1); + + if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { + numerNode = numerBody[0]; + } else { + numerNode = new _ParseNode2.default("ordgroup", numerBody, this.mode); + } + + if (denomBody.length === 1 && denomBody[0].type === "ordgroup") { + denomNode = denomBody[0]; + } else { + denomNode = new _ParseNode2.default("ordgroup", denomBody, this.mode); + } + + var value = this.callFunction(funcName, [numerNode, denomNode], []); + return [new _ParseNode2.default(value.type, value, this.mode)]; + } else { + return body; } - overIndex = i; - funcName = node.value.replaceWith; } - } - if (overIndex !== -1) { - var numerNode; - var denomNode; + // The greediness of a superscript or subscript - var numerBody = body.slice(0, overIndex); - var denomBody = body.slice(overIndex + 1); + }, { + key: "handleSupSubscript", - if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { - numerNode = numerBody[0]; - } else { - numerNode = new ParseNode("ordgroup", numerBody, this.mode); - } - if (denomBody.length === 1 && denomBody[0].type === "ordgroup") { - denomNode = denomBody[0]; - } else { - denomNode = new ParseNode("ordgroup", denomBody, this.mode); + /** + * Handle a subscript or superscript with nice errors. + * @param {string} name For error reporting. + * @return {ParsedNode} + */ + value: function handleSupSubscript(name) { + var symbolToken = this.nextToken; + var symbol = symbolToken.text; + this.consume(); + this.consumeSpaces(); // ignore spaces before sup/subscript argument + var group = this.parseGroup(); + + if (!group) { + if (!this.settings.throwOnError && this.nextToken.text[0] === "\\") { + return this.handleUnsupportedCmd(); + } else { + throw new _ParseError2.default("Expected group after '" + symbol + "'", symbolToken); + } + } + + var arg = assertFuncOrArg(group); + if (arg.type === "fn") { + // ^ and _ have a greediness, so handle interactions with functions' + // greediness + var funcGreediness = _functions2.default[group.result].greediness; + if (funcGreediness > Parser.SUPSUB_GREEDINESS) { + return this.parseGivenFunction(group); + } else { + throw new _ParseError2.default("Got function '" + group.result + "' with no arguments " + "as " + name, symbolToken); + } + } else { + return group.result; + } } - var value = this.callFunction( - funcName, [numerNode, denomNode], null); - return [new ParseNode(value.type, value, this.mode)]; - } else { - return body; - } -}; + /** + * Converts the textual input of an unsupported command into a text node + * contained within a color node whose color is determined by errorColor + */ -// The greediness of a superscript or subscript -var SUPSUB_GREEDINESS = 1; + }, { + key: "handleUnsupportedCmd", + value: function handleUnsupportedCmd() { + var text = this.nextToken.text; + var textordArray = []; -/** - * Handle a subscript or superscript with nice errors. - */ -Parser.prototype.handleSupSubscript = function(name) { - var symbolToken = this.nextToken; - var symbol = symbolToken.text; - this.consume(); - var group = this.parseGroup(); + for (var i = 0; i < text.length; i++) { + textordArray.push(new _ParseNode2.default("textord", text[i], "text")); + } - if (!group) { - if (!this.settings.throwOnError && this.nextToken.text[0] === "\\") { - return this.handleUnsupportedCmd(); - } else { - throw new ParseError( - "Expected group after '" + symbol + "'", - symbolToken - ); - } - } else if (group.isFunction) { - // ^ and _ have a greediness, so handle interactions with functions' - // greediness - var funcGreediness = functions[group.result].greediness; - if (funcGreediness > SUPSUB_GREEDINESS) { - return this.parseFunction(group); - } else { - throw new ParseError( - "Got function '" + group.result + "' with no arguments " + - "as " + name, symbolToken); + var textNode = new _ParseNode2.default("text", { + body: textordArray, + type: "text" + }, this.mode); + + var colorNode = new _ParseNode2.default("color", { + color: this.settings.errorColor, + value: [textNode], + type: "color" + }, this.mode); + + this.consume(); + return colorNode; } - } else { - return group.result; - } -}; -/** - * Converts the textual input of an unsupported command into a text node - * contained within a color node whose color is determined by errorColor - */ -Parser.prototype.handleUnsupportedCmd = function() { - var text = this.nextToken.text; - var textordArray = []; + /** + * Parses a group with optional super/subscripts. + * + * @param {"]" | "}"} breakOnTokenText - character to stop parsing the group on. + * @return {?ParseNode} + */ + + }, { + key: "parseAtom", + value: function parseAtom(breakOnTokenText) { + // The body of an atom is an implicit group, so that things like + // \left(x\right)^2 work correctly. + var base = this.parseImplicitGroup(breakOnTokenText); + + // In text mode, we don't have superscripts or subscripts + if (this.mode === "text") { + return base; + } - for (var i = 0; i < text.length; i++) { - textordArray.push(new ParseNode("textord", text[i], "text")); - } + // Note that base may be empty (i.e. null) at this point. + + var superscript = void 0; + var subscript = void 0; + while (true) { + // Guaranteed in math mode, so eat any spaces first. + this.consumeSpaces(); + + // Lex the first token + var lex = this.nextToken; + + if (lex.text === "\\limits" || lex.text === "\\nolimits") { + // We got a limit control + if (!base || base.type !== "op") { + throw new _ParseError2.default("Limit controls must follow a math operator", lex); + } else { + var limits = lex.text === "\\limits"; + base.value.limits = limits; + base.value.alwaysHandleSupSub = true; + } + this.consume(); + } else if (lex.text === "^") { + // We got a superscript start + if (superscript) { + throw new _ParseError2.default("Double superscript", lex); + } + superscript = this.handleSupSubscript("superscript"); + } else if (lex.text === "_") { + // We got a subscript start + if (subscript) { + throw new _ParseError2.default("Double subscript", lex); + } + subscript = this.handleSupSubscript("subscript"); + } else if (lex.text === "'") { + // We got a prime + if (superscript) { + throw new _ParseError2.default("Double superscript", lex); + } + var prime = new _ParseNode2.default("textord", "\\prime", this.mode); + + // Many primes can be grouped together, so we handle this here + var primes = [prime]; + this.consume(); + // Keep lexing tokens until we get something that's not a prime + while (this.nextToken.text === "'") { + // For each one, add another prime to the list + primes.push(prime); + this.consume(); + } + // If there's a superscript following the primes, combine that + // superscript in with the primes. + if (this.nextToken.text === "^") { + primes.push(this.handleSupSubscript("superscript")); + } + // Put everything into an ordgroup as the superscript + superscript = new _ParseNode2.default("ordgroup", primes, this.mode); + } else { + // If it wasn't ^, _, or ', stop parsing super/subscripts + break; + } + } - var textNode = new ParseNode( - "text", - { - body: textordArray, - type: "text", - }, - this.mode); + if (superscript || subscript) { + // If we got either a superscript or subscript, create a supsub + return new _ParseNode2.default("supsub", { + base: base, + sup: superscript, + sub: subscript + }, this.mode); + } else { + // Otherwise return the original body + return base; + } + } - var colorNode = new ParseNode( - "color", - { - color: this.settings.errorColor, - value: [textNode], - type: "color", - }, - this.mode); + // A list of the size-changing functions, for use in parseImplicitGroup - this.consume(); - return colorNode; -}; -/** - * Parses a group with optional super/subscripts. - * - * @return {?ParseNode} - */ -Parser.prototype.parseAtom = function() { - // The body of an atom is an implicit group, so that things like - // \left(x\right)^2 work correctly. - var base = this.parseImplicitGroup(); + // A list of the style-changing functions, for use in parseImplicitGroup - // In text mode, we don't have superscripts or subscripts - if (this.mode === "text") { - return base; - } - // Note that base may be empty (i.e. null) at this point. + // Old font functions - var superscript; - var subscript; - while (true) { - // Lex the first token - var lex = this.nextToken; - - if (lex.text === "\\limits" || lex.text === "\\nolimits") { - // We got a limit control - if (!base || base.type !== "op") { - throw new ParseError( - "Limit controls must follow a math operator", - lex); - } else { - var limits = lex.text === "\\limits"; - base.value.limits = limits; - base.value.alwaysHandleSupSub = true; + }, { + key: "parseImplicitGroup", + + + /** + * Parses an implicit group, which is a group that starts at the end of a + * specified, and ends right before a higher explicit group ends, or at EOL. It + * is used for functions that appear to affect the current style, like \Large or + * \textrm, where instead of keeping a style we just pretend that there is an + * implicit grouping after it until the end of the group. E.g. + * small text {\Large large text} small text again + * It is also used for \left and \right to get the correct grouping. + * + * @param {"]" | "}"} breakOnTokenText - character to stop parsing the group on. + * @return {?ParseNode} + */ + value: function parseImplicitGroup(breakOnTokenText) { + var start = this.parseSymbol(); + + if (start == null) { + // If we didn't get anything we handle, fall back to parseFunction + return this.parseFunction(); } - this.consume(); - } else if (lex.text === "^") { - // We got a superscript start - if (superscript) { - throw new ParseError("Double superscript", lex); - } - superscript = this.handleSupSubscript("superscript"); - } else if (lex.text === "_") { - // We got a subscript start - if (subscript) { - throw new ParseError("Double subscript", lex); - } - subscript = this.handleSupSubscript("subscript"); - } else if (lex.text === "'") { - // We got a prime - var prime = new ParseNode("textord", "\\prime", this.mode); - - // Many primes can be grouped together, so we handle this here - var primes = [prime]; - this.consume(); - // Keep lexing tokens until we get something that's not a prime - while (this.nextToken.text === "'") { - // For each one, add another prime to the list - primes.push(prime); + + var func = start.result; + + if (func === "\\left") { + // If we see a left: + // Parse the entire left function (including the delimiter) + var left = this.parseGivenFunction(start); + // Parse out the implicit body + ++this.leftrightDepth; + var body = this.parseExpression(false); + --this.leftrightDepth; + // Check the next token + this.expect("\\right", false); + var right = this.parseFunction(); + return new _ParseNode2.default("leftright", { + body: body, + left: left.value.value, + right: right.value.value + }, this.mode); + } else if (func === "\\begin") { + // begin...end is similar to left...right + var begin = this.parseGivenFunction(start); + var envName = begin.value.name; + if (!_environments2.default.has(envName)) { + throw new _ParseError2.default("No such environment: " + envName, begin.value.nameGroup); + } + // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + var env = _environments2.default.get(envName); + + var _parseArguments = this.parseArguments("\\begin{" + envName + "}", env), + args = _parseArguments.args, + optArgs = _parseArguments.optArgs; + + var context = { + mode: this.mode, + envName: envName, + parser: this + }; + var result = env.handler(context, args, optArgs); + this.expect("\\end", false); + var endNameToken = this.nextToken; + var end = this.parseFunction(); + if (end.value.name !== envName) { + throw new _ParseError2.default("Mismatch: \\begin{" + envName + "} matched " + "by \\end{" + end.value.name + "}", endNameToken); + } + result.position = end.position; + return result; + } else if (_utils2.default.contains(Parser.sizeFuncs, func)) { + // If we see a sizing function, parse out the implicit body + this.consumeSpaces(); + var _body = this.parseExpression(false, breakOnTokenText); + return new _ParseNode2.default("sizing", { + // Figure out what size to use based on the list of functions above + size: _utils2.default.indexOf(Parser.sizeFuncs, func) + 1, + value: _body + }, this.mode); + } else if (_utils2.default.contains(Parser.styleFuncs, func)) { + // If we see a styling function, parse out the implicit body + this.consumeSpaces(); + var _body2 = this.parseExpression(true, breakOnTokenText); + return new _ParseNode2.default("styling", { + // Figure out what style to use by pulling out the style from + // the function name + style: func.slice(1, func.length - 5), + value: _body2 + }, this.mode); + } else if (func in Parser.oldFontFuncs) { + var style = Parser.oldFontFuncs[func]; + // If we see an old font function, parse out the implicit body + this.consumeSpaces(); + var _body3 = this.parseExpression(true, breakOnTokenText); + if (style.slice(0, 4) === 'text') { + return new _ParseNode2.default("text", { + style: style, + body: new _ParseNode2.default("ordgroup", _body3, this.mode) + }, this.mode); + } else { + return new _ParseNode2.default("font", { + font: style, + body: new _ParseNode2.default("ordgroup", _body3, this.mode) + }, this.mode); + } + } else if (func === "\\color") { + // If we see a styling function, parse out the implicit body + var color = this.parseColorGroup(false); + if (!color) { + throw new _ParseError2.default("\\color not followed by color"); + } + var _body4 = this.parseExpression(true, breakOnTokenText); + return new _ParseNode2.default("color", { + type: "color", + color: color.result.value, + value: _body4 + }, this.mode); + } else if (func === "$") { + if (this.mode === "math") { + throw new _ParseError2.default("$ within math mode"); + } this.consume(); + var outerMode = this.mode; + this.switchMode("math"); + var _body5 = this.parseExpression(false, "$"); + this.expect("$", true); + this.switchMode(outerMode); + return new _ParseNode2.default("styling", { + style: "text", + value: _body5 + }, "math"); + } else { + // Defer to parseGivenFunction if it's not a function we handle + return this.parseGivenFunction(start); } - // Put them into an ordgroup as the superscript - superscript = new ParseNode("ordgroup", primes, this.mode); - } else { - // If it wasn't ^, _, or ', stop parsing super/subscripts - break; } - } - if (superscript || subscript) { - // If we got either a superscript or subscript, create a supsub - return new ParseNode("supsub", { - base: base, - sup: superscript, - sub: subscript, - }, this.mode); - } else { - // Otherwise return the original body - return base; - } -}; + /** + * Parses an entire function, including its base and all of its arguments. + * It also handles the case where the parsed node is not a function. + * + * @return {?ParseNode} + */ + + }, { + key: "parseFunction", + value: function parseFunction() { + var baseGroup = this.parseGroup(); + return baseGroup ? this.parseGivenFunction(baseGroup) : null; + } -// A list of the size-changing functions, for use in parseImplicitGroup -var sizeFuncs = [ - "\\tiny", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", - "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge", -]; + /** + * Same as parseFunction(), except that the base is provided, guaranteeing a + * non-nullable result. + * + * @param {ParsedFuncOrArgOrDollar} baseGroup + * @return {ParseNode} + */ + + }, { + key: "parseGivenFunction", + value: function parseGivenFunction(baseGroup) { + baseGroup = assertFuncOrArg(baseGroup); + if (baseGroup.type === "fn") { + var func = baseGroup.result; + var funcData = _functions2.default[func]; + if (this.mode === "text" && !funcData.allowedInText) { + throw new _ParseError2.default("Can't use function '" + func + "' in text mode", baseGroup.token); + } else if (this.mode === "math" && funcData.allowedInMath === false) { + throw new _ParseError2.default("Can't use function '" + func + "' in math mode", baseGroup.token); + } -// A list of the style-changing functions, for use in parseImplicitGroup -var styleFuncs = [ - "\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle", -]; + var _parseArguments2 = this.parseArguments(func, funcData), + args = _parseArguments2.args, + optArgs = _parseArguments2.optArgs; -/** - * Parses an implicit group, which is a group that starts at the end of a - * specified, and ends right before a higher explicit group ends, or at EOL. It - * is used for functions that appear to affect the current style, like \Large or - * \textrm, where instead of keeping a style we just pretend that there is an - * implicit grouping after it until the end of the group. E.g. - * small text {\Large large text} small text again - * It is also used for \left and \right to get the correct grouping. - * - * @return {?ParseNode} - */ -Parser.prototype.parseImplicitGroup = function() { - var start = this.parseSymbol(); - - if (start == null) { - // If we didn't get anything we handle, fall back to parseFunction - return this.parseFunction(); - } - - var func = start.result; - var body; - - if (func === "\\left") { - // If we see a left: - // Parse the entire left function (including the delimiter) - var left = this.parseFunction(start); - // Parse out the implicit body - body = this.parseExpression(false); - // Check the next token - this.expect("\\right", false); - var right = this.parseFunction(); - return new ParseNode("leftright", { - body: body, - left: left.value.value, - right: right.value.value, - }, this.mode); - } else if (func === "\\begin") { - // begin...end is similar to left...right - var begin = this.parseFunction(start); - var envName = begin.value.name; - if (!environments.hasOwnProperty(envName)) { - throw new ParseError( - "No such environment: " + envName, begin.value.nameGroup); - } - // Build the environment object. Arguments and other information will - // be made available to the begin and end methods using properties. - var env = environments[envName]; - var args = this.parseArguments("\\begin{" + envName + "}", env); - var context = { - mode: this.mode, - envName: envName, - parser: this, - positions: args.pop(), - }; - var result = env.handler(context, args); - this.expect("\\end", false); - var endNameToken = this.nextToken; - var end = this.parseFunction(); - if (end.value.name !== envName) { - throw new ParseError( - "Mismatch: \\begin{" + envName + "} matched " + - "by \\end{" + end.value.name + "}", - endNameToken); - } - result.position = end.position; - return result; - } else if (utils.contains(sizeFuncs, func)) { - // If we see a sizing function, parse out the implict body - body = this.parseExpression(false); - return new ParseNode("sizing", { - // Figure out what size to use based on the list of functions above - size: "size" + (utils.indexOf(sizeFuncs, func) + 1), - value: body, - }, this.mode); - } else if (utils.contains(styleFuncs, func)) { - // If we see a styling function, parse out the implict body - body = this.parseExpression(true); - return new ParseNode("styling", { - // Figure out what style to use by pulling out the style from - // the function name - style: func.slice(1, func.length - 5), - value: body, - }, this.mode); - } else { - // Defer to parseFunction if it's not a function we handle - return this.parseFunction(start); - } -}; + var token = baseGroup.token; + var result = this.callFunction(func, args, optArgs, token); + return new _ParseNode2.default(result.type, result, this.mode); + } else { + return baseGroup.result; + } + } -/** - * Parses an entire function, including its base and all of its arguments. - * The base might either have been parsed already, in which case - * it is provided as an argument, or it's the next group in the input. - * - * @param {ParseFuncOrArgument=} baseGroup optional as described above - * @return {?ParseNode} - */ -Parser.prototype.parseFunction = function(baseGroup) { - if (!baseGroup) { - baseGroup = this.parseGroup(); - } + /** + * Call a function handler with a suitable context and arguments. + * @param {string} name + * @param {Array<ParseNode>} args + * @param {Array<?ParseNode>} optArgs + * @param {Token=} token + */ + + }, { + key: "callFunction", + value: function callFunction(name, args, optArgs, token) { + var context = { + funcName: name, + parser: this, + token: token + }; + return _functions2.default[name].handler(context, args, optArgs); + } - if (baseGroup) { - if (baseGroup.isFunction) { - var func = baseGroup.result; - var funcData = functions[func]; - if (this.mode === "text" && !funcData.allowedInText) { - throw new ParseError( - "Can't use function '" + func + "' in text mode", - baseGroup.token); + /** + * Parses the arguments of a function or environment + * + * @param {string} func "\name" or "\begin{name}" + * @param {{ + * numArgs: number, + * numOptionalArgs: (number|undefined), + * }} funcData + * @return {{ + * args: Array<ParseNode>, + * optArgs: Array<?ParseNode>, + * }} + */ + + }, { + key: "parseArguments", + value: function parseArguments(func, funcData) { + var totalArgs = funcData.numArgs + funcData.numOptionalArgs; + if (totalArgs === 0) { + return { args: [], optArgs: [] }; } - var args = this.parseArguments(func, funcData); - var token = baseGroup.token; - var result = this.callFunction(func, args, args.pop(), token); - return new ParseNode(result.type, result, this.mode); - } else { - return baseGroup.result; + var baseGreediness = funcData.greediness; + var args = []; + var optArgs = []; + + for (var i = 0; i < totalArgs; i++) { + var argType = funcData.argTypes && funcData.argTypes[i]; + var isOptional = i < funcData.numOptionalArgs; + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + if (i > 0 && !isOptional) { + this.consumeSpaces(); + } + // Also consume leading spaces in math mode, as parseSymbol + // won't know what to do with them. This can only happen with + // macros, e.g. \frac\foo\foo where \foo expands to a space symbol. + // In LaTeX, the \foo's get treated as (blank) arguments). + // In KaTeX, for now, both spaces will get consumed. + // TODO(edemaine) + if (i === 0 && !isOptional && this.mode === "math") { + this.consumeSpaces(); + } + var nextToken = this.nextToken; + var arg = argType ? this.parseGroupOfType(argType, isOptional) : this.parseGroup(isOptional); + if (!arg) { + if (isOptional) { + optArgs.push(null); + continue; + } + if (!this.settings.throwOnError && this.nextToken.text[0] === "\\") { + arg = newArgument(this.handleUnsupportedCmd(), nextToken); + } else { + throw new _ParseError2.default("Expected group after '" + func + "'", nextToken); + } + } + var argNode = void 0; + arg = assertFuncOrArg(arg); + if (arg.type === "fn") { + var argGreediness = _functions2.default[arg.result].greediness; + if (argGreediness > baseGreediness) { + argNode = this.parseGivenFunction(arg); + } else { + throw new _ParseError2.default("Got function '" + arg.result + "' as " + "argument to '" + func + "'", nextToken); + } + } else { + argNode = arg.result; + } + (isOptional ? optArgs : args).push(argNode); + } + + return { args: args, optArgs: optArgs }; } - } else { - return null; - } -}; -/** - * Call a function handler with a suitable context and arguments. - */ -Parser.prototype.callFunction = function(name, args, positions, token) { - var context = { - funcName: name, - parser: this, - positions: positions, - token: token, - }; - return functions[name].handler(context, args); -}; + /** + * Parses a group when the mode is changing. + * + * @return {?ParsedFuncOrArgOrDollar} + */ + + }, { + key: "parseGroupOfType", + value: function parseGroupOfType(innerMode, optional) { + var outerMode = this.mode; + // Handle `original` argTypes + if (innerMode === "original") { + innerMode = outerMode; + } -/** - * Parses the arguments of a function or environment - * - * @param {string} func "\name" or "\begin{name}" - * @param {{numArgs:number,numOptionalArgs:number|undefined}} funcData - * @return the array of arguments, with the list of positions as last element - */ -Parser.prototype.parseArguments = function(func, funcData) { - var totalArgs = funcData.numArgs + funcData.numOptionalArgs; - if (totalArgs === 0) { - return [[this.pos]]; - } - - var baseGreediness = funcData.greediness; - var positions = [this.pos]; - var args = []; - - for (var i = 0; i < totalArgs; i++) { - var nextToken = this.nextToken; - var argType = funcData.argTypes && funcData.argTypes[i]; - var arg; - if (i < funcData.numOptionalArgs) { - if (argType) { - arg = this.parseGroupOfType(argType, true); + if (innerMode === "color") { + return this.parseColorGroup(optional); + } + if (innerMode === "size") { + return this.parseSizeGroup(optional); + } + if (innerMode === "url") { + return this.parseUrlGroup(optional); + } + + // By the time we get here, innerMode is one of "text" or "math". + // We switch the mode of the parser, recurse, then restore the old mode. + this.switchMode(innerMode); + var res = this.parseGroup(optional); + this.switchMode(outerMode); + return res; + } + }, { + key: "consumeSpaces", + value: function consumeSpaces() { + while (this.nextToken.text === " ") { + this.consume(); + } + } + + /** + * Parses a group, essentially returning the string formed by the + * brace-enclosed tokens plus some position information. + * + * @param {string} modeName Used to describe the mode in error messages + * @param {boolean=} optional Whether the group is optional or required + * @return {?Token} + */ + + }, { + key: "parseStringGroup", + value: function parseStringGroup(modeName, optional) { + if (optional && this.nextToken.text !== "[") { + return null; + } + var outerMode = this.mode; + this.mode = "text"; + this.expect(optional ? "[" : "{"); + var str = ""; + var firstToken = this.nextToken; + var lastToken = firstToken; + while (this.nextToken.text !== (optional ? "]" : "}")) { + if (this.nextToken.text === "EOF") { + throw new _ParseError2.default("Unexpected end of input in " + modeName, firstToken.range(this.nextToken, str)); + } + lastToken = this.nextToken; + str += lastToken.text; + this.consume(); + } + this.mode = outerMode; + this.expect(optional ? "]" : "}"); + return firstToken.range(lastToken, str); + } + + /** + * Parses a group, essentially returning the string formed by the + * brace-enclosed tokens plus some position information, possibly + * with nested braces. + * + * @param {string} modeName Used to describe the mode in error messages + * @param {boolean=} optional Whether the group is optional or required + * @return {?Token} + */ + + }, { + key: "parseStringGroupWithBalancedBraces", + value: function parseStringGroupWithBalancedBraces(modeName, optional) { + if (optional && this.nextToken.text !== "[") { + return null; + } + var outerMode = this.mode; + this.mode = "text"; + this.expect(optional ? "[" : "{"); + var str = ""; + var nest = 0; + var firstToken = this.nextToken; + var lastToken = firstToken; + while (nest > 0 || this.nextToken.text !== (optional ? "]" : "}")) { + if (this.nextToken.text === "EOF") { + throw new _ParseError2.default("Unexpected end of input in " + modeName, firstToken.range(this.nextToken, str)); + } + lastToken = this.nextToken; + str += lastToken.text; + if (lastToken.text === "{") { + nest += 1; + } else if (lastToken.text === "}") { + if (nest <= 0) { + throw new _ParseError2.default("Unbalanced brace of input in " + modeName, firstToken.range(this.nextToken, str)); + } else { + nest -= 1; + } + } + this.consume(); + } + this.mode = outerMode; + this.expect(optional ? "]" : "}"); + return firstToken.range(lastToken, str); + } + + /** + * Parses a regex-delimited group: the largest sequence of tokens + * whose concatenated strings match `regex`. Returns the string + * formed by the tokens plus some position information. + * + * @param {RegExp} regex + * @param {string} modeName Used to describe the mode in error messages + * @return {Token} + */ + + }, { + key: "parseRegexGroup", + value: function parseRegexGroup(regex, modeName) { + var outerMode = this.mode; + this.mode = "text"; + var firstToken = this.nextToken; + var lastToken = firstToken; + var str = ""; + while (this.nextToken.text !== "EOF" && regex.test(str + this.nextToken.text)) { + lastToken = this.nextToken; + str += lastToken.text; + this.consume(); + } + if (str === "") { + throw new _ParseError2.default("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken); + } + this.mode = outerMode; + return firstToken.range(lastToken, str); + } + + /** + * Parses a color description. + */ + + }, { + key: "parseColorGroup", + value: function parseColorGroup(optional) { + var res = this.parseStringGroup("color", optional); + if (!res) { + return null; + } + var match = /^(#[a-f0-9]{3}|#[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); + if (!match) { + throw new _ParseError2.default("Invalid color: '" + res.text + "'", res); + } + return newArgument(new _ParseNode2.default("color", match[0], this.mode), res); + } + + /** + * Parses a url string. + */ + + }, { + key: "parseUrlGroup", + value: function parseUrlGroup(optional) { + var res = this.parseStringGroupWithBalancedBraces("url", optional); + if (!res) { + return null; + } + var raw = res.text; + // hyperref package allows backslashes alone in href, but doesn't generate + // valid links in such cases; we interpret this as "undefiend" behaviour, + // and keep them as-is. Some browser will replace backslashes with + // forward slashes. + var url = raw.replace(/\\([#$%&~_^{}])/g, '$1'); + return newArgument(new _ParseNode2.default("url", url, this.mode), res); + } + + /** + * Parses a size specification, consisting of magnitude and unit. + */ + + }, { + key: "parseSizeGroup", + value: function parseSizeGroup(optional) { + var res = void 0; + if (!optional && this.nextToken.text !== "{") { + res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); } else { - arg = this.parseGroup(true); + res = this.parseStringGroup("size", optional); } - if (!arg) { - args.push(null); - positions.push(this.pos); - continue; + if (!res) { + return null; } - } else { - if (argType) { - arg = this.parseGroupOfType(argType); + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); + if (!match) { + throw new _ParseError2.default("Invalid size: '" + res.text + "'", res); + } + var data = { + number: +(match[1] + match[2]), // sign + magnitude, cast to number + unit: match[3] + }; + if (!(0, _units.validUnit)(data)) { + throw new _ParseError2.default("Invalid unit: '" + data.unit + "'", res); + } + return newArgument(new _ParseNode2.default("size", data, this.mode), res); + } + + /** + * If the argument is false or absent, this parses an ordinary group, + * which is either a single nucleus (like "x") or an expression + * in braces (like "{x+y}"). + * If the argument is true, it parses either a bracket-delimited expression + * (like "[x+y]") or returns null to indicate the absence of a + * bracket-enclosed group. + * + * @param {boolean=} optional Whether the group is optional or required + * @return {?ParsedFuncOrArgOrDollar} + */ + + }, { + key: "parseGroup", + value: function parseGroup(optional) { + var firstToken = this.nextToken; + // Try to parse an open brace + if (this.nextToken.text === (optional ? "[" : "{")) { + // If we get a brace, parse an expression + this.consume(); + var expression = this.parseExpression(false, optional ? "]" : "}"); + var lastToken = this.nextToken; + // Make sure we get a close brace + this.expect(optional ? "]" : "}"); + if (this.mode === "text") { + this.formLigatures(expression); + } + return newArgument(new _ParseNode2.default("ordgroup", expression, this.mode, firstToken, lastToken), firstToken.range(lastToken, firstToken.text)); } else { - arg = this.parseGroup(); - } - if (!arg) { - if (!this.settings.throwOnError && - this.nextToken.text[0] === "\\") { - arg = new ParseFuncOrArgument( - this.handleUnsupportedCmd(this.nextToken.text), - false); - } else { - throw new ParseError( - "Expected group after '" + func + "'", nextToken); + // Otherwise, just return a nucleus, or nothing for an optional group + return optional ? null : this.parseSymbol(); + } + } + + /** + * Form ligature-like combinations of characters for text mode. + * This includes inputs like "--", "---", "``" and "''". + * The result will simply replace multiple textord nodes with a single + * character in each value by a single textord node having multiple + * characters in its value. The representation is still ASCII source. + * + * @param {Array.<ParseNode>} group the nodes of this group, + * list will be moified in place + */ + + }, { + key: "formLigatures", + value: function formLigatures(group) { + var n = group.length - 1; + for (var i = 0; i < n; ++i) { + var a = group[i]; + var v = a.value; + if (v === "-" && group[i + 1].value === "-") { + if (i + 1 < n && group[i + 2].value === "-") { + group.splice(i, 3, new _ParseNode2.default("textord", "---", "text", a, group[i + 2])); + n -= 2; + } else { + group.splice(i, 2, new _ParseNode2.default("textord", "--", "text", a, group[i + 1])); + n -= 1; + } + } + if ((v === "'" || v === "`") && group[i + 1].value === v) { + group.splice(i, 2, new _ParseNode2.default("textord", v + v, "text", a, group[i + 1])); + n -= 1; } } } - var argNode; - if (arg.isFunction) { - var argGreediness = - functions[arg.result].greediness; - if (argGreediness > baseGreediness) { - argNode = this.parseFunction(arg); + + /** + * Parse a single symbol out of the string. Here, we handle both the functions + * we have defined, as well as the single character symbols + * + * @return {?ParsedFuncOrArgOrDollar} + */ + + }, { + key: "parseSymbol", + value: function parseSymbol() { + var nucleus = this.nextToken; + + if (_functions2.default[nucleus.text]) { + this.consume(); + // If there exists a function with this name, we return the function and + // say that it is a function. + return newFunction(nucleus); + } else if (_symbols2.default[this.mode][nucleus.text]) { + this.consume(); + // Otherwise if this is a no-argument function, find the type it + // corresponds to in the symbols map + return newArgument(new _ParseNode2.default(_symbols2.default[this.mode][nucleus.text].group, nucleus.text, this.mode, nucleus), nucleus); + } else if (this.mode === "text" && _unicodeRegexes.cjkRegex.test(nucleus.text)) { + this.consume(); + return newArgument(new _ParseNode2.default("textord", nucleus.text, this.mode, nucleus), nucleus); + } else if (nucleus.text === "$") { + return newDollar(nucleus); + } else if (/^\\verb[^a-zA-Z]/.test(nucleus.text)) { + this.consume(); + var arg = nucleus.text.slice(5); + var star = arg.charAt(0) === "*"; + if (star) { + arg = arg.slice(1); + } + // Lexer's tokenRegex is constructed to always have matching + // first/last characters. + if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) { + throw new _ParseError2.default("\\verb assertion failed --\n please report what input caused this bug"); + } + arg = arg.slice(1, -1); // remove first and last char + return newArgument(new _ParseNode2.default("verb", { + body: arg, + star: star + }, "text"), nucleus); } else { - throw new ParseError( - "Got function '" + arg.result + "' as " + - "argument to '" + func + "'", nextToken); + return null; } - } else { - argNode = arg.result; } - args.push(argNode); - positions.push(this.pos); - } + }]); + return Parser; +}(); + +Parser.endOfExpression = ["}", "\\end", "\\right", "&", "\\\\", "\\cr"]; +Parser.SUPSUB_GREEDINESS = 1; +Parser.sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; +Parser.styleFuncs = ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"]; +Parser.oldFontFuncs = { + "\\rm": "mathrm", + "\\sf": "mathsf", + "\\tt": "mathtt", + "\\bf": "mathbf", + "\\it": "mathit" + //"\\sl": "textsl", + //"\\sc": "textsc", +}; +exports.default = Parser; + +},{"./MacroExpander":82,"./ParseError":84,"./ParseNode":85,"./environments":99,"./functions":103,"./symbols":125,"./unicodeRegexes":126,"./units":127,"./utils":128,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],87:[function(require,module,exports){ +"use strict"; - args.push(positions); +Object.defineProperty(exports, "__esModule", { + value: true +}); - return args; -}; +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); -/** - * Parses a group when the mode is changing. - * - * @return {?ParseFuncOrArgument} - */ -Parser.prototype.parseGroupOfType = function(innerMode, optional) { - var outerMode = this.mode; - // Handle `original` argTypes - if (innerMode === "original") { - innerMode = outerMode; - } +var _utils = require("./utils"); - if (innerMode === "color") { - return this.parseColorGroup(optional); - } - if (innerMode === "size") { - return this.parseSizeGroup(optional); - } +var _utils2 = _interopRequireDefault(_utils); - this.switchMode(innerMode); - if (innerMode === "text") { - // text mode is special because it should ignore the whitespace before - // it - while (this.nextToken.text === " ") { - this.consume(); - } - } - // By the time we get here, innerMode is one of "text" or "math". - // We switch the mode of the parser, recurse, then restore the old mode. - var res = this.parseGroup(optional); - this.switchMode(outerMode); - return res; -}; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** - * Parses a group, essentially returning the string formed by the - * brace-enclosed tokens plus some position information. + * The main Settings object * - * @param {string} modeName Used to describe the mode in error messages - * @param {boolean=} optional Whether the group is optional or required + * The current options stored are: + * - displayMode: Whether the expression should be typeset as inline math + * (false, the default), meaning that the math starts in + * \textstyle and is placed in an inline-block); or as display + * math (true), meaning that the math starts in \displaystyle + * and is placed in a block with vertical margin. */ -Parser.prototype.parseStringGroup = function(modeName, optional) { - if (optional && this.nextToken.text !== "[") { - return null; - } - var outerMode = this.mode; - this.mode = "text"; - this.expect(optional ? "[" : "{"); - var str = ""; - var firstToken = this.nextToken; - var lastToken = firstToken; - while (this.nextToken.text !== (optional ? "]" : "}")) { - if (this.nextToken.text === "EOF") { - throw new ParseError( - "Unexpected end of input in " + modeName, - firstToken.range(this.nextToken, str)); - } - lastToken = this.nextToken; - str += lastToken.text; - this.consume(); - } - this.mode = outerMode; - this.expect(optional ? "]" : "}"); - return firstToken.range(lastToken, str); -}; +var Settings = function Settings(options) { + (0, _classCallCheck3.default)(this, Settings); -/** - * Parses a color description. - */ -Parser.prototype.parseColorGroup = function(optional) { - var res = this.parseStringGroup("color", optional); - if (!res) { - return null; - } - var match = (/^(#[a-z0-9]+|[a-z]+)$/i).exec(res.text); - if (!match) { - throw new ParseError("Invalid color: '" + res.text + "'", res); - } - return new ParseFuncOrArgument( - new ParseNode("color", match[0], this.mode), - false); + // allow null options + options = options || {}; + this.displayMode = _utils2.default.deflt(options.displayMode, false); + this.throwOnError = _utils2.default.deflt(options.throwOnError, true); + this.errorColor = _utils2.default.deflt(options.errorColor, "#cc0000"); + this.macros = options.macros || {}; + this.colorIsTextColor = _utils2.default.deflt(options.colorIsTextColor, false); + this.maxSize = Math.max(0, _utils2.default.deflt(options.maxSize, Infinity)); }; - /** - * Parses a size specification, consisting of magnitude and unit. + * This is a module for storing settings passed into KaTeX. It correctly handles + * default settings. */ -Parser.prototype.parseSizeGroup = function(optional) { - var res = this.parseStringGroup("size", optional); - if (!res) { - return null; - } - var match = (/(-?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/).exec(res.text); - if (!match) { - throw new ParseError("Invalid size: '" + res.text + "'", res); - } - var data = { - number: +(match[1] + match[2]), // sign + magnitude, cast to number - unit: match[3], - }; - if (data.unit !== "em" && data.unit !== "ex") { - throw new ParseError("Invalid unit: '" + data.unit + "'", res); - } - return new ParseFuncOrArgument( - new ParseNode("color", data, this.mode), - false); -}; + +exports.default = Settings; + +},{"./utils":128,"babel-runtime/helpers/classCallCheck":8}],88:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _freeze = require("babel-runtime/core-js/object/freeze"); + +var _freeze2 = _interopRequireDefault(_freeze); + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require("babel-runtime/helpers/createClass"); + +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** - * If the argument is false or absent, this parses an ordinary group, - * which is either a single nucleus (like "x") or an expression - * in braces (like "{x+y}"). - * If the argument is true, it parses either a bracket-delimited expression - * (like "[x+y]") or returns null to indicate the absence of a - * bracket-enclosed group. - * - * @param {boolean=} optional Whether the group is optional or required - * @return {?ParseFuncOrArgument} + * Lexing or parsing positional information for error reporting. + * This object is immutable. */ -Parser.prototype.parseGroup = function(optional) { - var firstToken = this.nextToken; - // Try to parse an open brace - if (this.nextToken.text === (optional ? "[" : "{")) { - // If we get a brace, parse an expression - this.consume(); - var expression = this.parseExpression(false, optional ? "]" : null); - var lastToken = this.nextToken; - // Make sure we get a close brace - this.expect(optional ? "]" : "}"); - if (this.mode === "text") { - this.formLigatures(expression); - } - return new ParseFuncOrArgument( - new ParseNode("ordgroup", expression, this.mode, - firstToken, lastToken), - false); - } else { - // Otherwise, just return a nucleus, or nothing for an optional group - return optional ? null : this.parseSymbol(); +var SourceLocation = function () { + // End offset, zero-based exclusive. + + // Lexer holding the input string. + function SourceLocation(lexer, start, end) { + (0, _classCallCheck3.default)(this, SourceLocation); + + this.lexer = lexer; + this.start = start; + this.end = end; + (0, _freeze2.default)(this); // Immutable to allow sharing in range(). } -}; -/** - * Form ligature-like combinations of characters for text mode. - * This includes inputs like "--", "---", "``" and "''". - * The result will simply replace multiple textord nodes with a single - * character in each value by a single textord node having multiple - * characters in its value. The representation is still ASCII source. - * - * @param {Array.<ParseNode>} group the nodes of this group, - * list will be moified in place - */ -Parser.prototype.formLigatures = function(group) { - var i; - var n = group.length - 1; - for (i = 0; i < n; ++i) { - var a = group[i]; - var v = a.value; - if (v === "-" && group[i + 1].value === "-") { - if (i + 1 < n && group[i + 2].value === "-") { - group.splice(i, 3, new ParseNode( - "textord", "---", "text", a, group[i + 2])); - n -= 2; + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + // Start offset, zero-based inclusive. + + + (0, _createClass3.default)(SourceLocation, null, [{ + key: "range", + value: function range(first, second) { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { + return null; } else { - group.splice(i, 2, new ParseNode( - "textord", "--", "text", a, group[i + 1])); - n -= 1; + return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); } } - if ((v === "'" || v === "`") && group[i + 1].value === v) { - group.splice(i, 2, new ParseNode( - "textord", v + v, "text", a, group[i + 1])); - n -= 1; - } - } -}; + }]); + return SourceLocation; +}(); -/** - * Parse a single symbol out of the string. Here, we handle both the functions - * we have defined, as well as the single character symbols - * - * @return {?ParseFuncOrArgument} - */ -Parser.prototype.parseSymbol = function() { - var nucleus = this.nextToken; - - if (functions[nucleus.text]) { - this.consume(); - // If there exists a function with this name, we return the function and - // say that it is a function. - return new ParseFuncOrArgument( - nucleus.text, - true, nucleus); - } else if (symbols[this.mode][nucleus.text]) { - this.consume(); - // Otherwise if this is a no-argument function, find the type it - // corresponds to in the symbols map - return new ParseFuncOrArgument( - new ParseNode(symbols[this.mode][nucleus.text].group, - nucleus.text, this.mode, nucleus), - false, nucleus); - } else if (this.mode === "text" && cjkRegex.test(nucleus.text)) { - this.consume(); - return new ParseFuncOrArgument( - new ParseNode("textord", nucleus.text, this.mode, nucleus), - false, nucleus); - } else { - return null; - } -}; +exports.default = SourceLocation; -Parser.prototype.ParseNode = ParseNode; +},{"babel-runtime/core-js/object/freeze":7,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],89:[function(require,module,exports){ +"use strict"; -module.exports = Parser; +Object.defineProperty(exports, "__esModule", { + value: true +}); -},{"./MacroExpander":4,"./ParseError":6,"./environments":16,"./functions":19,"./parseData":21,"./symbols":23,"./unicodeRegexes":24,"./utils":25}],8:[function(require,module,exports){ -/** - * This is a module for storing settings passed into KaTeX. It correctly handles - * default settings. - */ +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); -/** - * Helper function for getting a default value if the value is undefined - */ -function get(option, defaultValue) { - return option === undefined ? defaultValue : option; -} +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); -/** - * The main Settings object - * - * The current options stored are: - * - displayMode: Whether the expression should be typeset by default in - * textstyle or displaystyle (default false) - */ -function Settings(options) { - // allow null options - options = options || {}; - this.displayMode = get(options.displayMode, false); - this.throwOnError = get(options.throwOnError, true); - this.errorColor = get(options.errorColor, "#cc0000"); - this.macros = options.macros || {}; -} +var _createClass2 = require("babel-runtime/helpers/createClass"); -module.exports = Settings; +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -},{}],9:[function(require,module,exports){ /** * This file contains information and classes for the various kinds of styles * used in TeX. It provides a generic `Style` class, which holds information @@ -1454,68 +3491,97 @@ module.exports = Settings; /** * The main style class. Contains a unique id for the style, a size (which is - * the same for cramped and uncramped version of a style), a cramped flag, and a - * size multiplier, which gives the size difference between a style and - * textstyle. + * the same for cramped and uncramped version of a style), and a cramped flag. */ -function Style(id, size, multiplier, cramped) { - this.id = id; - this.size = size; - this.cramped = cramped; - this.sizeMultiplier = multiplier; -} +var Style = function () { + function Style(id, size, cramped) { + (0, _classCallCheck3.default)(this, Style); -/** - * Get the style of a superscript given a base in the current style. - */ -Style.prototype.sup = function() { - return styles[sup[this.id]]; -}; + this.id = id; + this.size = size; + this.cramped = cramped; + } -/** - * Get the style of a subscript given a base in the current style. - */ -Style.prototype.sub = function() { - return styles[sub[this.id]]; -}; + /** + * Get the style of a superscript given a base in the current style. + */ -/** - * Get the style of a fraction numerator given the fraction in the current - * style. - */ -Style.prototype.fracNum = function() { - return styles[fracNum[this.id]]; -}; -/** - * Get the style of a fraction denominator given the fraction in the current - * style. - */ -Style.prototype.fracDen = function() { - return styles[fracDen[this.id]]; -}; + (0, _createClass3.default)(Style, [{ + key: "sup", + value: function sup() { + return styles[_sup[this.id]]; + } -/** - * Get the cramped version of a style (in particular, cramping a cramped style - * doesn't change the style). - */ -Style.prototype.cramp = function() { - return styles[cramp[this.id]]; -}; + /** + * Get the style of a subscript given a base in the current style. + */ -/** - * HTML class name, like "displaystyle cramped" - */ -Style.prototype.cls = function() { - return sizeNames[this.size] + (this.cramped ? " cramped" : " uncramped"); -}; + }, { + key: "sub", + value: function sub() { + return styles[_sub[this.id]]; + } + + /** + * Get the style of a fraction numerator given the fraction in the current + * style. + */ + + }, { + key: "fracNum", + value: function fracNum() { + return styles[_fracNum[this.id]]; + } + + /** + * Get the style of a fraction denominator given the fraction in the current + * style. + */ + + }, { + key: "fracDen", + value: function fracDen() { + return styles[_fracDen[this.id]]; + } + + /** + * Get the cramped version of a style (in particular, cramping a cramped style + * doesn't change the style). + */ + + }, { + key: "cramp", + value: function cramp() { + return styles[_cramp[this.id]]; + } + + /** + * Get a text or display version of this style. + */ + + }, { + key: "text", + value: function text() { + return styles[_text[this.id]]; + } + + /** + * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) + */ + + }, { + key: "isTight", + value: function isTight() { + return this.size >= 2; + } + }]); + return Style; +}(); + +// Export an interface for type checking, but don't expose the implementation. +// This way, no more styles can be generated. -/** - * HTML Reset class name, like "reset-textstyle" - */ -Style.prototype.reset = function() { - return resetNames[this.size]; -}; // IDs of the different styles var D = 0; @@ -1527,111 +3593,191 @@ var Sc = 5; var SS = 6; var SSc = 7; -// String names for the different sizes -var sizeNames = [ - "displaystyle textstyle", - "textstyle", - "scriptstyle", - "scriptscriptstyle", -]; - -// Reset names for the different sizes -var resetNames = [ - "reset-textstyle", - "reset-textstyle", - "reset-scriptstyle", - "reset-scriptscriptstyle", -]; - // Instances of the different styles -var styles = [ - new Style(D, 0, 1.0, false), - new Style(Dc, 0, 1.0, true), - new Style(T, 1, 1.0, false), - new Style(Tc, 1, 1.0, true), - new Style(S, 2, 0.7, false), - new Style(Sc, 2, 0.7, true), - new Style(SS, 3, 0.5, false), - new Style(SSc, 3, 0.5, true), -]; +var styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; // Lookup tables for switching from one style to another -var sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; -var sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; -var fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; -var fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; -var cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; - -// We only export some of the styles. Also, we don't export the `Style` class so -// no more styles can be generated. -module.exports = { +var _sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +var _sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +var _fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +var _fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +var _cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +var _text = [D, Dc, T, Tc, T, Tc, T, Tc]; + +// We only export some of the styles. +exports.default = { DISPLAY: styles[D], TEXT: styles[T], SCRIPT: styles[S], - SCRIPTSCRIPT: styles[SS], + SCRIPTSCRIPT: styles[SS] }; -},{}],10:[function(require,module,exports){ +},{"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],90:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Token = undefined; + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require("babel-runtime/helpers/createClass"); + +var _createClass3 = _interopRequireDefault(_createClass2); + +var _SourceLocation = require("./SourceLocation"); + +var _SourceLocation2 = _interopRequireDefault(_SourceLocation); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ + + +/** + * Interface required to break circular dependency between Token, Lexer, and + * ParseError. + */ +var Token = exports.Token = function () { + function Token(text, // the text of this token + loc) { + (0, _classCallCheck3.default)(this, Token); + + this.text = text; + this.loc = loc; + } + + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ + + + (0, _createClass3.default)(Token, [{ + key: "range", + value: function range(endToken, // last token of the range, inclusive + text) // the text of the newly constructed token + { + return new Token(text, _SourceLocation2.default.range(this, endToken)); + } + }]); + return Token; +}(); + +},{"./SourceLocation":88,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],91:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _getIterator2 = require("babel-runtime/core-js/get-iterator"); + +var _getIterator3 = _interopRequireDefault(_getIterator2); + +var _domTree = require("./domTree"); + +var _domTree2 = _interopRequireDefault(_domTree); + +var _fontMetrics = require("./fontMetrics"); + +var _fontMetrics2 = _interopRequireDefault(_fontMetrics); + +var _symbols = require("./symbols"); + +var _symbols2 = _interopRequireDefault(_symbols); + +var _utils = require("./utils"); + +var _utils2 = _interopRequireDefault(_utils); + +var _stretchy = require("./stretchy"); + +var _stretchy2 = _interopRequireDefault(_stretchy); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// The following have to be loaded from Main-Italic font, using class mainit +var mainitLetters = ["\\imath", // dotless i +"\\jmath", // dotless j +"\\pounds"]; + +/** + * Looks up the given symbol in fontMetrics, after applying any symbol + * replacements defined in symbol.js + */ + /* eslint no-console:0 */ /** * This module contains general functions that can be used for building * different kinds of domTree nodes in a consistent manner. */ -var domTree = require("./domTree"); -var fontMetrics = require("./fontMetrics"); -var symbols = require("./symbols"); -var utils = require("./utils"); - -var greekCapitals = [ - "\\Gamma", - "\\Delta", - "\\Theta", - "\\Lambda", - "\\Xi", - "\\Pi", - "\\Sigma", - "\\Upsilon", - "\\Phi", - "\\Psi", - "\\Omega", -]; - -// The following have to be loaded from Main-Italic font, using class mainit -var mainitLetters = [ - "\u0131", // dotless i, \imath - "\u0237", // dotless j, \jmath - "\u00a3", // \pounds -]; +var lookupSymbol = function lookupSymbol(value, +// TODO(#963): Use a union type for this. +fontFamily, mode) { + // Replace the value with its replaced value from symbol.js + if (_symbols2.default[mode][value] && _symbols2.default[mode][value].replace) { + value = _symbols2.default[mode][value].replace; + } + return { + value: value, + metrics: _fontMetrics2.default.getCharacterMetrics(value, fontFamily) + }; +}; /** * Makes a symbolNode after translation via the list of symbols in symbols.js. * Correctly pulls out metrics for the character, and optionally takes a list of * classes to be attached to the node. + * + * TODO: make argument order closer to makeSpan + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + * TODO(#953): Make `options` mandatory and always pass it in. */ -var makeSymbol = function(value, style, mode, color, classes) { - // Replace the value with its replaced value from symbol.js - if (symbols[mode][value] && symbols[mode][value].replace) { - value = symbols[mode][value].replace; - } +var makeSymbol = function makeSymbol(value, fontFamily, mode, options, classes) { + var lookup = lookupSymbol(value, fontFamily, mode); + var metrics = lookup.metrics; + value = lookup.value; - var metrics = fontMetrics.getCharacterMetrics(value, style); - - var symbolNode; + var symbolNode = void 0; if (metrics) { - symbolNode = new domTree.symbolNode( - value, metrics.height, metrics.depth, metrics.italic, metrics.skew, - classes); + var italic = metrics.italic; + if (mode === "text") { + italic = 0; + } + symbolNode = new _domTree2.default.symbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, classes); } else { // TODO(emily): Figure out a good way to only print this in development - typeof console !== "undefined" && console.warn( - "No character metrics for '" + value + "' in style '" + - style + "'"); - symbolNode = new domTree.symbolNode(value, 0, 0, 0, 0, classes); + typeof console !== "undefined" && console.warn("No character metrics for '" + value + "' in style '" + fontFamily + "'"); + symbolNode = new _domTree2.default.symbolNode(value, 0, 0, 0, 0, classes); } - if (color) { - symbolNode.style.color = color; + if (options) { + symbolNode.maxFontSize = options.sizeMultiplier; + if (options.style.isTight()) { + symbolNode.classes.push("mtight"); + } + var color = options.getColor(); + if (color) { + symbolNode.style.color = color; + } } return symbolNode; @@ -1640,103 +3786,147 @@ var makeSymbol = function(value, style, mode, color, classes) { /** * Makes a symbol in Main-Regular or AMS-Regular. * Used for rel, bin, open, close, inner, and punct. + * + * TODO(#953): Make `options` mandatory and always pass it in. */ -var mathsym = function(value, mode, color, classes) { +var mathsym = function mathsym(value, mode, options) { + var classes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; + // Decide what font to render the symbol in by its entry in the symbols // table. // Have a special case for when the value = \ because the \ is used as a // textord in unsupported command errors but cannot be parsed as a regular // text ordinal and is therefore not present as a symbol in the symbols // table for text - if (value === "\\" || symbols[mode][value].font === "main") { - return makeSymbol(value, "Main-Regular", mode, color, classes); + if (value === "\\" || _symbols2.default[mode][value].font === "main") { + return makeSymbol(value, "Main-Regular", mode, options, classes); } else { - return makeSymbol( - value, "AMS-Regular", mode, color, classes.concat(["amsrm"])); + return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); } }; /** * Makes a symbol in the default font for mathords and textords. */ -var mathDefault = function(value, mode, color, classes, type) { +var mathDefault = function mathDefault(value, mode, options, classes, type) { if (type === "mathord") { - return mathit(value, mode, color, classes); + var fontLookup = mathit(value, mode, options, classes); + return makeSymbol(value, fontLookup.fontName, mode, options, classes.concat([fontLookup.fontClass])); } else if (type === "textord") { - return makeSymbol( - value, "Main-Regular", mode, color, classes.concat(["mathrm"])); + var font = _symbols2.default[mode][value] && _symbols2.default[mode][value].font; + if (font === "ams") { + return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); + } else { + // if (font === "main") { + return makeSymbol(value, "Main-Regular", mode, options, classes.concat(["mathrm"])); + } } else { throw new Error("unexpected type: " + type + " in mathDefault"); } }; /** - * Makes a symbol in the italic math font. + * Determines which of the two font names (Main-Italic and Math-Italic) and + * corresponding style tags (mainit or mathit) to use for font "mathit", + * depending on the symbol. Use this function instead of fontMap for font + * "mathit". */ -var mathit = function(value, mode, color, classes) { +var mathit = function mathit(value, mode, options, classes) { if (/[0-9]/.test(value.charAt(0)) || - // glyphs for \imath and \jmath do not exist in Math-Italic so we - // need to use Main-Italic instead - utils.contains(mainitLetters, value) || - utils.contains(greekCapitals, value)) { - return makeSymbol( - value, "Main-Italic", mode, color, classes.concat(["mainit"])); + // glyphs for \imath and \jmath do not exist in Math-Italic so we + // need to use Main-Italic instead + _utils2.default.contains(mainitLetters, value)) { + return { + fontName: "Main-Italic", + fontClass: "mainit" + }; } else { - return makeSymbol( - value, "Math-Italic", mode, color, classes.concat(["mathit"])); + return { + fontName: "Math-Italic", + fontClass: "mathit" + }; } }; /** * Makes either a mathord or textord in the correct font and color. */ -var makeOrd = function(group, options, type) { +var makeOrd = function makeOrd(group, options, type) { var mode = group.mode; var value = group.value; - if (symbols[mode][value] && symbols[mode][value].replace) { - value = symbols[mode][value].replace; - } var classes = ["mord"]; - var color = options.getColor(); var font = options.font; if (font) { - if (font === "mathit" || utils.contains(mainitLetters, value)) { - return mathit(value, mode, color, classes); + var fontLookup = void 0; + if (font === "mathit" || _utils2.default.contains(mainitLetters, value)) { + fontLookup = mathit(value, mode, options, classes); } else { - var fontName = fontMap[font].fontName; - if (fontMetrics.getCharacterMetrics(value, fontName)) { - return makeSymbol( - value, fontName, mode, color, classes.concat([font])); - } else { - return mathDefault(value, mode, color, classes, type); - } + fontLookup = fontMap[font]; + } + if (lookupSymbol(value, fontLookup.fontName, mode).metrics) { + return makeSymbol(value, fontLookup.fontName, mode, options, classes.concat([fontLookup.fontClass || font])); + } else { + return mathDefault(value, mode, options, classes, type); } } else { - return mathDefault(value, mode, color, classes, type); + return mathDefault(value, mode, options, classes, type); + } +}; + +/** + * Combine as many characters as possible in the given array of characters + * via their tryCombine method. + */ +var tryCombineChars = function tryCombineChars(chars) { + for (var i = 0; i < chars.length - 1; i++) { + if (chars[i].tryCombine(chars[i + 1])) { + chars.splice(i + 1, 1); + i--; + } } + return chars; }; /** * Calculate the height, depth, and maxFontSize of an element based on its * children. */ -var sizeElementFromChildren = function(elem) { +var sizeElementFromChildren = function sizeElementFromChildren(elem) { var height = 0; var depth = 0; var maxFontSize = 0; - if (elem.children) { - for (var i = 0; i < elem.children.length; i++) { - if (elem.children[i].height > height) { - height = elem.children[i].height; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = (0, _getIterator3.default)(elem.children), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var child = _step.value; + + if (child.height > height) { + height = child.height; } - if (elem.children[i].depth > depth) { - depth = elem.children[i].depth; + if (child.depth > depth) { + depth = child.depth; } - if (elem.children[i].maxFontSize > maxFontSize) { - maxFontSize = elem.children[i].maxFontSize; + if (child.maxFontSize > maxFontSize) { + maxFontSize = child.maxFontSize; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; } } } @@ -1747,189 +3937,290 @@ var sizeElementFromChildren = function(elem) { }; /** - * Makes a span with the given list of classes, list of children, and color. + * Makes a span with the given list of classes, list of children, and options. + * + * TODO(#953): Ensure that `options` is always provided (currently some call + * sites don't pass it) and make the type below mandatory. + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. */ -var makeSpan = function(classes, children, color) { - var span = new domTree.span(classes, children); +var makeSpan = function makeSpan(classes, children, options) { + var span = new _domTree2.default.span(classes, children, options); sizeElementFromChildren(span); - if (color) { - span.style.color = color; - } - return span; }; +var makeLineSpan = function makeLineSpan(className, options) { + // Fill the entire span instead of just a border. That way, the min-height + // value in katex.less will ensure that at least one screen pixel displays. + var line = _stretchy2.default.ruleSpan(className, options); + line.height = options.fontMetrics().defaultRuleThickness; + line.style.height = line.height + "em"; + line.maxFontSize = 1.0; + return line; +}; + /** - * Makes a document fragment with the given list of children. + * Makes an anchor with the given href, list of classes, list of children, + * and options. */ -var makeFragment = function(children) { - var fragment = new domTree.documentFragment(children); +var makeAnchor = function makeAnchor(href, classes, children, options) { + var anchor = new _domTree2.default.anchor(href, classes, children, options); - sizeElementFromChildren(fragment); + sizeElementFromChildren(anchor); - return fragment; + return anchor; }; /** - * Makes an element placed in each of the vlist elements to ensure that each - * element has the same max font size. To do this, we create a zero-width space - * with the correct font size. + * Prepends the given children to the given span, updating height, depth, and + * maxFontSize. */ -var makeFontSizer = function(options, fontSize) { - var fontSizeInner = makeSpan([], [new domTree.symbolNode("\u200b")]); - fontSizeInner.style.fontSize = - (fontSize / options.style.sizeMultiplier) + "em"; - - var fontSizer = makeSpan( - ["fontsize-ensurer", "reset-" + options.size, "size5"], - [fontSizeInner]); +var prependChildren = function prependChildren(span, children) { + span.children = children.concat(span.children); - return fontSizer; + sizeElementFromChildren(span); }; /** - * Makes a vertical list by stacking elements and kerns on top of each other. - * Allows for many different ways of specifying the positioning method. - * - * Arguments: - * - children: A list of child or kern nodes to be stacked on top of each other - * (i.e. the first element will be at the bottom, and the last at - * the top). Element nodes are specified as - * {type: "elem", elem: node} - * while kern nodes are specified as - * {type: "kern", size: size} - * - positionType: The method by which the vlist should be positioned. Valid - * values are: - * - "individualShift": The children list only contains elem - * nodes, and each node contains an extra - * "shift" value of how much it should be - * shifted (note that shifting is always - * moving downwards). positionData is - * ignored. - * - "top": The positionData specifies the topmost point of - * the vlist (note this is expected to be a height, - * so positive values move up) - * - "bottom": The positionData specifies the bottommost point - * of the vlist (note this is expected to be a - * depth, so positive values move down - * - "shift": The vlist will be positioned such that its - * baseline is positionData away from the baseline - * of the first child. Positive values move - * downwards. - * - "firstBaseline": The vlist will be positioned such that - * its baseline is aligned with the - * baseline of the first child. - * positionData is ignored. (this is - * equivalent to "shift" with - * positionData=0) - * - positionData: Data used in different ways depending on positionType - * - options: An Options object - * + * Makes a document fragment with the given list of children. */ -var makeVList = function(children, positionType, positionData, options) { - var depth; - var currPos; - var i; - if (positionType === "individualShift") { - var oldChildren = children; - children = [oldChildren[0]]; - - // Add in kerns to the list of children to get each element to be +var makeFragment = function makeFragment(children) { + var fragment = new _domTree2.default.documentFragment(children); + + sizeElementFromChildren(fragment); + + return fragment; +}; + +// These are exact object types to catch typos in the names of the optional fields. + + +// A list of child or kern nodes to be stacked on top of each other (i.e. the +// first element will be at the bottom, and the last at the top). + + +// Computes the updated `children` list and the overall depth. +// +// This helper function for makeVList makes it easier to enforce type safety by +// allowing early exits (returns) in the logic. +var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { + if (params.positionType === "individualShift") { + var oldChildren = params.children; + var _children = [oldChildren[0]]; + + // Add in kerns to the list of params.children to get each element to be // shifted to the correct specified shift - depth = -oldChildren[0].shift - oldChildren[0].elem.depth; - currPos = depth; - for (i = 1; i < oldChildren.length; i++) { - var diff = -oldChildren[i].shift - currPos - - oldChildren[i].elem.depth; - var size = diff - - (oldChildren[i - 1].elem.height + - oldChildren[i - 1].elem.depth); + var _depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + var currPos = _depth; + for (var i = 1; i < oldChildren.length; i++) { + var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; + var _size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); currPos = currPos + diff; - children.push({type: "kern", size: size}); - children.push(oldChildren[i]); + _children.push({ type: "kern", size: _size }); + _children.push(oldChildren[i]); } - } else if (positionType === "top") { + + return { children: _children, depth: _depth }; + } + + var depth = void 0; + if (params.positionType === "top") { // We always start at the bottom, so calculate the bottom by adding up // all the sizes - var bottom = positionData; - for (i = 0; i < children.length; i++) { - if (children[i].type === "kern") { - bottom -= children[i].size; - } else { - bottom -= children[i].elem.height + children[i].elem.depth; + var bottom = params.positionData; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = (0, _getIterator3.default)(params.children), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var child = _step2.value; + + bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth; + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } } } + depth = bottom; - } else if (positionType === "bottom") { - depth = -positionData; - } else if (positionType === "shift") { - depth = -children[0].elem.depth - positionData; - } else if (positionType === "firstBaseline") { - depth = -children[0].elem.depth; + } else if (params.positionType === "bottom") { + depth = -params.positionData; } else { - depth = 0; + var firstChild = params.children[0]; + if (firstChild.type !== "elem") { + throw new Error('First child must have type "elem".'); + } + if (params.positionType === "shift") { + depth = -firstChild.elem.depth - params.positionData; + } else if (params.positionType === "firstBaseline") { + depth = -firstChild.elem.depth; + } else { + throw new Error("Invalid positionType " + params.positionType + "."); + } } + return { children: params.children, depth: depth }; +}; - // Make the fontSizer - var maxFontSize = 0; - for (i = 0; i < children.length; i++) { - if (children[i].type === "elem") { - maxFontSize = Math.max(maxFontSize, children[i].elem.maxFontSize); +/** + * Makes a vertical list by stacking elements and kerns on top of each other. + * Allows for many different ways of specifying the positioning method. + * + * See VListParam documentation above. + */ +var makeVList = function makeVList(params, options) { + var _getVListChildrenAndD = getVListChildrenAndDepth(params), + children = _getVListChildrenAndD.children, + depth = _getVListChildrenAndD.depth; + + // Create a strut that is taller than any list item. The strut is added to + // each item, where it will determine the item's baseline. Since it has + // `overflow:hidden`, the strut's top edge will sit on the item's line box's + // top edge and the strut's bottom edge will sit on the item's baseline, + // with no additional line-height spacing. This allows the item baseline to + // be positioned precisely without worrying about font ascent and + // line-height. + + + var pstrutSize = 0; + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; + + try { + for (var _iterator3 = (0, _getIterator3.default)(children), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + var child = _step3.value; + + if (child.type === "elem") { + var _elem = child.elem; + pstrutSize = Math.max(pstrutSize, _elem.maxFontSize, _elem.height); + } + } + } catch (err) { + _didIteratorError3 = true; + _iteratorError3 = err; + } finally { + try { + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } } } - var fontSizer = makeFontSizer(options, maxFontSize); + + pstrutSize += 2; + var pstrut = makeSpan(["pstrut"], []); + pstrut.style.height = pstrutSize + "em"; // Create a new list of actual children at the correct offsets var realChildren = []; - currPos = depth; - for (i = 0; i < children.length; i++) { - if (children[i].type === "kern") { - currPos += children[i].size; - } else { - var child = children[i].elem; + var minPos = depth; + var maxPos = depth; + var currPos = depth; + var _iteratorNormalCompletion4 = true; + var _didIteratorError4 = false; + var _iteratorError4 = undefined; + + try { + for (var _iterator4 = (0, _getIterator3.default)(children), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { + var _child = _step4.value; + + if (_child.type === "kern") { + currPos += _child.size; + } else { + var _elem2 = _child.elem; - var shift = -child.depth - currPos; - currPos += child.height + child.depth; + var childWrap = makeSpan([], [pstrut, _elem2]); + childWrap.style.top = -pstrutSize - currPos - _elem2.depth + "em"; + if (_child.marginLeft) { + childWrap.style.marginLeft = _child.marginLeft; + } + if (_child.marginRight) { + childWrap.style.marginRight = _child.marginRight; + } - var childWrap = makeSpan([], [fontSizer, child]); - childWrap.height -= shift; - childWrap.depth += shift; - childWrap.style.top = shift + "em"; + realChildren.push(childWrap); + currPos += _elem2.height + _elem2.depth; + } + minPos = Math.min(minPos, currPos); + maxPos = Math.max(maxPos, currPos); + } - realChildren.push(childWrap); + // The vlist contents go in a table-cell with `vertical-align:bottom`. + // This cell's bottom edge will determine the containing table's baseline + // without overly expanding the containing line-box. + } catch (err) { + _didIteratorError4 = true; + _iteratorError4 = err; + } finally { + try { + if (!_iteratorNormalCompletion4 && _iterator4.return) { + _iterator4.return(); + } + } finally { + if (_didIteratorError4) { + throw _iteratorError4; + } } } - // Add in an element at the end with no offset to fix the calculation of - // baselines in some browsers (namely IE, sometimes safari) - var baselineFix = makeSpan( - ["baseline-fix"], [fontSizer, new domTree.symbolNode("\u200b")]); - realChildren.push(baselineFix); - var vlist = makeSpan(["vlist"], realChildren); - // Fix the final height and depth, in case there were kerns at the ends - // since the makeSpan calculation won't take that in to account. - vlist.height = Math.max(currPos, vlist.height); - vlist.depth = Math.max(-depth, vlist.depth); - return vlist; -}; - -// A table of size -> font size for the different sizing functions -var sizingMultiplier = { - size1: 0.5, - size2: 0.7, - size3: 0.8, - size4: 0.9, - size5: 1.0, - size6: 1.2, - size7: 1.44, - size8: 1.73, - size9: 2.07, - size10: 2.49, + vlist.style.height = maxPos + "em"; + + // A second row is used if necessary to represent the vlist's depth. + var rows = void 0; + if (minPos < 0) { + var depthStrut = makeSpan(["vlist"], []); + depthStrut.style.height = -minPos + "em"; + + // Safari wants the first row to have inline content; otherwise it + // puts the bottom of the *second* row on the baseline. + var topStrut = makeSpan(["vlist-s"], [new _domTree2.default.symbolNode("\u200B")]); + + rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])]; + } else { + rows = [makeSpan(["vlist-r"], [vlist])]; + } + + var vtable = makeSpan(["vlist-t"], rows); + if (rows.length === 2) { + vtable.classes.push("vlist-t2"); + } + vtable.height = maxPos; + vtable.depth = -minPos; + return vtable; +}; + +// Converts verb group into body string, dealing with \verb* form +var makeVerb = function makeVerb(group, options) { + // TODO(#892): Make ParseNode type-safe and confirm `group.type` to guarantee + // that `group.value.body` is of type string. + var text = group.value.body; + if (group.value.star) { + text = text.replace(/ /g, "\u2423"); // Open Box + } else { + text = text.replace(/ /g, '\xA0'); // No-Break Space + // (so that, in particular, spaces don't coalesce) + } + return text; }; // A map of spacing functions to their attributes, like size and corresponding @@ -1937,32 +4228,32 @@ var sizingMultiplier = { var spacingFunctions = { "\\qquad": { size: "2em", - className: "qquad", + className: "qquad" }, "\\quad": { size: "1em", - className: "quad", + className: "quad" }, "\\enspace": { size: "0.5em", - className: "enspace", + className: "enspace" }, "\\;": { size: "0.277778em", - className: "thickspace", + className: "thickspace" }, "\\:": { size: "0.22222em", - className: "mediumspace", + className: "mediumspace" }, "\\,": { size: "0.16667em", - className: "thinspace", + className: "thinspace" }, "\\!": { size: "-0.16667em", - className: "negativethinspace", - }, + className: "negativethinspace" + } }; /** @@ -1975,11 +4266,15 @@ var fontMap = { // styles "mathbf": { variant: "bold", - fontName: "Main-Bold", + fontName: "Main-Bold" }, "mathrm": { variant: "normal", - fontName: "Main-Regular", + fontName: "Main-Regular" + }, + "textit": { + variant: "italic", + fontName: "Main-Italic" }, // "mathit" is missing because it requires the use of two fonts: Main-Italic @@ -1989,136 +4284,249 @@ var fontMap = { // families "mathbb": { variant: "double-struck", - fontName: "AMS-Regular", + fontName: "AMS-Regular" }, "mathcal": { variant: "script", - fontName: "Caligraphic-Regular", + fontName: "Caligraphic-Regular" }, "mathfrak": { variant: "fraktur", - fontName: "Fraktur-Regular", + fontName: "Fraktur-Regular" }, "mathscr": { variant: "script", - fontName: "Script-Regular", + fontName: "Script-Regular" }, "mathsf": { variant: "sans-serif", - fontName: "SansSerif-Regular", + fontName: "SansSerif-Regular" }, "mathtt": { variant: "monospace", - fontName: "Typewriter-Regular", - }, + fontName: "Typewriter-Regular" + } }; -module.exports = { +exports.default = { fontMap: fontMap, makeSymbol: makeSymbol, mathsym: mathsym, makeSpan: makeSpan, + makeLineSpan: makeLineSpan, + makeAnchor: makeAnchor, makeFragment: makeFragment, makeVList: makeVList, makeOrd: makeOrd, - sizingMultiplier: sizingMultiplier, - spacingFunctions: spacingFunctions, + makeVerb: makeVerb, + tryCombineChars: tryCombineChars, + prependChildren: prependChildren, + spacingFunctions: spacingFunctions }; -},{"./domTree":15,"./fontMetrics":17,"./symbols":23,"./utils":25}],11:[function(require,module,exports){ -/* eslint no-console:0 */ +},{"./domTree":98,"./fontMetrics":101,"./stretchy":123,"./symbols":125,"./utils":128,"babel-runtime/core-js/get-iterator":3}],92:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.buildGroup = exports.groupTypes = exports.makeNullDelimiter = exports.getTypeOfDomTree = exports.buildExpression = exports.spliceSpaces = undefined; + +var _stringify = require("babel-runtime/core-js/json/stringify"); + +var _stringify2 = _interopRequireDefault(_stringify); + +exports.default = buildHTML; + +var _ParseError = require("./ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +var _Style = require("./Style"); + +var _Style2 = _interopRequireDefault(_Style); + +var _buildCommon = require("./buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _delimiter = require("./delimiter"); + +var _delimiter2 = _interopRequireDefault(_delimiter); + +var _domTree = require("./domTree"); + +var _domTree2 = _interopRequireDefault(_domTree); + +var _units = require("./units"); + +var _utils = require("./utils"); + +var _utils2 = _interopRequireDefault(_utils); + +var _stretchy = require("./stretchy"); + +var _stretchy2 = _interopRequireDefault(_stretchy); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + /** + * WARNING: New methods on groupTypes should be added to src/functions. + * * This file does the main work of building a domTree structure from a parse * tree. The entry point is the `buildHTML` function, which takes a parse tree. * Then, the buildExpression, buildGroup, and various groupTypes functions are * called, to produce a final HTML tree. */ -var ParseError = require("./ParseError"); -var Style = require("./Style"); +var makeSpan = _buildCommon2.default.makeSpan; -var buildCommon = require("./buildCommon"); -var delimiter = require("./delimiter"); -var domTree = require("./domTree"); -var fontMetrics = require("./fontMetrics"); -var utils = require("./utils"); +var isSpace = function isSpace(node) { + return node instanceof _domTree2.default.span && node.classes[0] === "mspace"; +}; -var makeSpan = buildCommon.makeSpan; +// Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, +// and the text before Rule 19. +var isBin = function isBin(node) { + return node && node.classes[0] === "mbin"; +}; + +var isBinLeftCanceller = function isBinLeftCanceller(node, isRealGroup) { + // TODO: This code assumes that a node's math class is the first element + // of its `classes` array. A later cleanup should ensure this, for + // instance by changing the signature of `makeSpan`. + if (node) { + return _utils2.default.contains(["mbin", "mopen", "mrel", "mop", "mpunct"], node.classes[0]); + } else { + return isRealGroup; + } +}; + +var isBinRightCanceller = function isBinRightCanceller(node, isRealGroup) { + if (node) { + return _utils2.default.contains(["mrel", "mclose", "mpunct"], node.classes[0]); + } else { + return isRealGroup; + } +}; + +/** + * Splice out any spaces from `children` starting at position `i`, and return + * the spliced-out array. Returns null if `children[i]` does not exist or is not + * a space. + */ +var spliceSpaces = exports.spliceSpaces = function spliceSpaces(children, i) { + var j = i; + while (j < children.length && isSpace(children[j])) { + j++; + } + if (j === i) { + return null; + } else { + return children.splice(i, j - i); + } +}; /** * Take a list of nodes, build them in order, and return a list of the built - * nodes. This function handles the `prev` node correctly, and passes the - * previous element from the list as the prev of the next element. + * nodes. documentFragments are flattened into their contents, so the + * returned list contains no fragments. `isRealGroup` is true if `expression` + * is a real group (no atoms will be added on either side), as opposed to + * a partial group (e.g. one created by \color). */ -var buildExpression = function(expression, options, prev) { +var buildExpression = exports.buildExpression = function buildExpression(expression, options, isRealGroup) { + // Parse expressions into `groups`. var groups = []; for (var i = 0; i < expression.length; i++) { var group = expression[i]; - groups.push(buildGroup(group, options, prev)); - prev = group; + var output = buildGroup(group, options); + if (output instanceof _domTree2.default.documentFragment) { + Array.prototype.push.apply(groups, output.children); + } else { + groups.push(output); + } + } + // At this point `groups` consists entirely of `symbolNode`s and `span`s. + + // Explicit spaces (e.g., \;, \,) should be ignored with respect to atom + // spacing (e.g., "add thick space between mord and mrel"). Since CSS + // adjacency rules implement atom spacing, spaces should be invisible to + // CSS. So we splice them out of `groups` and into the atoms themselves. + for (var _i = 0; _i < groups.length; _i++) { + var spaces = spliceSpaces(groups, _i); + if (spaces) { + // Splicing of spaces may have removed all remaining groups. + if (_i < groups.length) { + // If there is a following group, move space within it. + if (groups[_i] instanceof _domTree2.default.symbolNode) { + groups[_i] = makeSpan([].concat(groups[_i].classes), [groups[_i]]); + } + _buildCommon2.default.prependChildren(groups[_i], spaces); + } else { + // Otherwise, put any spaces back at the end of the groups. + Array.prototype.push.apply(groups, spaces); + break; + } + } + } + + // Binary operators change to ordinary symbols in some contexts. + for (var _i2 = 0; _i2 < groups.length; _i2++) { + if (isBin(groups[_i2]) && (isBinLeftCanceller(groups[_i2 - 1], isRealGroup) || isBinRightCanceller(groups[_i2 + 1], isRealGroup))) { + groups[_i2].classes[0] = "mord"; + } + } + + // Process \\not commands within the group. + // TODO(kevinb): Handle multiple \\not commands in a row. + // TODO(kevinb): Handle \\not{abc} correctly. The \\not should appear over + // the 'a' instead of the 'c'. + for (var _i3 = 0; _i3 < groups.length; _i3++) { + if (groups[_i3].value === "\u0338" && _i3 + 1 < groups.length) { + var children = groups.slice(_i3, _i3 + 2); + + children[0].classes = ["mainrm"]; + // \u0338 is a combining glyph so we could reorder the children so + // that it comes after the other glyph. This works correctly on + // most browsers except for Safari. Instead we absolutely position + // the glyph and set its right side to match that of the other + // glyph which is visually equivalent. + children[0].style.position = "absolute"; + children[0].style.right = "0"; + + // Copy the classes from the second glyph to the new container. + // This is so it behaves the same as though there was no \\not. + var classes = groups[_i3 + 1].classes; + var container = makeSpan(classes, children); + + // LaTeX adds a space between ords separated by a \\not. + if (classes.indexOf("mord") !== -1) { + // \glue(\thickmuskip) 2.77771 plus 2.77771 + container.style.paddingLeft = "0.277771em"; + } + + // Ensure that the \u0338 is positioned relative to the container. + container.style.position = "relative"; + groups.splice(_i3, 2, container); + } } - return groups; -}; -// List of types used by getTypeOfGroup, -// see https://github.com/Khan/KaTeX/wiki/Examining-TeX#group-types -var groupToType = { - mathord: "mord", - textord: "mord", - bin: "mbin", - rel: "mrel", - text: "mord", - open: "mopen", - close: "mclose", - inner: "minner", - genfrac: "mord", - array: "mord", - spacing: "mord", - punct: "mpunct", - ordgroup: "mord", - op: "mop", - katex: "mord", - overline: "mord", - underline: "mord", - rule: "mord", - leftright: "minner", - sqrt: "mord", - accent: "mord", + return groups; }; -/** - * Gets the final math type of an expression, given its group type. This type is - * used to determine spacing between elements, and affects bin elements by - * causing them to change depending on what types are around them. This type - * must be attached to the outermost node of an element as a CSS class so that - * spacing with its surrounding elements works correctly. - * - * Some elements can be mapped one-to-one from group type to math type, and - * those are listed in the `groupToType` table. - * - * Others (usually elements that wrap around other elements) often have - * recursive definitions, and thus call `getTypeOfGroup` on their inner - * elements. - */ -var getTypeOfGroup = function(group) { - if (group == null) { - // Like when typesetting $^3$ - return groupToType.mathord; - } else if (group.type === "supsub") { - return getTypeOfGroup(group.value.base); - } else if (group.type === "llap" || group.type === "rlap") { - return getTypeOfGroup(group.value); - } else if (group.type === "color") { - return getTypeOfGroup(group.value.value); - } else if (group.type === "sizing") { - return getTypeOfGroup(group.value.value); - } else if (group.type === "styling") { - return getTypeOfGroup(group.value.value); - } else if (group.type === "delimsizing") { - return groupToType[group.value.delimType]; +// Return math atom class (mclass) of a domTree. +var getTypeOfDomTree = exports.getTypeOfDomTree = function getTypeOfDomTree(node) { + if (node instanceof _domTree2.default.documentFragment) { + if (node.children.length) { + return getTypeOfDomTree(node.children[node.children.length - 1]); + } } else { - return groupToType[group.type]; + if (_utils2.default.contains(["mord", "mop", "mbin", "mrel", "mopen", "mclose", "mpunct", "minner"], node.classes[0])) { + return node.classes[0]; + } } + return null; }; /** @@ -2127,19 +4535,23 @@ var getTypeOfGroup = function(group) { * its inner element should handle the superscripts and subscripts instead of * handling them itself. */ -var shouldHandleSupSub = function(group, options) { - if (!group) { +var shouldHandleSupSub = function shouldHandleSupSub(group, options) { + if (!group.value.base) { return false; - } else if (group.type === "op") { - // Operators handle supsubs differently when they have limits - // (e.g. `\displaystyle\sum_2^3`) - return group.value.limits && - (options.style.size === Style.DISPLAY.size || - group.value.alwaysHandleSupSub); - } else if (group.type === "accent") { - return isCharacterBox(group.value.base); } else { - return null; + var base = group.value.base; + if (base.type === "op") { + // Operators handle supsubs differently when they have limits + // (e.g. `\displaystyle\sum_2^3`) + return base.value.limits && (options.style.size === _Style2.default.DISPLAY.size || base.value.alwaysHandleSupSub); + } else if (base.type === "accent") { + return isCharacterBox(base.value.base); + } else if (base.type === "horizBrace") { + var isSup = group.value.sub ? false : true; + return isSup === base.value.isOver; + } else { + return null; + } } }; @@ -2148,7 +4560,7 @@ var shouldHandleSupSub = function(group, options) { * cases, this will just be the group itself, but when ordgroups and colors have * a single element, we want to pull that out. */ -var getBaseElem = function(group) { +var getBaseElem = function getBaseElem(group) { if (!group) { return false; } else if (group.type === "ordgroup") { @@ -2175,1091 +4587,353 @@ var getBaseElem = function(group) { * with a single character in them. To decide if something is a character box, * we find its innermost group, and see if it is a single character. */ -var isCharacterBox = function(group) { +var isCharacterBox = function isCharacterBox(group) { var baseElem = getBaseElem(group); // These are all they types of groups which hold single characters - return baseElem.type === "mathord" || - baseElem.type === "textord" || - baseElem.type === "bin" || - baseElem.type === "rel" || - baseElem.type === "inner" || - baseElem.type === "open" || - baseElem.type === "close" || - baseElem.type === "punct"; + return baseElem.type === "mathord" || baseElem.type === "textord" || baseElem.type === "bin" || baseElem.type === "rel" || baseElem.type === "inner" || baseElem.type === "open" || baseElem.type === "close" || baseElem.type === "punct"; }; -var makeNullDelimiter = function(options) { - return makeSpan([ - "sizing", "reset-" + options.size, "size5", - options.style.reset(), Style.TEXT.cls(), - "nulldelimiter", - ]); +var makeNullDelimiter = exports.makeNullDelimiter = function makeNullDelimiter(options, classes) { + var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); + return makeSpan(classes.concat(moreClasses)); }; /** * This is a map of group types to the function used to handle that type. * Simpler types come at the beginning, while complicated types come afterwards. */ -var groupTypes = {}; - -groupTypes.mathord = function(group, options, prev) { - return buildCommon.makeOrd(group, options, "mathord"); -}; +var groupTypes = exports.groupTypes = {}; -groupTypes.textord = function(group, options, prev) { - return buildCommon.makeOrd(group, options, "textord"); +groupTypes.mathord = function (group, options) { + return _buildCommon2.default.makeOrd(group, options, "mathord"); }; -groupTypes.bin = function(group, options, prev) { - var className = "mbin"; - // Pull out the most recent element. Do some special handling to find - // things at the end of a \color group. Note that we don't use the same - // logic for ordgroups (which count as ords). - var prevAtom = prev; - while (prevAtom && prevAtom.type === "color") { - var atoms = prevAtom.value.value; - prevAtom = atoms[atoms.length - 1]; - } - // See TeXbook pg. 442-446, Rules 5 and 6, and the text before Rule 19. - // Here, we determine whether the bin should turn into an ord. We - // currently only apply Rule 5. - if (!prev || utils.contains(["mbin", "mopen", "mrel", "mop", "mpunct"], - getTypeOfGroup(prevAtom))) { - group.type = "textord"; - className = "mord"; - } - - return buildCommon.mathsym( - group.value, group.mode, options.getColor(), [className]); +groupTypes.textord = function (group, options) { + return _buildCommon2.default.makeOrd(group, options, "textord"); }; -groupTypes.rel = function(group, options, prev) { - return buildCommon.mathsym( - group.value, group.mode, options.getColor(), ["mrel"]); +groupTypes.bin = function (group, options) { + return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mbin"]); }; -groupTypes.open = function(group, options, prev) { - return buildCommon.mathsym( - group.value, group.mode, options.getColor(), ["mopen"]); +groupTypes.rel = function (group, options) { + return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mrel"]); }; -groupTypes.close = function(group, options, prev) { - return buildCommon.mathsym( - group.value, group.mode, options.getColor(), ["mclose"]); +groupTypes.open = function (group, options) { + return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mopen"]); }; -groupTypes.inner = function(group, options, prev) { - return buildCommon.mathsym( - group.value, group.mode, options.getColor(), ["minner"]); +groupTypes.close = function (group, options) { + return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mclose"]); }; -groupTypes.punct = function(group, options, prev) { - return buildCommon.mathsym( - group.value, group.mode, options.getColor(), ["mpunct"]); +groupTypes.inner = function (group, options) { + return _buildCommon2.default.mathsym(group.value, group.mode, options, ["minner"]); }; -groupTypes.ordgroup = function(group, options, prev) { - return makeSpan( - ["mord", options.style.cls()], - buildExpression(group.value, options.reset()) - ); +groupTypes.punct = function (group, options) { + return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mpunct"]); }; -groupTypes.text = function(group, options, prev) { - return makeSpan(["text", "mord", options.style.cls()], - buildExpression(group.value.body, options.reset())); -}; - -groupTypes.color = function(group, options, prev) { - var elements = buildExpression( - group.value.value, - options.withColor(group.value.color), - prev - ); - - // \color isn't supposed to affect the type of the elements it contains. - // To accomplish this, we wrap the results in a fragment, so the inner - // elements will be able to directly interact with their neighbors. For - // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` - return new buildCommon.makeFragment(elements); +groupTypes.ordgroup = function (group, options) { + return makeSpan(["mord"], buildExpression(group.value, options, true), options); }; -groupTypes.supsub = function(group, options, prev) { +groupTypes.supsub = function (group, options) { // Superscript and subscripts are handled in the TeXbook on page // 445-446, rules 18(a-f). // Here is where we defer to the inner group if it should handle // superscripts and subscripts itself. - if (shouldHandleSupSub(group.value.base, options)) { - return groupTypes[group.value.base.type](group, options, prev); + if (shouldHandleSupSub(group, options)) { + return groupTypes[group.value.base.type](group, options); } - var base = buildGroup(group.value.base, options.reset()); - var supmid; - var submid; - var sup; - var sub; + var base = buildGroup(group.value.base, options); + var supm = void 0; + var subm = void 0; + + var metrics = options.fontMetrics(); + var newOptions = void 0; + + // Rule 18a + var supShift = 0; + var subShift = 0; if (group.value.sup) { - sup = buildGroup(group.value.sup, - options.withStyle(options.style.sup())); - supmid = makeSpan( - [options.style.reset(), options.style.sup().cls()], [sup]); + newOptions = options.havingStyle(options.style.sup()); + supm = buildGroup(group.value.sup, newOptions, options); + if (!isCharacterBox(group.value.base)) { + supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + } } if (group.value.sub) { - sub = buildGroup(group.value.sub, - options.withStyle(options.style.sub())); - submid = makeSpan( - [options.style.reset(), options.style.sub().cls()], [sub]); - } - - // Rule 18a - var supShift; - var subShift; - if (isCharacterBox(group.value.base)) { - supShift = 0; - subShift = 0; - } else { - supShift = base.height - fontMetrics.metrics.supDrop; - subShift = base.depth + fontMetrics.metrics.subDrop; + newOptions = options.havingStyle(options.style.sub()); + subm = buildGroup(group.value.sub, newOptions, options); + if (!isCharacterBox(group.value.base)) { + subShift = base.depth + newOptions.fontMetrics().subDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + } } // Rule 18c - var minSupShift; - if (options.style === Style.DISPLAY) { - minSupShift = fontMetrics.metrics.sup1; + var minSupShift = void 0; + if (options.style === _Style2.default.DISPLAY) { + minSupShift = metrics.sup1; } else if (options.style.cramped) { - minSupShift = fontMetrics.metrics.sup3; + minSupShift = metrics.sup3; } else { - minSupShift = fontMetrics.metrics.sup2; + minSupShift = metrics.sup2; } // scriptspace is a font-size-independent size, so scale it // appropriately - var multiplier = Style.TEXT.sizeMultiplier * - options.style.sizeMultiplier; - var scriptspace = - (0.5 / fontMetrics.metrics.ptPerEm) / multiplier + "em"; + var multiplier = options.sizeMultiplier; + var scriptspace = 0.5 / metrics.ptPerEm / multiplier + "em"; - var supsub; + var supsub = void 0; if (!group.value.sup) { // Rule 18b - subShift = Math.max( - subShift, fontMetrics.metrics.sub1, - sub.height - 0.8 * fontMetrics.metrics.xHeight); - - supsub = buildCommon.makeVList([ - {type: "elem", elem: submid}, - ], "shift", subShift, options); - - supsub.children[0].style.marginRight = scriptspace; + subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight); + var vlistElem = [{ type: "elem", elem: subm, marginRight: scriptspace }]; // Subscripts shouldn't be shifted by the base's italic correction. // Account for that by shifting the subscript back the appropriate // amount. Note we only do this when the base is a single symbol. - if (base instanceof domTree.symbolNode) { - supsub.children[0].style.marginLeft = -base.italic + "em"; + if (base instanceof _domTree2.default.symbolNode) { + vlistElem[0].marginLeft = -base.italic + "em"; } + + supsub = _buildCommon2.default.makeVList({ + positionType: "shift", + positionData: subShift, + children: vlistElem + }, options); } else if (!group.value.sub) { // Rule 18c, d - supShift = Math.max(supShift, minSupShift, - sup.depth + 0.25 * fontMetrics.metrics.xHeight); + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); - supsub = buildCommon.makeVList([ - {type: "elem", elem: supmid}, - ], "shift", -supShift, options); - - supsub.children[0].style.marginRight = scriptspace; + supsub = _buildCommon2.default.makeVList({ + positionType: "shift", + positionData: -supShift, + children: [{ type: "elem", elem: supm, marginRight: scriptspace }] + }, options); } else { - supShift = Math.max( - supShift, minSupShift, - sup.depth + 0.25 * fontMetrics.metrics.xHeight); - subShift = Math.max(subShift, fontMetrics.metrics.sub2); + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + subShift = Math.max(subShift, metrics.sub2); - var ruleWidth = fontMetrics.metrics.defaultRuleThickness; + var ruleWidth = metrics.defaultRuleThickness; // Rule 18e - if ((supShift - sup.depth) - (sub.height - subShift) < - 4 * ruleWidth) { - subShift = 4 * ruleWidth - (supShift - sup.depth) + sub.height; - var psi = 0.8 * fontMetrics.metrics.xHeight - - (supShift - sup.depth); + if (supShift - supm.depth - (subm.height - subShift) < 4 * ruleWidth) { + subShift = 4 * ruleWidth - (supShift - supm.depth) + subm.height; + var psi = 0.8 * metrics.xHeight - (supShift - supm.depth); if (psi > 0) { supShift += psi; subShift -= psi; } } - supsub = buildCommon.makeVList([ - {type: "elem", elem: submid, shift: subShift}, - {type: "elem", elem: supmid, shift: -supShift}, - ], "individualShift", null, options); - + var _vlistElem = [{ type: "elem", elem: subm, shift: subShift, marginRight: scriptspace }, { type: "elem", elem: supm, shift: -supShift, marginRight: scriptspace }]; // See comment above about subscripts not being shifted - if (base instanceof domTree.symbolNode) { - supsub.children[0].style.marginLeft = -base.italic + "em"; + if (base instanceof _domTree2.default.symbolNode) { + _vlistElem[0].marginLeft = -base.italic + "em"; } - supsub.children[0].style.marginRight = scriptspace; - supsub.children[1].style.marginRight = scriptspace; + supsub = _buildCommon2.default.makeVList({ + positionType: "individualShift", + children: _vlistElem + }, options); } // We ensure to wrap the supsub vlist in a span.msupsub to reset text-align - return makeSpan([getTypeOfGroup(group.value.base)], - [base, makeSpan(["msupsub"], [supsub])]); + var mclass = getTypeOfDomTree(base) || "mord"; + return makeSpan([mclass], [base, makeSpan(["msupsub"], [supsub])], options); }; -groupTypes.genfrac = function(group, options, prev) { - // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). - // Figure out what style this fraction should be in based on the - // function used - var fstyle = options.style; - if (group.value.size === "display") { - fstyle = Style.DISPLAY; - } else if (group.value.size === "text") { - fstyle = Style.TEXT; - } - - var nstyle = fstyle.fracNum(); - var dstyle = fstyle.fracDen(); - - var numer = buildGroup(group.value.numer, options.withStyle(nstyle)); - var numerreset = makeSpan([fstyle.reset(), nstyle.cls()], [numer]); - - var denom = buildGroup(group.value.denom, options.withStyle(dstyle)); - var denomreset = makeSpan([fstyle.reset(), dstyle.cls()], [denom]); - - var ruleWidth; - if (group.value.hasBarLine) { - ruleWidth = fontMetrics.metrics.defaultRuleThickness / - options.style.sizeMultiplier; - } else { - ruleWidth = 0; - } - - // Rule 15b - var numShift; - var clearance; - var denomShift; - if (fstyle.size === Style.DISPLAY.size) { - numShift = fontMetrics.metrics.num1; - if (ruleWidth > 0) { - clearance = 3 * ruleWidth; - } else { - clearance = 7 * fontMetrics.metrics.defaultRuleThickness; - } - denomShift = fontMetrics.metrics.denom1; - } else { - if (ruleWidth > 0) { - numShift = fontMetrics.metrics.num2; - clearance = ruleWidth; - } else { - numShift = fontMetrics.metrics.num3; - clearance = 3 * fontMetrics.metrics.defaultRuleThickness; - } - denomShift = fontMetrics.metrics.denom2; - } - - var frac; - if (ruleWidth === 0) { - // Rule 15c - var candiateClearance = - (numShift - numer.depth) - (denom.height - denomShift); - if (candiateClearance < clearance) { - numShift += 0.5 * (clearance - candiateClearance); - denomShift += 0.5 * (clearance - candiateClearance); - } - - frac = buildCommon.makeVList([ - {type: "elem", elem: denomreset, shift: denomShift}, - {type: "elem", elem: numerreset, shift: -numShift}, - ], "individualShift", null, options); - } else { - // Rule 15d - var axisHeight = fontMetrics.metrics.axisHeight; - - if ((numShift - numer.depth) - (axisHeight + 0.5 * ruleWidth) < - clearance) { - numShift += - clearance - ((numShift - numer.depth) - - (axisHeight + 0.5 * ruleWidth)); - } - - if ((axisHeight - 0.5 * ruleWidth) - (denom.height - denomShift) < - clearance) { - denomShift += - clearance - ((axisHeight - 0.5 * ruleWidth) - - (denom.height - denomShift)); - } - - var mid = makeSpan( - [options.style.reset(), Style.TEXT.cls(), "frac-line"]); - // Manually set the height of the line because its height is - // created in CSS - mid.height = ruleWidth; - - var midShift = -(axisHeight - 0.5 * ruleWidth); - - frac = buildCommon.makeVList([ - {type: "elem", elem: denomreset, shift: denomShift}, - {type: "elem", elem: mid, shift: midShift}, - {type: "elem", elem: numerreset, shift: -numShift}, - ], "individualShift", null, options); - } - - // Since we manually change the style sometimes (with \dfrac or \tfrac), - // account for the possible size change here. - frac.height *= fstyle.sizeMultiplier / options.style.sizeMultiplier; - frac.depth *= fstyle.sizeMultiplier / options.style.sizeMultiplier; - - // Rule 15e - var delimSize; - if (fstyle.size === Style.DISPLAY.size) { - delimSize = fontMetrics.metrics.delim1; - } else { - delimSize = fontMetrics.metrics.getDelim2(fstyle); - } - - var leftDelim; - var rightDelim; - if (group.value.leftDelim == null) { - leftDelim = makeNullDelimiter(options); - } else { - leftDelim = delimiter.customSizedDelim( - group.value.leftDelim, delimSize, true, - options.withStyle(fstyle), group.mode); - } - if (group.value.rightDelim == null) { - rightDelim = makeNullDelimiter(options); - } else { - rightDelim = delimiter.customSizedDelim( - group.value.rightDelim, delimSize, true, - options.withStyle(fstyle), group.mode); - } - - return makeSpan( - ["mord", options.style.reset(), fstyle.cls()], - [leftDelim, makeSpan(["mfrac"], [frac]), rightDelim], - options.getColor()); -}; - -groupTypes.array = function(group, options, prev) { - var r; - var c; - var nr = group.value.body.length; - var nc = 0; - var body = new Array(nr); - - // Horizontal spacing - var pt = 1 / fontMetrics.metrics.ptPerEm; - var arraycolsep = 5 * pt; // \arraycolsep in article.cls - - // Vertical spacing - var baselineskip = 12 * pt; // see size10.clo - // Default \arraystretch from lttab.dtx - // TODO(gagern): may get redefined once we have user-defined macros - var arraystretch = utils.deflt(group.value.arraystretch, 1); - var arrayskip = arraystretch * baselineskip; - var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and - var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx - - var totalHeight = 0; - for (r = 0; r < group.value.body.length; ++r) { - var inrow = group.value.body[r]; - var height = arstrutHeight; // \@array adds an \@arstrut - var depth = arstrutDepth; // to each tow (via the template) - - if (nc < inrow.length) { - nc = inrow.length; - } - - var outrow = new Array(inrow.length); - for (c = 0; c < inrow.length; ++c) { - var elt = buildGroup(inrow[c], options); - if (depth < elt.depth) { - depth = elt.depth; - } - if (height < elt.height) { - height = elt.height; - } - outrow[c] = elt; - } - - var gap = 0; - if (group.value.rowGaps[r]) { - gap = group.value.rowGaps[r].value; - switch (gap.unit) { - case "em": - gap = gap.number; - break; - case "ex": - gap = gap.number * fontMetrics.metrics.emPerEx; - break; - default: - console.error("Can't handle unit " + gap.unit); - gap = 0; - } - if (gap > 0) { // \@argarraycr - gap += arstrutDepth; - if (depth < gap) { - depth = gap; // \@xargarraycr - } - gap = 0; - } - } - - outrow.height = height; - outrow.depth = depth; - totalHeight += height; - outrow.pos = totalHeight; - totalHeight += depth + gap; // \@yargarraycr - body[r] = outrow; - } - - var offset = totalHeight / 2 + fontMetrics.metrics.axisHeight; - var colDescriptions = group.value.cols || []; - var cols = []; - var colSep; - var colDescrNum; - for (c = 0, colDescrNum = 0; - // Continue while either there are more columns or more column - // descriptions, so trailing separators don't get lost. - c < nc || colDescrNum < colDescriptions.length; - ++c, ++colDescrNum) { - - var colDescr = colDescriptions[colDescrNum] || {}; - - var firstSeparator = true; - while (colDescr.type === "separator") { - // If there is more than one separator in a row, add a space - // between them. - if (!firstSeparator) { - colSep = makeSpan(["arraycolsep"], []); - colSep.style.width = - fontMetrics.metrics.doubleRuleSep + "em"; - cols.push(colSep); - } - - if (colDescr.separator === "|") { - var separator = makeSpan( - ["vertical-separator"], - []); - separator.style.height = totalHeight + "em"; - separator.style.verticalAlign = - -(totalHeight - offset) + "em"; - - cols.push(separator); - } else { - throw new ParseError( - "Invalid separator type: " + colDescr.separator); - } - - colDescrNum++; - colDescr = colDescriptions[colDescrNum] || {}; - firstSeparator = false; - } - - if (c >= nc) { - continue; - } - - var sepwidth; - if (c > 0 || group.value.hskipBeforeAndAfter) { - sepwidth = utils.deflt(colDescr.pregap, arraycolsep); - if (sepwidth !== 0) { - colSep = makeSpan(["arraycolsep"], []); - colSep.style.width = sepwidth + "em"; - cols.push(colSep); - } - } - - var col = []; - for (r = 0; r < nr; ++r) { - var row = body[r]; - var elem = row[c]; - if (!elem) { - continue; - } - var shift = row.pos - offset; - elem.depth = row.depth; - elem.height = row.height; - col.push({type: "elem", elem: elem, shift: shift}); - } - - col = buildCommon.makeVList(col, "individualShift", null, options); - col = makeSpan( - ["col-align-" + (colDescr.align || "c")], - [col]); - cols.push(col); - - if (c < nc - 1 || group.value.hskipBeforeAndAfter) { - sepwidth = utils.deflt(colDescr.postgap, arraycolsep); - if (sepwidth !== 0) { - colSep = makeSpan(["arraycolsep"], []); - colSep.style.width = sepwidth + "em"; - cols.push(colSep); - } - } - } - body = makeSpan(["mtable"], cols); - return makeSpan(["mord"], [body], options.getColor()); -}; - -groupTypes.spacing = function(group, options, prev) { - if (group.value === "\\ " || group.value === "\\space" || - group.value === " " || group.value === "~") { +groupTypes.spacing = function (group, options) { + if (group.value === "\\ " || group.value === "\\space" || group.value === " " || group.value === "~") { // Spaces are generated by adding an actual space. Each of these // things has an entry in the symbols table, so these will be turned // into appropriate outputs. - return makeSpan( - ["mord", "mspace"], - [buildCommon.mathsym(group.value, group.mode)] - ); + if (group.mode === "text") { + return _buildCommon2.default.makeOrd(group, options, "textord"); + } else { + return makeSpan(["mspace"], [_buildCommon2.default.mathsym(group.value, group.mode, options)], options); + } } else { // Other kinds of spaces are of arbitrary width. We use CSS to // generate these. - return makeSpan( - ["mord", "mspace", - buildCommon.spacingFunctions[group.value].className]); - } -}; - -groupTypes.llap = function(group, options, prev) { - var inner = makeSpan( - ["inner"], [buildGroup(group.value.body, options.reset())]); - var fix = makeSpan(["fix"], []); - return makeSpan( - ["llap", options.style.cls()], [inner, fix]); -}; - -groupTypes.rlap = function(group, options, prev) { - var inner = makeSpan( - ["inner"], [buildGroup(group.value.body, options.reset())]); - var fix = makeSpan(["fix"], []); - return makeSpan( - ["rlap", options.style.cls()], [inner, fix]); -}; - -groupTypes.op = function(group, options, prev) { - // Operators are handled in the TeXbook pg. 443-444, rule 13(a). - var supGroup; - var subGroup; - var hasLimits = false; - if (group.type === "supsub" ) { - // If we have limits, supsub will pass us its group to handle. Pull - // out the superscript and subscript and set the group to the op in - // its base. - supGroup = group.value.sup; - subGroup = group.value.sub; - group = group.value.base; - hasLimits = true; - } - - // Most operators have a large successor symbol, but these don't. - var noSuccessor = [ - "\\smallint", - ]; - - var large = false; - if (options.style.size === Style.DISPLAY.size && - group.value.symbol && - !utils.contains(noSuccessor, group.value.body)) { - - // Most symbol operators get larger in displaystyle (rule 13) - large = true; - } - - var base; - var baseShift = 0; - var slant = 0; - if (group.value.symbol) { - // If this is a symbol, create the symbol. - var style = large ? "Size2-Regular" : "Size1-Regular"; - base = buildCommon.makeSymbol( - group.value.body, style, "math", options.getColor(), - ["op-symbol", large ? "large-op" : "small-op", "mop"]); - - // Shift the symbol so its center lies on the axis (rule 13). It - // appears that our fonts have the centers of the symbols already - // almost on the axis, so these numbers are very small. Note we - // don't actually apply this here, but instead it is used either in - // the vlist creation or separately when there are no limits. - baseShift = (base.height - base.depth) / 2 - - fontMetrics.metrics.axisHeight * - options.style.sizeMultiplier; - - // The slant of the symbol is just its italic correction. - slant = base.italic; - } else { - // Otherwise, this is a text operator. Build the text from the - // operator's name. - // TODO(emily): Add a space in the middle of some of these - // operators, like \limsup - var output = []; - for (var i = 1; i < group.value.body.length; i++) { - output.push(buildCommon.mathsym(group.value.body[i], group.mode)); - } - base = makeSpan(["mop"], output, options.getColor()); - } - - if (hasLimits) { - // IE 8 clips \int if it is in a display: inline-block. We wrap it - // in a new span so it is an inline, and works. - base = makeSpan([], [base]); - - var supmid; - var supKern; - var submid; - var subKern; - // We manually have to handle the superscripts and subscripts. This, - // aside from the kern calculations, is copied from supsub. - if (supGroup) { - var sup = buildGroup( - supGroup, options.withStyle(options.style.sup())); - supmid = makeSpan( - [options.style.reset(), options.style.sup().cls()], [sup]); - - supKern = Math.max( - fontMetrics.metrics.bigOpSpacing1, - fontMetrics.metrics.bigOpSpacing3 - sup.depth); - } - - if (subGroup) { - var sub = buildGroup( - subGroup, options.withStyle(options.style.sub())); - submid = makeSpan( - [options.style.reset(), options.style.sub().cls()], - [sub]); - - subKern = Math.max( - fontMetrics.metrics.bigOpSpacing2, - fontMetrics.metrics.bigOpSpacing4 - sub.height); - } - - // Build the final group as a vlist of the possible subscript, base, - // and possible superscript. - var finalGroup; - var top; - var bottom; - if (!supGroup) { - top = base.height - baseShift; - - finalGroup = buildCommon.makeVList([ - {type: "kern", size: fontMetrics.metrics.bigOpSpacing5}, - {type: "elem", elem: submid}, - {type: "kern", size: subKern}, - {type: "elem", elem: base}, - ], "top", top, options); - - // Here, we shift the limits by the slant of the symbol. Note - // that we are supposed to shift the limits by 1/2 of the slant, - // but since we are centering the limits adding a full slant of - // margin will shift by 1/2 that. - finalGroup.children[0].style.marginLeft = -slant + "em"; - } else if (!subGroup) { - bottom = base.depth + baseShift; - - finalGroup = buildCommon.makeVList([ - {type: "elem", elem: base}, - {type: "kern", size: supKern}, - {type: "elem", elem: supmid}, - {type: "kern", size: fontMetrics.metrics.bigOpSpacing5}, - ], "bottom", bottom, options); - - // See comment above about slants - finalGroup.children[1].style.marginLeft = slant + "em"; - } else if (!supGroup && !subGroup) { - // This case probably shouldn't occur (this would mean the - // supsub was sending us a group with no superscript or - // subscript) but be safe. - return base; - } else { - bottom = fontMetrics.metrics.bigOpSpacing5 + - submid.height + submid.depth + - subKern + - base.depth + baseShift; - - finalGroup = buildCommon.makeVList([ - {type: "kern", size: fontMetrics.metrics.bigOpSpacing5}, - {type: "elem", elem: submid}, - {type: "kern", size: subKern}, - {type: "elem", elem: base}, - {type: "kern", size: supKern}, - {type: "elem", elem: supmid}, - {type: "kern", size: fontMetrics.metrics.bigOpSpacing5}, - ], "bottom", bottom, options); - - // See comment above about slants - finalGroup.children[0].style.marginLeft = -slant + "em"; - finalGroup.children[2].style.marginLeft = slant + "em"; - } - - return makeSpan(["mop", "op-limits"], [finalGroup]); - } else { - if (group.value.symbol) { - base.style.top = baseShift + "em"; - } - - return base; + return makeSpan(["mspace", _buildCommon2.default.spacingFunctions[group.value].className], [], options); } }; -groupTypes.katex = function(group, options, prev) { - // The KaTeX logo. The offsets for the K and a were chosen to look - // good, but the offsets for the T, E, and X were taken from the - // definition of \TeX in TeX (see TeXbook pg. 356) - var k = makeSpan( - ["k"], [buildCommon.mathsym("K", group.mode)]); - var a = makeSpan( - ["a"], [buildCommon.mathsym("A", group.mode)]); - - a.height = (a.height + 0.2) * 0.75; - a.depth = (a.height - 0.2) * 0.75; - - var t = makeSpan( - ["t"], [buildCommon.mathsym("T", group.mode)]); - var e = makeSpan( - ["e"], [buildCommon.mathsym("E", group.mode)]); - - e.height = (e.height - 0.2155); - e.depth = (e.depth + 0.2155); - - var x = makeSpan( - ["x"], [buildCommon.mathsym("X", group.mode)]); - - return makeSpan( - ["katex-logo", "mord"], [k, a, t, e, x], options.getColor()); -}; - -groupTypes.overline = function(group, options, prev) { - // Overlines are handled in the TeXbook pg 443, Rule 9. - - // Build the inner group in the cramped style. - var innerGroup = buildGroup(group.value.body, - options.withStyle(options.style.cramp())); - - var ruleWidth = fontMetrics.metrics.defaultRuleThickness / - options.style.sizeMultiplier; - - // Create the line above the body - var line = makeSpan( - [options.style.reset(), Style.TEXT.cls(), "overline-line"]); - line.height = ruleWidth; - line.maxFontSize = 1.0; - - // Generate the vlist, with the appropriate kerns - var vlist = buildCommon.makeVList([ - {type: "elem", elem: innerGroup}, - {type: "kern", size: 3 * ruleWidth}, - {type: "elem", elem: line}, - {type: "kern", size: ruleWidth}, - ], "firstBaseline", null, options); - - return makeSpan(["overline", "mord"], [vlist], options.getColor()); -}; - -groupTypes.underline = function(group, options, prev) { - // Underlines are handled in the TeXbook pg 443, Rule 10. - - // Build the inner group. - var innerGroup = buildGroup(group.value.body, options); - - var ruleWidth = fontMetrics.metrics.defaultRuleThickness / - options.style.sizeMultiplier; - - // Create the line above the body - var line = makeSpan( - [options.style.reset(), Style.TEXT.cls(), "underline-line"]); - line.height = ruleWidth; - line.maxFontSize = 1.0; - - // Generate the vlist, with the appropriate kerns - var vlist = buildCommon.makeVList([ - {type: "kern", size: ruleWidth}, - {type: "elem", elem: line}, - {type: "kern", size: 3 * ruleWidth}, - {type: "elem", elem: innerGroup}, - ], "top", innerGroup.height, options); - - return makeSpan(["underline", "mord"], [vlist], options.getColor()); -}; - -groupTypes.sqrt = function(group, options, prev) { +groupTypes.sqrt = function (group, options) { // Square roots are handled in the TeXbook pg. 443, Rule 11. // First, we do the same steps as in overline to build the inner group // and line - var inner = buildGroup(group.value.body, - options.withStyle(options.style.cramp())); + var inner = buildGroup(group.value.body, options.havingCrampedStyle()); + if (inner.height === 0) { + // Render a small surd. + inner.height = options.fontMetrics().xHeight; + } - var ruleWidth = fontMetrics.metrics.defaultRuleThickness / - options.style.sizeMultiplier; + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + if (inner instanceof _domTree2.default.documentFragment) { + inner = makeSpan([], [inner], options); + } - var line = makeSpan( - [options.style.reset(), Style.TEXT.cls(), "sqrt-line"], [], - options.getColor()); - line.height = ruleWidth; - line.maxFontSize = 1.0; + // Calculate the minimum size for the \surd delimiter + var metrics = options.fontMetrics(); + var theta = metrics.defaultRuleThickness; - var phi = ruleWidth; - if (options.style.id < Style.TEXT.id) { - phi = fontMetrics.metrics.xHeight; + var phi = theta; + if (options.style.id < _Style2.default.TEXT.id) { + phi = options.fontMetrics().xHeight; } // Calculate the clearance between the body and line - var lineClearance = ruleWidth + phi / 4; + var lineClearance = theta + phi / 4; + + var minDelimiterHeight = (inner.height + inner.depth + lineClearance + theta) * options.sizeMultiplier; - var innerHeight = - (inner.height + inner.depth) * options.style.sizeMultiplier; - var minDelimiterHeight = innerHeight + lineClearance + ruleWidth; + // Create a sqrt SVG of the required minimum size - // Create a \surd delimiter of the required minimum size - var delim = makeSpan(["sqrt-sign"], [ - delimiter.customSizedDelim("\\surd", minDelimiterHeight, - false, options, group.mode)], - options.getColor()); + var _delimiter$sqrtImage = _delimiter2.default.sqrtImage(minDelimiterHeight, options), + img = _delimiter$sqrtImage.span, + ruleWidth = _delimiter$sqrtImage.ruleWidth; - var delimDepth = (delim.height + delim.depth) - ruleWidth; + var delimDepth = img.height - ruleWidth; // Adjust the clearance based on the delimiter size if (delimDepth > inner.height + inner.depth + lineClearance) { - lineClearance = - (lineClearance + delimDepth - inner.height - inner.depth) / 2; - } - - // Shift the delimiter so that its top lines up with the top of the line - var delimShift = -(inner.height + lineClearance + ruleWidth) + delim.height; - delim.style.top = delimShift + "em"; - delim.height -= delimShift; - delim.depth += delimShift; - - // We add a special case here, because even when `inner` is empty, we - // still get a line. So, we use a simple heuristic to decide if we - // should omit the body entirely. (note this doesn't work for something - // like `\sqrt{\rlap{x}}`, but if someone is doing that they deserve for - // it not to work. - var body; - if (inner.height === 0 && inner.depth === 0) { - body = makeSpan(); - } else { - body = buildCommon.makeVList([ - {type: "elem", elem: inner}, - {type: "kern", size: lineClearance}, - {type: "elem", elem: line}, - {type: "kern", size: ruleWidth}, - ], "firstBaseline", null, options); + lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2; } + // Shift the sqrt image + var imgShift = img.height - inner.height - lineClearance - ruleWidth; + + inner.style.paddingLeft = img.advanceWidth + "em"; + + // Overlay the image and the argument. + var body = _buildCommon2.default.makeVList({ + positionType: "firstBaseline", + children: [{ type: "elem", elem: inner }, { type: "kern", size: -(inner.height + imgShift) }, { type: "elem", elem: img }, { type: "kern", size: ruleWidth }] + }, options); + body.children[0].children[0].classes.push("svg-align"); + if (!group.value.index) { - return makeSpan(["sqrt", "mord"], [delim, body]); + return makeSpan(["mord", "sqrt"], [body], options); } else { // Handle the optional root index // The index is always in scriptscript style - var root = buildGroup( - group.value.index, - options.withStyle(Style.SCRIPTSCRIPT)); - var rootWrap = makeSpan( - [options.style.reset(), Style.SCRIPTSCRIPT.cls()], - [root]); - - // Figure out the height and depth of the inner part - var innerRootHeight = Math.max(delim.height, body.height); - var innerRootDepth = Math.max(delim.depth, body.depth); + var newOptions = options.havingStyle(_Style2.default.SCRIPTSCRIPT); + var rootm = buildGroup(group.value.index, newOptions, options); // The amount the index is shifted by. This is taken from the TeX // source, in the definition of `\r@@t`. - var toShift = 0.6 * (innerRootHeight - innerRootDepth); + var toShift = 0.6 * (body.height - body.depth); // Build a VList with the superscript shifted up correctly - var rootVList = buildCommon.makeVList( - [{type: "elem", elem: rootWrap}], - "shift", -toShift, options); + var rootVList = _buildCommon2.default.makeVList({ + positionType: "shift", + positionData: -toShift, + children: [{ type: "elem", elem: rootm }] + }, options); // Add a class surrounding it so we can add on the appropriate // kerning var rootVListWrap = makeSpan(["root"], [rootVList]); - return makeSpan(["sqrt", "mord"], [rootVListWrap, delim, body]); + return makeSpan(["mord", "sqrt"], [rootVListWrap, body], options); } }; -groupTypes.sizing = function(group, options, prev) { - // Handle sizing operators like \Huge. Real TeX doesn't actually allow - // these functions inside of math expressions, so we do some special - // handling. - var inner = buildExpression(group.value.value, - options.withSize(group.value.size), prev); +function sizingGroup(value, options, baseOptions) { + var inner = buildExpression(value, options, false); + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; - var span = makeSpan(["mord"], - [makeSpan(["sizing", "reset-" + options.size, group.value.size, - options.style.cls()], - inner)]); + // Add size-resetting classes to the inner list and set maxFontSize + // manually. Handle nested size changes. + for (var i = 0; i < inner.length; i++) { + var pos = _utils2.default.indexOf(inner[i].classes, "sizing"); + if (pos < 0) { + Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions)); + } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) { + // This is a nested size change: e.g., inner[i] is the "b" in + // `\Huge a \small b`. Override the old size (the `reset-` class) + // but not the new size. + inner[i].classes[pos + 1] = "reset-size" + baseOptions.size; + } - // Calculate the correct maxFontSize manually - var fontSize = buildCommon.sizingMultiplier[group.value.size]; - span.maxFontSize = fontSize * options.style.sizeMultiplier; + inner[i].height *= multiplier; + inner[i].depth *= multiplier; + } - return span; + return _buildCommon2.default.makeFragment(inner); +} + +groupTypes.sizing = function (group, options) { + // Handle sizing operators like \Huge. Real TeX doesn't actually allow + // these functions inside of math expressions, so we do some special + // handling. + var newOptions = options.havingSize(group.value.size); + return sizingGroup(group.value.value, newOptions, options); }; -groupTypes.styling = function(group, options, prev) { +groupTypes.styling = function (group, options) { // Style changes are handled in the TeXbook on pg. 442, Rule 3. // Figure out what style we're changing to. - var style = { - "display": Style.DISPLAY, - "text": Style.TEXT, - "script": Style.SCRIPT, - "scriptscript": Style.SCRIPTSCRIPT, + var styleMap = { + "display": _Style2.default.DISPLAY, + "text": _Style2.default.TEXT, + "script": _Style2.default.SCRIPT, + "scriptscript": _Style2.default.SCRIPTSCRIPT }; - var newStyle = style[group.value.style]; - - // Build the inner expression in the new style. - var inner = buildExpression( - group.value.value, options.withStyle(newStyle), prev); - - return makeSpan([options.style.reset(), newStyle.cls()], inner); + var newStyle = styleMap[group.value.style]; + var newOptions = options.havingStyle(newStyle); + return sizingGroup(group.value.value, newOptions, options); }; -groupTypes.font = function(group, options, prev) { +groupTypes.font = function (group, options) { var font = group.value.font; - return buildGroup(group.value.body, options.withFont(font), prev); -}; - -groupTypes.delimsizing = function(group, options, prev) { - var delim = group.value.value; - - if (delim === ".") { - // Empty delimiters still count as elements, even though they don't - // show anything. - return makeSpan([groupToType[group.value.delimType]]); - } - - // Use delimiter.sizedDelim to generate the delimiter. - return makeSpan( - [groupToType[group.value.delimType]], - [delimiter.sizedDelim( - delim, group.value.size, options, group.mode)]); -}; - -groupTypes.leftright = function(group, options, prev) { - // Build the inner expression - var inner = buildExpression(group.value.body, options.reset()); - - var innerHeight = 0; - var innerDepth = 0; - - // Calculate its height and depth - for (var i = 0; i < inner.length; i++) { - innerHeight = Math.max(inner[i].height, innerHeight); - innerDepth = Math.max(inner[i].depth, innerDepth); - } - - // The size of delimiters is the same, regardless of what style we are - // in. Thus, to correctly calculate the size of delimiter we need around - // a group, we scale down the inner size based on the size. - innerHeight *= options.style.sizeMultiplier; - innerDepth *= options.style.sizeMultiplier; - - var leftDelim; - if (group.value.left === ".") { - // Empty delimiters in \left and \right make null delimiter spaces. - leftDelim = makeNullDelimiter(options); - } else { - // Otherwise, use leftRightDelim to generate the correct sized - // delimiter. - leftDelim = delimiter.leftRightDelim( - group.value.left, innerHeight, innerDepth, options, - group.mode); - } - // Add it to the beginning of the expression - inner.unshift(leftDelim); - - var rightDelim; - // Same for the right delimiter - if (group.value.right === ".") { - rightDelim = makeNullDelimiter(options); - } else { - rightDelim = delimiter.leftRightDelim( - group.value.right, innerHeight, innerDepth, options, - group.mode); - } - // Add it to the end of the expression. - inner.push(rightDelim); - - return makeSpan( - ["minner", options.style.cls()], inner, options.getColor()); -}; - -groupTypes.rule = function(group, options, prev) { - // Make an empty span for the rule - var rule = makeSpan(["mord", "rule"], [], options.getColor()); - - // Calculate the shift, width, and height of the rule, and account for units - var shift = 0; - if (group.value.shift) { - shift = group.value.shift.number; - if (group.value.shift.unit === "ex") { - shift *= fontMetrics.metrics.xHeight; - } - } - - var width = group.value.width.number; - if (group.value.width.unit === "ex") { - width *= fontMetrics.metrics.xHeight; - } - - var height = group.value.height.number; - if (group.value.height.unit === "ex") { - height *= fontMetrics.metrics.xHeight; - } - - // The sizes of rules are absolute, so make it larger if we are in a - // smaller style. - shift /= options.style.sizeMultiplier; - width /= options.style.sizeMultiplier; - height /= options.style.sizeMultiplier; - - // Style the rule to the right size - rule.style.borderRightWidth = width + "em"; - rule.style.borderTopWidth = height + "em"; - rule.style.bottom = shift + "em"; - - // Record the height and width - rule.width = width; - rule.height = height + shift; - rule.depth = -shift; - - return rule; + return buildGroup(group.value.body, options.withFont(font)); }; -groupTypes.kern = function(group, options, prev) { - // Make an empty span for the rule - var rule = makeSpan(["mord", "rule"], [], options.getColor()); - - var dimension = 0; - if (group.value.dimension) { - dimension = group.value.dimension.number; - if (group.value.dimension.unit === "ex") { - dimension *= fontMetrics.metrics.xHeight; +groupTypes.verb = function (group, options) { + var text = _buildCommon2.default.makeVerb(group, options); + var body = []; + // \verb enters text mode and therefore is sized like \textstyle + var newOptions = options.havingStyle(options.style.text()); + for (var i = 0; i < text.length; i++) { + if (text[i] === '\xA0') { + // spaces appear as nonbreaking space + // The space character isn't in the Typewriter-Regular font, + // so we implement it as a kern of the same size as a character. + // 0.525 is the width of a texttt character in LaTeX. + // It automatically gets scaled by the font size. + var rule = makeSpan(["mord", "rule"], [], newOptions); + rule.style.marginLeft = "0.525em"; + body.push(rule); + } else { + body.push(_buildCommon2.default.makeSymbol(text[i], "Typewriter-Regular", group.mode, newOptions, ["mathtt"])); } } - - dimension /= options.style.sizeMultiplier; - - rule.style.marginLeft = dimension + "em"; - - return rule; + _buildCommon2.default.tryCombineChars(body); + return makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), body, newOptions); }; -groupTypes.accent = function(group, options, prev) { +groupTypes.accent = function (group, options) { // Accents are handled in the TeXbook pg. 443, rule 12. var base = group.value.base; - var supsubGroup; + var supsubGroup = void 0; if (group.type === "supsub") { // If our base is a character box, and we have superscripts and // subscripts, the supsub will defer to us. In particular, we want @@ -3280,68 +4954,89 @@ groupTypes.accent = function(group, options, prev) { // Rerender the supsub group with its new base, and store that // result. - supsubGroup = buildGroup( - supsub, options.reset(), prev); + supsubGroup = buildGroup(supsub, options); } // Build the base group - var body = buildGroup( - base, options.withStyle(options.style.cramp())); + var body = buildGroup(base, options.havingCrampedStyle()); + + // Does the accent need to shift for the skew of a character? + var mustShift = group.value.isShifty && isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the // nucleus is not a single character, let s = 0; otherwise set s to the // kern amount for the nucleus followed by the \skewchar of its font." // Note that our skew metrics are just the kern between each character // and the skewchar. - var skew; - if (isCharacterBox(base)) { + var skew = 0; + if (mustShift) { // If the base is a character box, then we want the skew of the // innermost character. To do that, we find the innermost character: var baseChar = getBaseElem(base); // Then, we render its group to get the symbol inside it - var baseGroup = buildGroup( - baseChar, options.withStyle(options.style.cramp())); + var baseGroup = buildGroup(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol. skew = baseGroup.skew; // Note that we now throw away baseGroup, because the layers we // removed with getBaseElem might contain things like \color which // we can't get rid of. // TODO(emily): Find a better way to get the skew - } else { - skew = 0; } // calculate the amount of space between the body and the accent - var clearance = Math.min(body.height, fontMetrics.metrics.xHeight); + var clearance = Math.min(body.height, options.fontMetrics().xHeight); // Build the accent - var accent = buildCommon.makeSymbol( - group.value.accent, "Main-Regular", "math", options.getColor()); - // Remove the italic correction of the accent, because it only serves to - // shift the accent over to a place we don't want. - accent.italic = 0; - - // The \vec character that the fonts use is a combining character, and - // thus shows up much too far to the left. To account for this, we add a - // specific class which shifts the accent over to where we want it. - // TODO(emily): Fix this in a better way, like by changing the font - var vecClass = group.value.accent === "\\vec" ? "accent-vec" : null; - - var accentBody = makeSpan(["accent-body", vecClass], [ - makeSpan([], [accent])]); - - accentBody = buildCommon.makeVList([ - {type: "elem", elem: body}, - {type: "kern", size: -clearance}, - {type: "elem", elem: accentBody}, - ], "firstBaseline", null, options); - - // Shift the accent over by the skew. Note we shift by twice the skew - // because we are centering the accent, so by adding 2*skew to the left, - // we shift it to the right by 1*skew. - accentBody.children[1].style.marginLeft = 2 * skew + "em"; - - var accentWrap = makeSpan(["mord", "accent"], [accentBody]); + var accentBody = void 0; + if (!group.value.isStretchy) { + var accent = _buildCommon2.default.makeSymbol(group.value.label, "Main-Regular", group.mode, options); + // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. + accent.italic = 0; + + // The \vec character that the fonts use is a combining character, and + // thus shows up much too far to the left. To account for this, we add a + // specific class which shifts the accent over to where we want it. + // TODO(emily): Fix this in a better way, like by changing the font + // Similarly, text accent \H is a combining character and + // requires a different adjustment. + var accentClass = null; + if (group.value.label === "\\vec") { + accentClass = "accent-vec"; + } else if (group.value.label === '\\H') { + accentClass = "accent-hungarian"; + } + + accentBody = makeSpan([], [accent]); + accentBody = makeSpan(["accent-body", accentClass], [accentBody]); + + // Shift the accent over by the skew. Note we shift by twice the skew + // because we are centering the accent, so by adding 2*skew to the left, + // we shift it to the right by 1*skew. + accentBody.style.marginLeft = 2 * skew + "em"; + + accentBody = _buildCommon2.default.makeVList({ + positionType: "firstBaseline", + children: [{ type: "elem", elem: body }, { type: "kern", size: -clearance }, { type: "elem", elem: accentBody }] + }, options); + } else { + accentBody = _stretchy2.default.svgSpan(group, options); + + accentBody = _buildCommon2.default.makeVList({ + positionType: "firstBaseline", + children: [{ type: "elem", elem: body }, { type: "elem", elem: accentBody }] + }, options); + + var styleSpan = accentBody.children[0].children[0].children[1]; + styleSpan.classes.push("svg-align"); // text-align: left; + if (skew > 0) { + // Shorten the accent and nudge it to the right. + styleSpan.style.width = "calc(100% - " + 2 * skew + "em)"; + styleSpan.style.marginLeft = 2 * skew + "em"; + } + } + + var accentWrap = makeSpan(["mord", "accent"], [accentBody], options); if (supsubGroup) { // Here, we replace the "base" child of the supsub with our newly @@ -3361,16 +5056,233 @@ groupTypes.accent = function(group, options, prev) { } }; -groupTypes.phantom = function(group, options, prev) { - var elements = buildExpression( - group.value.value, - options.withPhantom(), - prev - ); +groupTypes.horizBrace = function (group, options) { + var style = options.style; + + var hasSupSub = group.type === "supsub"; + var supSubGroup = void 0; + var newOptions = void 0; + if (hasSupSub) { + // Ref: LaTeX source2e: }}}}\limits} + // i.e. LaTeX treats the brace similar to an op and passes it + // with \limits, so we need to assign supsub style. + if (group.value.sup) { + newOptions = options.havingStyle(style.sup()); + supSubGroup = buildGroup(group.value.sup, newOptions, options); + } else { + newOptions = options.havingStyle(style.sub()); + supSubGroup = buildGroup(group.value.sub, newOptions, options); + } + group = group.value.base; + } + + // Build the base group + var body = buildGroup(group.value.base, options.havingBaseStyle(_Style2.default.DISPLAY)); + + // Create the stretchy element + var braceBody = _stretchy2.default.svgSpan(group, options); + + // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + // This first vlist contains the subject matter and the brace: equation + var vlist = void 0; + if (group.value.isOver) { + vlist = _buildCommon2.default.makeVList({ + positionType: "firstBaseline", + children: [{ type: "elem", elem: body }, { type: "kern", size: 0.1 }, { type: "elem", elem: braceBody }] + }, options); + vlist.children[0].children[0].children[1].classes.push("svg-align"); + } else { + vlist = _buildCommon2.default.makeVList({ + positionType: "bottom", + positionData: body.depth + 0.1 + braceBody.height, + children: [{ type: "elem", elem: braceBody }, { type: "kern", size: 0.1 }, { type: "elem", elem: body }] + }, options); + vlist.children[0].children[0].children[0].classes.push("svg-align"); + } + + if (hasSupSub) { + // In order to write the supsub, wrap the first vlist in another vlist: + // They can't all go in the same vlist, because the note might be wider + // than the equation. We want the equation to control the brace width. + + // note long note long note + // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ + // equation eqn eqn + + var vSpan = makeSpan(["mord", group.value.isOver ? "mover" : "munder"], [vlist], options); + + if (group.value.isOver) { + vlist = _buildCommon2.default.makeVList({ + positionType: "firstBaseline", + children: [{ type: "elem", elem: vSpan }, { type: "kern", size: 0.2 }, { type: "elem", elem: supSubGroup }] + }, options); + } else { + vlist = _buildCommon2.default.makeVList({ + positionType: "bottom", + positionData: vSpan.depth + 0.2 + supSubGroup.height, + children: [{ type: "elem", elem: supSubGroup }, { type: "kern", size: 0.2 }, { type: "elem", elem: vSpan }] + }, options); + } + } + + return makeSpan(["mord", group.value.isOver ? "mover" : "munder"], [vlist], options); +}; + +groupTypes.accentUnder = function (group, options) { + // Treat under accents much like underlines. + var innerGroup = buildGroup(group.value.base, options); + + var accentBody = _stretchy2.default.svgSpan(group, options); + var kern = /tilde/.test(group.value.label) ? 0.12 : 0; + + // Generate the vlist, with the appropriate kerns + var vlist = _buildCommon2.default.makeVList({ + positionType: "bottom", + positionData: accentBody.height + kern, + children: [{ type: "elem", elem: accentBody }, { type: "kern", size: kern }, { type: "elem", elem: innerGroup }] + }, options); + + vlist.children[0].children[0].children[0].classes.push("svg-align"); + + return makeSpan(["mord", "accentunder"], [vlist], options); +}; + +groupTypes.enclose = function (group, options) { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox + var inner = buildGroup(group.value.body, options); + + var label = group.value.label.substr(1); + var scale = options.sizeMultiplier; + var img = void 0; + var imgShift = 0; + var isColorbox = /color/.test(label); + + if (label === "sout") { + img = makeSpan(["stretchy", "sout"]); + img.height = options.fontMetrics().defaultRuleThickness / scale; + imgShift = -0.5 * options.fontMetrics().xHeight; + } else { + // Add horizontal padding + inner.classes.push(/cancel/.test(label) ? "cancel-pad" : "boxpad"); + + // Add vertical padding + var vertPad = 0; + // ref: LaTeX source2e: \fboxsep = 3pt; \fboxrule = .4pt + // ref: cancel package: \advance\totalheight2\p@ % "+2" + if (/box/.test(label)) { + vertPad = label === "colorbox" ? 0.3 : 0.34; + } else { + vertPad = isCharacterBox(group.value.body) ? 0.2 : 0; + } + + img = _stretchy2.default.encloseSpan(inner, label, vertPad, options); + imgShift = inner.depth + vertPad; + + if (isColorbox) { + img.style.backgroundColor = group.value.backgroundColor.value; + if (label === "fcolorbox") { + img.style.borderColor = group.value.borderColor.value; + } + } + } + + var vlist = void 0; + if (isColorbox) { + vlist = _buildCommon2.default.makeVList({ + positionType: "individualShift", + children: [ + // Put the color background behind inner; + { type: "elem", elem: img, shift: imgShift }, { type: "elem", elem: inner, shift: 0 }] + }, options); + } else { + vlist = _buildCommon2.default.makeVList({ + positionType: "individualShift", + children: [ + // Write the \cancel stroke on top of inner. + { type: "elem", elem: inner, shift: 0 }, { type: "elem", elem: img, shift: imgShift }] + }, options); + } + + if (/cancel/.test(label)) { + vlist.children[0].children[0].children[1].classes.push("svg-align"); + + // cancel does not create horiz space for its line extension. + // That is, not when adjacent to a mord. + return makeSpan(["mord", "cancel-lap"], [vlist], options); + } else { + return makeSpan(["mord"], [vlist], options); + } +}; + +groupTypes.xArrow = function (group, options) { + var style = options.style; - // \phantom isn't supposed to affect the elements it contains. - // See "color" for more details. - return new buildCommon.makeFragment(elements); + // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + + var newOptions = options.havingStyle(style.sup()); + var upperGroup = buildGroup(group.value.body, newOptions, options); + upperGroup.classes.push("x-arrow-pad"); + + var lowerGroup = void 0; + if (group.value.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = buildGroup(group.value.below, newOptions, options); + lowerGroup.classes.push("x-arrow-pad"); + } + + var arrowBody = _stretchy2.default.svgSpan(group, options); + + // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; + // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; + + // Generate the vlist + var vlist = void 0; + if (group.value.below) { + var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; + vlist = _buildCommon2.default.makeVList({ + positionType: "individualShift", + children: [{ type: "elem", elem: upperGroup, shift: upperShift }, { type: "elem", elem: arrowBody, shift: arrowShift }, { type: "elem", elem: lowerGroup, shift: lowerShift }] + }, options); + } else { + vlist = _buildCommon2.default.makeVList({ + positionType: "individualShift", + children: [{ type: "elem", elem: upperGroup, shift: upperShift }, { type: "elem", elem: arrowBody, shift: arrowShift }] + }, options); + } + + vlist.children[0].children[0].children[1].classes.push("svg-align"); + + return makeSpan(["mrel", "x-arrow"], [vlist], options); +}; + +groupTypes.mclass = function (group, options) { + var elements = buildExpression(group.value.value, options, true); + + return makeSpan([group.value.mclass], elements, options); +}; + +groupTypes.raisebox = function (group, options) { + var body = groupTypes.sizing({ value: { + value: [{ + type: "text", + value: { + body: group.value.value, + font: "mathrm" // simulate \textrm + } + }], + size: 6 // simulate \normalsize + } }, options); + var dy = (0, _units.calculateSize)(group.value.dy.value, options); + return _buildCommon2.default.makeVList({ + positionType: "shift", + positionData: -dy, + children: [{ type: "elem", elem: body }] + }, options); }; /** @@ -3378,31 +5290,21 @@ groupTypes.phantom = function(group, options, prev) { * function for it. It also handles the interaction of size and style changes * between parents and children. */ -var buildGroup = function(group, options, prev) { +var buildGroup = exports.buildGroup = function buildGroup(group, options, baseOptions) { if (!group) { return makeSpan(); } if (groupTypes[group.type]) { // Call the groupTypes function - var groupNode = groupTypes[group.type](group, options, prev); - var multiplier; - - // If the style changed between the parent and the current group, - // account for the size difference - if (options.style !== options.parentStyle) { - multiplier = options.style.sizeMultiplier / - options.parentStyle.sizeMultiplier; - - groupNode.height *= multiplier; - groupNode.depth *= multiplier; - } + var groupNode = groupTypes[group.type](group, options); // If the size changed between the parent and the current group, account // for that size difference. - if (options.size !== options.parentSize) { - multiplier = buildCommon.sizingMultiplier[options.size] / - buildCommon.sizingMultiplier[options.parentSize]; + if (baseOptions && options.size !== baseOptions.size) { + groupNode = makeSpan(options.sizingClasses(baseOptions), [groupNode], options); + + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; groupNode.height *= multiplier; groupNode.depth *= multiplier; @@ -3410,8 +5312,7 @@ var buildGroup = function(group, options, prev) { return groupNode; } else { - throw new ParseError( - "Got group of unknown type: '" + group.type + "'"); + throw new _ParseError2.default("Got group of unknown type: '" + group.type + "'"); } }; @@ -3419,14 +5320,14 @@ var buildGroup = function(group, options, prev) { * Take an entire parse tree, and build it into an appropriate set of HTML * nodes. */ -var buildHTML = function(tree, options) { +function buildHTML(tree, options) { // buildExpression is destructive, so we need to make a clone // of the incoming tree so that it isn't accidentally changed - tree = JSON.parse(JSON.stringify(tree)); + tree = JSON.parse((0, _stringify2.default)(tree)); // Build the expression contained in the tree - var expression = buildExpression(tree, options); - var body = makeSpan(["base", options.style.cls()], expression); + var expression = buildExpression(tree, options, true); + var body = makeSpan(["base"], expression, options); // Add struts, which ensure that the top of the HTML element falls at the // height of the expression, and the bottom of the HTML element falls at the @@ -3435,7 +5336,7 @@ var buildHTML = function(tree, options) { var bottomStrut = makeSpan(["strut", "bottom"]); topStrut.style.height = body.height + "em"; - bottomStrut.style.height = (body.height + body.depth) + "em"; + bottomStrut.style.height = body.height + body.depth + "em"; // We'd like to use `vertical-align: top` but in IE 9 this lowers the // baseline of the box to the bottom of this strut (instead staying in the // normal place) so we use an absolute value for vertical-align instead @@ -3447,43 +5348,75 @@ var buildHTML = function(tree, options) { htmlNode.setAttribute("aria-hidden", "true"); return htmlNode; -}; +} -module.exports = buildHTML; +},{"./ParseError":84,"./Style":89,"./buildCommon":91,"./delimiter":97,"./domTree":98,"./stretchy":123,"./units":127,"./utils":128,"babel-runtime/core-js/json/stringify":5}],93:[function(require,module,exports){ +"use strict"; -},{"./ParseError":6,"./Style":9,"./buildCommon":10,"./delimiter":14,"./domTree":15,"./fontMetrics":17,"./utils":25}],12:[function(require,module,exports){ -/** - * This file converts a parse tree into a cooresponding MathML tree. The main - * entry point is the `buildMathML` function, which takes a parse tree from the - * parser. - */ +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.buildGroup = exports.buildExpression = exports.groupTypes = exports.makeText = undefined; +exports.default = buildMathML; + +var _buildCommon = require("./buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _fontMetrics = require("./fontMetrics"); + +var _fontMetrics2 = _interopRequireDefault(_fontMetrics); + +var _mathMLTree = require("./mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _ParseError = require("./ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +var _Style = require("./Style"); + +var _Style2 = _interopRequireDefault(_Style); + +var _symbols = require("./symbols"); -var buildCommon = require("./buildCommon"); -var fontMetrics = require("./fontMetrics"); -var mathMLTree = require("./mathMLTree"); -var ParseError = require("./ParseError"); -var symbols = require("./symbols"); -var utils = require("./utils"); +var _symbols2 = _interopRequireDefault(_symbols); -var makeSpan = buildCommon.makeSpan; -var fontMap = buildCommon.fontMap; +var _utils = require("./utils"); + +var _utils2 = _interopRequireDefault(_utils); + +var _stretchy = require("./stretchy"); + +var _stretchy2 = _interopRequireDefault(_stretchy); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Takes a symbol and converts it into a MathML text node after performing * optional replacement from symbols.js. */ -var makeText = function(text, mode) { - if (symbols[mode][text] && symbols[mode][text].replace) { - text = symbols[mode][text].replace; +/** + * WARNING: New methods on groupTypes should be added to src/functions. + * + * This file converts a parse tree into a cooresponding MathML tree. The main + * entry point is the `buildMathML` function, which takes a parse tree from the + * parser. + */ + +var makeText = exports.makeText = function makeText(text, mode) { + if (_symbols2.default[mode][text] && _symbols2.default[mode][text].replace) { + text = _symbols2.default[mode][text].replace; } - return new mathMLTree.TextNode(text); + return new _mathMLTree2.default.TextNode(text); }; /** * Returns the math variant as a string or null if none is required. */ -var getVariant = function(group, options) { +var getVariant = function getVariant(group, options) { var font = options.font; if (!font) { return null; @@ -3495,17 +5428,17 @@ var getVariant = function(group, options) { } var value = group.value; - if (utils.contains(["\\imath", "\\jmath"], value)) { + if (_utils2.default.contains(["\\imath", "\\jmath"], value)) { return null; } - if (symbols[mode][value] && symbols[mode][value].replace) { - value = symbols[mode][value].replace; + if (_symbols2.default[mode][value] && _symbols2.default[mode][value].replace) { + value = _symbols2.default[mode][value].replace; } - var fontName = fontMap[font].fontName; - if (fontMetrics.getCharacterMetrics(value, fontName)) { - return fontMap[options.font].variant; + var fontName = _buildCommon2.default.fontMap[font].fontName; + if (_fontMetrics2.default.getCharacterMetrics(value, fontName)) { + return _buildCommon2.default.fontMap[options.font].variant; } return null; @@ -3515,327 +5448,209 @@ var getVariant = function(group, options) { * Functions for handling the different types of groups found in the parse * tree. Each function should take a parse group and return a MathML node. */ -var groupTypes = {}; +var groupTypes = exports.groupTypes = {}; -groupTypes.mathord = function(group, options) { - var node = new mathMLTree.MathNode( - "mi", - [makeText(group.value, group.mode)]); +var defaultVariant = { + "mi": "italic", + "mn": "normal", + "mtext": "normal" +}; + +groupTypes.mathord = function (group, options) { + var node = new _mathMLTree2.default.MathNode("mi", [makeText(group.value, group.mode)]); - var variant = getVariant(group, options); - if (variant) { + var variant = getVariant(group, options) || "italic"; + if (variant !== defaultVariant[node.type]) { node.setAttribute("mathvariant", variant); } return node; }; -groupTypes.textord = function(group, options) { +groupTypes.textord = function (group, options) { var text = makeText(group.value, group.mode); var variant = getVariant(group, options) || "normal"; - var node; - if (/[0-9]/.test(group.value)) { + var node = void 0; + if (group.mode === 'text') { + node = new _mathMLTree2.default.MathNode("mtext", [text]); + } else if (/[0-9]/.test(group.value)) { // TODO(kevinb) merge adjacent <mn> nodes // do it as a post processing step - node = new mathMLTree.MathNode("mn", [text]); - if (options.font) { - node.setAttribute("mathvariant", variant); - } + node = new _mathMLTree2.default.MathNode("mn", [text]); + } else if (group.value === "\\prime") { + node = new _mathMLTree2.default.MathNode("mo", [text]); } else { - node = new mathMLTree.MathNode("mi", [text]); + node = new _mathMLTree2.default.MathNode("mi", [text]); + } + if (variant !== defaultVariant[node.type]) { node.setAttribute("mathvariant", variant); } return node; }; -groupTypes.bin = function(group) { - var node = new mathMLTree.MathNode( - "mo", [makeText(group.value, group.mode)]); +groupTypes.bin = function (group) { + var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]); return node; }; -groupTypes.rel = function(group) { - var node = new mathMLTree.MathNode( - "mo", [makeText(group.value, group.mode)]); +groupTypes.rel = function (group) { + var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]); return node; }; -groupTypes.open = function(group) { - var node = new mathMLTree.MathNode( - "mo", [makeText(group.value, group.mode)]); +groupTypes.open = function (group) { + var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]); return node; }; -groupTypes.close = function(group) { - var node = new mathMLTree.MathNode( - "mo", [makeText(group.value, group.mode)]); +groupTypes.close = function (group) { + var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]); return node; }; -groupTypes.inner = function(group) { - var node = new mathMLTree.MathNode( - "mo", [makeText(group.value, group.mode)]); +groupTypes.inner = function (group) { + var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]); return node; }; -groupTypes.punct = function(group) { - var node = new mathMLTree.MathNode( - "mo", [makeText(group.value, group.mode)]); +groupTypes.punct = function (group) { + var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]); node.setAttribute("separator", "true"); return node; }; -groupTypes.ordgroup = function(group, options) { +groupTypes.ordgroup = function (group, options) { var inner = buildExpression(group.value, options); - var node = new mathMLTree.MathNode("mrow", inner); + var node = new _mathMLTree2.default.MathNode("mrow", inner); return node; }; -groupTypes.text = function(group, options) { - var inner = buildExpression(group.value.body, options); - - var node = new mathMLTree.MathNode("mtext", inner); - - return node; -}; - -groupTypes.color = function(group, options) { - var inner = buildExpression(group.value.value, options); - - var node = new mathMLTree.MathNode("mstyle", inner); - - node.setAttribute("mathcolor", group.value.color); - - return node; -}; +groupTypes.supsub = function (group, options) { + // Is the inner group a relevant horizonal brace? + var isBrace = false; + var isOver = void 0; + var isSup = void 0; + if (group.value.base) { + if (group.value.base.value.type === "horizBrace") { + isSup = group.value.sup ? true : false; + if (isSup === group.value.base.value.isOver) { + isBrace = true; + isOver = group.value.base.value.isOver; + } + } + } -groupTypes.supsub = function(group, options) { - var children = [buildGroup(group.value.base, options)]; + var removeUnnecessaryRow = true; + var children = [buildGroup(group.value.base, options, removeUnnecessaryRow)]; if (group.value.sub) { - children.push(buildGroup(group.value.sub, options)); + children.push(buildGroup(group.value.sub, options, removeUnnecessaryRow)); } if (group.value.sup) { - children.push(buildGroup(group.value.sup, options)); + children.push(buildGroup(group.value.sup, options, removeUnnecessaryRow)); } - var nodeType; - if (!group.value.sub) { + var nodeType = void 0; + if (isBrace) { + nodeType = isOver ? "mover" : "munder"; + } else if (!group.value.sub) { nodeType = "msup"; } else if (!group.value.sup) { nodeType = "msub"; } else { - nodeType = "msubsup"; - } - - var node = new mathMLTree.MathNode(nodeType, children); - - return node; -}; - -groupTypes.genfrac = function(group, options) { - var node = new mathMLTree.MathNode( - "mfrac", - [buildGroup(group.value.numer, options), - buildGroup(group.value.denom, options)]); - - if (!group.value.hasBarLine) { - node.setAttribute("linethickness", "0px"); - } - - if (group.value.leftDelim != null || group.value.rightDelim != null) { - var withDelims = []; - - if (group.value.leftDelim != null) { - var leftOp = new mathMLTree.MathNode( - "mo", [new mathMLTree.TextNode(group.value.leftDelim)]); - - leftOp.setAttribute("fence", "true"); - - withDelims.push(leftOp); - } - - withDelims.push(node); - - if (group.value.rightDelim != null) { - var rightOp = new mathMLTree.MathNode( - "mo", [new mathMLTree.TextNode(group.value.rightDelim)]); - - rightOp.setAttribute("fence", "true"); - - withDelims.push(rightOp); + var base = group.value.base; + if (base && base.value.limits && options.style === _Style2.default.DISPLAY) { + nodeType = "munderover"; + } else { + nodeType = "msubsup"; } - - var outerNode = new mathMLTree.MathNode("mrow", withDelims); - - return outerNode; } - return node; -}; + var node = new _mathMLTree2.default.MathNode(nodeType, children); -groupTypes.array = function(group, options) { - return new mathMLTree.MathNode( - "mtable", group.value.body.map(function(row) { - return new mathMLTree.MathNode( - "mtr", row.map(function(cell) { - return new mathMLTree.MathNode( - "mtd", [buildGroup(cell, options)]); - })); - })); + return node; }; -groupTypes.sqrt = function(group, options) { - var node; +groupTypes.sqrt = function (group, options) { + var node = void 0; if (group.value.index) { - node = new mathMLTree.MathNode( - "mroot", [ - buildGroup(group.value.body, options), - buildGroup(group.value.index, options), - ]); + node = new _mathMLTree2.default.MathNode("mroot", [buildGroup(group.value.body, options), buildGroup(group.value.index, options)]); } else { - node = new mathMLTree.MathNode( - "msqrt", [buildGroup(group.value.body, options)]); + node = new _mathMLTree2.default.MathNode("msqrt", [buildGroup(group.value.body, options)]); } return node; }; -groupTypes.leftright = function(group, options) { - var inner = buildExpression(group.value.body, options); - - if (group.value.left !== ".") { - var leftNode = new mathMLTree.MathNode( - "mo", [makeText(group.value.left, group.mode)]); - - leftNode.setAttribute("fence", "true"); - - inner.unshift(leftNode); - } - - if (group.value.right !== ".") { - var rightNode = new mathMLTree.MathNode( - "mo", [makeText(group.value.right, group.mode)]); - - rightNode.setAttribute("fence", "true"); - - inner.push(rightNode); +groupTypes.accent = function (group, options) { + var accentNode = void 0; + if (group.value.isStretchy) { + accentNode = _stretchy2.default.mathMLnode(group.value.label); + } else { + accentNode = new _mathMLTree2.default.MathNode("mo", [makeText(group.value.label, group.mode)]); } - var outerNode = new mathMLTree.MathNode("mrow", inner); - - return outerNode; -}; - -groupTypes.accent = function(group, options) { - var accentNode = new mathMLTree.MathNode( - "mo", [makeText(group.value.accent, group.mode)]); - - var node = new mathMLTree.MathNode( - "mover", - [buildGroup(group.value.base, options), - accentNode]); + var node = new _mathMLTree2.default.MathNode("mover", [buildGroup(group.value.base, options), accentNode]); node.setAttribute("accent", "true"); return node; }; -groupTypes.spacing = function(group) { - var node; +groupTypes.spacing = function (group) { + var node = void 0; - if (group.value === "\\ " || group.value === "\\space" || - group.value === " " || group.value === "~") { - node = new mathMLTree.MathNode( - "mtext", [new mathMLTree.TextNode("\u00a0")]); + if (group.value === "\\ " || group.value === "\\space" || group.value === " " || group.value === "~") { + node = new _mathMLTree2.default.MathNode("mtext", [new _mathMLTree2.default.TextNode("\xA0")]); } else { - node = new mathMLTree.MathNode("mspace"); + node = new _mathMLTree2.default.MathNode("mspace"); - node.setAttribute( - "width", buildCommon.spacingFunctions[group.value].size); + node.setAttribute("width", _buildCommon2.default.spacingFunctions[group.value].size); } return node; }; -groupTypes.op = function(group) { - var node; - - // TODO(emily): handle big operators using the `largeop` attribute - - if (group.value.symbol) { - // This is a symbol. Just add the symbol. - node = new mathMLTree.MathNode( - "mo", [makeText(group.value.body, group.mode)]); - } else { - // This is a text operator. Add all of the characters from the - // operator's name. - // TODO(emily): Add a space in the middle of some of these - // operators, like \limsup. - node = new mathMLTree.MathNode( - "mi", [new mathMLTree.TextNode(group.value.body.slice(1))]); - } - - return node; -}; - -groupTypes.katex = function(group) { - var node = new mathMLTree.MathNode( - "mtext", [new mathMLTree.TextNode("KaTeX")]); - - return node; -}; - -groupTypes.font = function(group, options) { +groupTypes.font = function (group, options) { var font = group.value.font; return buildGroup(group.value.body, options.withFont(font)); }; -groupTypes.delimsizing = function(group) { - var children = []; - - if (group.value.value !== ".") { - children.push(makeText(group.value.value, group.mode)); - } - - var node = new mathMLTree.MathNode("mo", children); - - if (group.value.delimType === "open" || - group.value.delimType === "close") { - // Only some of the delimsizing functions act as fences, and they - // return "open" or "close" delimTypes. - node.setAttribute("fence", "true"); - } else { - // Explicitly disable fencing if it's not a fence, to override the - // defaults. - node.setAttribute("fence", "false"); - } +groupTypes.styling = function (group, options) { + // Figure out what style we're changing to. + // TODO(kevinb): dedupe this with buildHTML.js + // This will be easier of handling of styling nodes is in the same file. + var styleMap = { + "display": _Style2.default.DISPLAY, + "text": _Style2.default.TEXT, + "script": _Style2.default.SCRIPT, + "scriptscript": _Style2.default.SCRIPTSCRIPT + }; - return node; -}; + var newStyle = styleMap[group.value.style]; + var newOptions = options.havingStyle(newStyle); -groupTypes.styling = function(group, options) { - var inner = buildExpression(group.value.value, options); + var inner = buildExpression(group.value.value, newOptions); - var node = new mathMLTree.MathNode("mstyle", inner); + var node = new _mathMLTree2.default.MathNode("mstyle", inner); var styleAttributes = { "display": ["0", "true"], "text": ["0", "false"], "script": ["1", "false"], - "scriptscript": ["2", "false"], + "scriptscript": ["2", "false"] }; var attr = styleAttributes[group.value.style]; @@ -3846,87 +5661,103 @@ groupTypes.styling = function(group, options) { return node; }; -groupTypes.sizing = function(group, options) { - var inner = buildExpression(group.value.value, options); +groupTypes.sizing = function (group, options) { + var newOptions = options.havingSize(group.value.size); + var inner = buildExpression(group.value.value, newOptions); - var node = new mathMLTree.MathNode("mstyle", inner); + var node = new _mathMLTree2.default.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size // changes, because we don't keep state of what style we're currently // in, so we can't reset the size to normal before changing it. Now // that we're passing an options parameter we should be able to fix // this. - node.setAttribute( - "mathsize", buildCommon.sizingMultiplier[group.value.size] + "em"); + node.setAttribute("mathsize", newOptions.sizeMultiplier + "em"); return node; }; -groupTypes.overline = function(group, options) { - var operator = new mathMLTree.MathNode( - "mo", [new mathMLTree.TextNode("\u203e")]); - operator.setAttribute("stretchy", "true"); - - var node = new mathMLTree.MathNode( - "mover", - [buildGroup(group.value.body, options), - operator]); - node.setAttribute("accent", "true"); - +groupTypes.verb = function (group, options) { + var text = new _mathMLTree2.default.TextNode(_buildCommon2.default.makeVerb(group, options)); + var node = new _mathMLTree2.default.MathNode("mtext", [text]); + node.setAttribute("mathvariant", _buildCommon2.default.fontMap["mathtt"].variant); return node; }; -groupTypes.underline = function(group, options) { - var operator = new mathMLTree.MathNode( - "mo", [new mathMLTree.TextNode("\u203e")]); - operator.setAttribute("stretchy", "true"); - - var node = new mathMLTree.MathNode( - "munder", - [buildGroup(group.value.body, options), - operator]); +groupTypes.accentUnder = function (group, options) { + var accentNode = _stretchy2.default.mathMLnode(group.value.label); + var node = new _mathMLTree2.default.MathNode("munder", [buildGroup(group.value.body, options), accentNode]); node.setAttribute("accentunder", "true"); - return node; }; -groupTypes.rule = function(group) { - // TODO(emily): Figure out if there's an actual way to draw black boxes - // in MathML. - var node = new mathMLTree.MathNode("mrow"); - +groupTypes.enclose = function (group, options) { + var node = new _mathMLTree2.default.MathNode("menclose", [buildGroup(group.value.body, options)]); + switch (group.value.label) { + case "\\cancel": + node.setAttribute("notation", "updiagonalstrike"); + break; + case "\\bcancel": + node.setAttribute("notation", "downdiagonalstrike"); + break; + case "\\sout": + node.setAttribute("notation", "horizontalstrike"); + break; + case "\\fbox": + node.setAttribute("notation", "box"); + break; + case "\\colorbox": + node.setAttribute("mathbackground", group.value.backgroundColor.value); + break; + case "\\fcolorbox": + node.setAttribute("mathbackground", group.value.backgroundColor.value); + // TODO(ron): I don't know any way to set the border color. + node.setAttribute("notation", "box"); + break; + default: + // xcancel + node.setAttribute("notation", "updiagonalstrike downdiagonalstrike"); + } return node; }; -groupTypes.kern = function(group) { - // TODO(kevin): Figure out if there's a way to add space in MathML - var node = new mathMLTree.MathNode("mrow"); - - return node; +groupTypes.horizBrace = function (group, options) { + var accentNode = _stretchy2.default.mathMLnode(group.value.label); + return new _mathMLTree2.default.MathNode(group.value.isOver ? "mover" : "munder", [buildGroup(group.value.base, options), accentNode]); }; -groupTypes.llap = function(group, options) { - var node = new mathMLTree.MathNode( - "mpadded", [buildGroup(group.value.body, options)]); - - node.setAttribute("lspace", "-1width"); - node.setAttribute("width", "0px"); +groupTypes.xArrow = function (group, options) { + var arrowNode = _stretchy2.default.mathMLnode(group.value.label); + var node = void 0; + var lowerNode = void 0; + if (group.value.body) { + var upperNode = buildGroup(group.value.body, options); + if (group.value.below) { + lowerNode = buildGroup(group.value.below, options); + node = new _mathMLTree2.default.MathNode("munderover", [arrowNode, lowerNode, upperNode]); + } else { + node = new _mathMLTree2.default.MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.value.below) { + lowerNode = buildGroup(group.value.below, options); + node = new _mathMLTree2.default.MathNode("munder", [arrowNode, lowerNode]); + } else { + node = new _mathMLTree2.default.MathNode("mover", [arrowNode]); + } return node; }; -groupTypes.rlap = function(group, options) { - var node = new mathMLTree.MathNode( - "mpadded", [buildGroup(group.value.body, options)]); - - node.setAttribute("width", "0px"); - - return node; +groupTypes.mclass = function (group, options) { + var inner = buildExpression(group.value.value, options); + return new _mathMLTree2.default.MathNode("mstyle", inner); }; -groupTypes.phantom = function(group, options, prev) { - var inner = buildExpression(group.value.value, options); - return new mathMLTree.MathNode("mphantom", inner); +groupTypes.raisebox = function (group, options) { + var node = new _mathMLTree2.default.MathNode("mpadded", [buildGroup(group.value.body, options)]); + var dy = group.value.dy.value.number + group.value.dy.value.unit; + node.setAttribute("voffset", dy); + return node; }; /** @@ -3934,12 +5765,15 @@ groupTypes.phantom = function(group, options, prev) { * MathML nodes. A little simpler than the HTML version because we don't do any * previous-node handling. */ -var buildExpression = function(expression, options) { +var buildExpression = exports.buildExpression = function buildExpression(expression, options) { var groups = []; for (var i = 0; i < expression.length; i++) { var group = expression[i]; groups.push(buildGroup(group, options)); } + + // TODO(kevinb): combine \\not with mrels and mords + return groups; }; @@ -3947,17 +5781,24 @@ var buildExpression = function(expression, options) { * Takes a group from the parser and calls the appropriate groupTypes function * on it to produce a MathML node. */ -var buildGroup = function(group, options) { +var buildGroup = exports.buildGroup = function buildGroup(group, options) { + var removeUnnecessaryRow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + if (!group) { - return new mathMLTree.MathNode("mrow"); + return new _mathMLTree2.default.MathNode("mrow"); } if (groupTypes[group.type]) { // Call the groupTypes function - return groupTypes[group.type](group, options); + var result = groupTypes[group.type](group, options); + if (removeUnnecessaryRow) { + if (result.type === "mrow" && result.children.length === 1) { + return result.children[0]; + } + } + return result; } else { - throw new ParseError( - "Got group of unknown type: '" + group.type + "'"); + throw new _ParseError2.default("Got group of unknown type: '" + group.type + "'"); } }; @@ -3969,73 +5810,309 @@ var buildGroup = function(group, options) { * Note that we actually return a domTree element with a `<math>` inside it so * we can do appropriate styling. */ -var buildMathML = function(tree, texExpression, options) { +function buildMathML(tree, texExpression, options) { var expression = buildExpression(tree, options); // Wrap up the expression in an mrow so it is presented in the semantics // tag correctly. - var wrapper = new mathMLTree.MathNode("mrow", expression); + var wrapper = new _mathMLTree2.default.MathNode("mrow", expression); // Build a TeX annotation of the source - var annotation = new mathMLTree.MathNode( - "annotation", [new mathMLTree.TextNode(texExpression)]); + var annotation = new _mathMLTree2.default.MathNode("annotation", [new _mathMLTree2.default.TextNode(texExpression)]); annotation.setAttribute("encoding", "application/x-tex"); - var semantics = new mathMLTree.MathNode( - "semantics", [wrapper, annotation]); + var semantics = new _mathMLTree2.default.MathNode("semantics", [wrapper, annotation]); - var math = new mathMLTree.MathNode("math", [semantics]); + var math = new _mathMLTree2.default.MathNode("math", [semantics]); // You can't style <math> nodes, so we wrap the node in a span. - return makeSpan(["katex-mathml"], [math]); -}; + return _buildCommon2.default.makeSpan(["katex-mathml"], [math]); +} + +},{"./ParseError":84,"./Style":89,"./buildCommon":91,"./fontMetrics":101,"./mathMLTree":121,"./stretchy":123,"./symbols":125,"./utils":128}],94:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _buildHTML = require("./buildHTML"); + +var _buildHTML2 = _interopRequireDefault(_buildHTML); + +var _buildMathML = require("./buildMathML"); -module.exports = buildMathML; +var _buildMathML2 = _interopRequireDefault(_buildMathML); -},{"./ParseError":6,"./buildCommon":10,"./fontMetrics":17,"./mathMLTree":20,"./symbols":23,"./utils":25}],13:[function(require,module,exports){ -var buildHTML = require("./buildHTML"); -var buildMathML = require("./buildMathML"); -var buildCommon = require("./buildCommon"); -var Options = require("./Options"); -var Settings = require("./Settings"); -var Style = require("./Style"); +var _buildCommon = require("./buildCommon"); -var makeSpan = buildCommon.makeSpan; +var _buildCommon2 = _interopRequireDefault(_buildCommon); -var buildTree = function(tree, expression, settings) { - settings = settings || new Settings({}); +var _Options = require("./Options"); - var startStyle = Style.TEXT; +var _Options2 = _interopRequireDefault(_Options); + +var _Settings = require("./Settings"); + +var _Settings2 = _interopRequireDefault(_Settings); + +var _Style = require("./Style"); + +var _Style2 = _interopRequireDefault(_Style); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var buildTree = function buildTree(tree, expression, settings) { + settings = settings || new _Settings2.default({}); + + var startStyle = _Style2.default.TEXT; if (settings.displayMode) { - startStyle = Style.DISPLAY; + startStyle = _Style2.default.DISPLAY; } // Setup the default options - var options = new Options({ + var options = new _Options2.default({ style: startStyle, - size: "size5", + maxSize: settings.maxSize }); // `buildHTML` sometimes messes with the parse tree (like turning bins -> // ords), so we build the MathML version first. - var mathMLNode = buildMathML(tree, expression, options); - var htmlNode = buildHTML(tree, options); + var mathMLNode = (0, _buildMathML2.default)(tree, expression, options); + var htmlNode = (0, _buildHTML2.default)(tree, options); - var katexNode = makeSpan(["katex"], [ - mathMLNode, htmlNode, - ]); + var katexNode = _buildCommon2.default.makeSpan(["katex"], [mathMLNode, htmlNode]); if (settings.displayMode) { - return makeSpan(["katex-display"], [katexNode]); + return _buildCommon2.default.makeSpan(["katex-display"], [katexNode]); } else { return katexNode; } }; -module.exports = buildTree; +exports.default = buildTree; + +},{"./Options":83,"./Settings":87,"./Style":89,"./buildCommon":91,"./buildHTML":92,"./buildMathML":93}],95:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports._environments = undefined; +exports.default = defineEnvironment; + +var _buildHTML = require("./buildHTML"); + +var _buildMathML = require("./buildMathML"); + +var _Options = require("./Options"); + +var _Options2 = _interopRequireDefault(_Options); + +var _ParseNode = require("./ParseNode"); + +var _ParseNode2 = _interopRequireDefault(_ParseNode); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * All registered environments. + * `environments.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `environments.js`. + */ + + +/** + * The context contains the following properties: + * - mode: current parsing mode. + * - envName: the name of the environment, one of the listed names. + * - parser: the parser object. + */ + -},{"./Options":5,"./Settings":8,"./Style":9,"./buildCommon":10,"./buildHTML":11,"./buildMathML":12}],14:[function(require,module,exports){ +/** + * - context: information and references provided by the parser + * - args: an array of arguments passed to \begin{name} + * - optArgs: an array of optional arguments passed to \begin{name} + */ + + +/** + * - numArgs: (default 0) The number of arguments after the \begin{name} function. + * - argTypes: (optional) Just like for a function + * - allowedInText: (default false) Whether or not the environment is allowed + * inside text mode (not enforced yet). + * - numOptionalArgs: (default 0) Just like for a function + */ + + +/** + * Final enviornment spec for use at parse time. + * This is almost identical to `EnvDefSpec`, except it + * 1. includes the function handler + * 2. requires all arguments except argType + * It is generated by `defineEnvironment()` below. + */ +var _environments = exports._environments = {}; + +function defineEnvironment(_ref) { + var type = _ref.type, + names = _ref.names, + props = _ref.props, + handler = _ref.handler, + htmlBuilder = _ref.htmlBuilder, + mathmlBuilder = _ref.mathmlBuilder; + + // Set default values of environments + var data = { + numArgs: props.numArgs || 0, + greediness: 1, + allowedInText: false, + numOptionalArgs: 0, + handler: handler + }; + for (var i = 0; i < names.length; ++i) { + _environments[names[i]] = data; + } + if (htmlBuilder) { + _buildHTML.groupTypes[type] = htmlBuilder; + } + if (mathmlBuilder) { + _buildMathML.groupTypes[type] = mathmlBuilder; + } +} + +},{"./Options":83,"./ParseNode":85,"./buildHTML":92,"./buildMathML":93}],96:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.ordargument = exports._functions = undefined; +exports.default = defineFunction; + +var _buildHTML = require("./buildHTML"); + +var _buildMathML = require("./buildMathML"); + +/** + * All registered functions. + * `functions.js` just exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary. + */ + + +/** Context provided to function handlers for error messages. */ + + +// TODO: Enumerate all allowed output types. + + +/** + * Final function spec for use at parse time. + * This is almost identical to `FunctionPropSpec`, except it + * 1. includes the function handler, and + * 2. requires all arguments except argTypes. + * It is generated by `defineFunction()` below. + */ +var _functions = exports._functions = {}; + +function defineFunction(_ref) { + var type = _ref.type, + names = _ref.names, + props = _ref.props, + handler = _ref.handler, + htmlBuilder = _ref.htmlBuilder, + mathmlBuilder = _ref.mathmlBuilder; + + // Set default values of functions + var data = { + numArgs: props.numArgs, + argTypes: props.argTypes, + greediness: props.greediness === undefined ? 1 : props.greediness, + allowedInText: !!props.allowedInText, + allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath, + numOptionalArgs: props.numOptionalArgs || 0, + infix: !!props.infix, + handler: handler + }; + for (var i = 0; i < names.length; ++i) { + _functions[names[i]] = data; + } + if (type) { + if (htmlBuilder) { + _buildHTML.groupTypes[type] = htmlBuilder; + } + if (mathmlBuilder) { + _buildMathML.groupTypes[type] = mathmlBuilder; + } + } +} + +// Since the corresponding buildHTML/buildMathML function expects a +// list of elements, we normalize for different kinds of arguments +var ordargument = exports.ordargument = function ordargument(arg) { + if (arg.type === "ordgroup") { + return arg.value; + } else { + return [arg]; + } +}; + +},{"./buildHTML":92,"./buildMathML":93}],97:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _ParseError = require("./ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +var _Style = require("./Style"); + +var _Style2 = _interopRequireDefault(_Style); + +var _domTree = require("./domTree"); + +var _domTree2 = _interopRequireDefault(_domTree); + +var _buildCommon = require("./buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _fontMetrics = require("./fontMetrics"); + +var _fontMetrics2 = _interopRequireDefault(_fontMetrics); + +var _symbols = require("./symbols"); + +var _symbols2 = _interopRequireDefault(_symbols); + +var _utils = require("./utils"); + +var _utils2 = _interopRequireDefault(_utils); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Get the metrics for a given symbol and font, after transformation (i.e. + * after following replacement from symbols.js) + */ +var getMetrics = function getMetrics(symbol, font) { + if (_symbols2.default.math[symbol] && _symbols2.default.math[symbol].replace) { + return _fontMetrics2.default.getCharacterMetrics(_symbols2.default.math[symbol].replace, font); + } else { + return _fontMetrics2.default.getCharacterMetrics(symbol, font); + } +}; + +/** + * Puts a delimiter span in a given style, and adds appropriate height, depth, + * and maxFontSizes. + */ /** * This file deals with creating delimiters of various sizes. The TeXbook * discusses these routines on page 441-442, in the "Another subroutine sets box @@ -4058,52 +6135,27 @@ module.exports = buildTree; * used in `\left` and `\right`. */ -var ParseError = require("./ParseError"); -var Style = require("./Style"); - -var buildCommon = require("./buildCommon"); -var fontMetrics = require("./fontMetrics"); -var symbols = require("./symbols"); -var utils = require("./utils"); +var styleWrap = function styleWrap(delim, toStyle, options, classes) { + var newOptions = options.havingBaseStyle(toStyle); -var makeSpan = buildCommon.makeSpan; + var span = _buildCommon2.default.makeSpan((classes || []).concat(newOptions.sizingClasses(options)), [delim], options); -/** - * Get the metrics for a given symbol and font, after transformation (i.e. - * after following replacement from symbols.js) - */ -var getMetrics = function(symbol, font) { - if (symbols.math[symbol] && symbols.math[symbol].replace) { - return fontMetrics.getCharacterMetrics( - symbols.math[symbol].replace, font); - } else { - return fontMetrics.getCharacterMetrics( - symbol, font); - } -}; + span.delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; + span.height *= span.delimSizeMultiplier; + span.depth *= span.delimSizeMultiplier; + span.maxFontSize = newOptions.sizeMultiplier; -/** - * Builds a symbol in the given font size (note size is an integer) - */ -var mathrmSize = function(value, size, mode) { - return buildCommon.makeSymbol(value, "Size" + size + "-Regular", mode); + return span; }; -/** - * Puts a delimiter span in a given style, and adds appropriate height, depth, - * and maxFontSizes. - */ -var styleWrap = function(delim, toStyle, options) { - var span = makeSpan( - ["style-wrap", options.style.reset(), toStyle.cls()], [delim]); - - var multiplier = toStyle.sizeMultiplier / options.style.sizeMultiplier; - - span.height *= multiplier; - span.depth *= multiplier; - span.maxFontSize = toStyle.sizeMultiplier; +var centerSpan = function centerSpan(span, options, style) { + var newOptions = options.havingBaseStyle(style); + var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; - return span; + span.classes.push("delimcenter"); + span.style.top = shift + "em"; + span.height -= shift; + span.depth += shift; }; /** @@ -4111,45 +6163,32 @@ var styleWrap = function(delim, toStyle, options) { * font, but is restyled to either be in textstyle, scriptstyle, or * scriptscriptstyle. */ -var makeSmallDelim = function(delim, style, center, options, mode) { - var text = buildCommon.makeSymbol(delim, "Main-Regular", mode); - - var span = styleWrap(text, style, options); - +var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) { + var text = _buildCommon2.default.makeSymbol(delim, "Main-Regular", mode, options); + var span = styleWrap(text, style, options, classes); if (center) { - var shift = - (1 - options.style.sizeMultiplier / style.sizeMultiplier) * - fontMetrics.metrics.axisHeight; - - span.style.top = shift + "em"; - span.height -= shift; - span.depth += shift; + centerSpan(span, options, style); } - return span; }; /** + * Builds a symbol in the given font size (note size is an integer) + */ +var mathrmSize = function mathrmSize(value, size, mode, options) { + return _buildCommon2.default.makeSymbol(value, "Size" + size + "-Regular", mode, options); +}; + +/** * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2, * Size3, or Size4 fonts. It is always rendered in textstyle. */ -var makeLargeDelim = function(delim, size, center, options, mode) { - var inner = mathrmSize(delim, size, mode); - - var span = styleWrap( - makeSpan(["delimsizing", "size" + size], - [inner], options.getColor()), - Style.TEXT, options); - +var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) { + var inner = mathrmSize(delim, size, mode, options); + var span = styleWrap(_buildCommon2.default.makeSpan(["delimsizing", "size" + size], [inner], options), _Style2.default.TEXT, options, classes); if (center) { - var shift = (1 - options.style.sizeMultiplier) * - fontMetrics.metrics.axisHeight; - - span.style.top = shift + "em"; - span.height -= shift; - span.depth += shift; + centerSpan(span, options, _Style2.default.TEXT); } - return span; }; @@ -4157,8 +6196,8 @@ var makeLargeDelim = function(delim, size, center, options, mode) { * Make an inner span with the given offset and in the given font. This is used * in `makeStackedDelim` to make the stacking pieces for the delimiter. */ -var makeInner = function(symbol, font, mode) { - var sizeClass; +var makeInner = function makeInner(symbol, font, mode) { + var sizeClass = void 0; // Apply the correct CSS class to choose the right font. if (font === "Size1-Regular") { sizeClass = "delim-size1"; @@ -4166,26 +6205,24 @@ var makeInner = function(symbol, font, mode) { sizeClass = "delim-size4"; } - var inner = makeSpan( - ["delimsizinginner", sizeClass], - [makeSpan([], [buildCommon.makeSymbol(symbol, font, mode)])]); + var inner = _buildCommon2.default.makeSpan(["delimsizinginner", sizeClass], [_buildCommon2.default.makeSpan([], [_buildCommon2.default.makeSymbol(symbol, font, mode)])]); // Since this will be passed into `makeVList` in the end, wrap the element // in the appropriate tag that VList uses. - return {type: "elem", elem: inner}; + return { type: "elem", elem: inner }; }; /** * Make a stacked delimiter out of a given delimiter, with the total height at * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. */ -var makeStackedDelim = function(delim, heightTotal, center, options, mode) { +var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) { // There are four parts, the top, an optional middle, a repeated part, and a // bottom. - var top; - var middle; - var repeat; - var bottom; + var top = void 0; + var middle = void 0; + var repeat = void 0; + var bottom = void 0; top = repeat = bottom = delim; middle = null; // Also keep track of what font the delimiters are in @@ -4195,93 +6232,88 @@ var makeStackedDelim = function(delim, heightTotal, center, options, mode) { // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the // repeats of the arrows if (delim === "\\uparrow") { - repeat = bottom = "\u23d0"; + repeat = bottom = "\u23D0"; } else if (delim === "\\Uparrow") { repeat = bottom = "\u2016"; } else if (delim === "\\downarrow") { - top = repeat = "\u23d0"; + top = repeat = "\u23D0"; } else if (delim === "\\Downarrow") { top = repeat = "\u2016"; } else if (delim === "\\updownarrow") { top = "\\uparrow"; - repeat = "\u23d0"; + repeat = "\u23D0"; bottom = "\\downarrow"; } else if (delim === "\\Updownarrow") { top = "\\Uparrow"; repeat = "\u2016"; bottom = "\\Downarrow"; } else if (delim === "[" || delim === "\\lbrack") { - top = "\u23a1"; - repeat = "\u23a2"; - bottom = "\u23a3"; + top = "\u23A1"; + repeat = "\u23A2"; + bottom = "\u23A3"; font = "Size4-Regular"; } else if (delim === "]" || delim === "\\rbrack") { - top = "\u23a4"; - repeat = "\u23a5"; - bottom = "\u23a6"; + top = "\u23A4"; + repeat = "\u23A5"; + bottom = "\u23A6"; font = "Size4-Regular"; } else if (delim === "\\lfloor") { - repeat = top = "\u23a2"; - bottom = "\u23a3"; + repeat = top = "\u23A2"; + bottom = "\u23A3"; font = "Size4-Regular"; } else if (delim === "\\lceil") { - top = "\u23a1"; - repeat = bottom = "\u23a2"; + top = "\u23A1"; + repeat = bottom = "\u23A2"; font = "Size4-Regular"; } else if (delim === "\\rfloor") { - repeat = top = "\u23a5"; - bottom = "\u23a6"; + repeat = top = "\u23A5"; + bottom = "\u23A6"; font = "Size4-Regular"; } else if (delim === "\\rceil") { - top = "\u23a4"; - repeat = bottom = "\u23a5"; + top = "\u23A4"; + repeat = bottom = "\u23A5"; font = "Size4-Regular"; } else if (delim === "(") { - top = "\u239b"; - repeat = "\u239c"; - bottom = "\u239d"; + top = "\u239B"; + repeat = "\u239C"; + bottom = "\u239D"; font = "Size4-Regular"; } else if (delim === ")") { - top = "\u239e"; - repeat = "\u239f"; - bottom = "\u23a0"; + top = "\u239E"; + repeat = "\u239F"; + bottom = "\u23A0"; font = "Size4-Regular"; } else if (delim === "\\{" || delim === "\\lbrace") { - top = "\u23a7"; - middle = "\u23a8"; - bottom = "\u23a9"; - repeat = "\u23aa"; + top = "\u23A7"; + middle = "\u23A8"; + bottom = "\u23A9"; + repeat = "\u23AA"; font = "Size4-Regular"; } else if (delim === "\\}" || delim === "\\rbrace") { - top = "\u23ab"; - middle = "\u23ac"; - bottom = "\u23ad"; - repeat = "\u23aa"; + top = "\u23AB"; + middle = "\u23AC"; + bottom = "\u23AD"; + repeat = "\u23AA"; font = "Size4-Regular"; } else if (delim === "\\lgroup") { - top = "\u23a7"; - bottom = "\u23a9"; - repeat = "\u23aa"; + top = "\u23A7"; + bottom = "\u23A9"; + repeat = "\u23AA"; font = "Size4-Regular"; } else if (delim === "\\rgroup") { - top = "\u23ab"; - bottom = "\u23ad"; - repeat = "\u23aa"; + top = "\u23AB"; + bottom = "\u23AD"; + repeat = "\u23AA"; font = "Size4-Regular"; } else if (delim === "\\lmoustache") { - top = "\u23a7"; - bottom = "\u23ad"; - repeat = "\u23aa"; + top = "\u23A7"; + bottom = "\u23AD"; + repeat = "\u23AA"; font = "Size4-Regular"; } else if (delim === "\\rmoustache") { - top = "\u23ab"; - bottom = "\u23a9"; - repeat = "\u23aa"; - font = "Size4-Regular"; - } else if (delim === "\\surd") { - top = "\ue001"; - bottom = "\u23b7"; - repeat = "\ue000"; + top = "\u23AB"; + bottom = "\u23A9"; + repeat = "\u23AA"; font = "Size4-Regular"; } @@ -4305,20 +6337,18 @@ var makeStackedDelim = function(delim, heightTotal, center, options, mode) { var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; // Compute the number of copies of the repeat symbol we will need - var repeatCount = Math.ceil( - (heightTotal - minHeight) / (middleFactor * repeatHeightTotal)); + var repeatCount = Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal)); // Compute the total height of the delimiter including all the symbols - var realHeightTotal = - minHeight + repeatCount * middleFactor * repeatHeightTotal; + var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; // The center of the delimiter is placed at the center of the axis. Note // that in this context, "center" means that the delimiter should be // centered around the axis in the current style, while normally it is // centered around the axis in textstyle. - var axisHeight = fontMetrics.metrics.axisHeight; + var axisHeight = options.fontMetrics().axisHeight; if (center) { - axisHeight *= options.style.sizeMultiplier; + axisHeight *= options.sizeMultiplier; } // Calculate the depth var depth = realHeightTotal / 2 - axisHeight; @@ -4331,20 +6361,19 @@ var makeStackedDelim = function(delim, heightTotal, center, options, mode) { // Add the bottom symbol inners.push(makeInner(bottom, font, mode)); - var i; if (middle === null) { // Add that many symbols - for (i = 0; i < repeatCount; i++) { + for (var i = 0; i < repeatCount; i++) { inners.push(makeInner(repeat, font, mode)); } } else { // When there is a middle bit, we need the middle part and two repeated // sections - for (i = 0; i < repeatCount; i++) { + for (var _i = 0; _i < repeatCount; _i++) { inners.push(makeInner(repeat, font, mode)); } inners.push(makeInner(middle, font, mode)); - for (i = 0; i < repeatCount; i++) { + for (var _i2 = 0; _i2 < repeatCount; _i2++) { inners.push(makeInner(repeat, font, mode)); } } @@ -4353,35 +6382,99 @@ var makeStackedDelim = function(delim, heightTotal, center, options, mode) { inners.push(makeInner(top, font, mode)); // Finally, build the vlist - var inner = buildCommon.makeVList(inners, "bottom", depth, options); + var newOptions = options.havingBaseStyle(_Style2.default.TEXT); + var inner = _buildCommon2.default.makeVList({ + positionType: "bottom", + positionData: depth, + children: inners + }, newOptions); + + return styleWrap(_buildCommon2.default.makeSpan(["delimsizing", "mult"], [inner], newOptions), _Style2.default.TEXT, options, classes); +}; + +var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, options) { + var alternate = void 0; + if (sqrtName === "sqrtTall") { + // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular + // One path edge has a variable length. It runs from the viniculumn + // to a point near (14 units) the bottom of the surd. The viniculum + // is 40 units thick. So the length of the line in question is: + var vertSegment = viewBoxHeight - 54; + alternate = "M702 0H400000v40H742v" + vertSegment + "l-4 4-4 4c-.667.667\n-2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1h-12l-28-84c-16.667-52-96.667\n-294.333-240-727l-212 -643 -85 170c-4-3.333-8.333-7.667-13 -13l-13-13l77-155\n 77-156c66 199.333 139 419.667 219 661 l218 661zM702 0H400000v40H742z"; + } + var pathNode = new _domTree2.default.pathNode(sqrtName, alternate); + + var svg = new _domTree2.default.svgNode([pathNode], { + // Note: 1000:1 ratio of viewBox to document em width. + "width": "400em", + "height": height + "em", + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + + return _buildCommon2.default.makeSpan(["hide-tail"], [svg], options); +}; + +/** + * Make a sqrt image of the given height, + */ +var makeSqrtImage = function makeSqrtImage(height, options) { + var delim = traverseSequence("\\surd", height, stackLargeDelimiterSequence, options); + + // Create a span containing an SVG image of a sqrt symbol. + var span = void 0; + var sizeMultiplier = options.sizeMultiplier; // default + var spanHeight = void 0; + var viewBoxHeight = void 0; + + if (delim.type === "small") { + // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. + viewBoxHeight = 1000; // from font + var newOptions = options.havingBaseStyle(delim.style); + sizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; + spanHeight = 1 * sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, options); + span.style.minWidth = "0.853em"; + span.advanceWidth = 0.833 * sizeMultiplier; // from the font. + } else if (delim.type === "large") { + // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. + viewBoxHeight = 1000 * sizeToMaxHeight[delim.size]; + spanHeight = sizeToMaxHeight[delim.size] / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, options); + span.style.minWidth = "1.02em"; + span.advanceWidth = 1.0 / sizeMultiplier; // from the font + } else { + // Tall sqrt. In TeX, this would be stacked using multiple glyphs. + // We'll use a single SVG to accomplish the same thing. + spanHeight = height / sizeMultiplier; + viewBoxHeight = Math.floor(1000 * height); + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, options); + span.style.minWidth = "0.742em"; + span.advanceWidth = 1.056 / sizeMultiplier; + } + + span.height = spanHeight; + span.style.height = spanHeight + "em"; - return styleWrap( - makeSpan(["delimsizing", "mult"], [inner], options.getColor()), - Style.TEXT, options); + return { + span: span, + // Calculate the actual line width. + // This actually should depend on the chosen font -- e.g. \boldmath + // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and + // have thicker rules. + ruleWidth: options.fontMetrics().sqrtRuleThickness * sizeMultiplier + }; }; // There are three kinds of delimiters, delimiters that stack when they become // too large -var stackLargeDelimiters = [ - "(", ")", "[", "\\lbrack", "]", "\\rbrack", - "\\{", "\\lbrace", "\\}", "\\rbrace", - "\\lfloor", "\\rfloor", "\\lceil", "\\rceil", - "\\surd", -]; +var stackLargeDelimiters = ["(", ")", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\\lceil", "\\rceil", "\\surd"]; // delimiters that always stack -var stackAlwaysDelimiters = [ - "\\uparrow", "\\downarrow", "\\updownarrow", - "\\Uparrow", "\\Downarrow", "\\Updownarrow", - "|", "\\|", "\\vert", "\\Vert", - "\\lvert", "\\rvert", "\\lVert", "\\rVert", - "\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache", -]; +var stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache"]; // and delimiters that never stack -var stackNeverDelimiters = [ - "<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt", -]; +var stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]; // Metrics of the different sizes. Found by looking at TeX's output of // $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ @@ -4391,7 +6484,7 @@ var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; /** * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. */ -var makeSizedDelim = function(delim, size, options, mode) { +var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) { // < and > turn into \langle and \rangle in delimiters if (delim === "<" || delim === "\\lt") { delim = "\\langle"; @@ -4400,14 +6493,12 @@ var makeSizedDelim = function(delim, size, options, mode) { } // Sized delimiters are never centered. - if (utils.contains(stackLargeDelimiters, delim) || - utils.contains(stackNeverDelimiters, delim)) { - return makeLargeDelim(delim, size, false, options, mode); - } else if (utils.contains(stackAlwaysDelimiters, delim)) { - return makeStackedDelim( - delim, sizeToMaxHeight[size], false, options, mode); + if (_utils2.default.contains(stackLargeDelimiters, delim) || _utils2.default.contains(stackNeverDelimiters, delim)) { + return makeLargeDelim(delim, size, false, options, mode, classes); + } else if (_utils2.default.contains(stackAlwaysDelimiters, delim)) { + return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes); } else { - throw new ParseError("Illegal delimiter: '" + delim + "'"); + throw new _ParseError2.default("Illegal delimiter: '" + delim + "'"); } }; @@ -4424,41 +6515,19 @@ var makeSizedDelim = function(delim, size, options, mode) { */ // Delimiters that never stack try small delimiters and large delimiters only -var stackNeverDelimiterSequence = [ - {type: "small", style: Style.SCRIPTSCRIPT}, - {type: "small", style: Style.SCRIPT}, - {type: "small", style: Style.TEXT}, - {type: "large", size: 1}, - {type: "large", size: 2}, - {type: "large", size: 3}, - {type: "large", size: 4}, -]; +var stackNeverDelimiterSequence = [{ type: "small", style: _Style2.default.SCRIPTSCRIPT }, { type: "small", style: _Style2.default.SCRIPT }, { type: "small", style: _Style2.default.TEXT }, { type: "large", size: 1 }, { type: "large", size: 2 }, { type: "large", size: 3 }, { type: "large", size: 4 }]; // Delimiters that always stack try the small delimiters first, then stack -var stackAlwaysDelimiterSequence = [ - {type: "small", style: Style.SCRIPTSCRIPT}, - {type: "small", style: Style.SCRIPT}, - {type: "small", style: Style.TEXT}, - {type: "stack"}, -]; +var stackAlwaysDelimiterSequence = [{ type: "small", style: _Style2.default.SCRIPTSCRIPT }, { type: "small", style: _Style2.default.SCRIPT }, { type: "small", style: _Style2.default.TEXT }, { type: "stack" }]; // Delimiters that stack when large try the small and then large delimiters, and // stack afterwards -var stackLargeDelimiterSequence = [ - {type: "small", style: Style.SCRIPTSCRIPT}, - {type: "small", style: Style.SCRIPT}, - {type: "small", style: Style.TEXT}, - {type: "large", size: 1}, - {type: "large", size: 2}, - {type: "large", size: 3}, - {type: "large", size: 4}, - {type: "stack"}, -]; +var stackLargeDelimiterSequence = [{ type: "small", style: _Style2.default.SCRIPTSCRIPT }, { type: "small", style: _Style2.default.SCRIPT }, { type: "small", style: _Style2.default.TEXT }, { type: "large", size: 1 }, { type: "large", size: 2 }, { type: "large", size: 3 }, { type: "large", size: 4 }, { type: "stack" }]; /** * Get the font used in a delimiter based on what kind of delimiter it is. */ -var delimTypeToFont = function(type) { +var delimTypeToFont = function delimTypeToFont(type) { if (type.type === "small") { return "Main-Regular"; } else if (type.type === "large") { @@ -4472,7 +6541,7 @@ var delimTypeToFont = function(type) { * Traverse a sequence of types of delimiters to decide what kind of delimiter * should be used to create a delimiter of the given height+depth. */ -var traverseSequence = function(delim, height, sequence, options) { +var traverseSequence = function traverseSequence(delim, height, sequence, options) { // Here, we choose the index we should start at in the sequences. In smaller // sizes (which correspond to larger numbers in style.size) we start earlier // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts @@ -4491,7 +6560,8 @@ var traverseSequence = function(delim, height, sequence, options) { // account for the style change size. if (sequence[i].type === "small") { - heightDepth *= sequence[i].style.sizeMultiplier; + var newOptions = options.havingBaseStyle(sequence[i].style); + heightDepth *= newOptions.sizeMultiplier; } // Check if the delimiter at this size works for the given height. @@ -4508,7 +6578,7 @@ var traverseSequence = function(delim, height, sequence, options) { * Make a delimiter of a given height+depth, with optional centering. Here, we * traverse the sequences, and create a delimiter that the sequence tells us to. */ -var makeCustomSizedDelim = function(delim, height, center, options, mode) { +var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) { if (delim === "<" || delim === "\\lt") { delim = "\\langle"; } else if (delim === ">" || delim === "\\gt") { @@ -4516,10 +6586,10 @@ var makeCustomSizedDelim = function(delim, height, center, options, mode) { } // Decide what sequence to use - var sequence; - if (utils.contains(stackNeverDelimiters, delim)) { + var sequence = void 0; + if (_utils2.default.contains(stackNeverDelimiters, delim)) { sequence = stackNeverDelimiterSequence; - } else if (utils.contains(stackLargeDelimiters, delim)) { + } else if (_utils2.default.contains(stackLargeDelimiters, delim)) { sequence = stackLargeDelimiterSequence; } else { sequence = stackAlwaysDelimiterSequence; @@ -4528,75 +6598,92 @@ var makeCustomSizedDelim = function(delim, height, center, options, mode) { // Look through the sequence var delimType = traverseSequence(delim, height, sequence, options); - // Depending on the sequence element we decided on, call the appropriate - // function. + // Get the delimiter from font glyphs. + // Depending on the sequence element we decided on, call the + // appropriate function. if (delimType.type === "small") { - return makeSmallDelim(delim, delimType.style, center, options, mode); + return makeSmallDelim(delim, delimType.style, center, options, mode, classes); } else if (delimType.type === "large") { - return makeLargeDelim(delim, delimType.size, center, options, mode); - } else if (delimType.type === "stack") { - return makeStackedDelim(delim, height, center, options, mode); - } + return makeLargeDelim(delim, delimType.size, center, options, mode, classes); + } else /* if (delimType.type === "stack") */{ + return makeStackedDelim(delim, height, center, options, mode, classes); + } }; /** * Make a delimiter for use with `\left` and `\right`, given a height and depth * of an expression that the delimiters surround. */ -var makeLeftRightDelim = function(delim, height, depth, options, mode) { +var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) { // We always center \left/\right delimiters, so the axis is always shifted - var axisHeight = - fontMetrics.metrics.axisHeight * options.style.sizeMultiplier; + var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; // Taken from TeX source, tex.web, function make_left_right var delimiterFactor = 901; - var delimiterExtend = 5.0 / fontMetrics.metrics.ptPerEm; + var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; - var maxDistFromAxis = Math.max( - height - axisHeight, depth + axisHeight); + var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); var totalHeight = Math.max( - // In real TeX, calculations are done using integral values which are - // 65536 per pt, or 655360 per em. So, the division here truncates in - // TeX but doesn't here, producing different results. If we wanted to - // exactly match TeX's calculation, we could do - // Math.floor(655360 * maxDistFromAxis / 500) * - // delimiterFactor / 655360 - // (To see the difference, compare - // x^{x^{\left(\rule{0.1em}{0.68em}\right)}} - // in TeX and KaTeX) - maxDistFromAxis / 500 * delimiterFactor, - 2 * maxDistFromAxis - delimiterExtend); + // In real TeX, calculations are done using integral values which are + // 65536 per pt, or 655360 per em. So, the division here truncates in + // TeX but doesn't here, producing different results. If we wanted to + // exactly match TeX's calculation, we could do + // Math.floor(655360 * maxDistFromAxis / 500) * + // delimiterFactor / 655360 + // (To see the difference, compare + // x^{x^{\left(\rule{0.1em}{0.68em}\right)}} + // in TeX and KaTeX) + maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); // Finally, we defer to `makeCustomSizedDelim` with our calculated total // height - return makeCustomSizedDelim(delim, totalHeight, true, options, mode); + return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); }; -module.exports = { +exports.default = { + sqrtImage: makeSqrtImage, sizedDelim: makeSizedDelim, customSizedDelim: makeCustomSizedDelim, - leftRightDelim: makeLeftRightDelim, + leftRightDelim: makeLeftRightDelim }; -},{"./ParseError":6,"./Style":9,"./buildCommon":10,"./fontMetrics":17,"./symbols":23,"./utils":25}],15:[function(require,module,exports){ -/** - * These objects store the data about the DOM nodes we create, as well as some - * extra data. They can then be transformed into real DOM nodes with the - * `toNode` function or HTML markup using `toMarkup`. They are useful for both - * storing extra properties on the nodes, as well as providing a way to easily - * work with the DOM. - * - * Similar functions for working with MathML nodes exist in mathMLTree.js. - */ -var unicodeRegexes = require("./unicodeRegexes"); -var utils = require("./utils"); +},{"./ParseError":84,"./Style":89,"./buildCommon":91,"./domTree":98,"./fontMetrics":101,"./symbols":125,"./utils":128}],98:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _getIterator2 = require("babel-runtime/core-js/get-iterator"); + +var _getIterator3 = _interopRequireDefault(_getIterator2); + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require("babel-runtime/helpers/createClass"); + +var _createClass3 = _interopRequireDefault(_createClass2); + +var _unicodeRegexes = require("./unicodeRegexes"); + +var _utils = require("./utils"); + +var _utils2 = _interopRequireDefault(_utils); + +var _svgGeometry = require("./svgGeometry"); + +var _svgGeometry2 = _interopRequireDefault(_svgGeometry); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Create an HTML className based on a list of classes. In addition to joining * with spaces, we also remove null or empty classes. */ -var createClass = function(classes) { +var createClass = function createClass(classes) { classes = classes.slice(); for (var i = classes.length - 1; i >= 0; i--) { if (!classes[i]) { @@ -4607,107 +6694,317 @@ var createClass = function(classes) { return classes.join(" "); }; +// To ensure that all nodes have compatible signatures for these methods. + + /** - * This node represents a span node, with a className, a list of children, and - * an inline style. It also contains information about its height, depth, and - * maxFontSize. + * All `DomChildNode`s MUST have `height`, `depth`, and `maxFontSize` numeric + * fields. + * + * `DomChildNode` is not defined as an interface since `documentFragment` also + * has these fields but should not be considered a `DomChildNode`. */ -function span(classes, children, height, depth, maxFontSize, style) { - this.classes = classes || []; - this.children = children || []; - this.height = height || 0; - this.depth = depth || 0; - this.maxFontSize = maxFontSize || 0; - this.style = style || {}; - this.attributes = {}; -} /** - * Sets an arbitrary attribute on the span. Warning: use this wisely. Not all - * browsers support attributes the same, and having too many custom attributes - * is probably bad. + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. */ -span.prototype.setAttribute = function(attribute, value) { - this.attributes[attribute] = value; -}; /** - * Convert the span into an HTML node + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. */ -span.prototype.toNode = function() { - var span = document.createElement("span"); +var span = function () { + function span(classes, children, options) { + (0, _classCallCheck3.default)(this, span); + + this.classes = classes || []; + this.children = children || []; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = {}; + this.attributes = {}; + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + var color = options.getColor(); + if (color) { + this.style.color = color; + } + } + } - // Apply the class - span.className = createClass(this.classes); + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not all + * browsers support attributes the same, and having too many custom attributes + * is probably bad. + */ - // Apply inline styles - for (var style in this.style) { - if (Object.prototype.hasOwnProperty.call(this.style, style)) { - span.style[style] = this.style[style]; + + (0, _createClass3.default)(span, [{ + key: "setAttribute", + value: function setAttribute(attribute, value) { + this.attributes[attribute] = value; } - } + }, { + key: "tryCombine", + value: function tryCombine(sibling) { + return false; + } + + /** + * Convert the span into an HTML node + */ + + }, { + key: "toNode", + value: function toNode() { + var span = document.createElement("span"); + + // Apply the class + span.className = createClass(this.classes); + + // Apply inline styles + for (var style in this.style) { + if (Object.prototype.hasOwnProperty.call(this.style, style)) { + // $FlowFixMe Flow doesn't seem to understand span.style's type. + span.style[style] = this.style[style]; + } + } + + // Apply attributes + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + span.setAttribute(attr, this.attributes[attr]); + } + } - // Apply attributes - for (var attr in this.attributes) { - if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - span.setAttribute(attr, this.attributes[attr]); + // Append the children, also as HTML nodes + for (var i = 0; i < this.children.length; i++) { + span.appendChild(this.children[i].toNode()); + } + + return span; } - } - // Append the children, also as HTML nodes - for (var i = 0; i < this.children.length; i++) { - span.appendChild(this.children[i].toNode()); - } + /** + * Convert the span into an HTML markup string + */ + + }, { + key: "toMarkup", + value: function toMarkup() { + var markup = "<span"; + + // Add the class + if (this.classes.length) { + markup += " class=\""; + markup += _utils2.default.escape(createClass(this.classes)); + markup += "\""; + } + + var styles = ""; + + // Add the styles, after hyphenation + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += _utils2.default.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + markup += " style=\"" + _utils2.default.escape(styles) + "\""; + } + + // Add the attributes + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\""; + markup += _utils2.default.escape(this.attributes[attr]); + markup += "\""; + } + } + markup += ">"; + + // Add the markup of the children, also as markup + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += "</span>"; + + return markup; + } + }]); return span; -}; +}(); /** - * Convert the span into an HTML markup string + * This node represents an anchor (<a>) element with a hyperlink, a list of classes, + * a list of children, and an inline style. It also contains information about its + * height, depth, and maxFontSize. */ -span.prototype.toMarkup = function() { - var markup = "<span"; - // Add the class - if (this.classes.length) { - markup += " class=\""; - markup += utils.escape(createClass(this.classes)); - markup += "\""; - } - var styles = ""; +var anchor = function () { + function anchor(href, classes, children, options) { + (0, _classCallCheck3.default)(this, anchor); - // Add the styles, after hyphenation - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; + this.href = href; + this.classes = classes; + this.children = children; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = {}; + this.attributes = {}; + if (options.style.isTight()) { + this.classes.push("mtight"); + } + var color = options.getColor(); + if (color) { + this.style.color = color; } } - if (styles) { - markup += " style=\"" + utils.escape(styles) + "\""; - } + /** + * Sets an arbitrary attribute on the anchor. Warning: use this wisely. Not all + * browsers support attributes the same, and having too many custom attributes + * is probably bad. + */ + - // Add the attributes - for (var attr in this.attributes) { - if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - markup += " " + attr + "=\""; - markup += utils.escape(this.attributes[attr]); - markup += "\""; + (0, _createClass3.default)(anchor, [{ + key: "setAttribute", + value: function setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + }, { + key: "tryCombine", + value: function tryCombine(sibling) { + return false; } - } - markup += ">"; + /** + * Convert the anchor into an HTML node + */ - // Add the markup of the children, also as markup - for (var i = 0; i < this.children.length; i++) { - markup += this.children[i].toMarkup(); - } + }, { + key: "toNode", + value: function toNode() { + var a = document.createElement("a"); - markup += "</span>"; + // Apply the href + a.setAttribute('href', this.href); - return markup; -}; + // Apply the class + if (this.classes.length) { + a.className = createClass(this.classes); + } + + // Apply inline styles + for (var style in this.style) { + if (Object.prototype.hasOwnProperty.call(this.style, style)) { + // $FlowFixMe Flow doesn't seem to understand a.style's type. + a.style[style] = this.style[style]; + } + } + + // Apply attributes + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + a.setAttribute(attr, this.attributes[attr]); + } + } + + // Append the children, also as HTML nodes + for (var i = 0; i < this.children.length; i++) { + a.appendChild(this.children[i].toNode()); + } + + return a; + } + + /** + * Convert the a into an HTML markup string + */ + + }, { + key: "toMarkup", + value: function toMarkup() { + var markup = "<a"; + + // Add the href + markup += "href=\"" + (markup += _utils2.default.escape(this.href)) + "\""; + // Add the class + if (this.classes.length) { + markup += " class=\"" + _utils2.default.escape(createClass(this.classes)) + "\""; + } + + var styles = ""; + + // Add the styles, after hyphenation + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += _utils2.default.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + markup += " style=\"" + _utils2.default.escape(styles) + "\""; + } + + // Add the attributes + for (var attr in this.attributes) { + if (attr !== "href" && Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\"" + _utils2.default.escape(this.attributes[attr]) + "\""; + } + } + + markup += ">"; + + // Add the markup of the children, also as markup + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = (0, _getIterator3.default)(this.children), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var child = _step.value; + + markup += child.toMarkup(); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + markup += "</a>"; + + return markup; + } + }]); + return anchor; +}(); /** * This node represents a document fragment, which contains elements, but when @@ -4715,48 +7012,63 @@ span.prototype.toMarkup = function() { * contains children and doesn't have any HTML properties. It also keeps track * of a height, depth, and maxFontSize. */ -function documentFragment(children, height, depth, maxFontSize) { - this.children = children || []; - this.height = height || 0; - this.depth = depth || 0; - this.maxFontSize = maxFontSize || 0; -} -/** - * Convert the fragment into a node - */ -documentFragment.prototype.toNode = function() { - // Create a fragment - var frag = document.createDocumentFragment(); - // Append the children - for (var i = 0; i < this.children.length; i++) { - frag.appendChild(this.children[i].toNode()); +var documentFragment = function () { + function documentFragment(children) { + (0, _classCallCheck3.default)(this, documentFragment); + + this.children = children || []; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; } - return frag; -}; + /** + * Convert the fragment into a node + */ -/** - * Convert the fragment into HTML markup - */ -documentFragment.prototype.toMarkup = function() { - var markup = ""; - // Simply concatenate the markup for the children together - for (var i = 0; i < this.children.length; i++) { - markup += this.children[i].toMarkup(); - } + (0, _createClass3.default)(documentFragment, [{ + key: "toNode", + value: function toNode() { + // Create a fragment + var frag = document.createDocumentFragment(); - return markup; -}; + // Append the children + for (var i = 0; i < this.children.length; i++) { + frag.appendChild(this.children[i].toNode()); + } + + return frag; + } + + /** + * Convert the fragment into HTML markup + */ + + }, { + key: "toMarkup", + value: function toMarkup() { + var markup = ""; + + // Simply concatenate the markup for the children together + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + return markup; + } + }]); + return documentFragment; +}(); var iCombinations = { - 'î': '\u0131\u0302', - 'ï': '\u0131\u0308', - 'í': '\u0131\u0301', + 'î': "\u0131\u0302", + 'ï': "\u0131\u0308", + 'í': "\u0131\u0301", // 'ī': '\u0131\u0304', // enable when we add Extended Latin - 'ì': '\u0131\u0300', + 'ì': "\u0131\u0300" }; /** @@ -4764,143 +7076,401 @@ var iCombinations = { * to a single text node, or a span with a single text node in it, depending on * whether it has CSS classes, styles, or needs italic correction. */ -function symbolNode(value, height, depth, italic, skew, classes, style) { - this.value = value || ""; - this.height = height || 0; - this.depth = depth || 0; - this.italic = italic || 0; - this.skew = skew || 0; - this.classes = classes || []; - this.style = style || {}; - this.maxFontSize = 0; - - // Mark CJK characters with specific classes so that we can specify which - // fonts to use. This allows us to render these characters with a serif - // font in situations where the browser would either default to a sans serif - // or render a placeholder character. - if (unicodeRegexes.cjkRegex.test(value)) { - // I couldn't find any fonts that contained Hangul as well as all of - // the other characters we wanted to test there for it gets its own - // CSS class. - if (unicodeRegexes.hangulRegex.test(value)) { - this.classes.push('hangul_fallback'); - } else { - this.classes.push('cjk_fallback'); + +var symbolNode = function () { + function symbolNode(value, height, depth, italic, skew, classes, style) { + (0, _classCallCheck3.default)(this, symbolNode); + + this.value = value; + this.height = height || 0; + this.depth = depth || 0; + this.italic = italic || 0; + this.skew = skew || 0; + this.classes = classes || []; + this.style = style || {}; + this.maxFontSize = 0; + + // Mark CJK characters with specific classes so that we can specify which + // fonts to use. This allows us to render these characters with a serif + // font in situations where the browser would either default to a sans serif + // or render a placeholder character. + if (_unicodeRegexes.cjkRegex.test(this.value)) { + // I couldn't find any fonts that contained Hangul as well as all of + // the other characters we wanted to test there for it gets its own + // CSS class. + if (_unicodeRegexes.hangulRegex.test(this.value)) { + this.classes.push('hangul_fallback'); + } else { + this.classes.push('cjk_fallback'); + } } - } - if (/[îïíì]/.test(this.value)) { // add ī when we add Extended Latin - this.value = iCombinations[this.value]; + if (/[îïíì]/.test(this.value)) { + // add ī when we add Extended Latin + this.value = iCombinations[this.value]; + } } -} -/** - * Creates a text node or span from a symbol node. Note that a span is only - * created if it is needed. - */ -symbolNode.prototype.toNode = function() { - var node = document.createTextNode(this.value); - var span = null; + (0, _createClass3.default)(symbolNode, [{ + key: "tryCombine", + value: function tryCombine(sibling) { + if (!sibling || !(sibling instanceof symbolNode) || this.italic > 0 || createClass(this.classes) !== createClass(sibling.classes) || this.skew !== sibling.skew || this.maxFontSize !== sibling.maxFontSize) { + return false; + } + for (var style in this.style) { + if (this.style.hasOwnProperty(style) && this.style[style] !== sibling.style[style]) { + return false; + } + } + for (var _style in sibling.style) { + if (sibling.style.hasOwnProperty(_style) && this.style[_style] !== sibling.style[_style]) { + return false; + } + } + this.value += sibling.value; + this.height = Math.max(this.height, sibling.height); + this.depth = Math.max(this.depth, sibling.depth); + this.italic = sibling.italic; + return true; + } - if (this.italic > 0) { - span = document.createElement("span"); - span.style.marginRight = this.italic + "em"; - } + /** + * Creates a text node or span from a symbol node. Note that a span is only + * created if it is needed. + */ - if (this.classes.length > 0) { - span = span || document.createElement("span"); - span.className = createClass(this.classes); - } + }, { + key: "toNode", + value: function toNode() { + var node = document.createTextNode(this.value); + var span = null; + + if (this.italic > 0) { + span = document.createElement("span"); + span.style.marginRight = this.italic + "em"; + } + + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + span = span || document.createElement("span"); + // $FlowFixMe Flow doesn't seem to understand span.style's type. + span.style[style] = this.style[style]; + } + } - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - span = span || document.createElement("span"); - span.style[style] = this.style[style]; + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } } - } - if (span) { - span.appendChild(node); - return span; - } else { - return node; - } -}; + /** + * Creates markup for a symbol node. + */ + + }, { + key: "toMarkup", + value: function toMarkup() { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + var needsSpan = false; + + var markup = "<span"; + + if (this.classes.length) { + needsSpan = true; + markup += " class=\""; + markup += _utils2.default.escape(createClass(this.classes)); + markup += "\""; + } + + var styles = ""; + + if (this.italic > 0) { + styles += "margin-right:" + this.italic + "em;"; + } + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += _utils2.default.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + needsSpan = true; + markup += " style=\"" + _utils2.default.escape(styles) + "\""; + } + + var escaped = _utils2.default.escape(this.value); + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += "</span>"; + return markup; + } else { + return escaped; + } + } + }]); + return symbolNode; +}(); /** - * Creates markup for a symbol node. + * SVG nodes are used to render stretchy wide elements. */ -symbolNode.prototype.toMarkup = function() { - // TODO(alpert): More duplication than I'd like from - // span.prototype.toMarkup and symbolNode.prototype.toNode... - var needsSpan = false; - var markup = "<span"; - if (this.classes.length) { - needsSpan = true; - markup += " class=\""; - markup += utils.escape(createClass(this.classes)); - markup += "\""; +var svgNode = function () { + function svgNode(children, attributes) { + (0, _classCallCheck3.default)(this, svgNode); + + this.children = children || []; + this.attributes = attributes || {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; } + // Required for all `DomChildNode`s. Are always 0 for svgNode. - var styles = ""; - if (this.italic > 0) { - styles += "margin-right:" + this.italic + "em;"; - } - for (var style in this.style) { - if (this.style.hasOwnProperty(style)) { - styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; + (0, _createClass3.default)(svgNode, [{ + key: "toNode", + value: function toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "svg"); + + // Apply attributes + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; } - } + }, { + key: "toMarkup", + value: function toMarkup() { + var markup = "<svg"; + + // Apply attributes + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "='" + this.attributes[attr] + "'"; + } + } + + markup += ">"; + + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += "</svg>"; + + return markup; + } + }]); + return svgNode; +}(); + +var pathNode = function () { + function pathNode(pathName, alternate) { + (0, _classCallCheck3.default)(this, pathNode); - if (styles) { - needsSpan = true; - markup += " style=\"" + utils.escape(styles) + "\""; + this.pathName = pathName; + this.alternate = alternate; // Used only for tall \sqrt } - var escaped = utils.escape(this.value); - if (needsSpan) { - markup += ">"; - markup += escaped; - markup += "</span>"; - return markup; - } else { - return escaped; + (0, _createClass3.default)(pathNode, [{ + key: "toNode", + value: function toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "path"); + + if (this.alternate) { + node.setAttribute("d", this.alternate); + } else { + node.setAttribute("d", _svgGeometry2.default.path[this.pathName]); + } + + return node; + } + }, { + key: "toMarkup", + value: function toMarkup() { + if (this.alternate) { + return "<path d='" + this.alternate + "'/>"; + } else { + return "<path d='" + _svgGeometry2.default.path[this.pathName] + "'/>"; + } + } + }]); + return pathNode; +}(); + +var lineNode = function () { + function lineNode(attributes) { + (0, _classCallCheck3.default)(this, lineNode); + + this.attributes = attributes || {}; } -}; -module.exports = { + (0, _createClass3.default)(lineNode, [{ + key: "toNode", + value: function toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "line"); + + // Apply attributes + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + return node; + } + }, { + key: "toMarkup", + value: function toMarkup() { + var markup = "<line"; + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "='" + this.attributes[attr] + "'"; + } + } + + markup += "/>"; + + return markup; + } + }]); + return lineNode; +}(); + +exports.default = { span: span, + anchor: anchor, documentFragment: documentFragment, symbolNode: symbolNode, + svgNode: svgNode, + pathNode: pathNode, + lineNode: lineNode }; -},{"./unicodeRegexes":24,"./utils":25}],16:[function(require,module,exports){ -/* eslint no-constant-condition:0 */ -var fontMetrics = require("./fontMetrics"); -var parseData = require("./parseData"); -var ParseError = require("./ParseError"); +},{"./svgGeometry":124,"./unicodeRegexes":126,"./utils":128,"babel-runtime/core-js/get-iterator":3,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],99:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _defineEnvironment = require("./defineEnvironment"); + +require("./environments/array.js"); + +var environments = { + has: function has(envName) { + return _defineEnvironment._environments.hasOwnProperty(envName); + }, + get: function get(envName) { + return _defineEnvironment._environments[envName]; + } +}; +exports.default = environments; -var ParseNode = parseData.ParseNode; +// All environment definitions should be imported below + +},{"./defineEnvironment":95,"./environments/array.js":100}],100:[function(require,module,exports){ +"use strict"; + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _defineEnvironment = require("../defineEnvironment"); + +var _defineEnvironment2 = _interopRequireDefault(_defineEnvironment); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _ParseError = require("../ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +var _ParseNode = require("../ParseNode"); + +var _ParseNode2 = _interopRequireDefault(_ParseNode); + +var _units = require("../units"); + +var _utils = require("../utils"); + +var _utils2 = _interopRequireDefault(_utils); + +var _stretchy = require("../stretchy"); + +var _stretchy2 = _interopRequireDefault(_stretchy); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Parse the body of the environment, with rows delimited by \\ and * columns delimited by &, and create a nested list in row-major order - * with one group per cell. + * with one group per cell. If given an optional argument style + * ("text", "display", etc.), then each cell is cast into that style. */ -function parseArray(parser, result) { + + +// Data stored in the ParseNode associated with the environment. +function parseArray(parser, result, style) { var row = []; var body = [row]; var rowGaps = []; while (true) { + // eslint-disable-line no-constant-condition var cell = parser.parseExpression(false, null); - row.push(new ParseNode("ordgroup", cell, parser.mode)); + cell = new _ParseNode2.default("ordgroup", cell, parser.mode); + if (style) { + cell = new _ParseNode2.default("styling", { + style: style, + value: [cell] + }, parser.mode); + } + row.push(cell); var next = parser.nextToken.text; if (next === "&") { parser.consume(); } else if (next === "\\end") { + // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. + var lastRow = body[body.length - 1]; + if (body.length > 1 && lastRow.length === 1 && lastRow[0].value.value[0].value.length === 0) { + body.pop(); + } break; } else if (next === "\\\\" || next === "\\cr") { var cr = parser.parseFunction(); @@ -4908,201 +7478,447 @@ function parseArray(parser, result) { row = []; body.push(row); } else { - throw new ParseError("Expected & or \\\\ or \\end", - parser.nextToken); + throw new _ParseError2.default("Expected & or \\\\ or \\end", parser.nextToken); } } result.body = body; result.rowGaps = rowGaps; - return new ParseNode(result.type, result, parser.mode); + return new _ParseNode2.default(result.type, result, parser.mode); } -/* - * An environment definition is very similar to a function definition: - * it is declared with a name or a list of names, a set of properties - * and a handler containing the actual implementation. - * - * The properties include: - * - numArgs: The number of arguments after the \begin{name} function. - * - argTypes: (optional) Just like for a function - * - allowedInText: (optional) Whether or not the environment is allowed inside - * text mode (default false) (not enforced yet) - * - numOptionalArgs: (optional) Just like for a function - * A bare number instead of that object indicates the numArgs value. - * - * The handler function will receive two arguments - * - context: information and references provided by the parser - * - args: an array of arguments passed to \begin{name} - * The context contains the following properties: - * - envName: the name of the environment, one of the listed names. - * - parser: the parser object - * - lexer: the lexer object - * - positions: the positions associated with these arguments from args. - * The handler must return a ParseResult. - */ - -function defineEnvironment(names, props, handler) { - if (typeof names === "string") { - names = [names]; - } - if (typeof props === "number") { - props = { numArgs: props }; - } - // Set default values of environments - var data = { - numArgs: props.numArgs || 0, - argTypes: props.argTypes, - greediness: 1, - allowedInText: !!props.allowedInText, - numOptionalArgs: props.numOptionalArgs || 0, - handler: handler, - }; - for (var i = 0; i < names.length; ++i) { - module.exports[names[i]] = data; +// Decides on a style for cells in an array according to whether the given +// environment name starts with the letter 'd'. +function dCellStyle(envName) { + if (envName.substr(0, 1) === "d") { + return "display"; + } else { + return "text"; } } -// Arrays are part of LaTeX, defined in lttab.dtx so its documentation -// is part of the source2e.pdf file of LaTeX2e source documentation. -defineEnvironment("array", { - numArgs: 1, -}, function(context, args) { - var colalign = args[0]; - colalign = colalign.value.map ? colalign.value : [colalign]; - var cols = colalign.map(function(node) { - var ca = node.value; - if ("lcr".indexOf(ca) !== -1) { - return { - type: "align", - align: ca, - }; - } else if (ca === "|") { - return { - type: "separator", - separator: "|", - }; +var htmlBuilder = function htmlBuilder(group, options) { + var r = void 0; + var c = void 0; + var nr = group.value.body.length; + var nc = 0; + var body = new Array(nr); + + // Horizontal spacing + var pt = 1 / options.fontMetrics().ptPerEm; + var arraycolsep = 5 * pt; // \arraycolsep in article.cls + + // Vertical spacing + var baselineskip = 12 * pt; // see size10.clo + // Default \jot from ltmath.dtx + // TODO(edemaine): allow overriding \jot via \setlength (#687) + var jot = 3 * pt; + // Default \arraystretch from lttab.dtx + // TODO(gagern): may get redefined once we have user-defined macros + var arraystretch = _utils2.default.deflt(group.value.arraystretch, 1); + var arrayskip = arraystretch * baselineskip; + var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + + var totalHeight = 0; + for (r = 0; r < group.value.body.length; ++r) { + var inrow = group.value.body[r]; + var _height = arstrutHeight; // \@array adds an \@arstrut + var _depth = arstrutDepth; // to each tow (via the template) + + if (nc < inrow.length) { + nc = inrow.length; } - throw new ParseError( - "Unknown column alignment: " + node.value, - node); - }); + + var outrow = new Array(inrow.length); + for (c = 0; c < inrow.length; ++c) { + var elt = html.buildGroup(inrow[c], options); + if (_depth < elt.depth) { + _depth = elt.depth; + } + if (_height < elt.height) { + _height = elt.height; + } + outrow[c] = elt; + } + + var gap = 0; + if (group.value.rowGaps[r]) { + gap = (0, _units.calculateSize)(group.value.rowGaps[r].value, options); + if (gap > 0) { + // \@argarraycr + gap += arstrutDepth; + if (_depth < gap) { + _depth = gap; // \@xargarraycr + } + gap = 0; + } + } + // In AMS multiline environments such as aligned and gathered, rows + // correspond to lines that have additional \jot added to the + // \baselineskip via \openup. + if (group.value.addJot) { + _depth += jot; + } + + outrow.height = _height; + outrow.depth = _depth; + totalHeight += _height; + outrow.pos = totalHeight; + totalHeight += _depth + gap; // \@yargarraycr + body[r] = outrow; + } + + var offset = totalHeight / 2 + options.fontMetrics().axisHeight; + var colDescriptions = group.value.cols || []; + var cols = []; + var colSep = void 0; + var colDescrNum = void 0; + for (c = 0, colDescrNum = 0; + // Continue while either there are more columns or more column + // descriptions, so trailing separators don't get lost. + c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) { + + var colDescr = colDescriptions[colDescrNum] || {}; + + var firstSeparator = true; + while (colDescr.type === "separator") { + // If there is more than one separator in a row, add a space + // between them. + if (!firstSeparator) { + colSep = _buildCommon2.default.makeSpan(["arraycolsep"], []); + colSep.style.width = options.fontMetrics().doubleRuleSep + "em"; + cols.push(colSep); + } + + if (colDescr.separator === "|") { + var _separator = _stretchy2.default.ruleSpan("vertical-separator", options); + _separator.style.height = totalHeight + "em"; + _separator.style.verticalAlign = -(totalHeight - offset) + "em"; + + cols.push(_separator); + } else { + throw new _ParseError2.default("Invalid separator type: " + colDescr.separator); + } + + colDescrNum++; + colDescr = colDescriptions[colDescrNum] || {}; + firstSeparator = false; + } + + if (c >= nc) { + continue; + } + + var sepwidth = void 0; + if (c > 0 || group.value.hskipBeforeAndAfter) { + sepwidth = _utils2.default.deflt(colDescr.pregap, arraycolsep); + if (sepwidth !== 0) { + colSep = _buildCommon2.default.makeSpan(["arraycolsep"], []); + colSep.style.width = sepwidth + "em"; + cols.push(colSep); + } + } + + var col = []; + for (r = 0; r < nr; ++r) { + var row = body[r]; + var elem = row[c]; + if (!elem) { + continue; + } + var shift = row.pos - offset; + elem.depth = row.depth; + elem.height = row.height; + col.push({ type: "elem", elem: elem, shift: shift }); + } + + col = _buildCommon2.default.makeVList({ + positionType: "individualShift", + children: col + }, options); + col = _buildCommon2.default.makeSpan(["col-align-" + (colDescr.align || "c")], [col]); + cols.push(col); + + if (c < nc - 1 || group.value.hskipBeforeAndAfter) { + sepwidth = _utils2.default.deflt(colDescr.postgap, arraycolsep); + if (sepwidth !== 0) { + colSep = _buildCommon2.default.makeSpan(["arraycolsep"], []); + colSep.style.width = sepwidth + "em"; + cols.push(colSep); + } + } + } + body = _buildCommon2.default.makeSpan(["mtable"], cols); + return _buildCommon2.default.makeSpan(["mord"], [body], options); +}; + +var mathmlBuilder = function mathmlBuilder(group, options) { + return new _mathMLTree2.default.MathNode("mtable", group.value.body.map(function (row) { + return new _mathMLTree2.default.MathNode("mtr", row.map(function (cell) { + return new _mathMLTree2.default.MathNode("mtd", [mml.buildGroup(cell, options)]); + })); + })); +}; + +// Convinient function for aligned and alignedat environments. +var alignedHandler = function alignedHandler(context, args) { var res = { type: "array", - cols: cols, - hskipBeforeAndAfter: true, // \@preamble in lttab.dtx + cols: [], + addJot: true }; - res = parseArray(context.parser, res); + res = parseArray(context.parser, res, "display"); + + // Determining number of columns. + // 1. If the first argument is given, we use it as a number of columns, + // and makes sure that each row doesn't exceed that number. + // 2. Otherwise, just count number of columns = maximum number + // of cells in each row ("aligned" mode -- isAligned will be true). + // + // At the same time, prepend empty group {} at beginning of every second + // cell in each row (starting with second cell) so that operators become + // binary. This behavior is implemented in amsmath's \start@aligned. + var numMaths = void 0; + var numCols = 0; + var emptyGroup = new _ParseNode2.default("ordgroup", [], context.mode); + if (args[0] && args[0].value) { + var arg0 = ""; + for (var i = 0; i < args[0].value.length; i++) { + arg0 += args[0].value[i].value; + } + numMaths = Number(arg0); + numCols = numMaths * 2; + } + var isAligned = !numCols; + res.value.body.forEach(function (row) { + for (var _i = 1; _i < row.length; _i += 2) { + // Modify ordgroup node within styling node + var ordgroup = row[_i].value.value[0]; + ordgroup.value.unshift(emptyGroup); + } + if (!isAligned) { + // Case 1 + var curMaths = row.length / 2; + if (numMaths < curMaths) { + throw new _ParseError2.default("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row); + } + } else if (numCols < row.length) { + // Case 2 + numCols = row.length; + } + }); + + // Adjusting alignment. + // In aligned mode, we add one \qquad between columns; + // otherwise we add nothing. + for (var _i2 = 0; _i2 < numCols; ++_i2) { + var _align = "r"; + var _pregap = 0; + if (_i2 % 2 === 1) { + _align = "l"; + } else if (_i2 > 0 && isAligned) { + // "aligned" mode. + _pregap = 1; // add one \quad + } + res.value.cols[_i2] = { + type: "align", + align: _align, + pregap: _pregap, + postgap: 0 + }; + } return res; +}; + +// Arrays are part of LaTeX, defined in lttab.dtx so its documentation +// is part of the source2e.pdf file of LaTeX2e source documentation. +// {darray} is an {array} environment where cells are set in \displaystyle, +// as defined in nccmath.sty. +(0, _defineEnvironment2.default)({ + type: "array", + names: ["array", "darray"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var colalign = args[0]; + colalign = colalign.value.map ? colalign.value : [colalign]; + var cols = colalign.map(function (node) { + var ca = node.value; + if ("lcr".indexOf(ca) !== -1) { + return { + type: "align", + align: ca + }; + } else if (ca === "|") { + return { + type: "separator", + separator: "|" + }; + } + throw new _ParseError2.default("Unknown column alignment: " + node.value, node); + }); + var res = { + type: "array", + cols: cols, + hskipBeforeAndAfter: true // \@preamble in lttab.dtx + }; + res = parseArray(context.parser, res, dCellStyle(context.envName)); + return res; + }, + htmlBuilder: htmlBuilder, + mathmlBuilder: mathmlBuilder }); // The matrix environments of amsmath builds on the array environment // of LaTeX, which is discussed above. -defineEnvironment([ - "matrix", - "pmatrix", - "bmatrix", - "Bmatrix", - "vmatrix", - "Vmatrix", -], { -}, function(context) { - var delimiters = { - "matrix": null, - "pmatrix": ["(", ")"], - "bmatrix": ["[", "]"], - "Bmatrix": ["\\{", "\\}"], - "vmatrix": ["|", "|"], - "Vmatrix": ["\\Vert", "\\Vert"], - }[context.envName]; - var res = { - type: "array", - hskipBeforeAndAfter: false, // \hskip -\arraycolsep in amsmath - }; - res = parseArray(context.parser, res); - if (delimiters) { - res = new ParseNode("leftright", { - body: [res], - left: delimiters[0], - right: delimiters[1], - }, context.mode); - } - return res; +(0, _defineEnvironment2.default)({ + type: "array", + names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix"], + props: { + numArgs: 0 + }, + handler: function handler(context) { + var delimiters = { + "matrix": null, + "pmatrix": ["(", ")"], + "bmatrix": ["[", "]"], + "Bmatrix": ["\\{", "\\}"], + "vmatrix": ["|", "|"], + "Vmatrix": ["\\Vert", "\\Vert"] + }[context.envName]; + var res = { + type: "array", + hskipBeforeAndAfter: false // \hskip -\arraycolsep in amsmath + }; + res = parseArray(context.parser, res, dCellStyle(context.envName)); + if (delimiters) { + res = new _ParseNode2.default("leftright", { + body: [res], + left: delimiters[0], + right: delimiters[1] + }, context.mode); + } + return res; + }, + htmlBuilder: htmlBuilder, + mathmlBuilder: mathmlBuilder }); // A cases environment (in amsmath.sty) is almost equivalent to // \def\arraystretch{1.2}% // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. -defineEnvironment("cases", { -}, function(context) { - var res = { - type: "array", - arraystretch: 1.2, - cols: [{ - type: "align", - align: "l", - pregap: 0, - postgap: fontMetrics.metrics.quad, - }, { - type: "align", - align: "l", - pregap: 0, - postgap: 0, - }], - }; - res = parseArray(context.parser, res); - res = new ParseNode("leftright", { - body: [res], - left: "\\{", - right: ".", - }, context.mode); - return res; +// {dcases} is a {cases} environment where cells are set in \displaystyle, +// as defined in mathtools.sty. +(0, _defineEnvironment2.default)({ + type: "array", + names: ["cases", "dcases"], + props: { + numArgs: 0 + }, + handler: function handler(context) { + var res = { + type: "array", + arraystretch: 1.2, + cols: [{ + type: "align", + align: "l", + pregap: 0, + // TODO(kevinb) get the current style. + // For now we use the metrics for TEXT style which is what we were + // doing before. Before attempting to get the current style we + // should look at TeX's behavior especially for \over and matrices. + postgap: 1.0 /* 1em quad */ + }, { + type: "align", + align: "l", + pregap: 0, + postgap: 0 + }] + }; + res = parseArray(context.parser, res, dCellStyle(context.envName)); + res = new _ParseNode2.default("leftright", { + body: [res], + left: "\\{", + right: "." + }, context.mode); + return res; + }, + htmlBuilder: htmlBuilder, + mathmlBuilder: mathmlBuilder }); // An aligned environment is like the align* environment // except it operates within math mode. // Note that we assume \nomallineskiplimit to be zero, // so that \strut@ is the same as \strut. -defineEnvironment("aligned", { -}, function(context) { - var res = { - type: "array", - cols: [], - }; - res = parseArray(context.parser, res); - var emptyGroup = new ParseNode("ordgroup", [], context.mode); - var numCols = 0; - res.value.body.forEach(function(row) { - var i; - for (i = 1; i < row.length; i += 2) { - row[i].value.unshift(emptyGroup); - } - if (numCols < row.length) { - numCols = row.length; - } - }); - for (var i = 0; i < numCols; ++i) { - var align = "r"; - var pregap = 0; - if (i % 2 === 1) { - align = "l"; - } else if (i > 0) { - pregap = 2; // one \qquad between columns - } - res.value.cols[i] = { - type: "align", - align: align, - pregap: pregap, - postgap: 0, +(0, _defineEnvironment2.default)({ + type: "array", + names: ["aligned"], + props: { + numArgs: 0 + }, + handler: alignedHandler, + htmlBuilder: htmlBuilder, + mathmlBuilder: mathmlBuilder +}); + +// A gathered environment is like an array environment with one centered +// column, but where rows are considered lines so get \jot line spacing +// and contents are set in \displaystyle. +(0, _defineEnvironment2.default)({ + type: "array", + names: ["gathered"], + props: { + numArgs: 0 + }, + handler: function handler(context) { + var res = { + type: "array", + cols: [{ + type: "align", + align: "c" + }], + addJot: true }; - } - return res; + res = parseArray(context.parser, res, "display"); + return res; + }, + htmlBuilder: htmlBuilder, + mathmlBuilder: mathmlBuilder }); -},{"./ParseError":6,"./fontMetrics":17,"./parseData":21}],17:[function(require,module,exports){ -/* eslint no-unused-vars:0 */ +// alignat environment is like an align environment, but one must explicitly +// specify maximum number of columns in each row, and can adjust spacing between +// each columns. +(0, _defineEnvironment2.default)({ + type: "array", + names: ["alignedat"], + // One for numbered and for unnumbered; + // but, KaTeX doesn't supports math numbering yet, + // they make no difference for now. + props: { + numArgs: 1 + }, + handler: alignedHandler, + htmlBuilder: htmlBuilder, + mathmlBuilder: mathmlBuilder +}); -var Style = require("./Style"); -var cjkRegex = require("./unicodeRegexes").cjkRegex; +},{"../ParseError":84,"../ParseNode":85,"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineEnvironment":95,"../mathMLTree":121,"../stretchy":123,"../units":127,"../utils":128}],101:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _unicodeRegexes = require("./unicodeRegexes"); + +var _fontMetricsData = require("./fontMetricsData"); + +var _fontMetricsData2 = _interopRequireDefault(_fontMetricsData); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * This file contains metrics regarding fonts and individual symbols. The sigma @@ -5111,117 +7927,85 @@ var cjkRegex = require("./unicodeRegexes").cjkRegex; * `metrics` variable and the getCharacterMetrics function. */ -// These font metrics are extracted from TeX by using -// \font\a=cmmi10 -// \showthe\fontdimenX\a -// where X is the corresponding variable number. These correspond to the font -// parameters of the symbol fonts. In TeX, there are actually three sets of -// dimensions, one for each of textstyle, scriptstyle, and scriptscriptstyle, -// but we only use the textstyle ones, and scale certain dimensions accordingly. -// See the TeXbook, page 441. -var sigma1 = 0.025; -var sigma2 = 0; -var sigma3 = 0; -var sigma4 = 0; -var sigma5 = 0.431; -var sigma6 = 1; -var sigma7 = 0; -var sigma8 = 0.677; -var sigma9 = 0.394; -var sigma10 = 0.444; -var sigma11 = 0.686; -var sigma12 = 0.345; -var sigma13 = 0.413; -var sigma14 = 0.363; -var sigma15 = 0.289; -var sigma16 = 0.150; -var sigma17 = 0.247; -var sigma18 = 0.386; -var sigma19 = 0.050; -var sigma20 = 2.390; -var sigma21 = 1.01; -var sigma21Script = 0.81; -var sigma21ScriptScript = 0.71; -var sigma22 = 0.250; - -// These font metrics are extracted from TeX by using -// \font\a=cmex10 -// \showthe\fontdimenX\a -// where X is the corresponding variable number. These correspond to the font -// parameters of the extension fonts (family 3). See the TeXbook, page 441. -var xi1 = 0; -var xi2 = 0; -var xi3 = 0; -var xi4 = 0; -var xi5 = 0.431; -var xi6 = 1; -var xi7 = 0; -var xi8 = 0.04; -var xi9 = 0.111; -var xi10 = 0.166; -var xi11 = 0.2; -var xi12 = 0.6; -var xi13 = 0.1; - -// This value determines how large a pt is, for metrics which are defined in -// terms of pts. -// This value is also used in katex.less; if you change it make sure the values -// match. -var ptPerEm = 10.0; - -// The space between adjacent `|` columns in an array definition. From -// `\showthe\doublerulesep` in LaTeX. -var doubleRuleSep = 2.0 / ptPerEm; - -/** - * This is just a mapping from common names to real metrics - */ -var metrics = { - xHeight: sigma5, - quad: sigma6, - num1: sigma8, - num2: sigma9, - num3: sigma10, - denom1: sigma11, - denom2: sigma12, - sup1: sigma13, - sup2: sigma14, - sup3: sigma15, - sub1: sigma16, - sub2: sigma17, - supDrop: sigma18, - subDrop: sigma19, - axisHeight: sigma22, - defaultRuleThickness: xi8, - bigOpSpacing1: xi9, - bigOpSpacing2: xi10, - bigOpSpacing3: xi11, - bigOpSpacing4: xi12, - bigOpSpacing5: xi13, - ptPerEm: ptPerEm, - emPerEx: sigma5 / sigma6, - doubleRuleSep: doubleRuleSep, - - // TODO(alpert): Missing parallel structure here. We should probably add - // style-specific metrics for all of these. - delim1: sigma20, - getDelim2: function(style) { - if (style.size === Style.TEXT.size) { - return sigma21; - } else if (style.size === Style.SCRIPT.size) { - return sigma21Script; - } else if (style.size === Style.SCRIPTSCRIPT.size) { - return sigma21ScriptScript; - } - throw new Error("Unexpected style size: " + style.size); - }, +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retreived using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +var sigmasAndXis = { + slant: [0.250, 0.250, 0.250], // sigma1 + space: [0.000, 0.000, 0.000], // sigma2 + stretch: [0.000, 0.000, 0.000], // sigma3 + shrink: [0.000, 0.000, 0.000], // sigma4 + xHeight: [0.431, 0.431, 0.431], // sigma5 + quad: [1.000, 1.171, 1.472], // sigma6 + extraSpace: [0.000, 0.000, 0.000], // sigma7 + num1: [0.677, 0.732, 0.925], // sigma8 + num2: [0.394, 0.384, 0.387], // sigma9 + num3: [0.444, 0.471, 0.504], // sigma10 + denom1: [0.686, 0.752, 1.025], // sigma11 + denom2: [0.345, 0.344, 0.532], // sigma12 + sup1: [0.413, 0.503, 0.504], // sigma13 + sup2: [0.363, 0.431, 0.404], // sigma14 + sup3: [0.289, 0.286, 0.294], // sigma15 + sub1: [0.150, 0.143, 0.200], // sigma16 + sub2: [0.247, 0.286, 0.400], // sigma17 + supDrop: [0.386, 0.353, 0.494], // sigma18 + subDrop: [0.050, 0.071, 0.100], // sigma19 + delim1: [2.390, 1.700, 1.980], // sigma20 + delim2: [1.010, 1.157, 1.420], // sigma21 + axisHeight: [0.250, 0.250, 0.250], // sigma22 + + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], // xi13; cmex7: 0.143 + + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.less; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2] }; // This map contains a mapping from font name and character code to character // metrics, including height, depth, italic correction, and skew (kern from the // character to the corresponding \skewchar) // This map is generated via `make metrics`. It should not be changed manually. -var metricMap = require("./fontMetricsData"); + // These are very rough approximations. We default to Times New Roman which // should have Latin-1 and Cyrillic characters, but may not depending on the @@ -5359,42 +8143,74 @@ var extraCharacterMap = { 'ь': 'a', 'э': 'e', 'ю': 'm', - 'я': 'r', + 'я': 'r' }; /** * This function is a convenience function for looking up information in the - * metricMap table. It takes a character as a string, and a style. + * metricMap table. It takes a character as a string, and a font. * * Note: the `width` property may be undefined if fontMetricsData.js wasn't * built using `Make extended_metrics`. */ -var getCharacterMetrics = function(character, style) { +var getCharacterMetrics = function getCharacterMetrics(character, font) { var ch = character.charCodeAt(0); if (character[0] in extraCharacterMap) { ch = extraCharacterMap[character[0]].charCodeAt(0); - } else if (cjkRegex.test(character[0])) { + } else if (_unicodeRegexes.cjkRegex.test(character[0])) { ch = 'M'.charCodeAt(0); } - var metrics = metricMap[style][ch]; + var metrics = _fontMetricsData2.default[font]['' + ch]; if (metrics) { return { depth: metrics[0], height: metrics[1], italic: metrics[2], skew: metrics[3], - width: metrics[4], + width: metrics[4] }; } }; -module.exports = { - metrics: metrics, - getCharacterMetrics: getCharacterMetrics, +var fontMetricsBySizeIndex = {}; + +/** + * Get the font metrics for a given size. + */ +var getFontMetrics = function getFontMetrics(size) { + var sizeIndex = void 0; + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + if (!fontMetricsBySizeIndex[sizeIndex]) { + var metrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 + }; + for (var key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + return fontMetricsBySizeIndex[sizeIndex]; }; -},{"./Style":9,"./fontMetricsData":18,"./unicodeRegexes":24}],18:[function(require,module,exports){ -module.exports = { +exports.default = { + getFontMetrics: getFontMetrics, + getCharacterMetrics: getCharacterMetrics +}; + +},{"./fontMetricsData":102,"./unicodeRegexes":126}],102:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var fontMetricsData = { "AMS-Regular": { "65": [0, 0.68889, 0, 0], "66": [0, 0.68889, 0, 0], @@ -5650,7 +8466,7 @@ module.exports = { "57368": [0.25142, 0.75726, 0, 0], "57369": [0.25142, 0.75726, 0, 0], "57370": [0.13597, 0.63597, 0, 0], - "57371": [0.13597, 0.63597, 0, 0], + "57371": [0.13597, 0.63597, 0, 0] }, "Caligraphic-Regular": { "48": [0, 0.43056, 0, 0], @@ -5688,7 +8504,7 @@ module.exports = { "87": [0, 0.68333, 0.08222, 0.08334], "88": [0, 0.68333, 0.14643, 0.13889], "89": [0.09722, 0.68333, 0.08222, 0.08334], - "90": [0, 0.68333, 0.07944, 0.13889], + "90": [0, 0.68333, 0.07944, 0.13889] }, "Fraktur-Regular": { "33": [0, 0.69141, 0, 0], @@ -5781,7 +8597,7 @@ module.exports = { "58116": [0.18906, 0.47534, 0, 0], "58117": [0, 0.69141, 0, 0], "58118": [0, 0.62119, 0, 0], - "58119": [0, 0.47534, 0, 0], + "58119": [0, 0.47534, 0, 0] }, "Main-Bold": { "33": [0, 0.69444, 0, 0], @@ -6036,7 +8852,7 @@ module.exports = { "10217": [0.25, 0.75, 0, 0], "10815": [0, 0.68611, 0, 0], "10927": [0.19667, 0.69667, 0, 0], - "10928": [0.19667, 0.69667, 0, 0], + "10928": [0.19667, 0.69667, 0, 0] }, "Main-Italic": { "33": [0, 0.69444, 0.12417, 0], @@ -6156,7 +8972,7 @@ module.exports = { "8217": [0, 0.69444, 0.12417, 0], "8220": [0, 0.69444, 0.1685, 0], "8221": [0, 0.69444, 0.06961, 0], - "8463": [0, 0.68889, 0, 0], + "8463": [0, 0.68889, 0, 0] }, "Main-Regular": { "32": [0, 0, 0, 0], @@ -6437,7 +9253,7 @@ module.exports = { "10236": [0.011, 0.511, 0, 0], "10815": [0, 0.68333, 0, 0], "10927": [0.13597, 0.63597, 0, 0], - "10928": [0.13597, 0.63597, 0, 0], + "10928": [0.13597, 0.63597, 0, 0] }, "Math-BoldItalic": { "47": [0.19444, 0.69444, 0, 0], @@ -6533,7 +9349,7 @@ module.exports = { "981": [0.19444, 0.69444, 0, 0], "982": [0, 0.44444, 0.03194, 0], "1009": [0.19444, 0.44444, 0, 0], - "1013": [0, 0.44444, 0, 0], + "1013": [0, 0.44444, 0, 0] }, "Math-Italic": { "47": [0.19444, 0.69444, 0, 0], @@ -6629,7 +9445,7 @@ module.exports = { "981": [0.19444, 0.69444, 0, 0.08334], "982": [0, 0.43056, 0.02778, 0], "1009": [0.19444, 0.43056, 0, 0.08334], - "1013": [0, 0.43056, 0, 0.05556], + "1013": [0, 0.43056, 0, 0.05556] }, "Math-Regular": { "65": [0, 0.68333, 0, 0.13889], @@ -6724,7 +9540,7 @@ module.exports = { "981": [0.19444, 0.69444, 0, 0.08334], "982": [0, 0.43056, 0.02778, 0], "1009": [0.19444, 0.43056, 0, 0.08334], - "1013": [0, 0.43056, 0, 0.05556], + "1013": [0, 0.43056, 0, 0.05556] }, "SansSerif-Regular": { "33": [0, 0.69444, 0, 0], @@ -6843,7 +9659,7 @@ module.exports = { "8216": [0, 0.69444, 0, 0], "8217": [0, 0.69444, 0, 0], "8220": [0, 0.69444, 0, 0], - "8221": [0, 0.69444, 0, 0], + "8221": [0, 0.69444, 0, 0] }, "Script-Regular": { "65": [0, 0.7, 0.22925, 0], @@ -6871,7 +9687,7 @@ module.exports = { "87": [0, 0.7, 0.27523, 0], "88": [0, 0.7, 0.26006, 0], "89": [0, 0.7, 0.2939, 0], - "90": [0, 0.7, 0.24037, 0], + "90": [0, 0.7, 0.24037, 0] }, "Size1-Regular": { "40": [0.35001, 0.85, 0, 0], @@ -6916,7 +9732,7 @@ module.exports = { "10753": [0.25001, 0.75, 0, 0], "10754": [0.25001, 0.75, 0, 0], "10756": [0.25001, 0.75, 0, 0], - "10758": [0.25001, 0.75, 0, 0], + "10758": [0.25001, 0.75, 0, 0] }, "Size2-Regular": { "40": [0.65002, 1.15, 0, 0], @@ -6953,7 +9769,7 @@ module.exports = { "10753": [0.55001, 1.05, 0, 0], "10754": [0.55001, 1.05, 0, 0], "10756": [0.55001, 1.05, 0, 0], - "10758": [0.55001, 1.05, 0, 0], + "10758": [0.55001, 1.05, 0, 0] }, "Size3-Regular": { "40": [0.95003, 1.45, 0, 0], @@ -6974,7 +9790,7 @@ module.exports = { "8970": [0.95003, 1.45, 0, 0], "8971": [0.95003, 1.45, 0, 0], "10216": [0.95003, 1.45, 0, 0], - "10217": [0.95003, 1.45, 0, 0], + "10217": [0.95003, 1.45, 0, 0] }, "Size4-Regular": { "40": [1.25003, 1.75, 0, 0], @@ -7021,7 +9837,7 @@ module.exports = { "57680": [0, 0.12, 0, 0], "57681": [0, 0.12, 0, 0], "57682": [0, 0.12, 0, 0], - "57683": [0, 0.12, 0, 0], + "57683": [0, 0.12, 0, 0] }, "Typewriter-Regular": { "33": [0, 0.61111, 0, 0], @@ -7143,553 +9959,369 @@ module.exports = { "937": [0, 0.61111, 0, 0], "2018": [0, 0.61111, 0, 0], "2019": [0, 0.61111, 0, 0], + "8216": [0, 0.61111, 0, 0], + "8217": [0, 0.61111, 0, 0], "8242": [0, 0.61111, 0, 0], - }, + "9251": [0.11111, 0.21944, 0, 0] + } }; -},{}],19:[function(require,module,exports){ -var utils = require("./utils"); -var ParseError = require("./ParseError"); +exports.default = fontMetricsData; -/* This file contains a list of functions that we parse, identified by - * the calls to defineFunction. - * - * The first argument to defineFunction is a single name or a list of names. - * All functions named in such a list will share a single implementation. - * - * Each declared function can have associated properties, which - * include the following: - * - * - numArgs: The number of arguments the function takes. - * If this is the only property, it can be passed as a number - * instead of an element of a properties object. - * - argTypes: (optional) An array corresponding to each argument of the - * function, giving the type of argument that should be parsed. Its - * length should be equal to `numArgs + numOptionalArgs`. Valid - * types: - * - "size": A size-like thing, such as "1em" or "5ex" - * - "color": An html color, like "#abc" or "blue" - * - "original": The same type as the environment that the - * function being parsed is in (e.g. used for the - * bodies of functions like \color where the first - * argument is special and the second argument is - * parsed normally) - * Other possible types (probably shouldn't be used) - * - "text": Text-like (e.g. \text) - * - "math": Normal math - * If undefined, this will be treated as an appropriate length - * array of "original" strings - * - greediness: (optional) The greediness of the function to use ungrouped - * arguments. - * - * E.g. if you have an expression - * \sqrt \frac 1 2 - * since \frac has greediness=2 vs \sqrt's greediness=1, \frac - * will use the two arguments '1' and '2' as its two arguments, - * then that whole function will be used as the argument to - * \sqrt. On the other hand, the expressions - * \frac \frac 1 2 3 - * and - * \frac \sqrt 1 2 - * will fail because \frac and \frac have equal greediness - * and \sqrt has a lower greediness than \frac respectively. To - * make these parse, we would have to change them to: - * \frac {\frac 1 2} 3 - * and - * \frac {\sqrt 1} 2 - * - * The default value is `1` - * - allowedInText: (optional) Whether or not the function is allowed inside - * text mode (default false) - * - numOptionalArgs: (optional) The number of optional arguments the function - * should parse. If the optional arguments aren't found, - * `null` will be passed to the handler in their place. - * (default 0) - * - infix: (optional) Must be true if the function is an infix operator. - * - * The last argument is that implementation, the handler for the function(s). - * It is called to handle these functions and their arguments. - * It receives two arguments: - * - context contains information and references provided by the parser - * - args is an array of arguments obtained from TeX input - * The context contains the following properties: - * - funcName: the text (i.e. name) of the function, including \ - * - parser: the parser object - * - lexer: the lexer object - * - positions: the positions in the overall string of the function - * and the arguments. - * The latter three should only be used to produce error messages. - * - * The function should return an object with the following keys: - * - type: The type of element that this is. This is then used in - * buildHTML/buildMathML to determine which function - * should be called to build this node into a DOM node - * Any other data can be added to the object, which will be passed - * in to the function in buildHTML/buildMathML as `group.value`. - */ +},{}],103:[function(require,module,exports){ +"use strict"; -function defineFunction(names, props, handler) { - if (typeof names === "string") { - names = [names]; - } - if (typeof props === "number") { - props = { numArgs: props }; - } - // Set default values of functions - var data = { - numArgs: props.numArgs, - argTypes: props.argTypes, - greediness: (props.greediness === undefined) ? 1 : props.greediness, - allowedInText: !!props.allowedInText, - numOptionalArgs: props.numOptionalArgs || 0, - infix: !!props.infix, - handler: handler, - }; - for (var i = 0; i < names.length; ++i) { - module.exports[names[i]] = data; - } -} +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _utils = require("./utils"); + +var _utils2 = _interopRequireDefault(_utils); + +var _ParseError = require("./ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +var _ParseNode = require("./ParseNode"); + +var _ParseNode2 = _interopRequireDefault(_ParseNode); + +var _defineFunction2 = require("./defineFunction"); + +var _defineFunction3 = _interopRequireDefault(_defineFunction2); + +require("./functions/color"); + +require("./functions/text"); + +require("./functions/overline"); + +require("./functions/underline"); + +require("./functions/rule"); + +require("./functions/kern"); + +require("./functions/phantom"); + +require("./functions/mod"); + +require("./functions/op"); + +require("./functions/operatorname"); + +require("./functions/genfrac"); + +require("./functions/lap"); + +require("./functions/smash"); + +require("./functions/delimsizing"); + +require("./functions/href"); + +require("./functions/mathchoice"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// WARNING: New functions should be added to src/functions and imported here. + +/** Include this to ensure that all functions are defined. */ +var functions = _defineFunction2._functions; +exports.default = functions; + +// Define a convenience function that mimcs the old semantics of defineFunction +// to support existing code so that we can migrate it a little bit at a time. + +var defineFunction = function defineFunction(names, props, handler) // null only if handled in parser +{ + (0, _defineFunction3.default)({ names: names, props: props, handler: handler }); +}; // A normal square root -defineFunction("\\sqrt", { +defineFunction(["\\sqrt"], { numArgs: 1, - numOptionalArgs: 1, -}, function(context, args) { - var index = args[0]; - var body = args[1]; + numOptionalArgs: 1 +}, function (context, args, optArgs) { + var index = optArgs[0]; + var body = args[0]; return { type: "sqrt", body: body, - index: index, + index: index }; }); -// Some non-mathy text -defineFunction("\\text", { +// \color is handled in Parser.js's parseImplicitGroup +defineFunction(["\\color"], { numArgs: 1, - argTypes: ["text"], - greediness: 2, -}, function(context, args) { - var body = args[0]; - // Since the corresponding buildHTML/buildMathML function expects a - // list of elements, we normalize for different kinds of arguments - // TODO(emily): maybe this should be done somewhere else - var inner; - if (body.type === "ordgroup") { - inner = body.value; - } else { - inner = [body]; - } - - return { - type: "text", - body: inner, - }; -}); + allowedInText: true, + greediness: 3, + argTypes: ["color"] +}, null); -// A two-argument custom color -defineFunction("\\color", { +// colorbox +defineFunction(["\\colorbox"], { numArgs: 2, allowedInText: true, greediness: 3, - argTypes: ["color", "original"], -}, function(context, args) { + argTypes: ["color", "text"] +}, function (context, args) { var color = args[0]; var body = args[1]; - // Normalize the different kinds of bodies (see \text above) - var inner; - if (body.type === "ordgroup") { - inner = body.value; - } else { - inner = [body]; - } - return { - type: "color", - color: color.value, - value: inner, + type: "enclose", + label: context.funcName, + backgroundColor: color, + body: body }; }); -// An overline -defineFunction("\\overline", { - numArgs: 1, -}, function(context, args) { - var body = args[0]; +// fcolorbox +defineFunction(["\\fcolorbox"], { + numArgs: 3, + allowedInText: true, + greediness: 3, + argTypes: ["color", "color", "text"] +}, function (context, args) { + var borderColor = args[0]; + var backgroundColor = args[1]; + var body = args[2]; return { - type: "overline", - body: body, + type: "enclose", + label: context.funcName, + backgroundColor: backgroundColor, + borderColor: borderColor, + body: body }; }); -// An underline -defineFunction("\\underline", { - numArgs: 1, -}, function(context, args) { +// Math class commands except \mathop +defineFunction(["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], { + numArgs: 1 +}, function (context, args) { var body = args[0]; return { - type: "underline", - body: body, + type: "mclass", + mclass: "m" + context.funcName.substr(5), + value: (0, _defineFunction2.ordargument)(body) }; }); -// A box of the width and height -defineFunction("\\rule", { - numArgs: 2, - numOptionalArgs: 1, - argTypes: ["size", "size", "size"], -}, function(context, args) { - var shift = args[0]; - var width = args[1]; - var height = args[2]; - return { - type: "rule", - shift: shift && shift.value, - width: width.value, - height: height.value, - }; -}); +// Build a relation by placing one symbol on top of another +defineFunction(["\\stackrel"], { + numArgs: 2 +}, function (context, args) { + var top = args[0]; + var bottom = args[1]; -defineFunction("\\kern", { - numArgs: 1, - argTypes: ["size"], -}, function(context, args) { - return { - type: "kern", - dimension: args[0].value, - }; -}); - -// A KaTeX logo -defineFunction("\\KaTeX", { - numArgs: 0, -}, function(context) { - return { - type: "katex", - }; -}); + var bottomop = new _ParseNode2.default("op", { + type: "op", + limits: true, + alwaysHandleSupSub: true, + symbol: false, + value: (0, _defineFunction2.ordargument)(bottom) + }, bottom.mode); -defineFunction("\\phantom", { - numArgs: 1, -}, function(context, args) { - var body = args[0]; - var inner; - if (body.type === "ordgroup") { - inner = body.value; - } else { - inner = [body]; - } + var supsub = new _ParseNode2.default("supsub", { + base: bottomop, + sup: top, + sub: null + }, top.mode); return { - type: "phantom", - value: inner, + type: "mclass", + mclass: "mrel", + value: [supsub] }; }); -// Extra data needed for the delimiter handler down below -var delimiterSizes = { - "\\bigl" : {type: "open", size: 1}, - "\\Bigl" : {type: "open", size: 2}, - "\\biggl": {type: "open", size: 3}, - "\\Biggl": {type: "open", size: 4}, - "\\bigr" : {type: "close", size: 1}, - "\\Bigr" : {type: "close", size: 2}, - "\\biggr": {type: "close", size: 3}, - "\\Biggr": {type: "close", size: 4}, - "\\bigm" : {type: "rel", size: 1}, - "\\Bigm" : {type: "rel", size: 2}, - "\\biggm": {type: "rel", size: 3}, - "\\Biggm": {type: "rel", size: 4}, - "\\big" : {type: "textord", size: 1}, - "\\Big" : {type: "textord", size: 2}, - "\\bigg" : {type: "textord", size: 3}, - "\\Bigg" : {type: "textord", size: 4}, -}; - -var delimiters = [ - "(", ")", "[", "\\lbrack", "]", "\\rbrack", - "\\{", "\\lbrace", "\\}", "\\rbrace", - "\\lfloor", "\\rfloor", "\\lceil", "\\rceil", - "<", ">", "\\langle", "\\rangle", "\\lt", "\\gt", - "\\lvert", "\\rvert", "\\lVert", "\\rVert", - "\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache", - "/", "\\backslash", - "|", "\\vert", "\\|", "\\Vert", - "\\uparrow", "\\Uparrow", - "\\downarrow", "\\Downarrow", - "\\updownarrow", "\\Updownarrow", - ".", -]; - var fontAliases = { "\\Bbb": "\\mathbb", "\\bold": "\\mathbf", - "\\frak": "\\mathfrak", + "\\frak": "\\mathfrak" }; -// Single-argument color functions -defineFunction([ - "\\blue", "\\orange", "\\pink", "\\red", - "\\green", "\\gray", "\\purple", - "\\blueA", "\\blueB", "\\blueC", "\\blueD", "\\blueE", - "\\tealA", "\\tealB", "\\tealC", "\\tealD", "\\tealE", - "\\greenA", "\\greenB", "\\greenC", "\\greenD", "\\greenE", - "\\goldA", "\\goldB", "\\goldC", "\\goldD", "\\goldE", - "\\redA", "\\redB", "\\redC", "\\redD", "\\redE", - "\\maroonA", "\\maroonB", "\\maroonC", "\\maroonD", "\\maroonE", - "\\purpleA", "\\purpleB", "\\purpleC", "\\purpleD", "\\purpleE", - "\\mintA", "\\mintB", "\\mintC", - "\\grayA", "\\grayB", "\\grayC", "\\grayD", "\\grayE", - "\\grayF", "\\grayG", "\\grayH", "\\grayI", - "\\kaBlue", "\\kaGreen", -], { - numArgs: 1, - allowedInText: true, - greediness: 3, -}, function(context, args) { - var body = args[0]; - var atoms; - if (body.type === "ordgroup") { - atoms = body.value; - } else { - atoms = [body]; - } - - return { - type: "color", - color: "katex-" + context.funcName.slice(1), - value: atoms, - }; -}); +var singleCharIntegrals = { + "\u222B": "\\int", + "\u222C": "\\iint", + "\u222D": "\\iiint", + "\u222E": "\\oint" +}; // There are 2 flags for operators; whether they produce limits in // displaystyle, and whether they are symbols and should grow in // displaystyle. These four groups cover the four possible choices. // No limits, not symbols -defineFunction([ - "\\arcsin", "\\arccos", "\\arctan", "\\arg", "\\cos", "\\cosh", - "\\cot", "\\coth", "\\csc", "\\deg", "\\dim", "\\exp", "\\hom", - "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", - "\\tan", "\\tanh", -], { - numArgs: 0, -}, function(context) { +defineFunction(["\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th"], { + numArgs: 0 +}, function (context) { return { type: "op", limits: false, symbol: false, - body: context.funcName, + body: context.funcName }; }); // Limits, not symbols -defineFunction([ - "\\det", "\\gcd", "\\inf", "\\lim", "\\liminf", "\\limsup", "\\max", - "\\min", "\\Pr", "\\sup", -], { - numArgs: 0, -}, function(context) { +defineFunction(["\\det", "\\gcd", "\\inf", "\\lim", "\\liminf", "\\limsup", "\\max", "\\min", "\\Pr", "\\sup"], { + numArgs: 0 +}, function (context) { return { type: "op", limits: true, symbol: false, - body: context.funcName, + body: context.funcName }; }); // No limits, symbols -defineFunction([ - "\\int", "\\iint", "\\iiint", "\\oint", -], { - numArgs: 0, -}, function(context) { +defineFunction(["\\int", "\\iint", "\\iiint", "\\oint", "\u222B", "\u222C", "\u222D", "\u222E"], { + numArgs: 0 +}, function (context) { + var fName = context.funcName; + if (fName.length === 1) { + fName = singleCharIntegrals[fName]; + } return { type: "op", limits: false, symbol: true, - body: context.funcName, + body: fName }; }); -// Limits, symbols +// Sizing functions (handled in Parser.js explicitly, hence no handler) +defineFunction(["\\tiny", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"], { numArgs: 0 }, null); + +// Style changing functions (handled in Parser.js explicitly, hence no +// handler) +defineFunction(["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], { numArgs: 0 }, null); + +// Old font changing functions +defineFunction(["\\rm", "\\sf", "\\tt", "\\bf", "\\it"], { numArgs: 0 }, null); + defineFunction([ - "\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", - "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", - "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", -], { - numArgs: 0, -}, function(context) { +// styles +"\\mathrm", "\\mathit", "\\mathbf", + +// families +"\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt", + +// aliases +"\\Bbb", "\\bold", "\\frak"], { + numArgs: 1, + greediness: 2 +}, function (context, args) { + var body = args[0]; + var func = context.funcName; + if (func in fontAliases) { + func = fontAliases[func]; + } return { - type: "op", - limits: true, - symbol: true, - body: context.funcName, + type: "font", + font: func.slice(1), + body: body }; }); -// Fractions -defineFunction([ - "\\dfrac", "\\frac", "\\tfrac", - "\\dbinom", "\\binom", "\\tbinom", -], { - numArgs: 2, - greediness: 2, -}, function(context, args) { - var numer = args[0]; - var denom = args[1]; - var hasBarLine; - var leftDelim = null; - var rightDelim = null; - var size = "auto"; +// Accents +defineFunction(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], { + numArgs: 1 +}, function (context, args) { + var base = args[0]; - switch (context.funcName) { - case "\\dfrac": - case "\\frac": - case "\\tfrac": - hasBarLine = true; - break; - case "\\dbinom": - case "\\binom": - case "\\tbinom": - hasBarLine = false; - leftDelim = "("; - rightDelim = ")"; - break; - default: - throw new Error("Unrecognized genfrac command"); - } + var isStretchy = !_utils2.default.contains(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot"], context.funcName); - switch (context.funcName) { - case "\\dfrac": - case "\\dbinom": - size = "display"; - break; - case "\\tfrac": - case "\\tbinom": - size = "text"; - break; - } + var isShifty = !isStretchy || _utils2.default.contains(["\\widehat", "\\widetilde"], context.funcName); return { - type: "genfrac", - numer: numer, - denom: denom, - hasBarLine: hasBarLine, - leftDelim: leftDelim, - rightDelim: rightDelim, - size: size, + type: "accent", + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base }; }); -// Left and right overlap functions -defineFunction(["\\llap", "\\rlap"], { +// Text-mode accents +defineFunction(["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v"], { numArgs: 1, allowedInText: true, -}, function(context, args) { - var body = args[0]; + allowedInMath: false +}, function (context, args) { + var base = args[0]; + return { - type: context.funcName.slice(1), - body: body, + type: "accent", + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base }; }); -// Delimiter functions -defineFunction([ - "\\bigl", "\\Bigl", "\\biggl", "\\Biggl", - "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", - "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", - "\\big", "\\Big", "\\bigg", "\\Bigg", - "\\left", "\\right", -], { - numArgs: 1, -}, function(context, args) { - var delim = args[0]; - if (!utils.contains(delimiters, delim.value)) { - throw new ParseError( - "Invalid delimiter: '" + delim.value + "' after '" + - context.funcName + "'", delim); - } - - // \left and \right are caught somewhere in Parser.js, which is - // why this data doesn't match what is in buildHTML. - if (context.funcName === "\\left" || context.funcName === "\\right") { - return { - type: "leftright", - value: delim.value, - }; - } else { - return { - type: "delimsizing", - size: delimiterSizes[context.funcName].size, - delimType: delimiterSizes[context.funcName].type, - value: delim.value, - }; - } +// Horizontal stretchy braces +defineFunction(["\\overbrace", "\\underbrace"], { + numArgs: 1 +}, function (context, args) { + var base = args[0]; + return { + type: "horizBrace", + label: context.funcName, + isOver: /^\\over/.test(context.funcName), + base: base + }; }); -// Sizing functions (handled in Parser.js explicitly, hence no handler) -defineFunction([ - "\\tiny", "\\scriptsize", "\\footnotesize", "\\small", - "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge", -], 0, null); - -// Style changing functions (handled in Parser.js explicitly, hence no -// handler) -defineFunction([ - "\\displaystyle", "\\textstyle", "\\scriptstyle", - "\\scriptscriptstyle", -], 0, null); - -defineFunction([ - // styles - "\\mathrm", "\\mathit", "\\mathbf", - - // families - "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", - "\\mathtt", +// Stretchy accents under the body +defineFunction(["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], { + numArgs: 1 +}, function (context, args) { + var base = args[0]; + return { + type: "accentUnder", + label: context.funcName, + base: base + }; +}); - // aliases - "\\Bbb", "\\bold", "\\frak", -], { +// Stretchy arrows with an optional argument +defineFunction(["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom"], { numArgs: 1, - greediness: 2, -}, function(context, args) { + numOptionalArgs: 1 +}, function (context, args, optArgs) { + var below = optArgs[0]; var body = args[0]; - var func = context.funcName; - if (func in fontAliases) { - func = fontAliases[func]; - } return { - type: "font", - font: func.slice(1), + type: "xArrow", // x for extensible + label: context.funcName, body: body, + below: below }; }); -// Accents -defineFunction([ - "\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", - "\\check", "\\hat", "\\vec", "\\dot", - // We don't support expanding accents yet - // "\\widetilde", "\\widehat" -], { - numArgs: 1, -}, function(context, args) { - var base = args[0]; +// enclose +defineFunction(["\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\fbox"], { + numArgs: 1 +}, function (context, args) { + var body = args[0]; return { - type: "accent", - accent: context.funcName, - base: base, + type: "enclose", + label: context.funcName, + body: body }; }); // Infix generalized fractions -defineFunction(["\\over", "\\choose"], { +defineFunction(["\\over", "\\choose", "\\atop"], { numArgs: 0, - infix: true, -}, function(context) { - var replaceWith; + infix: true +}, function (context) { + var replaceWith = void 0; switch (context.funcName) { case "\\over": replaceWith = "\\frac"; @@ -7697,13 +10329,16 @@ defineFunction(["\\over", "\\choose"], { case "\\choose": replaceWith = "\\binom"; break; + case "\\atop": + replaceWith = "\\\\atopfrac"; + break; default: throw new Error("Unrecognized infix genfrac command"); } return { type: "infix", replaceWith: replaceWith, - token: context.token, + token: context.token }; }); @@ -7711,23 +10346,23 @@ defineFunction(["\\over", "\\choose"], { defineFunction(["\\\\", "\\cr"], { numArgs: 0, numOptionalArgs: 1, - argTypes: ["size"], -}, function(context, args) { - var size = args[0]; + argTypes: ["size"] +}, function (context, args, optArgs) { + var size = optArgs[0]; return { type: "cr", - size: size, + size: size }; }); // Environment delimiters defineFunction(["\\begin", "\\end"], { numArgs: 1, - argTypes: ["text"], -}, function(context, args) { + argTypes: ["text"] +}, function (context, args) { var nameGroup = args[0]; if (nameGroup.type !== "ordgroup") { - throw new ParseError("Invalid environment name", nameGroup); + throw new _ParseError2.default("Invalid environment name", nameGroup); } var name = ""; for (var i = 0; i < nameGroup.value.length; ++i) { @@ -7736,171 +10371,3071 @@ defineFunction(["\\begin", "\\end"], { return { type: "environment", name: name, - nameGroup: nameGroup, + nameGroup: nameGroup }; }); -},{"./ParseError":6,"./utils":25}],20:[function(require,module,exports){ -/** - * These objects store data about MathML nodes. This is the MathML equivalent - * of the types in domTree.js. Since MathML handles its own rendering, and - * since we're mainly using MathML to improve accessibility, we don't manage - * any of the styling state that the plain DOM nodes do. - * - * The `toNode` and `toMarkup` functions work simlarly to how they do in - * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. - */ +// Box manipulation +defineFunction(["\\raisebox"], { + numArgs: 2, + argTypes: ["size", "text"], + allowedInText: true +}, function (context, args) { + var amount = args[0]; + var body = args[1]; + return { + type: "raisebox", + dy: amount, + body: body, + value: (0, _defineFunction2.ordargument)(body) + }; +}); -var utils = require("./utils"); +// \verb and \verb* are dealt with directly in Parser.js. +// If we end up here, it's because of a failure to match the two delimiters +// in the regex in Lexer.js. LaTeX raises the following error when \verb is +// terminated by end of line (or file). +defineFunction(["\\verb"], { + numArgs: 0, + allowedInText: true +}, function (context) { + throw new _ParseError2.default("\\verb ended by end of line instead of matching delimiter"); +}); -/** - * This node represents a general purpose MathML node of any type. The - * constructor requires the type of node to create (for example, `"mo"` or - * `"mspace"`, corresponding to `<mo>` and `<mspace>` tags). - */ -function MathNode(type, children) { - this.type = type; - this.attributes = {}; - this.children = children || []; +// Hyperlinks + + +// MathChoice + +},{"./ParseError":84,"./ParseNode":85,"./defineFunction":96,"./functions/color":104,"./functions/delimsizing":105,"./functions/genfrac":106,"./functions/href":107,"./functions/kern":108,"./functions/lap":109,"./functions/mathchoice":110,"./functions/mod":111,"./functions/op":112,"./functions/operatorname":113,"./functions/overline":114,"./functions/phantom":115,"./functions/rule":116,"./functions/smash":117,"./functions/text":118,"./functions/underline":119,"./utils":128}],104:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var htmlBuilder = function htmlBuilder(group, options) { + var elements = html.buildExpression(group.value.value, options.withColor(group.value.color), false); + + // \color isn't supposed to affect the type of the elements it contains. + // To accomplish this, we wrap the results in a fragment, so the inner + // elements will be able to directly interact with their neighbors. For + // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` + return new _buildCommon2.default.makeFragment(elements); +}; + + +var mathmlBuilder = function mathmlBuilder(group, options) { + var inner = mml.buildExpression(group.value.value, options); + + var node = new _mathMLTree2.default.MathNode("mstyle", inner); + + node.setAttribute("mathcolor", group.value.color); + + return node; +}; + +(0, _defineFunction2.default)({ + type: "color", + names: ["\\textcolor"], + props: { + numArgs: 2, + allowedInText: true, + greediness: 3, + argTypes: ["color", "original"] + }, + handler: function handler(context, args) { + var color = args[0]; + var body = args[1]; + return { + type: "color", + color: color.value, + value: (0, _defineFunction.ordargument)(body) + }; + }, + + htmlBuilder: htmlBuilder, + mathmlBuilder: mathmlBuilder +}); + +// TODO(kevinb): define these using macros +(0, _defineFunction2.default)({ + type: "color", + names: ["\\blue", "\\orange", "\\pink", "\\red", "\\green", "\\gray", "\\purple", "\\blueA", "\\blueB", "\\blueC", "\\blueD", "\\blueE", "\\tealA", "\\tealB", "\\tealC", "\\tealD", "\\tealE", "\\greenA", "\\greenB", "\\greenC", "\\greenD", "\\greenE", "\\goldA", "\\goldB", "\\goldC", "\\goldD", "\\goldE", "\\redA", "\\redB", "\\redC", "\\redD", "\\redE", "\\maroonA", "\\maroonB", "\\maroonC", "\\maroonD", "\\maroonE", "\\purpleA", "\\purpleB", "\\purpleC", "\\purpleD", "\\purpleE", "\\mintA", "\\mintB", "\\mintC", "\\grayA", "\\grayB", "\\grayC", "\\grayD", "\\grayE", "\\grayF", "\\grayG", "\\grayH", "\\grayI", "\\kaBlue", "\\kaGreen"], + props: { + numArgs: 1, + allowedInText: true, + greediness: 3 + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "color", + color: "katex-" + context.funcName.slice(1), + value: (0, _defineFunction.ordargument)(body) + }; + }, + + htmlBuilder: htmlBuilder, + mathmlBuilder: mathmlBuilder +}); + +},{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":121}],105:[function(require,module,exports){ +"use strict"; + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _delimiter = require("../delimiter"); + +var _delimiter2 = _interopRequireDefault(_delimiter); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _ParseError = require("../ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +var _utils = require("../utils"); + +var _utils2 = _interopRequireDefault(_utils); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Extra data needed for the delimiter handler down below +var delimiterSizes = { + "\\bigl": { mclass: "mopen", size: 1 }, + "\\Bigl": { mclass: "mopen", size: 2 }, + "\\biggl": { mclass: "mopen", size: 3 }, + "\\Biggl": { mclass: "mopen", size: 4 }, + "\\bigr": { mclass: "mclose", size: 1 }, + "\\Bigr": { mclass: "mclose", size: 2 }, + "\\biggr": { mclass: "mclose", size: 3 }, + "\\Biggr": { mclass: "mclose", size: 4 }, + "\\bigm": { mclass: "mrel", size: 1 }, + "\\Bigm": { mclass: "mrel", size: 2 }, + "\\biggm": { mclass: "mrel", size: 3 }, + "\\Biggm": { mclass: "mrel", size: 4 }, + "\\big": { mclass: "mord", size: 1 }, + "\\Big": { mclass: "mord", size: 2 }, + "\\bigg": { mclass: "mord", size: 3 }, + "\\Bigg": { mclass: "mord", size: 4 } +}; + +var delimiters = ["(", ")", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\\lceil", "\\rceil", "<", ">", "\\langle", "\\rangle", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]; + +// Delimiter functions +function checkDelimiter(delim, context) { + if (_utils2.default.contains(delimiters, delim.value)) { + return delim; + } else { + throw new _ParseError2.default("Invalid delimiter: '" + delim.value + "' after '" + context.funcName + "'", delim); + } } -/** - * Sets an attribute on a MathML node. MathML depends on attributes to convey a - * semantic content, so this is used heavily. - */ -MathNode.prototype.setAttribute = function(name, value) { - this.attributes[name] = value; +(0, _defineFunction2.default)({ + type: "delimsizing", + names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var delim = checkDelimiter(args[0], context); + + return { + type: "delimsizing", + size: delimiterSizes[context.funcName].size, + mclass: delimiterSizes[context.funcName].mclass, + value: delim.value + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + var delim = group.value.value; + + if (delim === ".") { + // Empty delimiters still count as elements, even though they don't + // show anything. + return _buildCommon2.default.makeSpan([group.value.mclass]); + } + + // Use delimiter.sizedDelim to generate the delimiter. + return _delimiter2.default.sizedDelim(delim, group.value.size, options, group.mode, [group.value.mclass]); + }, + mathmlBuilder: function mathmlBuilder(group) { + var children = []; + + if (group.value.value !== ".") { + children.push(mml.makeText(group.value.value, group.mode)); + } + + var node = new _mathMLTree2.default.MathNode("mo", children); + + if (group.value.mclass === "mopen" || group.value.mclass === "mclose") { + // Only some of the delimsizing functions act as fences, and they + // return "mopen" or "mclose" mclass. + node.setAttribute("fence", "true"); + } else { + // Explicitly disable fencing if it's not a fence, to override the + // defaults. + node.setAttribute("fence", "false"); + } + + return node; + } +}); + +(0, _defineFunction2.default)({ + type: "leftright", + names: ["\\left", "\\right"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var delim = checkDelimiter(args[0], context); + + // \left and \right are caught somewhere in Parser.js, which is + // why this data doesn't match what is in buildHTML. + return { + type: "leftright", + value: delim.value + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + // Build the inner expression + var inner = html.buildExpression(group.value.body, options, true); + + var innerHeight = 0; + var innerDepth = 0; + var hadMiddle = false; + + // Calculate its height and depth + for (var i = 0; i < inner.length; i++) { + if (inner[i].isMiddle) { + hadMiddle = true; + } else { + innerHeight = Math.max(inner[i].height, innerHeight); + innerDepth = Math.max(inner[i].depth, innerDepth); + } + } + + // The size of delimiters is the same, regardless of what style we are + // in. Thus, to correctly calculate the size of delimiter we need around + // a group, we scale down the inner size based on the size. + innerHeight *= options.sizeMultiplier; + innerDepth *= options.sizeMultiplier; + + var leftDelim = void 0; + if (group.value.left === ".") { + // Empty delimiters in \left and \right make null delimiter spaces. + leftDelim = html.makeNullDelimiter(options, ["mopen"]); + } else { + // Otherwise, use leftRightDelim to generate the correct sized + // delimiter. + leftDelim = _delimiter2.default.leftRightDelim(group.value.left, innerHeight, innerDepth, options, group.mode, ["mopen"]); + } + // Add it to the beginning of the expression + inner.unshift(leftDelim); + + // Handle middle delimiters + if (hadMiddle) { + for (var _i = 1; _i < inner.length; _i++) { + var middleDelim = inner[_i]; + if (middleDelim.isMiddle) { + // Apply the options that were active when \middle was called + inner[_i] = _delimiter2.default.leftRightDelim(middleDelim.isMiddle.value, innerHeight, innerDepth, middleDelim.isMiddle.options, group.mode, []); + // Add back spaces shifted into the delimiter + var spaces = html.spliceSpaces(middleDelim.children, 0); + if (spaces) { + _buildCommon2.default.prependChildren(inner[_i], spaces); + } + } + } + } + + var rightDelim = void 0; + // Same for the right delimiter + if (group.value.right === ".") { + rightDelim = html.makeNullDelimiter(options, ["mclose"]); + } else { + rightDelim = _delimiter2.default.leftRightDelim(group.value.right, innerHeight, innerDepth, options, group.mode, ["mclose"]); + } + // Add it to the end of the expression. + inner.push(rightDelim); + + return _buildCommon2.default.makeSpan(["minner"], inner, options); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var inner = mml.buildExpression(group.value.body, options); + + if (group.value.left !== ".") { + var leftNode = new _mathMLTree2.default.MathNode("mo", [mml.makeText(group.value.left, group.mode)]); + + leftNode.setAttribute("fence", "true"); + + inner.unshift(leftNode); + } + + if (group.value.right !== ".") { + var rightNode = new _mathMLTree2.default.MathNode("mo", [mml.makeText(group.value.right, group.mode)]); + + rightNode.setAttribute("fence", "true"); + + inner.push(rightNode); + } + + var outerNode = new _mathMLTree2.default.MathNode("mrow", inner); + + return outerNode; + } +}); + +(0, _defineFunction2.default)({ + type: "middle", + names: ["\\middle"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var delim = checkDelimiter(args[0], context); + if (!context.parser.leftrightDepth) { + throw new _ParseError2.default("\\middle without preceding \\left", delim); + } + + return { + type: "middle", + value: delim.value + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + var middleDelim = void 0; + if (group.value.value === ".") { + middleDelim = html.makeNullDelimiter(options, []); + } else { + middleDelim = _delimiter2.default.sizedDelim(group.value.value, 1, options, group.mode, []); + middleDelim.isMiddle = { value: group.value.value, options: options }; + } + return middleDelim; + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var middleNode = new _mathMLTree2.default.MathNode("mo", [mml.makeText(group.value.middle, group.mode)]); + middleNode.setAttribute("fence", "true"); + return middleNode; + } +}); + +},{"../ParseError":84,"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../delimiter":97,"../mathMLTree":121,"../utils":128}],106:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _delimiter = require("../delimiter"); + +var _delimiter2 = _interopRequireDefault(_delimiter); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _Style = require("../Style"); + +var _Style2 = _interopRequireDefault(_Style); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _defineFunction2.default)({ + type: "genfrac", + names: ["\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac"], + props: { + numArgs: 2, + greediness: 2 + }, + handler: function handler(context, args) { + var numer = args[0]; + var denom = args[1]; + var hasBarLine = void 0; + var leftDelim = null; + var rightDelim = null; + var size = "auto"; + + switch (context.funcName) { + case "\\dfrac": + case "\\frac": + case "\\tfrac": + hasBarLine = true; + break; + case "\\\\atopfrac": + hasBarLine = false; + break; + case "\\dbinom": + case "\\binom": + case "\\tbinom": + hasBarLine = false; + leftDelim = "("; + rightDelim = ")"; + break; + default: + throw new Error("Unrecognized genfrac command"); + } + + switch (context.funcName) { + case "\\dfrac": + case "\\dbinom": + size = "display"; + break; + case "\\tfrac": + case "\\tbinom": + size = "text"; + break; + } + + return { + type: "genfrac", + numer: numer, + denom: denom, + hasBarLine: hasBarLine, + leftDelim: leftDelim, + rightDelim: rightDelim, + size: size + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). + // Figure out what style this fraction should be in based on the + // function used + var style = options.style; + if (group.value.size === "display") { + style = _Style2.default.DISPLAY; + } else if (group.value.size === "text") { + style = _Style2.default.TEXT; + } + + var nstyle = style.fracNum(); + var dstyle = style.fracDen(); + var newOptions = void 0; + + newOptions = options.havingStyle(nstyle); + var numerm = html.buildGroup(group.value.numer, newOptions, options); + + newOptions = options.havingStyle(dstyle); + var denomm = html.buildGroup(group.value.denom, newOptions, options); + + var rule = void 0; + var ruleWidth = void 0; + var ruleSpacing = void 0; + if (group.value.hasBarLine) { + rule = _buildCommon2.default.makeLineSpan("frac-line", options); + ruleWidth = rule.height; + ruleSpacing = rule.height; + } else { + rule = null; + ruleWidth = 0; + ruleSpacing = options.fontMetrics().defaultRuleThickness; + } + + // Rule 15b + var numShift = void 0; + var clearance = void 0; + var denomShift = void 0; + if (style.size === _Style2.default.DISPLAY.size) { + numShift = options.fontMetrics().num1; + if (ruleWidth > 0) { + clearance = 3 * ruleSpacing; + } else { + clearance = 7 * ruleSpacing; + } + denomShift = options.fontMetrics().denom1; + } else { + if (ruleWidth > 0) { + numShift = options.fontMetrics().num2; + clearance = ruleSpacing; + } else { + numShift = options.fontMetrics().num3; + clearance = 3 * ruleSpacing; + } + denomShift = options.fontMetrics().denom2; + } + + var frac = void 0; + if (ruleWidth === 0) { + // Rule 15c + var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); + if (candidateClearance < clearance) { + numShift += 0.5 * (clearance - candidateClearance); + denomShift += 0.5 * (clearance - candidateClearance); + } + + frac = _buildCommon2.default.makeVList({ + positionType: "individualShift", + children: [{ type: "elem", elem: denomm, shift: denomShift }, { type: "elem", elem: numerm, shift: -numShift }] + }, options); + } else { + // Rule 15d + var axisHeight = options.fontMetrics().axisHeight; + + if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) { + numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth)); + } + + if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) { + denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift)); + } + + var midShift = -(axisHeight - 0.5 * ruleWidth); + + frac = _buildCommon2.default.makeVList({ + positionType: "individualShift", + children: [{ type: "elem", elem: denomm, shift: denomShift }, + // $FlowFixMe `rule` cannot be `null` here. + { type: "elem", elem: rule, shift: midShift }, { type: "elem", elem: numerm, shift: -numShift }] + }, options); + } + + // Since we manually change the style sometimes (with \dfrac or \tfrac), + // account for the possible size change here. + newOptions = options.havingStyle(style); + frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; + frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; + + // Rule 15e + var delimSize = void 0; + if (style.size === _Style2.default.DISPLAY.size) { + delimSize = options.fontMetrics().delim1; + } else { + delimSize = options.fontMetrics().delim2; + } + + var leftDelim = void 0; + var rightDelim = void 0; + if (group.value.leftDelim == null) { + leftDelim = html.makeNullDelimiter(options, ["mopen"]); + } else { + leftDelim = _delimiter2.default.customSizedDelim(group.value.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]); + } + if (group.value.rightDelim == null) { + rightDelim = html.makeNullDelimiter(options, ["mclose"]); + } else { + rightDelim = _delimiter2.default.customSizedDelim(group.value.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]); + } + + return _buildCommon2.default.makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, _buildCommon2.default.makeSpan(["mfrac"], [frac]), rightDelim], options); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var node = new _mathMLTree2.default.MathNode("mfrac", [mml.buildGroup(group.value.numer, options), mml.buildGroup(group.value.denom, options)]); + + if (!group.value.hasBarLine) { + node.setAttribute("linethickness", "0px"); + } + + if (group.value.leftDelim != null || group.value.rightDelim != null) { + var withDelims = []; + + if (group.value.leftDelim != null) { + var leftOp = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode(group.value.leftDelim)]); + + leftOp.setAttribute("fence", "true"); + + withDelims.push(leftOp); + } + + withDelims.push(node); + + if (group.value.rightDelim != null) { + var rightOp = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode(group.value.rightDelim)]); + + rightOp.setAttribute("fence", "true"); + + withDelims.push(rightOp); + } + + var outerNode = new _mathMLTree2.default.MathNode("mrow", withDelims); + + return outerNode; + } + + return node; + } +}); + +},{"../Style":89,"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../delimiter":97,"../mathMLTree":121}],107:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _defineFunction2.default)({ + type: "href", + names: ["\\href"], + props: { + numArgs: 2, + argTypes: ["url", "original"] + }, + handler: function handler(context, args) { + var body = args[1]; + var href = args[0].value; + return { + type: "href", + href: href, + body: (0, _defineFunction.ordargument)(body) + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + var elements = html.buildExpression(group.value.body, options, false); + + var href = group.value.href; + + /** + * Determining class for anchors. + * 1. if it has the only element, use its class; + * 2. if it has more than two elements, and the classes + * of its first and last elements coincide, then use it; + * 3. otherwise, we will inject an empty <span>s at both ends, + * with the same classes of both ends of elements, with the + * first span having the same class as the first element of body, + * and the second one the same as the last. + */ + + var classes = []; // Default behaviour for Case 3. + var first = void 0; // mathtype of the first child + var last = void 0; // mathtype of the last child + // Invariants: both first and last must be non-null if classes is null. + if (elements.length === 1) { + // Case 1 + classes = elements[0].classes; + } else if (elements.length >= 2) { + first = html.getTypeOfDomTree(elements[0]) || 'mord'; + last = html.getTypeOfDomTree(elements[elements.length - 1]) || 'mord'; + if (first === last) { + // Case 2 : type of both ends coincides + classes = [first]; + } else { + // Case 3: both ends have different types. + var anc = _buildCommon2.default.makeAnchor(href, [], elements, options); + return new _buildCommon2.default.makeFragment([new _buildCommon2.default.makeSpan([first], [], options), anc, new _buildCommon2.default.makeSpan([last], [], options)]); + } + } + return new _buildCommon2.default.makeAnchor(href, classes, elements, options); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var inner = mml.buildExpression(group.value.body, options); + var math = new _mathMLTree2.default.MathNode("mrow", inner); + math.setAttribute("href", group.value.href); + return math; + } +}); + +},{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":121}],108:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _units = require("../units"); + +var _ParseError = require("../ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// TODO: \hskip and \mskip should support plus and minus in lengths + +(0, _defineFunction2.default)({ + type: "kern", + names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"], + props: { + numArgs: 1, + argTypes: ["size"], + allowedInText: true + }, + handler: function handler(context, args) { + var mathFunction = context.funcName[1] === 'm'; // \mkern, \mskip + var muUnit = args[0].value.unit === 'mu'; + if (mathFunction) { + if (!muUnit) { + typeof console !== "undefined" && console.warn("In LaTeX, " + context.funcName + " supports only mu units, " + ("not " + args[0].value.unit + " units")); + } + if (context.parser.mode !== "math") { + throw new _ParseError2.default("Can't use function '" + context.funcName + "' in text mode"); + } + } else { + // !mathFunction + if (muUnit) { + typeof console !== "undefined" && console.warn("In LaTeX, " + context.funcName + " does not support mu units"); + } + } + return { + type: "kern", + dimension: args[0].value + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + // Make an empty span for the rule + var rule = _buildCommon2.default.makeSpan(["mord", "rule"], [], options); + + if (group.value.dimension) { + var dimension = (0, _units.calculateSize)(group.value.dimension, options); + rule.style.marginLeft = dimension + "em"; + } + + return rule; + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var node = new _mathMLTree2.default.MathNode("mspace"); + + if (group.value.dimension) { + var dimension = (0, _units.calculateSize)(group.value.dimension, options); + node.setAttribute("width", dimension + "em"); + } + + return node; + } +}); +/* eslint no-console:0 */ +// Horizontal spacing commands + +},{"../ParseError":84,"../buildCommon":91,"../defineFunction":96,"../mathMLTree":121,"../units":127}],109:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _defineFunction2.default)({ + type: "lap", + names: ["\\mathllap", "\\mathrlap", "\\mathclap"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "lap", + alignment: context.funcName.slice(5), + body: body + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + // mathllap, mathrlap, mathclap + var inner = void 0; + if (group.value.alignment === "clap") { + // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ + inner = _buildCommon2.default.makeSpan([], [html.buildGroup(group.value.body, options)]); + // wrap, since CSS will center a .clap > .inner > span + inner = _buildCommon2.default.makeSpan(["inner"], [inner], options); + } else { + inner = _buildCommon2.default.makeSpan(["inner"], [html.buildGroup(group.value.body, options)]); + } + var fix = _buildCommon2.default.makeSpan(["fix"], []); + return _buildCommon2.default.makeSpan(["mord", group.value.alignment], [inner, fix], options); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + // mathllap, mathrlap, mathclap + var node = new _mathMLTree2.default.MathNode("mpadded", [mml.buildGroup(group.value.body, options)]); + + if (group.value.alignment !== "rlap") { + var offset = group.value.alignment === "llap" ? "-1" : "-0.5"; + node.setAttribute("lspace", offset + "width"); + } + node.setAttribute("width", "0px"); + + return node; + } +}); +// Horizontal overlap functions + +},{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":121}],110:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _Style = require("../Style"); + +var _Style2 = _interopRequireDefault(_Style); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var chooseMathStyle = function chooseMathStyle(group, options) { + var style = options.style; + if (style.size === _Style2.default.DISPLAY.size) { + return group.value.display; + } else if (style.size === _Style2.default.TEXT.size) { + return group.value.text; + } else if (style.size === _Style2.default.SCRIPT.size) { + return group.value.script; + } else if (style.size === _Style2.default.SCRIPTSCRIPT.size) { + return group.value.scriptscript; + } + return group.value.text; }; -/** - * Converts the math node into a MathML-namespaced DOM element. - */ -MathNode.prototype.toNode = function() { - var node = document.createElementNS( - "http://www.w3.org/1998/Math/MathML", this.type); +(0, _defineFunction2.default)({ + type: "mathchoice", + names: ["\\mathchoice"], + props: { + numArgs: 4 + }, + handler: function handler(context, args) { + return { + type: "mathchoice", + display: (0, _defineFunction.ordargument)(args[0]), + text: (0, _defineFunction.ordargument)(args[1]), + script: (0, _defineFunction.ordargument)(args[2]), + scriptscript: (0, _defineFunction.ordargument)(args[3]) + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + var body = chooseMathStyle(group, options); + var elements = html.buildExpression(body, options, false); + return new _buildCommon2.default.makeFragment(elements); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var body = chooseMathStyle(group, options); + var elements = mml.buildExpression(body, options, false); + return new _mathMLTree2.default.MathNode("mrow", elements); + } +}); + +},{"../Style":89,"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":121}],111:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _Style = require("../Style"); + +var _Style2 = _interopRequireDefault(_Style); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// \mod-type functions +var htmlModBuilder = function htmlModBuilder(group, options) { + var inner = []; + + if (group.value.modType === "bmod") { + // “\nonscript\mskip-\medmuskip\mkern5mu”, where \medmuskip is + // 4mu plus 2mu minus 1mu, translates to 1mu space in + // display/textstyle and 5mu space in script/scriptscriptstyle. + if (!options.style.isTight()) { + inner.push(_buildCommon2.default.makeSpan(["mspace", "muspace"], [], options)); + } else { + inner.push(_buildCommon2.default.makeSpan(["mspace", "thickspace"], [], options)); + } + } else if (options.style.size === _Style2.default.DISPLAY.size) { + inner.push(_buildCommon2.default.makeSpan(["mspace", "quad"], [], options)); + } else if (group.value.modType === "mod") { + inner.push(_buildCommon2.default.makeSpan(["mspace", "twelvemuspace"], [], options)); + } else { + inner.push(_buildCommon2.default.makeSpan(["mspace", "eightmuspace"], [], options)); + } + + if (group.value.modType === "pod" || group.value.modType === "pmod") { + inner.push(_buildCommon2.default.mathsym("(", group.mode)); + } - for (var attr in this.attributes) { - if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - node.setAttribute(attr, this.attributes[attr]); + if (group.value.modType !== "pod") { + var modInner = [_buildCommon2.default.mathsym("m", group.mode), _buildCommon2.default.mathsym("o", group.mode), _buildCommon2.default.mathsym("d", group.mode)]; + if (group.value.modType === "bmod") { + inner.push(_buildCommon2.default.makeSpan(["mbin"], modInner, options)); + // “\mkern5mu\nonscript\mskip-\medmuskip” as above + if (!options.style.isTight()) { + inner.push(_buildCommon2.default.makeSpan(["mspace", "muspace"], [], options)); + } else { + inner.push(_buildCommon2.default.makeSpan(["mspace", "thickspace"], [], options)); + } + } else { + Array.prototype.push.apply(inner, modInner); + inner.push(_buildCommon2.default.makeSpan(["mspace", "sixmuspace"], [], options)); } } - for (var i = 0; i < this.children.length; i++) { - node.appendChild(this.children[i].toNode()); + if (group.value.value) { + Array.prototype.push.apply(inner, html.buildExpression(group.value.value, options, false)); + } + + if (group.value.modType === "pod" || group.value.modType === "pmod") { + inner.push(_buildCommon2.default.mathsym(")", group.mode)); + } + + return _buildCommon2.default.makeFragment(inner); +}; + +var mmlModBuilder = function mmlModBuilder(group, options) { + var inner = []; + + if (group.value.modType === "pod" || group.value.modType === "pmod") { + inner.push(new _mathMLTree2.default.MathNode("mo", [mml.makeText("(", group.mode)])); + } + if (group.value.modType !== "pod") { + inner.push(new _mathMLTree2.default.MathNode("mo", [mml.makeText("mod", group.mode)])); + } + if (group.value.value) { + var space = new _mathMLTree2.default.MathNode("mspace"); + space.setAttribute("width", "0.333333em"); + inner.push(space); + inner = inner.concat(mml.buildExpression(group.value.value, options)); + } + if (group.value.modType === "pod" || group.value.modType === "pmod") { + inner.push(new _mathMLTree2.default.MathNode("mo", [mml.makeText(")", group.mode)])); + } + + return new _mathMLTree2.default.MathNode("mo", inner); +}; + +(0, _defineFunction2.default)({ + type: "mod", + names: ["\\bmod"], + props: { + numArgs: 0 + }, + handler: function handler(context, args) { + return { + type: "mod", + modType: "bmod", + value: null + }; + }, + htmlBuilder: htmlModBuilder, + mathmlBuilder: mmlModBuilder +}); + +// Note: calling defineFunction with a type that's already been defined only +// works because the same htmlBuilder and mathmlBuilder are being used. +(0, _defineFunction2.default)({ + type: "mod", + names: ["\\pod", "\\pmod", "\\mod"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "mod", + modType: context.funcName.substr(1), + value: (0, _defineFunction.ordargument)(body) + }; + }, + htmlBuilder: htmlModBuilder, + mathmlBuilder: mmlModBuilder +}); + +},{"../Style":89,"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":121}],112:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _domTree = require("../domTree"); + +var _domTree2 = _interopRequireDefault(_domTree); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _utils = require("../utils"); + +var _utils2 = _interopRequireDefault(_utils); + +var _Style = require("../Style"); + +var _Style2 = _interopRequireDefault(_Style); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Limits, symbols +var htmlBuilder = function htmlBuilder(group, options) { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + var supGroup = void 0; + var subGroup = void 0; + var hasLimits = false; + if (group.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = group.value.sup; + subGroup = group.value.sub; + group = group.value.base; + hasLimits = true; + } + + var style = options.style; + + // Most operators have a large successor symbol, but these don't. + var noSuccessor = ["\\smallint"]; + + var large = false; + if (style.size === _Style2.default.DISPLAY.size && group.value.symbol && !_utils2.default.contains(noSuccessor, group.value.body)) { + + // Most symbol operators get larger in displaystyle (rule 13) + large = true; + } + + var base = void 0; + if (group.value.symbol) { + // If this is a symbol, create the symbol. + var fontName = large ? "Size2-Regular" : "Size1-Regular"; + base = _buildCommon2.default.makeSymbol(group.value.body, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]); + } else if (group.value.value) { + // If this is a list, compose that list. + var inner = html.buildExpression(group.value.value, options, true); + if (inner.length === 1 && inner[0] instanceof _domTree2.default.symbolNode) { + base = inner[0]; + base.classes[0] = "mop"; // replace old mclass + } else { + base = _buildCommon2.default.makeSpan(["mop"], inner, options); + } + } else { + // Otherwise, this is a text operator. Build the text from the + // operator's name. + // TODO(emily): Add a space in the middle of some of these + // operators, like \limsup + var output = []; + for (var i = 1; i < group.value.body.length; i++) { + output.push(_buildCommon2.default.mathsym(group.value.body[i], group.mode)); + } + base = _buildCommon2.default.makeSpan(["mop"], output, options); + } + + // If content of op is a single symbol, shift it vertically. + var baseShift = 0; + var slant = 0; + if (base instanceof _domTree2.default.symbolNode) { + // Shift the symbol so its center lies on the axis (rule 13). It + // appears that our fonts have the centers of the symbols already + // almost on the axis, so these numbers are very small. Note we + // don't actually apply this here, but instead it is used either in + // the vlist creation or separately when there are no limits. + baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight; + + // The slant of the symbol is just its italic correction. + slant = base.italic; + } + + if (hasLimits) { + // IE 8 clips \int if it is in a display: inline-block. We wrap it + // in a new span so it is an inline, and works. + base = _buildCommon2.default.makeSpan([], [base]); + + var sub = void 0; + var sup = void 0; + // We manually have to handle the superscripts and subscripts. This, + // aside from the kern calculations, is copied from supsub. + if (supGroup) { + var elem = html.buildGroup(supGroup, options.havingStyle(style.sup()), options); + + sup = { + elem: elem, + kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth) + }; + } + + if (subGroup) { + var _elem = html.buildGroup(subGroup, options.havingStyle(style.sub()), options); + + sub = { + elem: _elem, + kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height) + }; + } + + // Build the final group as a vlist of the possible subscript, base, + // and possible superscript. + var finalGroup = void 0; + if (sup && sub) { + var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; + + finalGroup = _buildCommon2.default.makeVList({ + positionType: "bottom", + positionData: bottom, + children: [{ type: "kern", size: options.fontMetrics().bigOpSpacing5 }, { type: "elem", elem: sub.elem, marginLeft: -slant + "em" }, { type: "kern", size: sub.kern }, { type: "elem", elem: base }, { type: "kern", size: sup.kern }, { type: "elem", elem: sup.elem, marginLeft: slant + "em" }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 }] + }, options); + } else if (sub) { + var top = base.height - baseShift; + + // Shift the limits by the slant of the symbol. Note + // that we are supposed to shift the limits by 1/2 of the slant, + // but since we are centering the limits adding a full slant of + // margin will shift by 1/2 that. + finalGroup = _buildCommon2.default.makeVList({ + positionType: "top", + positionData: top, + children: [{ type: "kern", size: options.fontMetrics().bigOpSpacing5 }, { type: "elem", elem: sub.elem, marginLeft: -slant + "em" }, { type: "kern", size: sub.kern }, { type: "elem", elem: base }] + }, options); + } else if (sup) { + var _bottom = base.depth + baseShift; + + finalGroup = _buildCommon2.default.makeVList({ + positionType: "bottom", + positionData: _bottom, + children: [{ type: "elem", elem: base }, { type: "kern", size: sup.kern }, { type: "elem", elem: sup.elem, marginLeft: slant + "em" }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 }] + }, options); + } else { + // This case probably shouldn't occur (this would mean the + // supsub was sending us a group with no superscript or + // subscript) but be safe. + return base; + } + + return _buildCommon2.default.makeSpan(["mop", "op-limits"], [finalGroup], options); + } else { + if (baseShift) { + base.style.position = "relative"; + base.style.top = baseShift + "em"; + } + + return base; + } +}; + +var mathmlBuilder = function mathmlBuilder(group, options) { + var node = void 0; + + // TODO(emily): handle big operators using the `largeop` attribute + + if (group.value.symbol) { + // This is a symbol. Just add the symbol. + node = new _mathMLTree2.default.MathNode("mo", [mml.makeText(group.value.body, group.mode)]); + } else if (group.value.value) { + // This is an operator with children. Add them. + node = new _mathMLTree2.default.MathNode("mo", mml.buildExpression(group.value.value, options)); + } else { + // This is a text operator. Add all of the characters from the + // operator's name. + // TODO(emily): Add a space in the middle of some of these + // operators, like \limsup. + node = new _mathMLTree2.default.MathNode("mi", [new _mathMLTree2.default.TextNode(group.value.body.slice(1))]); + + // Append an <mo>⁡</mo>. + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + var operator = new _mathMLTree2.default.MathNode("mo", [mml.makeText("\u2061", "text")]); + + return new _domTree2.default.documentFragment([node, operator]); } return node; }; -/** - * Converts the math node into an HTML markup string. - */ -MathNode.prototype.toMarkup = function() { - var markup = "<" + this.type; +var singleCharBigOps = { + "\u220F": "\\prod", + "\u2210": "\\coprod", + "\u2211": "\\sum", + "\u22C0": "\\bigwedge", + "\u22C1": "\\bigvee", + "\u22C2": "\\bigcap", + "\u22C3": "\\bigcap", + "\u2A00": "\\bigodot", + "\u2A01": "\\bigoplus", + "\u2A02": "\\bigotimes", + "\u2A04": "\\biguplus", + "\u2A06": "\\bigsqcup" +}; + +(0, _defineFunction2.default)({ + type: "op", + names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22C0", "\u22C1", "\u22C2", "\u22C3", "\u2A00", "\u2A01", "\u2A02", "\u2A04", "\u2A06"], + props: { + numArgs: 0 + }, + handler: function handler(context, args) { + var fName = context.funcName; + if (fName.length === 1) { + fName = singleCharBigOps[fName]; + } + return { + type: "op", + limits: true, + symbol: true, + body: fName + }; + }, + htmlBuilder: htmlBuilder, + mathmlBuilder: mathmlBuilder +}); + +// Note: calling defineFunction with a type that's already been defined only +// works because the same htmlBuilder and mathmlBuilder are being used. +(0, _defineFunction2.default)({ + type: "op", + names: ["\\mathop"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "op", + limits: false, + symbol: false, + value: (0, _defineFunction.ordargument)(body) + }; + }, + htmlBuilder: htmlBuilder, + mathmlBuilder: mathmlBuilder +}); + +},{"../Style":89,"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../domTree":98,"../mathMLTree":121,"../utils":128}],113:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _domTree = require("../domTree"); + +var _domTree2 = _interopRequireDefault(_domTree); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// \operatorname +// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@ +(0, _defineFunction2.default)({ + type: "operatorname", + names: ["\\operatorname"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "operatorname", + value: (0, _defineFunction.ordargument)(body) + }; + }, + + htmlBuilder: function htmlBuilder(group, options) { + var output = []; + if (group.value.value.length > 0) { + var letter = ""; + var mode = ""; + + // Consolidate Greek letter function names into symbol characters. + var temp = html.buildExpression(group.value.value, options, true); + + // All we want from temp are the letters. With them, we'll + // create a text operator similar to \tan or \cos. + for (var i = 0; i < temp.length; i++) { + letter = temp[i].value; + + // In the amsopn package, \newmcodes@ changes four + // characters, *-/:’, from math operators back into text. + // Given what is in temp, we have to address two of them. + letter = letter.replace(/\u2212/, "-"); // minus => hyphen + letter = letter.replace(/\u2217/, "*"); + + // Use math mode for Greek letters + mode = /[\u0391-\u03D7]/.test(letter) ? "math" : "text"; + output.push(_buildCommon2.default.mathsym(letter, mode)); + } + } + return _buildCommon2.default.makeSpan(["mop"], output, options); + }, + + mathmlBuilder: function mathmlBuilder(group, options) { + // The steps taken here are similar to the html version. + var output = []; + if (group.value.value.length > 0) { + var temp = mml.buildExpression(group.value.value, options); + + var word = ""; + for (var i = 0; i < temp.length; i++) { + word += temp[i].children[0].text; + } + word = word.replace(/\u2212/g, "-"); + word = word.replace(/\u2217/g, "*"); + output = [new _mathMLTree2.default.TextNode(word)]; + } + var identifier = new _mathMLTree2.default.MathNode("mi", output); + identifier.setAttribute("mathvariant", "normal"); + + // \u2061 is the same as ⁡ + // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp + var operator = new _mathMLTree2.default.MathNode("mo", [mml.makeText("\u2061", "text")]); + + return new _domTree2.default.documentFragment([identifier, operator]); + } +}); + +},{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../domTree":98,"../mathMLTree":121}],114:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _defineFunction2.default)({ + type: "overline", + names: ["\\overline"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "overline", + body: body + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + // Overlines are handled in the TeXbook pg 443, Rule 9. + + // Build the inner group in the cramped style. + var innerGroup = html.buildGroup(group.value.body, options.havingCrampedStyle()); + + // Create the line above the body + var line = _buildCommon2.default.makeLineSpan("overline-line", options); + + // Generate the vlist, with the appropriate kerns + var vlist = _buildCommon2.default.makeVList({ + positionType: "firstBaseline", + children: [{ type: "elem", elem: innerGroup }, { type: "kern", size: 3 * line.height }, { type: "elem", elem: line }, { type: "kern", size: line.height }] + }, options); + + return _buildCommon2.default.makeSpan(["mord", "overline"], [vlist], options); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var operator = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode("\u203E")]); + operator.setAttribute("stretchy", "true"); + + var node = new _mathMLTree2.default.MathNode("mover", [mml.buildGroup(group.value.body, options), operator]); + node.setAttribute("accent", "true"); + + return node; + } +}); + +},{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":121}],115:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _defineFunction2.default)({ + type: "phantom", + names: ["\\phantom"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "phantom", + value: (0, _defineFunction.ordargument)(body) + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + var elements = html.buildExpression(group.value.value, options.withPhantom(), false); + + // \phantom isn't supposed to affect the elements it contains. + // See "color" for more details. + return new _buildCommon2.default.makeFragment(elements); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var inner = mml.buildExpression(group.value.value, options); + return new _mathMLTree2.default.MathNode("mphantom", inner); + } +}); + + +(0, _defineFunction2.default)({ + type: "hphantom", + names: ["\\hphantom"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "hphantom", + value: (0, _defineFunction.ordargument)(body), + body: body + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + var node = _buildCommon2.default.makeSpan([], [html.buildGroup(group.value.body, options.withPhantom())]); + node.height = 0; + node.depth = 0; + if (node.children) { + for (var i = 0; i < node.children.length; i++) { + node.children[i].height = 0; + node.children[i].depth = 0; + } + } + + // See smash for comment re: use of makeVList + node = _buildCommon2.default.makeVList({ + positionType: "firstBaseline", + children: [{ type: "elem", elem: node }] + }, options); + + return node; + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var inner = mml.buildExpression(group.value.value, options); + var node = new _mathMLTree2.default.MathNode("mphantom", inner); + node.setAttribute("height", "0px"); + return node; + } +}); + +(0, _defineFunction2.default)({ + type: "vphantom", + names: ["\\vphantom"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "vphantom", + value: (0, _defineFunction.ordargument)(body), + body: body + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + var inner = _buildCommon2.default.makeSpan(["inner"], [html.buildGroup(group.value.body, options.withPhantom())]); + var fix = _buildCommon2.default.makeSpan(["fix"], []); + return _buildCommon2.default.makeSpan(["mord", "rlap"], [inner, fix], options); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var inner = mml.buildExpression(group.value.value, options); + var node = new _mathMLTree2.default.MathNode("mphantom", inner); + node.setAttribute("width", "0px"); + return node; + } +}); + +},{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":121}],116:[function(require,module,exports){ +"use strict"; + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _units = require("../units"); - // Add the attributes - for (var attr in this.attributes) { - if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - markup += " " + attr + "=\""; - markup += utils.escape(this.attributes[attr]); - markup += "\""; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _defineFunction2.default)({ + type: "rule", + names: ["\\rule"], + props: { + numArgs: 2, + numOptionalArgs: 1, + argTypes: ["size", "size", "size"] + }, + handler: function handler(context, args, optArgs) { + var shift = optArgs[0]; + var width = args[0]; + var height = args[1]; + return { + type: "rule", + shift: shift && shift.value, + width: width.value, + height: height.value + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + // Make an empty span for the rule + var rule = _buildCommon2.default.makeSpan(["mord", "rule"], [], options); + + // Calculate the shift, width, and height of the rule, and account for units + var shift = 0; + if (group.value.shift) { + shift = (0, _units.calculateSize)(group.value.shift, options); } + + var width = (0, _units.calculateSize)(group.value.width, options); + var height = (0, _units.calculateSize)(group.value.height, options); + + // Style the rule to the right size + rule.style.borderRightWidth = width + "em"; + rule.style.borderTopWidth = height + "em"; + rule.style.bottom = shift + "em"; + + // Record the height and width + rule.width = width; + rule.height = height + shift; + rule.depth = -shift; + // Font size is the number large enough that the browser will + // reserve at least `absHeight` space above the baseline. + // The 1.125 factor was empirically determined + rule.maxFontSize = height * 1.125 * options.sizeMultiplier; + + return rule; + }, + mathmlBuilder: function mathmlBuilder(group, options) { + // TODO(emily): Figure out if there's an actual way to draw black boxes + // in MathML. + var node = new _mathMLTree2.default.MathNode("mrow"); + + return node; } +}); + +},{"../buildCommon":91,"../defineFunction":96,"../mathMLTree":121,"../units":127}],117:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); - markup += ">"; +var _buildHTML = require("../buildHTML"); - for (var i = 0; i < this.children.length; i++) { - markup += this.children[i].toMarkup(); +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _defineFunction2.default)({ + type: "smash", + names: ["\\smash"], + props: { + numArgs: 1, + numOptionalArgs: 1, + allowedInText: true + }, + handler: function handler(context, args, optArgs) { + var smashHeight = false; + var smashDepth = false; + var tbArg = optArgs[0]; + if (tbArg) { + // Optional [tb] argument is engaged. + // ref: amsmath: \renewcommand{\smash}[1][tb]{% + // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + var letter = ""; + for (var i = 0; i < tbArg.value.length; ++i) { + letter = tbArg.value[i].value; + if (letter === "t") { + smashHeight = true; + } else if (letter === "b") { + smashDepth = true; + } else { + smashHeight = false; + smashDepth = false; + break; + } + } + } else { + smashHeight = true; + smashDepth = true; + } + + var body = args[0]; + return { + type: "smash", + body: body, + smashHeight: smashHeight, + smashDepth: smashDepth + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + var node = _buildCommon2.default.makeSpan(["mord"], [html.buildGroup(group.value.body, options)]); + + if (!group.value.smashHeight && !group.value.smashDepth) { + return node; + } + + if (group.value.smashHeight) { + node.height = 0; + // In order to influence makeVList, we have to reset the children. + if (node.children) { + for (var i = 0; i < node.children.length; i++) { + node.children[i].height = 0; + } + } + } + + if (group.value.smashDepth) { + node.depth = 0; + if (node.children) { + for (var _i = 0; _i < node.children.length; _i++) { + node.children[_i].depth = 0; + } + } + } + + // At this point, we've reset the TeX-like height and depth values. + // But the span still has an HTML line height. + // makeVList applies "display: table-cell", which prevents the browser + // from acting on that line height. So we'll call makeVList now. + + return _buildCommon2.default.makeVList({ + positionType: "firstBaseline", + children: [{ type: "elem", elem: node }] + }, options); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var node = new _mathMLTree2.default.MathNode("mpadded", [mml.buildGroup(group.value.body, options)]); + + if (group.value.smashHeight) { + node.setAttribute("height", "0px"); + } + + if (group.value.smashDepth) { + node.setAttribute("depth", "0px"); + } + + return node; } +}); +// smash, with optional [tb], as in AMS + +},{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":121}],118:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); - markup += "</" + this.type + ">"; +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - return markup; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Non-mathy text, possibly in a font +var textFunctionFonts = { + "\\text": undefined, "\\textrm": "mathrm", "\\textsf": "mathsf", + "\\texttt": "mathtt", "\\textnormal": "mathrm", "\\textbf": "mathbf", + "\\textit": "textit" }; + +(0, _defineFunction2.default)({ + type: "text", + names: ["\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", "\\textbf", "\\textit"], + props: { + numArgs: 1, + argTypes: ["text"], + greediness: 2, + allowedInText: true + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "text", + body: (0, _defineFunction.ordargument)(body), + font: textFunctionFonts[context.funcName] + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + var newOptions = options.withFont(group.value.font); + var inner = html.buildExpression(group.value.body, newOptions, true); + _buildCommon2.default.tryCombineChars(inner); + return _buildCommon2.default.makeSpan(["mord", "text"], inner, newOptions); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var body = group.value.body; + + // Convert each element of the body into MathML, and combine consecutive + // <mtext> outputs into a single <mtext> tag. In this way, we don't + // nest non-text items (e.g., $nested-math$) within an <mtext>. + var inner = []; + var currentText = null; + for (var i = 0; i < body.length; i++) { + var _group = mml.buildGroup(body[i], options); + if (_group.type === 'mtext' && currentText != null) { + Array.prototype.push.apply(currentText.children, _group.children); + } else { + inner.push(_group); + if (_group.type === 'mtext') { + currentText = _group; + } + } + } + + // If there is a single tag in the end (presumably <mtext>), + // just return it. Otherwise, wrap them in an <mrow>. + if (inner.length === 1) { + return inner[0]; + } else { + return new _mathMLTree2.default.MathNode("mrow", inner); + } + } +}); + +},{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":121}],119:[function(require,module,exports){ +"use strict"; + +var _defineFunction = require("../defineFunction"); + +var _defineFunction2 = _interopRequireDefault(_defineFunction); + +var _buildCommon = require("../buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("../mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _buildHTML = require("../buildHTML"); + +var html = _interopRequireWildcard(_buildHTML); + +var _buildMathML = require("../buildMathML"); + +var mml = _interopRequireWildcard(_buildMathML); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +(0, _defineFunction2.default)({ + type: "underline", + names: ["\\underline"], + props: { + numArgs: 1 + }, + handler: function handler(context, args) { + var body = args[0]; + return { + type: "underline", + body: body + }; + }, + htmlBuilder: function htmlBuilder(group, options) { + // Underlines are handled in the TeXbook pg 443, Rule 10. + // Build the inner group. + var innerGroup = html.buildGroup(group.value.body, options); + + // Create the line above the body + var line = _buildCommon2.default.makeLineSpan("underline-line", options); + + // Generate the vlist, with the appropriate kerns + var vlist = _buildCommon2.default.makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ type: "kern", size: line.height }, { type: "elem", elem: line }, { type: "kern", size: 3 * line.height }, { type: "elem", elem: innerGroup }] + }, options); + + return _buildCommon2.default.makeSpan(["mord", "underline"], [vlist], options); + }, + mathmlBuilder: function mathmlBuilder(group, options) { + var operator = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode("\u203E")]); + operator.setAttribute("stretchy", "true"); + + var node = new _mathMLTree2.default.MathNode("munder", [mml.buildGroup(group.value.body, options), operator]); + node.setAttribute("accentunder", "true"); + + return node; + } +}); + +},{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":121}],120:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _fontMetricsData = require("./fontMetricsData"); + +var _fontMetricsData2 = _interopRequireDefault(_fontMetricsData); + +var _symbols = require("./symbols"); + +var _symbols2 = _interopRequireDefault(_symbols); + +var _utils = require("./utils"); + +var _utils2 = _interopRequireDefault(_utils); + +var _Token = require("./Token"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + /** - * This node represents a piece of text. + * Provides context to macros defined by functions. Implemented by + * MacroExpander. + */ + + +/** Macro tokens (in reverse order). */ + +/** + * Predefined macros for KaTeX. + * This can be used to define some commands in terms of others. */ -function TextNode(text) { - this.text = text; + +var builtinMacros = {}; +exports.default = builtinMacros; + +// This function might one day accept an additional argument and do more things. + +function defineMacro(name, body) { + builtinMacros[name] = body; } +////////////////////////////////////////////////////////////////////// +// macro tools + +defineMacro("\\@firstoftwo", function (context) { + var args = context.consumeArgs(2); + return { tokens: args[0], numArgs: 0 }; +}); + +defineMacro("\\@ifnextchar", function (context) { + var args = context.consumeArgs(3); // symbol, if, else + var nextToken = context.future(); + if (args[0].length === 1 && args[0][0].text === nextToken.text) { + return { tokens: args[1], numArgs: 0 }; + } else { + return { tokens: args[2], numArgs: 0 }; + } +}); + +// \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} +defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); + +////////////////////////////////////////////////////////////////////// +// basics +defineMacro("\\bgroup", "{"); +defineMacro("\\egroup", "}"); +defineMacro("\\begingroup", "{"); +defineMacro("\\endgroup", "}"); + +// Unicode double-struck letters +defineMacro("\u2102", "\\mathbb{C}"); +defineMacro("\u210D", "\\mathbb{H}"); +defineMacro("\u2115", "\\mathbb{N}"); +defineMacro("\u2119", "\\mathbb{P}"); +defineMacro("\u211A", "\\mathbb{Q}"); +defineMacro("\u211D", "\\mathbb{R}"); +defineMacro("\u2124", "\\mathbb{Z}"); + +// \llap and \rlap render their contents in text mode +defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); +defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); + +////////////////////////////////////////////////////////////////////// +// amsmath.sty +// http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf + +// \def\overset#1#2{\binrel@{#2}\binrel@@{\mathop{\kern\z@#2}\limits^{#1}}} +defineMacro("\\overset", "\\mathop{#2}\\limits^{#1}"); +defineMacro("\\underset", "\\mathop{#2}\\limits_{#1}"); + +// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +defineMacro("\\boxed", "\\fbox{\\displaystyle{#1}}"); + +// \def\iff{\DOTSB\;\Longleftrightarrow\;} +// \def\implies{\DOTSB\;\Longrightarrow\;} +// \def\impliedby{\DOTSB\;\Longleftarrow\;} +defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); +defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); +defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); + +// AMSMath's automatic \dots, based on \mdots@@ macro. +var dotsByToken = { + ',': '\\dotsc', + '\\not': '\\dotsb', + // \keybin@ checks for the following: + '+': '\\dotsb', + '=': '\\dotsb', + '<': '\\dotsb', + '>': '\\dotsb', + '-': '\\dotsb', + '*': '\\dotsb', + ':': '\\dotsb', + // Symbols whose definition starts with \DOTSB: + '\\DOTSB': '\\dotsb', + '\\coprod': '\\dotsb', + '\\bigvee': '\\dotsb', + '\\bigwedge': '\\dotsb', + '\\biguplus': '\\dotsb', + '\\bigcap': '\\dotsb', + '\\bigcup': '\\dotsb', + '\\prod': '\\dotsb', + '\\sum': '\\dotsb', + '\\bigotimes': '\\dotsb', + '\\bigoplus': '\\dotsb', + '\\bigodot': '\\dotsb', + '\\bigsqcup': '\\dotsb', + '\\implies': '\\dotsb', + '\\impliedby': '\\dotsb', + '\\And': '\\dotsb', + '\\longrightarrow': '\\dotsb', + '\\Longrightarrow': '\\dotsb', + '\\longleftarrow': '\\dotsb', + '\\Longleftarrow': '\\dotsb', + '\\longleftrightarrow': '\\dotsb', + '\\Longleftrightarrow': '\\dotsb', + '\\mapsto': '\\dotsb', + '\\longmapsto': '\\dotsb', + '\\hookrightarrow': '\\dotsb', + '\\iff': '\\dotsb', + '\\doteq': '\\dotsb', + // Symbols whose definition starts with \mathbin: + '\\mathbin': '\\dotsb', + '\\bmod': '\\dotsb', + // Symbols whose definition starts with \mathrel: + '\\mathrel': '\\dotsb', + '\\relbar': '\\dotsb', + '\\Relbar': '\\dotsb', + '\\xrightarrow': '\\dotsb', + '\\xleftarrow': '\\dotsb', + // Symbols whose definition starts with \DOTSI: + '\\DOTSI': '\\dotsi', + '\\int': '\\dotsi', + '\\oint': '\\dotsi', + '\\iint': '\\dotsi', + '\\iiint': '\\dotsi', + '\\iiiint': '\\dotsi', + '\\idotsint': '\\dotsi', + // Symbols whose definition starts with \DOTSX: + '\\DOTSX': '\\dotsx' +}; + +defineMacro("\\dots", function (context) { + // TODO: If used in text mode, should expand to \textellipsis. + // However, in KaTeX, \textellipsis and \ldots behave the same + // (in text mode), and it's unlikely we'd see any of the math commands + // that affect the behavior of \dots when in text mode. So fine for now + // (until we support \ifmmode ... \else ... \fi). + var thedots = '\\dotso'; + var next = context.expandAfterFuture().text; + if (next in dotsByToken) { + thedots = dotsByToken[next]; + } else if (next.substr(0, 4) === '\\not') { + thedots = '\\dotsb'; + } else if (next in _symbols2.default.math) { + if (_utils2.default.contains(['bin', 'rel'], _symbols2.default.math[next].group)) { + thedots = '\\dotsb'; + } + } + return thedots; +}); + +var spaceAfterDots = { + // \rightdelim@ checks for the following: + ')': true, + ']': true, + '\\rbrack': true, + '\\}': true, + '\\rbrace': true, + '\\rangle': true, + '\\rceil': true, + '\\rfloor': true, + '\\rgroup': true, + '\\rmoustache': true, + '\\right': true, + '\\bigr': true, + '\\biggr': true, + '\\Bigr': true, + '\\Biggr': true, + // \extra@ also tests for the following: + '$': true, + // \extrap@ checks for the following: + ';': true, + '.': true, + ',': true +}; + +defineMacro("\\dotso", function (context) { + var next = context.future().text; + if (next in spaceAfterDots) { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); + +defineMacro("\\dotsc", function (context) { + var next = context.future().text; + // \dotsc uses \extra@ but not \extrap@, instead specially checking for + // ';' and '.', but doesn't check for ','. + if (next in spaceAfterDots && next !== ',') { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); + +defineMacro("\\cdots", function (context) { + var next = context.future().text; + if (next in spaceAfterDots) { + return "\\@cdots\\,"; + } else { + return "\\@cdots"; + } +}); + +defineMacro("\\dotsb", "\\cdots"); +defineMacro("\\dotsm", "\\cdots"); +defineMacro("\\dotsi", "\\!\\cdots"); +// amsmath doesn't actually define \dotsx, but \dots followed by a macro +// starting with \DOTSX implies \dotso, and then \extra@ detects this case +// and forces the added `\,`. +defineMacro("\\dotsx", "\\ldots\\,"); + +// \let\DOTSI\relax +// \let\DOTSB\relax +// \let\DOTSX\relax +defineMacro("\\DOTSI", "\\relax"); +defineMacro("\\DOTSB", "\\relax"); +defineMacro("\\DOTSX", "\\relax"); + +// http://texdoc.net/texmf-dist/doc/latex/amsmath/amsmath.pdf +defineMacro("\\thinspace", "\\,"); // \let\thinspace\, +defineMacro("\\medspace", "\\:"); // \let\medspace\: +defineMacro("\\thickspace", "\\;"); // \let\thickspace\; + +////////////////////////////////////////////////////////////////////// +// LaTeX source2e + +// \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +// TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't +// support \@ yet, so that's omitted, and we add \text so that the result +// doesn't look funny in math mode. +defineMacro("\\TeX", "\\textrm{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}"); + +// \DeclareRobustCommand{\LaTeX}{L\kern-.36em% +// {\sbox\z@ T% +// \vbox to\ht\z@{\hbox{\check@mathfonts +// \fontsize\sf@size\z@ +// \math@fontsfalse\selectfont +// A}% +// \vss}% +// }% +// \kern-.15em% +// \TeX} +// This code aligns the top of the A with the T (from the perspective of TeX's +// boxes, though visually the A appears to extend above slightly). +// We compute the corresponding \raisebox when A is rendered at \scriptsize, +// which is size3, which has a scale factor of 0.7 (see Options.js). +var latexRaiseA = _fontMetricsData2.default['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * _fontMetricsData2.default['Main-Regular']["A".charCodeAt(0)][1] + "em"; +defineMacro("\\LaTeX", "\\textrm{L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptsize A}" + "\\kern-.15em\\TeX}"); + +// New KaTeX logo based on tweaking LaTeX logo +defineMacro("\\KaTeX", "\\textrm{K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptsize A}" + "\\kern-.15em\\TeX}"); + +// \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} +// \def\@hspace#1{\hskip #1\relax} +// KaTeX doesn't do line breaks, so \hspace and \hspace* are the same as \kern +defineMacro("\\hspace", "\\@ifstar\\kern\\kern"); + +////////////////////////////////////////////////////////////////////// +// mathtools.sty + +//\providecommand\ordinarycolon{:} +defineMacro("\\ordinarycolon", ":"); +//\def\vcentcolon{\mathrel{\mathop\ordinarycolon}} +//TODO(edemaine): Not yet centered. Fix via \raisebox or #726 +defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); +// \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon} +defineMacro("\\dblcolon", "\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon"); +// \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\coloneqq", "\\vcentcolon\\mathrel{\\mkern-1.2mu}="); +// \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\Coloneqq", "\\dblcolon\\mathrel{\\mkern-1.2mu}="); +// \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\coloneq", "\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}"); +// \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\Coloneq", "\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}"); +// \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqqcolon", "=\\mathrel{\\mkern-1.2mu}\\vcentcolon"); +// \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqqcolon", "=\\mathrel{\\mkern-1.2mu}\\dblcolon"); +// \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqcolon", "\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon"); +// \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqcolon", "\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon"); +// \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\colonapprox", "\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx"); +// \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\Colonapprox", "\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx"); +// \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\colonsim", "\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim"); +// \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\Colonsim", "\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim"); + +////////////////////////////////////////////////////////////////////// +// colonequals.sty + +// Alternate names for mathtools's macros: +defineMacro("\\ratio", "\\vcentcolon"); +defineMacro("\\coloncolon", "\\dblcolon"); +defineMacro("\\colonequals", "\\coloneqq"); +defineMacro("\\coloncolonequals", "\\Coloneqq"); +defineMacro("\\equalscolon", "\\eqqcolon"); +defineMacro("\\equalscoloncolon", "\\Eqqcolon"); +defineMacro("\\colonminus", "\\coloneq"); +defineMacro("\\coloncolonminus", "\\Coloneq"); +defineMacro("\\minuscolon", "\\eqcolon"); +defineMacro("\\minuscoloncolon", "\\Eqcolon"); +// \colonapprox name is same in mathtools and colonequals. +defineMacro("\\coloncolonapprox", "\\Colonapprox"); +// \colonsim name is same in mathtools and colonequals. +defineMacro("\\coloncolonsim", "\\Colonsim"); + +// Additional macros, implemented by analogy with mathtools definitions: +defineMacro("\\simcolon", "\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon"); +defineMacro("\\simcoloncolon", "\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon"); +defineMacro("\\approxcolon", "\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon"); +defineMacro("\\approxcoloncolon", "\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon"); + +// Present in newtxmath, pxfonts and txfonts +// TODO: The unicode character U+220C ∌ should be added to the font, and this +// macro turned into a propper defineSymbol in symbols.js. That way, the +// MathML result will be much cleaner. +defineMacro("\\notni", "\\not\\ni"); + +},{"./Token":90,"./fontMetricsData":102,"./symbols":125,"./utils":128}],121:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _getIterator2 = require("babel-runtime/core-js/get-iterator"); + +var _getIterator3 = _interopRequireDefault(_getIterator2); + +var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = require("babel-runtime/helpers/createClass"); + +var _createClass3 = _interopRequireDefault(_createClass2); + +var _utils = require("./utils"); + +var _utils2 = _interopRequireDefault(_utils); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + /** - * Converts the text node into a DOM text node. + * This node represents a general purpose MathML node of any type. The + * constructor requires the type of node to create (for example, `"mo"` or + * `"mspace"`, corresponding to `<mo>` and `<mspace>` tags). */ -TextNode.prototype.toNode = function() { - return document.createTextNode(this.text); -}; + /** - * Converts the text node into HTML markup (which is just the text itself). + * MathML node types used in KaTeX. For a complete list of MathML nodes, see + * https://developer.mozilla.org/en-US/docs/Web/MathML/Element. */ -TextNode.prototype.toMarkup = function() { - return utils.escape(this.text); -}; +var MathNode = function () { + function MathNode(type, children) { + (0, _classCallCheck3.default)(this, MathNode); -module.exports = { - MathNode: MathNode, - TextNode: TextNode, -}; + this.type = type; + this.attributes = {}; + this.children = children || []; + } + + /** + * Sets an attribute on a MathML node. MathML depends on attributes to convey a + * semantic content, so this is used heavily. + */ + + + (0, _createClass3.default)(MathNode, [{ + key: "setAttribute", + value: function setAttribute(name, value) { + this.attributes[name] = value; + } + + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + + }, { + key: "toNode", + value: function toNode() { + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = (0, _getIterator3.default)(this.children), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var child = _step.value; + + node.appendChild(child.toNode()); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return node; + } + + /** + * Converts the math node into an HTML markup string. + */ + + }, { + key: "toMarkup", + value: function toMarkup() { + var markup = "<" + this.type; + + // Add the attributes + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\""; + markup += _utils2.default.escape(this.attributes[attr]); + markup += "\""; + } + } + + markup += ">"; + + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += "</" + this.type + ">"; + + return markup; + } + }]); + return MathNode; +}(); -},{"./utils":25}],21:[function(require,module,exports){ /** - * The resulting parse tree nodes of the parse tree. - * - * It is possible to provide position information, so that a ParseNode can - * fulfil a role similar to a Token in error reporting. - * For details on the corresponding properties see Token constructor. - * Providing such information can lead to better error reporting. + * This node represents a piece of text. + */ + +/** + * These objects store data about MathML nodes. This is the MathML equivalent + * of the types in domTree.js. Since MathML handles its own rendering, and + * since we're mainly using MathML to improve accessibility, we don't manage + * any of the styling state that the plain DOM nodes do. * - * @param {string} type type of node, like e.g. "ordgroup" - * @param {?object} value type-specific representation of the node - * @param {string} mode parse mode in action for this node, - * "math" or "text" - * @param {Token=} firstToken first token of the input for this node, - * will omit position information if unset - * @param {Token=} lastToken last token of the input for this node, - * will default to firstToken if unset + * The `toNode` and `toMarkup` functions work simlarly to how they do in + * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. */ -function ParseNode(type, value, mode, firstToken, lastToken) { - this.type = type; - this.value = value; - this.mode = mode; - if (firstToken && (!lastToken || lastToken.lexer === firstToken.lexer)) { - this.lexer = firstToken.lexer; - this.start = firstToken.start; - this.end = (lastToken || firstToken).end; + +var TextNode = function () { + function TextNode(text) { + (0, _classCallCheck3.default)(this, TextNode); + + this.text = text; } -} -module.exports = { - ParseNode: ParseNode, + /** + * Converts the text node into a DOM text node. + */ + + + (0, _createClass3.default)(TextNode, [{ + key: "toNode", + value: function toNode() { + return document.createTextNode(this.text); + } + + /** + * Converts the text node into HTML markup (which is just the text itself). + */ + + }, { + key: "toMarkup", + value: function toMarkup() { + return _utils2.default.escape(this.text); + } + }]); + return TextNode; +}(); + +exports.default = { + MathNode: MathNode, + TextNode: TextNode }; +},{"./utils":128,"babel-runtime/core-js/get-iterator":3,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],122:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _Parser = require("./Parser"); + +var _Parser2 = _interopRequireDefault(_Parser); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Parses an expression using a Parser, then returns the parsed result. + */ +var parseTree = function parseTree(toParse, settings) { + if (!(typeof toParse === 'string' || toParse instanceof String)) { + throw new TypeError('KaTeX can only parse string typed expression'); + } + var parser = new _Parser2.default(toParse, settings); -},{}],22:[function(require,module,exports){ + return parser.parse(); +}; /** * Provides a single function for parsing an expression using a Parser * TODO(emily): Remove this */ -var Parser = require("./Parser"); +exports.default = parseTree; + +},{"./Parser":86}],123:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _slicedToArray2 = require("babel-runtime/helpers/slicedToArray"); + +var _slicedToArray3 = _interopRequireDefault(_slicedToArray2); + +var _domTree = require("./domTree"); + +var _domTree2 = _interopRequireDefault(_domTree); + +var _buildCommon = require("./buildCommon"); + +var _buildCommon2 = _interopRequireDefault(_buildCommon); + +var _mathMLTree = require("./mathMLTree"); + +var _mathMLTree2 = _interopRequireDefault(_mathMLTree); + +var _utils = require("./utils"); + +var _utils2 = _interopRequireDefault(_utils); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** - * Parses an expression using a Parser, then returns the parsed result. + * This file provides support to buildMathML.js and buildHTML.js + * for stretchy wide elements rendered from SVG files + * and other CSS trickery. */ -var parseTree = function(toParse, settings) { - if (!(typeof toParse === 'string' || toParse instanceof String)) { - throw new TypeError('KaTeX can only parse string typed expression'); + +var stretchyCodePoint = { + widehat: "^", + widetilde: "~", + utilde: "~", + overleftarrow: "\u2190", + underleftarrow: "\u2190", + xleftarrow: "\u2190", + overrightarrow: "\u2192", + underrightarrow: "\u2192", + xrightarrow: "\u2192", + underbrace: "\u23B5", + overbrace: "\u23DE", + overleftrightarrow: "\u2194", + underleftrightarrow: "\u2194", + xleftrightarrow: "\u2194", + Overrightarrow: "\u21D2", + xRightarrow: "\u21D2", + overleftharpoon: "\u21BC", + xleftharpoonup: "\u21BC", + overrightharpoon: "\u21C0", + xrightharpoonup: "\u21C0", + xLeftarrow: "\u21D0", + xLeftrightarrow: "\u21D4", + xhookleftarrow: "\u21A9", + xhookrightarrow: "\u21AA", + xmapsto: "\u21A6", + xrightharpoondown: "\u21C1", + xleftharpoondown: "\u21BD", + xrightleftharpoons: "\u21CC", + xleftrightharpoons: "\u21CB", + xtwoheadleftarrow: "\u219E", + xtwoheadrightarrow: "\u21A0", + xlongequal: "=", + xtofrom: "\u21C4" +}; + +var mathMLnode = function mathMLnode(label) { + var node = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode(stretchyCodePoint[label.substr(1)])]); + node.setAttribute("stretchy", "true"); + return node; +}; + +// Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts. +// Copyright (c) 2009-2010, Design Science, Inc. (<www.mathjax.org>) +// Copyright (c) 2014-2017 Khan Academy (<www.khanacademy.org>) +// Licensed under the SIL Open Font License, Version 1.1. +// See \nhttp://scripts.sil.org/OFL + +// Very Long SVGs +// Many of the KaTeX stretchy wide elements use a long SVG image and an +// overflow: hidden tactic to achieve a stretchy image while avoiding +// distortion of arrowheads or brace corners. + +// The SVG typically contains a very long (400 em) arrow. + +// The SVG is in a container span that has overflow: hidden, so the span +// acts like a window that exposes only part of the SVG. + +// The SVG always has a longer, thinner aspect ratio than the container span. +// After the SVG fills 100% of the height of the container span, +// there is a long arrow shaft left over. That left-over shaft is not shown. +// Instead, it is sliced off because the span's CSS has overflow: hidden. + +// Thus, the reader sees an arrow that matches the subject matter width +// without distortion. + +// Some functions, such as \cancel, need to vary their aspect ratio. These +// functions do not get the overflow SVG treatment. + +// Second Brush Stroke +// Low resolution monitors struggle to display images in fine detail. +// So browsers apply anti-aliasing. A long straight arrow shaft therefore +// will sometimes appear as if it has a blurred edge. + +// To mitigate this, these SVG files contain a second "brush-stroke" on the +// arrow shafts. That is, a second long thin rectangular SVG path has been +// written directly on top of each arrow shaft. This reinforcement causes +// some of the screen pixels to display as black instead of the anti-aliased +// gray pixel that a single path would generate. So we get arrow shafts +// whose edges appear to be sharper. + +// In the katexImagesData object just below, the dimensions all +// correspond to path geometry inside the relevant SVG. +// For example, \overrightarrow uses the same arrowhead as glyph U+2192 +// from the KaTeX Main font. The scaling factor is 1000. +// That is, inside the font, that arrowhead is 522 units tall, which +// corresponds to 0.522 em inside the document. + +var katexImagesData = { + // path(s), minWidth, height, align + overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], + xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], + xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], + overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"], + overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], + xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], + xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], + + overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548], + underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548], + underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522], + xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560], + xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716], + xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716], + xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522], + xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522], + overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + overgroup: [["leftgroup", "rightgroup"], 0.888, 342], + undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342], + xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522], + xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528] +}; + +var groupLength = function groupLength(arg) { + if (arg.type === "ordgroup") { + return arg.value.length; + } else { + return 1; + } +}; + +var svgSpan = function svgSpan(group, options) { + // Create a span with inline SVG for the element. + function buildSvgSpan_() { + var viewBoxWidth = 400000; // default + var label = group.value.label.substr(1); + if (_utils2.default.contains(["widehat", "widetilde", "utilde"], label)) { + // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + var numChars = groupLength(group.value.base); + var viewBoxHeight = void 0; + var pathName = void 0; + var _height = void 0; + + if (numChars > 5) { + viewBoxHeight = label === "widehat" ? 420 : 312; + viewBoxWidth = label === "widehat" ? 2364 : 2340; + // Next get the span height, in 1000 ems + _height = label === "widehat" ? 0.42 : 0.34; + pathName = (label === "widehat" ? "widehat" : "tilde") + "4"; + } else { + var imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + if (label === "widehat") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = "widehat" + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + var path = new _domTree2.default.pathNode(pathName); + var svgNode = new _domTree2.default.svgNode([path], { + "width": "100%", + "height": _height + "em", + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": "none" + }); + return { + span: _buildCommon2.default.makeSpan([], [svgNode], options), + minWidth: 0, + height: _height + }; + } else { + var spans = []; + + var _katexImagesData$labe = (0, _slicedToArray3.default)(katexImagesData[label], 4), + paths = _katexImagesData$labe[0], + _minWidth = _katexImagesData$labe[1], + _viewBoxHeight = _katexImagesData$labe[2], + align1 = _katexImagesData$labe[3]; + + var _height2 = _viewBoxHeight / 1000; + + var numSvgChildren = paths.length; + var widthClasses = void 0; + var aligns = void 0; + if (numSvgChildren === 1) { + widthClasses = ["hide-tail"]; + aligns = [align1]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children."); + } + + for (var i = 0; i < numSvgChildren; i++) { + var _path = new _domTree2.default.pathNode(paths[i]); + + var _svgNode = new _domTree2.default.svgNode([_path], { + "width": "400em", + "height": _height2 + "em", + "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight, + "preserveAspectRatio": aligns[i] + " slice" + }); + + var _span = _buildCommon2.default.makeSpan([widthClasses[i]], [_svgNode], options); + if (numSvgChildren === 1) { + return { span: _span, minWidth: _minWidth, height: _height2 }; + } else { + _span.style.height = _height2 + "em"; + spans.push(_span); + } + } + + return { + span: _buildCommon2.default.makeSpan(["stretchy"], spans, options), + minWidth: _minWidth, + height: _height2 + }; + } + } // buildSvgSpan_() + + var _buildSvgSpan_ = buildSvgSpan_(), + span = _buildSvgSpan_.span, + minWidth = _buildSvgSpan_.minWidth, + height = _buildSvgSpan_.height; + + // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + + + span.height = height; + span.style.height = height + "em"; + if (minWidth > 0) { + span.style.minWidth = minWidth + "em"; } - var parser = new Parser(toParse, settings); - return parser.parse(); + return span; }; -module.exports = parseTree; +var encloseSpan = function encloseSpan(inner, label, pad, options) { + // Return an image span for \cancel, \bcancel, \xcancel, or \fbox + var img = void 0; + var totalHeight = inner.height + inner.depth + 2 * pad; + + if (/fbox|color/.test(label)) { + img = _buildCommon2.default.makeSpan(["stretchy", label], [], options); + + if (label === "fbox") { + var color = options.color && options.getColor(); + if (color) { + img.style.borderColor = color; + } + } + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + + var lines = []; + if (/^[bx]cancel$/.test(label)) { + lines.push(new _domTree2.default.lineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em" + })); + } + + if (/^x?cancel$/.test(label)) { + lines.push(new _domTree2.default.lineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em" + })); + } + + var svgNode = new _domTree2.default.svgNode(lines, { + "width": "100%", + "height": totalHeight + "em" + }); + + img = _buildCommon2.default.makeSpan([], [svgNode], options); + } + + img.height = totalHeight; + img.style.height = totalHeight + "em"; + + return img; +}; + +var ruleSpan = function ruleSpan(className, options) { + // Get a big square image. The parent span will hide the overflow. + var pathNode = new _domTree2.default.pathNode('bigRule'); + var svg = new _domTree2.default.svgNode([pathNode], { + "width": "400em", + "height": "400em", + "viewBox": "0 0 400000 400000", + "preserveAspectRatio": "xMinYMin slice" + }); + return _buildCommon2.default.makeSpan([className, "hide-tail"], [svg], options); +}; + +exports.default = { + encloseSpan: encloseSpan, + mathMLnode: mathMLnode, + ruleSpan: ruleSpan, + svgSpan: svgSpan +}; + +},{"./buildCommon":91,"./domTree":98,"./mathMLTree":121,"./utils":128,"babel-runtime/helpers/slicedToArray":10}],124:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var path = { + // bigRule provides a big square image for frac-lines, etc. + // The actual rendered rule is smaller, controlled by overflow:hidden. + bigRule: 'M0 0 h400000 v400000 h-400000z M0 0 h400000 v400000 h-400000z', + + // sqrtMain path geometry is from glyph U221A in the font KaTeX Main + sqrtMain: 'M95 622c-2.667 0-7.167-2.667-13.5\n-8S72 604 72 600c0-2 .333-3.333 1-4 1.333-2.667 23.833-20.667 67.5-54s\n65.833-50.333 66.5-51c1.333-1.333 3-2 5-2 4.667 0 8.667 3.333 12 10l173\n378c.667 0 35.333-71 104-213s137.5-285 206.5-429S812 17.333 812 14c5.333\n-9.333 12-14 20-14h399166v40H845.272L620 507 385 993c-2.667 4.667-9 7-19\n7-6 0-10-1-12-3L160 575l-65 47zM834 0h399166v40H845z', + + // size1 is from glyph U221A in the font KaTeX_Size1-Regular + sqrtSize1: 'M263 601c.667 0 18 39.667 52 119s68.167\n 158.667 102.5 238 51.833 119.333 52.5 120C810 373.333 980.667 17.667 982 11\nc4.667-7.333 11-11 19-11h398999v40H1012.333L741 607c-38.667 80.667-84 175-136\n 283s-89.167 185.333-111.5 232-33.833 70.333-34.5 71c-4.667 4.667-12.333 7-23\n 7l-12-1-109-253c-72.667-168-109.333-252-110-252-10.667 8-22 16.667-34 26-22\n 17.333-33.333 26-34 26l-26-26 76-59 76-60zM1001 0h398999v40H1012z', + + // size2 is from glyph U221A in the font KaTeX_Size2-Regular + sqrtSize2: 'M1001 0h398999v40H1013.084S929.667 308 749\n 880s-277 876.333-289 913c-4.667 4.667-12.667 7-24 7h-12c-1.333-3.333-3.667\n-11.667-7-25-35.333-125.333-106.667-373.333-214-744-10 12-21 25-33 39l-32 39\nc-6-5.333-15-14-27-26l25-30c26.667-32.667 52-63 76-91l52-60 208 722c56-175.333\n 126.333-397.333 211-666s153.833-488.167 207.5-658.5C944.167 129.167 975 32.667\n 983 10c4-6.667 10-10 18-10zm0 0h398999v40H1013z', + + // size3 is from glyph U221A in the font KaTeX_Size3-Regular + sqrtSize3: 'M424 2398c-1.333-.667-38.5-172-111.5-514 S202.667 1370.667 202\n 1370c0-2-10.667 14.333-32 49-4.667 7.333-9.833 15.667-15.5 25s-9.833 16-12.5\n 20l-5 7c-4-3.333-8.333-7.667-13-13l-13-13 76-122 77-121 209 968c0-2 84.667\n-361.667 254-1079C896.333 373.667 981.667 13.333 983 10c4-6.667 10-10 18-10\nh398999v40H1014.622S927.332 418.667 742 1206c-185.333 787.333-279.333 1182.333\n-282 1185-2 6-10 9-24 9-8 0-12-.667-12-2zM1001 0h398999v40H1014z', + + // size4 is from glyph U221A in the font KaTeX_Size4-Regular + sqrtSize4: 'M473 2713C812.333 913.667 982.333 13 983 11c3.333-7.333 9.333\n-11 18-11h399110v40H1017.698S927.168 518 741.5 1506C555.833 2494 462 2989 460\n 2991c-2 6-10 9-24 9-8 0-12-.667-12-2s-5.333-32-16-92c-50.667-293.333-119.667\n-693.333-207-1200 0-1.333-5.333 8.667-16 30l-32 64-16 33-26-26 76-153 77-151\nc.667.667 35.667 202 105 604 67.333 400.667 102 602.667 104 606z\nM1001 0h398999v40H1017z', + + // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main + doubleleftarrow: 'M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z', + + // doublerightarrow is from glyph U+21D2 in font KaTeX Main + doublerightarrow: 'M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z', + + // leftarrow is from glyph U+2190 in font KaTeX Main + leftarrow: 'M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z', + + // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular + leftbrace: 'M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z', + + leftbraceunder: 'M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z', + + // overgroup is from the MnSymbol package (public domain) + leftgroup: 'M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z', + + leftgroupunder: 'M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z', + + // Harpoons are from glyph U+21BD in font KaTeX Main + leftharpoon: 'M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z', + + leftharpoonplus: 'M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z', + + leftharpoondown: 'M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z', + + leftharpoondownplus: 'M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z', + + // hook is from glyph U+21A9 in font KaTeX Main + lefthook: 'M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z', + + leftlinesegment: 'M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z', + + leftmapsto: 'M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z', + + // tofrom is from glyph U+21C4 in font KaTeX AMS Regular + leftToFrom: 'M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z', + + longequal: 'M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z', + + midbrace: 'M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z', + + midbraceunder: 'M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z', + + rightarrow: 'M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z', + + rightbrace: 'M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z', + + rightbraceunder: 'M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z', + + rightgroup: 'M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z', + + rightgroupunder: 'M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z', + + rightharpoon: 'M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z', + + rightharpoonplus: 'M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z', + + rightharpoondown: 'M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z', + + rightharpoondownplus: 'M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z', + + righthook: 'M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z', + + rightlinesegment: 'M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z', + + rightToFrom: 'M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z', + + // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular + twoheadleftarrow: 'M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z', + + twoheadrightarrow: 'M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z', + + // tilde1 is a modified version of a glyph from the MnSymbol package + tilde1: 'M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z', + + // ditto tilde2, tilde3, & tilde4 + tilde2: 'M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z', + + tilde3: 'M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z', + + tilde4: 'M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z', + + // widehat1 is a modified version of a glyph from the MnSymbol package + widehat1: 'M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z', + + // ditto widehat2, widehat3, & widehat4 + widehat2: 'M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z', + + widehat3: 'M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z', + + widehat4: 'M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z' +}; + +exports.default = { path: path }; + +},{}],125:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); -},{"./Parser":7}],23:[function(require,module,exports){ /** * This file holds a list of all no-argument functions and single-character * symbols (like 'a' or ';'). @@ -7919,17 +13454,20 @@ module.exports = parseTree; * accepted in (e.g. "math" or "text"). */ -module.exports = { - math: {}, - text: {}, +var symbols = { + "math": {}, + "text": {} }; +exports.default = symbols; -function defineSymbol(mode, font, group, replace, name) { - module.exports[mode][name] = { - font: font, - group: group, - replace: replace, - }; +/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */ + +function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { + symbols[mode][name] = { font: font, group: group, replace: replace }; + + if (acceptUnicodeChar && replace) { + symbols[mode][replace] = symbols[mode][name]; + } } // Some abbreviations for commonly used strings. @@ -7959,621 +13497,810 @@ var textord = "textord"; // Now comes the symbol table // Relation Symbols -defineSymbol(math, main, rel, "\u2261", "\\equiv"); -defineSymbol(math, main, rel, "\u227a", "\\prec"); -defineSymbol(math, main, rel, "\u227b", "\\succ"); -defineSymbol(math, main, rel, "\u223c", "\\sim"); -defineSymbol(math, main, rel, "\u22a5", "\\perp"); -defineSymbol(math, main, rel, "\u2aaf", "\\preceq"); -defineSymbol(math, main, rel, "\u2ab0", "\\succeq"); -defineSymbol(math, main, rel, "\u2243", "\\simeq"); -defineSymbol(math, main, rel, "\u2223", "\\mid"); -defineSymbol(math, main, rel, "\u226a", "\\ll"); -defineSymbol(math, main, rel, "\u226b", "\\gg"); -defineSymbol(math, main, rel, "\u224d", "\\asymp"); +defineSymbol(math, main, rel, "\u2261", "\\equiv", true); +defineSymbol(math, main, rel, "\u227A", "\\prec", true); +defineSymbol(math, main, rel, "\u227B", "\\succ", true); +defineSymbol(math, main, rel, "\u223C", "\\sim", true); +defineSymbol(math, main, rel, "\u22A5", "\\perp"); +defineSymbol(math, main, rel, "\u2AAF", "\\preceq", true); +defineSymbol(math, main, rel, "\u2AB0", "\\succeq", true); +defineSymbol(math, main, rel, "\u2243", "\\simeq", true); +defineSymbol(math, main, rel, "\u2223", "\\mid", true); +defineSymbol(math, main, rel, "\u226A", "\\ll"); +defineSymbol(math, main, rel, "\u226B", "\\gg", true); +defineSymbol(math, main, rel, "\u224D", "\\asymp", true); defineSymbol(math, main, rel, "\u2225", "\\parallel"); -defineSymbol(math, main, rel, "\u22c8", "\\bowtie"); -defineSymbol(math, main, rel, "\u2323", "\\smile"); -defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq"); -defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq"); -defineSymbol(math, main, rel, "\u2250", "\\doteq"); -defineSymbol(math, main, rel, "\u2322", "\\frown"); -defineSymbol(math, main, rel, "\u220b", "\\ni"); -defineSymbol(math, main, rel, "\u221d", "\\propto"); -defineSymbol(math, main, rel, "\u22a2", "\\vdash"); -defineSymbol(math, main, rel, "\u22a3", "\\dashv"); -defineSymbol(math, main, rel, "\u220b", "\\owns"); +defineSymbol(math, main, rel, "\u22C8", "\\bowtie", true); +defineSymbol(math, main, rel, "\u2323", "\\smile", true); +defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true); +defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true); +defineSymbol(math, main, rel, "\u2250", "\\doteq", true); +defineSymbol(math, main, rel, "\u2322", "\\frown", true); +defineSymbol(math, main, rel, "\u220B", "\\ni", true); +defineSymbol(math, main, rel, "\u221D", "\\propto", true); +defineSymbol(math, main, rel, "\u22A2", "\\vdash", true); +defineSymbol(math, main, rel, "\u22A3", "\\dashv", true); +defineSymbol(math, main, rel, "\u220B", "\\owns"); // Punctuation -defineSymbol(math, main, punct, "\u002e", "\\ldotp"); -defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); +defineSymbol(math, main, punct, ".", "\\ldotp"); +defineSymbol(math, main, punct, "\u22C5", "\\cdotp"); // Misc Symbols -defineSymbol(math, main, textord, "\u0023", "\\#"); -defineSymbol(math, main, textord, "\u0026", "\\&"); -defineSymbol(math, main, textord, "\u2135", "\\aleph"); -defineSymbol(math, main, textord, "\u2200", "\\forall"); -defineSymbol(math, main, textord, "\u210f", "\\hbar"); -defineSymbol(math, main, textord, "\u2203", "\\exists"); -defineSymbol(math, main, textord, "\u2207", "\\nabla"); -defineSymbol(math, main, textord, "\u266d", "\\flat"); -defineSymbol(math, main, textord, "\u2113", "\\ell"); -defineSymbol(math, main, textord, "\u266e", "\\natural"); -defineSymbol(math, main, textord, "\u2663", "\\clubsuit"); -defineSymbol(math, main, textord, "\u2118", "\\wp"); -defineSymbol(math, main, textord, "\u266f", "\\sharp"); -defineSymbol(math, main, textord, "\u2662", "\\diamondsuit"); -defineSymbol(math, main, textord, "\u211c", "\\Re"); -defineSymbol(math, main, textord, "\u2661", "\\heartsuit"); -defineSymbol(math, main, textord, "\u2111", "\\Im"); -defineSymbol(math, main, textord, "\u2660", "\\spadesuit"); +defineSymbol(math, main, textord, "#", "\\#"); +defineSymbol(text, main, textord, "#", "\\#"); +defineSymbol(math, main, textord, "&", "\\&"); +defineSymbol(text, main, textord, "&", "\\&"); +defineSymbol(math, main, textord, "\u2135", "\\aleph", true); +defineSymbol(math, main, textord, "\u2200", "\\forall", true); +defineSymbol(math, main, textord, "\u210F", "\\hbar"); +defineSymbol(math, main, textord, "\u2203", "\\exists", true); +defineSymbol(math, main, textord, "\u2207", "\\nabla", true); +defineSymbol(math, main, textord, "\u266D", "\\flat", true); +defineSymbol(math, main, textord, "\u2113", "\\ell", true); +defineSymbol(math, main, textord, "\u266E", "\\natural", true); +defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true); +defineSymbol(math, main, textord, "\u2118", "\\wp", true); +defineSymbol(math, main, textord, "\u266F", "\\sharp", true); +defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true); +defineSymbol(math, main, textord, "\u211C", "\\Re", true); +defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); +defineSymbol(math, main, textord, "\u2111", "\\Im", true); +defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); // Math and Text defineSymbol(math, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\textdagger"); defineSymbol(math, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2020", "\\textdaggerdbl"); // Large Delimiters -defineSymbol(math, main, close, "\u23b1", "\\rmoustache"); -defineSymbol(math, main, open, "\u23b0", "\\lmoustache"); -defineSymbol(math, main, close, "\u27ef", "\\rgroup"); -defineSymbol(math, main, open, "\u27ee", "\\lgroup"); +defineSymbol(math, main, close, "\u23B1", "\\rmoustache"); +defineSymbol(math, main, open, "\u23B0", "\\lmoustache"); +defineSymbol(math, main, close, "\u27EF", "\\rgroup"); +defineSymbol(math, main, open, "\u27EE", "\\lgroup"); // Binary Operators -defineSymbol(math, main, bin, "\u2213", "\\mp"); -defineSymbol(math, main, bin, "\u2296", "\\ominus"); -defineSymbol(math, main, bin, "\u228e", "\\uplus"); -defineSymbol(math, main, bin, "\u2293", "\\sqcap"); +defineSymbol(math, main, bin, "\u2213", "\\mp", true); +defineSymbol(math, main, bin, "\u2296", "\\ominus", true); +defineSymbol(math, main, bin, "\u228E", "\\uplus", true); +defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); defineSymbol(math, main, bin, "\u2217", "\\ast"); -defineSymbol(math, main, bin, "\u2294", "\\sqcup"); -defineSymbol(math, main, bin, "\u25ef", "\\bigcirc"); +defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); +defineSymbol(math, main, bin, "\u25EF", "\\bigcirc"); defineSymbol(math, main, bin, "\u2219", "\\bullet"); defineSymbol(math, main, bin, "\u2021", "\\ddagger"); -defineSymbol(math, main, bin, "\u2240", "\\wr"); -defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); +defineSymbol(math, main, bin, "\u2240", "\\wr", true); +defineSymbol(math, main, bin, "\u2A3F", "\\amalg"); +defineSymbol(math, main, bin, "&", "\\And"); // from amsmath // Arrow Symbols -defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow"); -defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow"); -defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow"); -defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow"); -defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow"); -defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow"); -defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow"); -defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow"); -defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow"); -defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow"); -defineSymbol(math, main, rel, "\u21a6", "\\mapsto"); -defineSymbol(math, main, rel, "\u27fc", "\\longmapsto"); -defineSymbol(math, main, rel, "\u2197", "\\nearrow"); -defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow"); -defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow"); -defineSymbol(math, main, rel, "\u2198", "\\searrow"); -defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup"); -defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup"); -defineSymbol(math, main, rel, "\u2199", "\\swarrow"); -defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown"); -defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown"); -defineSymbol(math, main, rel, "\u2196", "\\nwarrow"); -defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons"); +defineSymbol(math, main, rel, "\u27F5", "\\longleftarrow", true); +defineSymbol(math, main, rel, "\u21D0", "\\Leftarrow", true); +defineSymbol(math, main, rel, "\u27F8", "\\Longleftarrow", true); +defineSymbol(math, main, rel, "\u27F6", "\\longrightarrow", true); +defineSymbol(math, main, rel, "\u21D2", "\\Rightarrow", true); +defineSymbol(math, main, rel, "\u27F9", "\\Longrightarrow", true); +defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true); +defineSymbol(math, main, rel, "\u27F7", "\\longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21D4", "\\Leftrightarrow", true); +defineSymbol(math, main, rel, "\u27FA", "\\Longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21A6", "\\mapsto", true); +defineSymbol(math, main, rel, "\u27FC", "\\longmapsto", true); +defineSymbol(math, main, rel, "\u2197", "\\nearrow", true); +defineSymbol(math, main, rel, "\u21A9", "\\hookleftarrow", true); +defineSymbol(math, main, rel, "\u21AA", "\\hookrightarrow", true); +defineSymbol(math, main, rel, "\u2198", "\\searrow", true); +defineSymbol(math, main, rel, "\u21BC", "\\leftharpoonup", true); +defineSymbol(math, main, rel, "\u21C0", "\\rightharpoonup", true); +defineSymbol(math, main, rel, "\u2199", "\\swarrow", true); +defineSymbol(math, main, rel, "\u21BD", "\\leftharpoondown", true); +defineSymbol(math, main, rel, "\u21C1", "\\rightharpoondown", true); +defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); +defineSymbol(math, main, rel, "\u21CC", "\\rightleftharpoons", true); // AMS Negated Binary Relations -defineSymbol(math, ams, rel, "\u226e", "\\nless"); -defineSymbol(math, ams, rel, "\ue010", "\\nleqslant"); -defineSymbol(math, ams, rel, "\ue011", "\\nleqq"); -defineSymbol(math, ams, rel, "\u2a87", "\\lneq"); -defineSymbol(math, ams, rel, "\u2268", "\\lneqq"); -defineSymbol(math, ams, rel, "\ue00c", "\\lvertneqq"); -defineSymbol(math, ams, rel, "\u22e6", "\\lnsim"); -defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox"); -defineSymbol(math, ams, rel, "\u2280", "\\nprec"); -defineSymbol(math, ams, rel, "\u22e0", "\\npreceq"); -defineSymbol(math, ams, rel, "\u22e8", "\\precnsim"); -defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox"); -defineSymbol(math, ams, rel, "\u2241", "\\nsim"); -defineSymbol(math, ams, rel, "\ue006", "\\nshortmid"); -defineSymbol(math, ams, rel, "\u2224", "\\nmid"); -defineSymbol(math, ams, rel, "\u22ac", "\\nvdash"); -defineSymbol(math, ams, rel, "\u22ad", "\\nvDash"); -defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft"); -defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq"); -defineSymbol(math, ams, rel, "\u228a", "\\subsetneq"); -defineSymbol(math, ams, rel, "\ue01a", "\\varsubsetneq"); -defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq"); -defineSymbol(math, ams, rel, "\ue017", "\\varsubsetneqq"); -defineSymbol(math, ams, rel, "\u226f", "\\ngtr"); -defineSymbol(math, ams, rel, "\ue00f", "\\ngeqslant"); -defineSymbol(math, ams, rel, "\ue00e", "\\ngeqq"); -defineSymbol(math, ams, rel, "\u2a88", "\\gneq"); -defineSymbol(math, ams, rel, "\u2269", "\\gneqq"); -defineSymbol(math, ams, rel, "\ue00d", "\\gvertneqq"); -defineSymbol(math, ams, rel, "\u22e7", "\\gnsim"); -defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox"); -defineSymbol(math, ams, rel, "\u2281", "\\nsucc"); -defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq"); -defineSymbol(math, ams, rel, "\u22e9", "\\succnsim"); -defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox"); -defineSymbol(math, ams, rel, "\u2246", "\\ncong"); -defineSymbol(math, ams, rel, "\ue007", "\\nshortparallel"); -defineSymbol(math, ams, rel, "\u2226", "\\nparallel"); -defineSymbol(math, ams, rel, "\u22af", "\\nVDash"); -defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright"); -defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq"); -defineSymbol(math, ams, rel, "\ue018", "\\nsupseteqq"); -defineSymbol(math, ams, rel, "\u228b", "\\supsetneq"); -defineSymbol(math, ams, rel, "\ue01b", "\\varsupsetneq"); -defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq"); -defineSymbol(math, ams, rel, "\ue019", "\\varsupsetneqq"); -defineSymbol(math, ams, rel, "\u22ae", "\\nVdash"); -defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq"); -defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq"); -defineSymbol(math, ams, rel, "\ue016", "\\nsubseteqq"); -defineSymbol(math, ams, bin, "\u22b4", "\\unlhd"); -defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); +defineSymbol(math, ams, rel, "\u226E", "\\nless", true); +defineSymbol(math, ams, rel, "\uE010", "\\nleqslant"); +defineSymbol(math, ams, rel, "\uE011", "\\nleqq"); +defineSymbol(math, ams, rel, "\u2A87", "\\lneq", true); +defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true); +defineSymbol(math, ams, rel, "\uE00C", "\\lvertneqq"); +defineSymbol(math, ams, rel, "\u22E6", "\\lnsim", true); +defineSymbol(math, ams, rel, "\u2A89", "\\lnapprox", true); +defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); +// unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22E0", "\\npreceq", true); +defineSymbol(math, ams, rel, "\u22E8", "\\precnsim", true); +defineSymbol(math, ams, rel, "\u2AB9", "\\precnapprox", true); +defineSymbol(math, ams, rel, "\u2241", "\\nsim", true); +defineSymbol(math, ams, rel, "\uE006", "\\nshortmid"); +defineSymbol(math, ams, rel, "\u2224", "\\nmid", true); +defineSymbol(math, ams, rel, "\u22AC", "\\nvdash", true); +defineSymbol(math, ams, rel, "\u22AD", "\\nvDash", true); +defineSymbol(math, ams, rel, "\u22EA", "\\ntriangleleft"); +defineSymbol(math, ams, rel, "\u22EC", "\\ntrianglelefteq", true); +defineSymbol(math, ams, rel, "\u228A", "\\subsetneq", true); +defineSymbol(math, ams, rel, "\uE01A", "\\varsubsetneq"); +defineSymbol(math, ams, rel, "\u2ACB", "\\subsetneqq", true); +defineSymbol(math, ams, rel, "\uE017", "\\varsubsetneqq"); +defineSymbol(math, ams, rel, "\u226F", "\\ngtr", true); +defineSymbol(math, ams, rel, "\uE00F", "\\ngeqslant"); +defineSymbol(math, ams, rel, "\uE00E", "\\ngeqq"); +defineSymbol(math, ams, rel, "\u2A88", "\\gneq", true); +defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true); +defineSymbol(math, ams, rel, "\uE00D", "\\gvertneqq"); +defineSymbol(math, ams, rel, "\u22E7", "\\gnsim", true); +defineSymbol(math, ams, rel, "\u2A8A", "\\gnapprox", true); +defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); +// unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22E1", "\\nsucceq", true); +defineSymbol(math, ams, rel, "\u22E9", "\\succnsim", true); +defineSymbol(math, ams, rel, "\u2ABA", "\\succnapprox", true); +// unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u2246", "\\ncong", true); +defineSymbol(math, ams, rel, "\uE007", "\\nshortparallel"); +defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true); +defineSymbol(math, ams, rel, "\u22AF", "\\nVDash", true); +defineSymbol(math, ams, rel, "\u22EB", "\\ntriangleright"); +defineSymbol(math, ams, rel, "\u22ED", "\\ntrianglerighteq", true); +defineSymbol(math, ams, rel, "\uE018", "\\nsupseteqq"); +defineSymbol(math, ams, rel, "\u228B", "\\supsetneq", true); +defineSymbol(math, ams, rel, "\uE01B", "\\varsupsetneq"); +defineSymbol(math, ams, rel, "\u2ACC", "\\supsetneqq", true); +defineSymbol(math, ams, rel, "\uE019", "\\varsupsetneqq"); +defineSymbol(math, ams, rel, "\u22AE", "\\nVdash", true); +defineSymbol(math, ams, rel, "\u2AB5", "\\precneqq", true); +defineSymbol(math, ams, rel, "\u2AB6", "\\succneqq", true); +defineSymbol(math, ams, rel, "\uE016", "\\nsubseteqq"); +defineSymbol(math, ams, bin, "\u22B4", "\\unlhd"); +defineSymbol(math, ams, bin, "\u22B5", "\\unrhd"); // AMS Negated Arrows -defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow"); -defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow"); -defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow"); -defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow"); -defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow"); -defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow"); +defineSymbol(math, ams, rel, "\u219A", "\\nleftarrow", true); +defineSymbol(math, ams, rel, "\u219B", "\\nrightarrow", true); +defineSymbol(math, ams, rel, "\u21CD", "\\nLeftarrow", true); +defineSymbol(math, ams, rel, "\u21CF", "\\nRightarrow", true); +defineSymbol(math, ams, rel, "\u21AE", "\\nleftrightarrow", true); +defineSymbol(math, ams, rel, "\u21CE", "\\nLeftrightarrow", true); // AMS Misc -defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle"); -defineSymbol(math, ams, textord, "\u210f", "\\hslash"); -defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); -defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); -defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); -defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); -defineSymbol(math, ams, textord, "\u2221", "\\measuredangle"); +defineSymbol(math, ams, rel, "\u25B3", "\\vartriangle"); +defineSymbol(math, ams, textord, "\u210F", "\\hslash"); +defineSymbol(math, ams, textord, "\u25BD", "\\triangledown"); +defineSymbol(math, ams, textord, "\u25CA", "\\lozenge"); +defineSymbol(math, ams, textord, "\u24C8", "\\circledS"); +defineSymbol(math, ams, textord, "\xAE", "\\circledR"); +defineSymbol(text, ams, textord, "\xAE", "\\circledR"); +defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); defineSymbol(math, ams, textord, "\u2204", "\\nexists"); defineSymbol(math, ams, textord, "\u2127", "\\mho"); -defineSymbol(math, ams, textord, "\u2132", "\\Finv"); -defineSymbol(math, ams, textord, "\u2141", "\\Game"); -defineSymbol(math, ams, textord, "\u006b", "\\Bbbk"); +defineSymbol(math, ams, textord, "\u2132", "\\Finv", true); +defineSymbol(math, ams, textord, "\u2141", "\\Game", true); +defineSymbol(math, ams, textord, "k", "\\Bbbk"); defineSymbol(math, ams, textord, "\u2035", "\\backprime"); -defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle"); -defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown"); -defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); -defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); +defineSymbol(math, ams, textord, "\u25B2", "\\blacktriangle"); +defineSymbol(math, ams, textord, "\u25BC", "\\blacktriangledown"); +defineSymbol(math, ams, textord, "\u25A0", "\\blacksquare"); +defineSymbol(math, ams, textord, "\u29EB", "\\blacklozenge"); defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); -defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle"); -defineSymbol(math, ams, textord, "\u2201", "\\complement"); -defineSymbol(math, ams, textord, "\u00f0", "\\eth"); +defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); +// unicode-math maps U+F0 to \matheth. We map to AMS function \eth +defineSymbol(math, ams, textord, "\xF0", "\\eth", true); defineSymbol(math, ams, textord, "\u2571", "\\diagup"); defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); -defineSymbol(math, ams, textord, "\u25a1", "\\square"); -defineSymbol(math, ams, textord, "\u25a1", "\\Box"); -defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); -defineSymbol(math, ams, textord, "\u00a5", "\\yen"); -defineSymbol(math, ams, textord, "\u2713", "\\checkmark"); +defineSymbol(math, ams, textord, "\u25A1", "\\square"); +defineSymbol(math, ams, textord, "\u25A1", "\\Box"); +defineSymbol(math, ams, textord, "\u25CA", "\\Diamond"); +// unicode-math maps U+A5 to \mathyen. We map to AMS function \yen +defineSymbol(math, ams, textord, "\xA5", "\\yen", true); +defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); +defineSymbol(text, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew -defineSymbol(math, ams, textord, "\u2136", "\\beth"); -defineSymbol(math, ams, textord, "\u2138", "\\daleth"); -defineSymbol(math, ams, textord, "\u2137", "\\gimel"); +defineSymbol(math, ams, textord, "\u2136", "\\beth", true); +defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); +defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); // AMS Greek -defineSymbol(math, ams, textord, "\u03dd", "\\digamma"); -defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); +defineSymbol(math, ams, textord, "\u03DD", "\\digamma"); +defineSymbol(math, ams, textord, "\u03F0", "\\varkappa"); // AMS Delimiters -defineSymbol(math, ams, open, "\u250c", "\\ulcorner"); +defineSymbol(math, ams, open, "\u250C", "\\ulcorner"); defineSymbol(math, ams, close, "\u2510", "\\urcorner"); defineSymbol(math, ams, open, "\u2514", "\\llcorner"); defineSymbol(math, ams, close, "\u2518", "\\lrcorner"); // AMS Binary Relations -defineSymbol(math, ams, rel, "\u2266", "\\leqq"); -defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant"); -defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless"); +defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); +defineSymbol(math, ams, rel, "\u2A7D", "\\leqslant"); +defineSymbol(math, ams, rel, "\u2A95", "\\eqslantless", true); defineSymbol(math, ams, rel, "\u2272", "\\lesssim"); -defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox"); -defineSymbol(math, ams, rel, "\u224a", "\\approxeq"); -defineSymbol(math, ams, bin, "\u22d6", "\\lessdot"); -defineSymbol(math, ams, rel, "\u22d8", "\\lll"); +defineSymbol(math, ams, rel, "\u2A85", "\\lessapprox"); +defineSymbol(math, ams, rel, "\u224A", "\\approxeq", true); +defineSymbol(math, ams, bin, "\u22D6", "\\lessdot"); +defineSymbol(math, ams, rel, "\u22D8", "\\lll"); defineSymbol(math, ams, rel, "\u2276", "\\lessgtr"); -defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr"); -defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr"); +defineSymbol(math, ams, rel, "\u22DA", "\\lesseqgtr"); +defineSymbol(math, ams, rel, "\u2A8B", "\\lesseqqgtr"); defineSymbol(math, ams, rel, "\u2251", "\\doteqdot"); -defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq"); -defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq"); -defineSymbol(math, ams, rel, "\u223d", "\\backsim"); -defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq"); -defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq"); -defineSymbol(math, ams, rel, "\u22d0", "\\Subset"); -defineSymbol(math, ams, rel, "\u228f", "\\sqsubset"); -defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq"); -defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec"); -defineSymbol(math, ams, rel, "\u227e", "\\precsim"); -defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox"); -defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft"); -defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq"); -defineSymbol(math, ams, rel, "\u22a8", "\\vDash"); -defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash"); +defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true); +defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true); +defineSymbol(math, ams, rel, "\u223D", "\\backsim", true); +defineSymbol(math, ams, rel, "\u22CD", "\\backsimeq", true); +defineSymbol(math, ams, rel, "\u2AC5", "\\subseteqq", true); +defineSymbol(math, ams, rel, "\u22D0", "\\Subset", true); +defineSymbol(math, ams, rel, "\u228F", "\\sqsubset", true); +defineSymbol(math, ams, rel, "\u227C", "\\preccurlyeq", true); +defineSymbol(math, ams, rel, "\u22DE", "\\curlyeqprec", true); +defineSymbol(math, ams, rel, "\u227E", "\\precsim", true); +defineSymbol(math, ams, rel, "\u2AB7", "\\precapprox", true); +defineSymbol(math, ams, rel, "\u22B2", "\\vartriangleleft"); +defineSymbol(math, ams, rel, "\u22B4", "\\trianglelefteq"); +defineSymbol(math, ams, rel, "\u22A8", "\\vDash"); +defineSymbol(math, ams, rel, "\u22AA", "\\Vvdash", true); defineSymbol(math, ams, rel, "\u2323", "\\smallsmile"); defineSymbol(math, ams, rel, "\u2322", "\\smallfrown"); -defineSymbol(math, ams, rel, "\u224f", "\\bumpeq"); -defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq"); -defineSymbol(math, ams, rel, "\u2267", "\\geqq"); -defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant"); -defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr"); -defineSymbol(math, ams, rel, "\u2273", "\\gtrsim"); -defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox"); -defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot"); -defineSymbol(math, ams, rel, "\u22d9", "\\ggg"); -defineSymbol(math, ams, rel, "\u2277", "\\gtrless"); -defineSymbol(math, ams, rel, "\u22db", "\\gtreqless"); -defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless"); -defineSymbol(math, ams, rel, "\u2256", "\\eqcirc"); -defineSymbol(math, ams, rel, "\u2257", "\\circeq"); -defineSymbol(math, ams, rel, "\u225c", "\\triangleq"); -defineSymbol(math, ams, rel, "\u223c", "\\thicksim"); +defineSymbol(math, ams, rel, "\u224F", "\\bumpeq", true); +defineSymbol(math, ams, rel, "\u224E", "\\Bumpeq", true); +defineSymbol(math, ams, rel, "\u2267", "\\geqq", true); +defineSymbol(math, ams, rel, "\u2A7E", "\\geqslant", true); +defineSymbol(math, ams, rel, "\u2A96", "\\eqslantgtr", true); +defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true); +defineSymbol(math, ams, rel, "\u2A86", "\\gtrapprox", true); +defineSymbol(math, ams, bin, "\u22D7", "\\gtrdot"); +defineSymbol(math, ams, rel, "\u22D9", "\\ggg", true); +defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true); +defineSymbol(math, ams, rel, "\u22DB", "\\gtreqless", true); +defineSymbol(math, ams, rel, "\u2A8C", "\\gtreqqless", true); +defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true); +defineSymbol(math, ams, rel, "\u2257", "\\circeq", true); +defineSymbol(math, ams, rel, "\u225C", "\\triangleq", true); +defineSymbol(math, ams, rel, "\u223C", "\\thicksim"); defineSymbol(math, ams, rel, "\u2248", "\\thickapprox"); -defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq"); -defineSymbol(math, ams, rel, "\u22d1", "\\Supset"); -defineSymbol(math, ams, rel, "\u2290", "\\sqsupset"); -defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq"); -defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc"); -defineSymbol(math, ams, rel, "\u227f", "\\succsim"); -defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox"); -defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright"); -defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq"); -defineSymbol(math, ams, rel, "\u22a9", "\\Vdash"); +defineSymbol(math, ams, rel, "\u2AC6", "\\supseteqq", true); +defineSymbol(math, ams, rel, "\u22D1", "\\Supset", true); +defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true); +defineSymbol(math, ams, rel, "\u227D", "\\succcurlyeq", true); +defineSymbol(math, ams, rel, "\u22DF", "\\curlyeqsucc", true); +defineSymbol(math, ams, rel, "\u227F", "\\succsim", true); +defineSymbol(math, ams, rel, "\u2AB8", "\\succapprox", true); +defineSymbol(math, ams, rel, "\u22B3", "\\vartriangleright"); +defineSymbol(math, ams, rel, "\u22B5", "\\trianglerighteq"); +defineSymbol(math, ams, rel, "\u22A9", "\\Vdash", true); defineSymbol(math, ams, rel, "\u2223", "\\shortmid"); defineSymbol(math, ams, rel, "\u2225", "\\shortparallel"); -defineSymbol(math, ams, rel, "\u226c", "\\between"); -defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork"); -defineSymbol(math, ams, rel, "\u221d", "\\varpropto"); -defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); -defineSymbol(math, ams, rel, "\u2234", "\\therefore"); -defineSymbol(math, ams, rel, "\u220d", "\\backepsilon"); -defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); -defineSymbol(math, ams, rel, "\u2235", "\\because"); -defineSymbol(math, ams, rel, "\u22d8", "\\llless"); -defineSymbol(math, ams, rel, "\u22d9", "\\gggtr"); -defineSymbol(math, ams, bin, "\u22b2", "\\lhd"); -defineSymbol(math, ams, bin, "\u22b3", "\\rhd"); -defineSymbol(math, ams, rel, "\u2242", "\\eqsim"); -defineSymbol(math, main, rel, "\u22c8", "\\Join"); -defineSymbol(math, ams, rel, "\u2251", "\\Doteq"); +defineSymbol(math, ams, rel, "\u226C", "\\between", true); +defineSymbol(math, ams, rel, "\u22D4", "\\pitchfork", true); +defineSymbol(math, ams, rel, "\u221D", "\\varpropto"); +defineSymbol(math, ams, rel, "\u25C0", "\\blacktriangleleft"); +// unicode-math says that \therefore is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2234", "\\therefore", true); +defineSymbol(math, ams, rel, "\u220D", "\\backepsilon"); +defineSymbol(math, ams, rel, "\u25B6", "\\blacktriangleright"); +// unicode-math says that \because is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2235", "\\because", true); +defineSymbol(math, ams, rel, "\u22D8", "\\llless"); +defineSymbol(math, ams, rel, "\u22D9", "\\gggtr"); +defineSymbol(math, ams, bin, "\u22B2", "\\lhd"); +defineSymbol(math, ams, bin, "\u22B3", "\\rhd"); +defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true); +defineSymbol(math, main, rel, "\u22C8", "\\Join"); +defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); // AMS Binary Operators -defineSymbol(math, ams, bin, "\u2214", "\\dotplus"); +defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true); defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus"); -defineSymbol(math, ams, bin, "\u22d2", "\\Cap"); -defineSymbol(math, ams, bin, "\u22d3", "\\Cup"); -defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge"); -defineSymbol(math, ams, bin, "\u229f", "\\boxminus"); -defineSymbol(math, ams, bin, "\u229e", "\\boxplus"); -defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes"); -defineSymbol(math, ams, bin, "\u22c9", "\\ltimes"); -defineSymbol(math, ams, bin, "\u22ca", "\\rtimes"); -defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes"); -defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes"); -defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge"); -defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee"); -defineSymbol(math, ams, bin, "\u229d", "\\circleddash"); -defineSymbol(math, ams, bin, "\u229b", "\\circledast"); -defineSymbol(math, ams, bin, "\u22c5", "\\centerdot"); -defineSymbol(math, ams, bin, "\u22ba", "\\intercal"); -defineSymbol(math, ams, bin, "\u22d2", "\\doublecap"); -defineSymbol(math, ams, bin, "\u22d3", "\\doublecup"); -defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes"); +defineSymbol(math, ams, bin, "\u22D2", "\\Cap", true); +defineSymbol(math, ams, bin, "\u22D3", "\\Cup", true); +defineSymbol(math, ams, bin, "\u2A5E", "\\doublebarwedge", true); +defineSymbol(math, ams, bin, "\u229F", "\\boxminus", true); +defineSymbol(math, ams, bin, "\u229E", "\\boxplus", true); +defineSymbol(math, ams, bin, "\u22C7", "\\divideontimes", true); +defineSymbol(math, ams, bin, "\u22C9", "\\ltimes", true); +defineSymbol(math, ams, bin, "\u22CA", "\\rtimes", true); +defineSymbol(math, ams, bin, "\u22CB", "\\leftthreetimes", true); +defineSymbol(math, ams, bin, "\u22CC", "\\rightthreetimes", true); +defineSymbol(math, ams, bin, "\u22CF", "\\curlywedge", true); +defineSymbol(math, ams, bin, "\u22CE", "\\curlyvee", true); +defineSymbol(math, ams, bin, "\u229D", "\\circleddash", true); +defineSymbol(math, ams, bin, "\u229B", "\\circledast", true); +defineSymbol(math, ams, bin, "\u22C5", "\\centerdot"); +defineSymbol(math, ams, bin, "\u22BA", "\\intercal", true); +defineSymbol(math, ams, bin, "\u22D2", "\\doublecap"); +defineSymbol(math, ams, bin, "\u22D3", "\\doublecup"); +defineSymbol(math, ams, bin, "\u22A0", "\\boxtimes", true); // AMS Arrows -defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow"); -defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow"); -defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows"); -defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows"); -defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow"); -defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow"); -defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail"); -defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft"); -defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons"); -defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft"); -defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft"); -defineSymbol(math, ams, rel, "\u21b0", "\\Lsh"); -defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows"); -defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft"); -defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft"); -defineSymbol(math, ams, rel, "\u22b8", "\\multimap"); -defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow"); -defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows"); -defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows"); -defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow"); -defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail"); -defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright"); -defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright"); -defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright"); -defineSymbol(math, ams, rel, "\u21b1", "\\Rsh"); -defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows"); -defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright"); -defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright"); -defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow"); -defineSymbol(math, ams, rel, "\u21dd", "\\leadsto"); -defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow"); -defineSymbol(math, ams, rel, "\u21be", "\\restriction"); +// Note: unicode-math maps \u21e2 to their own function \rightdasharrow. +// We'll map it to AMS function \dashrightarrow. It produces the same atom. +defineSymbol(math, ams, rel, "\u21E2", "\\dashrightarrow", true); +// unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21E0", "\\dashleftarrow", true); +defineSymbol(math, ams, rel, "\u21C7", "\\leftleftarrows", true); +defineSymbol(math, ams, rel, "\u21C6", "\\leftrightarrows", true); +defineSymbol(math, ams, rel, "\u21DA", "\\Lleftarrow", true); +defineSymbol(math, ams, rel, "\u219E", "\\twoheadleftarrow", true); +defineSymbol(math, ams, rel, "\u21A2", "\\leftarrowtail", true); +defineSymbol(math, ams, rel, "\u21AB", "\\looparrowleft", true); +defineSymbol(math, ams, rel, "\u21CB", "\\leftrightharpoons", true); +defineSymbol(math, ams, rel, "\u21B6", "\\curvearrowleft", true); +// unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21BA", "\\circlearrowleft", true); +defineSymbol(math, ams, rel, "\u21B0", "\\Lsh", true); +defineSymbol(math, ams, rel, "\u21C8", "\\upuparrows", true); +defineSymbol(math, ams, rel, "\u21BF", "\\upharpoonleft", true); +defineSymbol(math, ams, rel, "\u21C3", "\\downharpoonleft", true); +defineSymbol(math, ams, rel, "\u22B8", "\\multimap", true); +defineSymbol(math, ams, rel, "\u21AD", "\\leftrightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21C9", "\\rightrightarrows", true); +defineSymbol(math, ams, rel, "\u21C4", "\\rightleftarrows", true); +defineSymbol(math, ams, rel, "\u21A0", "\\twoheadrightarrow", true); +defineSymbol(math, ams, rel, "\u21A3", "\\rightarrowtail", true); +defineSymbol(math, ams, rel, "\u21AC", "\\looparrowright", true); +defineSymbol(math, ams, rel, "\u21B7", "\\curvearrowright", true); +// unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21BB", "\\circlearrowright", true); +defineSymbol(math, ams, rel, "\u21B1", "\\Rsh", true); +defineSymbol(math, ams, rel, "\u21CA", "\\downdownarrows", true); +defineSymbol(math, ams, rel, "\u21BE", "\\upharpoonright", true); +defineSymbol(math, ams, rel, "\u21C2", "\\downharpoonright", true); +defineSymbol(math, ams, rel, "\u21DD", "\\rightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21DD", "\\leadsto"); +defineSymbol(math, ams, rel, "\u21DB", "\\Rrightarrow", true); +defineSymbol(math, ams, rel, "\u21BE", "\\restriction"); defineSymbol(math, main, textord, "\u2018", "`"); defineSymbol(math, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\textdollar"); defineSymbol(math, main, textord, "%", "\\%"); +defineSymbol(text, main, textord, "%", "\\%"); defineSymbol(math, main, textord, "_", "\\_"); -defineSymbol(math, main, textord, "\u2220", "\\angle"); -defineSymbol(math, main, textord, "\u221e", "\\infty"); +defineSymbol(text, main, textord, "_", "\\_"); +defineSymbol(text, main, textord, "_", "\\textunderscore"); +defineSymbol(math, main, textord, "\u2220", "\\angle", true); +defineSymbol(math, main, textord, "\u221E", "\\infty", true); defineSymbol(math, main, textord, "\u2032", "\\prime"); -defineSymbol(math, main, textord, "\u25b3", "\\triangle"); -defineSymbol(math, main, textord, "\u0393", "\\Gamma"); -defineSymbol(math, main, textord, "\u0394", "\\Delta"); -defineSymbol(math, main, textord, "\u0398", "\\Theta"); -defineSymbol(math, main, textord, "\u039b", "\\Lambda"); -defineSymbol(math, main, textord, "\u039e", "\\Xi"); -defineSymbol(math, main, textord, "\u03a0", "\\Pi"); -defineSymbol(math, main, textord, "\u03a3", "\\Sigma"); -defineSymbol(math, main, textord, "\u03a5", "\\Upsilon"); -defineSymbol(math, main, textord, "\u03a6", "\\Phi"); -defineSymbol(math, main, textord, "\u03a8", "\\Psi"); -defineSymbol(math, main, textord, "\u03a9", "\\Omega"); -defineSymbol(math, main, textord, "\u00ac", "\\neg"); -defineSymbol(math, main, textord, "\u00ac", "\\lnot"); -defineSymbol(math, main, textord, "\u22a4", "\\top"); -defineSymbol(math, main, textord, "\u22a5", "\\bot"); +defineSymbol(math, main, textord, "\u25B3", "\\triangle"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039B", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039E", "\\Xi", true); +defineSymbol(math, main, textord, "\u03A0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03A3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03A5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03A6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03A8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03A9", "\\Omega", true); +defineSymbol(math, main, textord, "\xAC", "\\neg"); +defineSymbol(math, main, textord, "\xAC", "\\lnot"); +defineSymbol(math, main, textord, "\u22A4", "\\top"); +defineSymbol(math, main, textord, "\u22A5", "\\bot"); defineSymbol(math, main, textord, "\u2205", "\\emptyset"); defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); -defineSymbol(math, main, mathord, "\u03b1", "\\alpha"); -defineSymbol(math, main, mathord, "\u03b2", "\\beta"); -defineSymbol(math, main, mathord, "\u03b3", "\\gamma"); -defineSymbol(math, main, mathord, "\u03b4", "\\delta"); -defineSymbol(math, main, mathord, "\u03f5", "\\epsilon"); -defineSymbol(math, main, mathord, "\u03b6", "\\zeta"); -defineSymbol(math, main, mathord, "\u03b7", "\\eta"); -defineSymbol(math, main, mathord, "\u03b8", "\\theta"); -defineSymbol(math, main, mathord, "\u03b9", "\\iota"); -defineSymbol(math, main, mathord, "\u03ba", "\\kappa"); -defineSymbol(math, main, mathord, "\u03bb", "\\lambda"); -defineSymbol(math, main, mathord, "\u03bc", "\\mu"); -defineSymbol(math, main, mathord, "\u03bd", "\\nu"); -defineSymbol(math, main, mathord, "\u03be", "\\xi"); -defineSymbol(math, main, mathord, "o", "\\omicron"); -defineSymbol(math, main, mathord, "\u03c0", "\\pi"); -defineSymbol(math, main, mathord, "\u03c1", "\\rho"); -defineSymbol(math, main, mathord, "\u03c3", "\\sigma"); -defineSymbol(math, main, mathord, "\u03c4", "\\tau"); -defineSymbol(math, main, mathord, "\u03c5", "\\upsilon"); -defineSymbol(math, main, mathord, "\u03d5", "\\phi"); -defineSymbol(math, main, mathord, "\u03c7", "\\chi"); -defineSymbol(math, main, mathord, "\u03c8", "\\psi"); -defineSymbol(math, main, mathord, "\u03c9", "\\omega"); -defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon"); -defineSymbol(math, main, mathord, "\u03d1", "\\vartheta"); -defineSymbol(math, main, mathord, "\u03d6", "\\varpi"); -defineSymbol(math, main, mathord, "\u03f1", "\\varrho"); -defineSymbol(math, main, mathord, "\u03c2", "\\varsigma"); -defineSymbol(math, main, mathord, "\u03c6", "\\varphi"); +defineSymbol(math, main, mathord, "\u03B1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03B2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03B3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03B4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03F5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03B6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03B7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03B8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03B9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03BA", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03BB", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03BC", "\\mu", true); +defineSymbol(math, main, mathord, "\u03BD", "\\nu", true); +defineSymbol(math, main, mathord, "\u03BE", "\\xi", true); +defineSymbol(math, main, mathord, "\u03BF", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03C0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03C1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03C3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03C4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03C5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03D5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03C7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03C8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03C9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03B5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03D1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03D6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03F1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03C2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03C6", "\\varphi", true); defineSymbol(math, main, bin, "\u2217", "*"); defineSymbol(math, main, bin, "+", "+"); defineSymbol(math, main, bin, "\u2212", "-"); -defineSymbol(math, main, bin, "\u22c5", "\\cdot"); +defineSymbol(math, main, bin, "\u22C5", "\\cdot"); defineSymbol(math, main, bin, "\u2218", "\\circ"); -defineSymbol(math, main, bin, "\u00f7", "\\div"); -defineSymbol(math, main, bin, "\u00b1", "\\pm"); -defineSymbol(math, main, bin, "\u00d7", "\\times"); -defineSymbol(math, main, bin, "\u2229", "\\cap"); -defineSymbol(math, main, bin, "\u222a", "\\cup"); +defineSymbol(math, main, bin, "\xF7", "\\div", true); +defineSymbol(math, main, bin, "\xB1", "\\pm", true); +defineSymbol(math, main, bin, "\xD7", "\\times", true); +defineSymbol(math, main, bin, "\u2229", "\\cap", true); +defineSymbol(math, main, bin, "\u222A", "\\cup", true); defineSymbol(math, main, bin, "\u2216", "\\setminus"); defineSymbol(math, main, bin, "\u2227", "\\land"); defineSymbol(math, main, bin, "\u2228", "\\lor"); -defineSymbol(math, main, bin, "\u2227", "\\wedge"); -defineSymbol(math, main, bin, "\u2228", "\\vee"); -defineSymbol(math, main, textord, "\u221a", "\\surd"); +defineSymbol(math, main, bin, "\u2227", "\\wedge", true); +defineSymbol(math, main, bin, "\u2228", "\\vee", true); +defineSymbol(math, main, textord, "\u221A", "\\surd"); defineSymbol(math, main, open, "(", "("); defineSymbol(math, main, open, "[", "["); -defineSymbol(math, main, open, "\u27e8", "\\langle"); +defineSymbol(math, main, open, "\u27E8", "\\langle"); defineSymbol(math, main, open, "\u2223", "\\lvert"); defineSymbol(math, main, open, "\u2225", "\\lVert"); defineSymbol(math, main, close, ")", ")"); defineSymbol(math, main, close, "]", "]"); defineSymbol(math, main, close, "?", "?"); defineSymbol(math, main, close, "!", "!"); -defineSymbol(math, main, close, "\u27e9", "\\rangle"); +defineSymbol(math, main, close, "\u27E9", "\\rangle"); defineSymbol(math, main, close, "\u2223", "\\rvert"); defineSymbol(math, main, close, "\u2225", "\\rVert"); defineSymbol(math, main, rel, "=", "="); defineSymbol(math, main, rel, "<", "<"); defineSymbol(math, main, rel, ">", ">"); defineSymbol(math, main, rel, ":", ":"); -defineSymbol(math, main, rel, "\u2248", "\\approx"); -defineSymbol(math, main, rel, "\u2245", "\\cong"); +defineSymbol(math, main, rel, "\u2248", "\\approx", true); +defineSymbol(math, main, rel, "\u2245", "\\cong", true); defineSymbol(math, main, rel, "\u2265", "\\ge"); -defineSymbol(math, main, rel, "\u2265", "\\geq"); +defineSymbol(math, main, rel, "\u2265", "\\geq", true); defineSymbol(math, main, rel, "\u2190", "\\gets"); defineSymbol(math, main, rel, ">", "\\gt"); -defineSymbol(math, main, rel, "\u2208", "\\in"); -defineSymbol(math, main, rel, "\u2209", "\\notin"); -defineSymbol(math, main, rel, "\u2282", "\\subset"); -defineSymbol(math, main, rel, "\u2283", "\\supset"); -defineSymbol(math, main, rel, "\u2286", "\\subseteq"); -defineSymbol(math, main, rel, "\u2287", "\\supseteq"); -defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq"); -defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq"); -defineSymbol(math, main, rel, "\u22a8", "\\models"); -defineSymbol(math, main, rel, "\u2190", "\\leftarrow"); +defineSymbol(math, main, rel, "\u2208", "\\in", true); +defineSymbol(math, main, rel, "\u2209", "\\notin", true); +defineSymbol(math, main, rel, "\u0338", "\\not"); +defineSymbol(math, main, rel, "\u2282", "\\subset", true); +defineSymbol(math, main, rel, "\u2283", "\\supset", true); +defineSymbol(math, main, rel, "\u2286", "\\subseteq", true); +defineSymbol(math, main, rel, "\u2287", "\\supseteq", true); +defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true); +defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true); +defineSymbol(math, main, rel, "\u22A8", "\\models"); +defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); defineSymbol(math, main, rel, "\u2264", "\\le"); -defineSymbol(math, main, rel, "\u2264", "\\leq"); +defineSymbol(math, main, rel, "\u2264", "\\leq", true); defineSymbol(math, main, rel, "<", "\\lt"); -defineSymbol(math, main, rel, "\u2260", "\\ne"); +defineSymbol(math, main, rel, "\u2260", "\\ne", true); defineSymbol(math, main, rel, "\u2260", "\\neq"); -defineSymbol(math, main, rel, "\u2192", "\\rightarrow"); +defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); defineSymbol(math, main, rel, "\u2192", "\\to"); -defineSymbol(math, ams, rel, "\u2271", "\\ngeq"); -defineSymbol(math, ams, rel, "\u2270", "\\nleq"); +defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); +defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); defineSymbol(math, main, spacing, null, "\\!"); -defineSymbol(math, main, spacing, "\u00a0", "\\ "); -defineSymbol(math, main, spacing, "\u00a0", "~"); +defineSymbol(math, main, spacing, "\xA0", "\\ "); +defineSymbol(math, main, spacing, "\xA0", "~"); defineSymbol(math, main, spacing, null, "\\,"); defineSymbol(math, main, spacing, null, "\\:"); defineSymbol(math, main, spacing, null, "\\;"); defineSymbol(math, main, spacing, null, "\\enspace"); defineSymbol(math, main, spacing, null, "\\qquad"); defineSymbol(math, main, spacing, null, "\\quad"); -defineSymbol(math, main, spacing, "\u00a0", "\\space"); +defineSymbol(math, main, spacing, "\xA0", "\\space"); defineSymbol(math, main, punct, ",", ","); defineSymbol(math, main, punct, ";", ";"); defineSymbol(math, main, punct, ":", "\\colon"); -defineSymbol(math, ams, bin, "\u22bc", "\\barwedge"); -defineSymbol(math, ams, bin, "\u22bb", "\\veebar"); -defineSymbol(math, main, bin, "\u2299", "\\odot"); -defineSymbol(math, main, bin, "\u2295", "\\oplus"); -defineSymbol(math, main, bin, "\u2297", "\\otimes"); -defineSymbol(math, main, textord, "\u2202", "\\partial"); -defineSymbol(math, main, bin, "\u2298", "\\oslash"); -defineSymbol(math, ams, bin, "\u229a", "\\circledcirc"); -defineSymbol(math, ams, bin, "\u22a1", "\\boxdot"); -defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup"); -defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown"); +defineSymbol(math, ams, bin, "\u22BC", "\\barwedge", true); +defineSymbol(math, ams, bin, "\u22BB", "\\veebar", true); +defineSymbol(math, main, bin, "\u2299", "\\odot", true); +defineSymbol(math, main, bin, "\u2295", "\\oplus", true); +defineSymbol(math, main, bin, "\u2297", "\\otimes", true); +defineSymbol(math, main, textord, "\u2202", "\\partial", true); +defineSymbol(math, main, bin, "\u2298", "\\oslash", true); +defineSymbol(math, ams, bin, "\u229A", "\\circledcirc", true); +defineSymbol(math, ams, bin, "\u22A1", "\\boxdot", true); +defineSymbol(math, main, bin, "\u25B3", "\\bigtriangleup"); +defineSymbol(math, main, bin, "\u25BD", "\\bigtriangledown"); defineSymbol(math, main, bin, "\u2020", "\\dagger"); -defineSymbol(math, main, bin, "\u22c4", "\\diamond"); -defineSymbol(math, main, bin, "\u22c6", "\\star"); -defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); -defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); +defineSymbol(math, main, bin, "\u22C4", "\\diamond"); +defineSymbol(math, main, bin, "\u22C6", "\\star"); +defineSymbol(math, main, bin, "\u25C3", "\\triangleleft"); +defineSymbol(math, main, bin, "\u25B9", "\\triangleright"); defineSymbol(math, main, open, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\textbraceleft"); defineSymbol(math, main, close, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\textbraceright"); defineSymbol(math, main, open, "{", "\\lbrace"); defineSymbol(math, main, close, "}", "\\rbrace"); defineSymbol(math, main, open, "[", "\\lbrack"); defineSymbol(math, main, close, "]", "\\rbrack"); -defineSymbol(math, main, open, "\u230a", "\\lfloor"); -defineSymbol(math, main, close, "\u230b", "\\rfloor"); +defineSymbol(text, main, textord, "<", "\\textless"); // in T1 fontenc +defineSymbol(text, main, textord, ">", "\\textgreater"); // in T1 fontenc +defineSymbol(math, main, open, "\u230A", "\\lfloor"); +defineSymbol(math, main, close, "\u230B", "\\rfloor"); defineSymbol(math, main, open, "\u2308", "\\lceil"); defineSymbol(math, main, close, "\u2309", "\\rceil"); defineSymbol(math, main, textord, "\\", "\\backslash"); defineSymbol(math, main, textord, "\u2223", "|"); defineSymbol(math, main, textord, "\u2223", "\\vert"); +defineSymbol(text, main, textord, "|", "\\textbar"); // in T1 fontenc defineSymbol(math, main, textord, "\u2225", "\\|"); defineSymbol(math, main, textord, "\u2225", "\\Vert"); -defineSymbol(math, main, rel, "\u2191", "\\uparrow"); -defineSymbol(math, main, rel, "\u21d1", "\\Uparrow"); -defineSymbol(math, main, rel, "\u2193", "\\downarrow"); -defineSymbol(math, main, rel, "\u21d3", "\\Downarrow"); -defineSymbol(math, main, rel, "\u2195", "\\updownarrow"); -defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow"); -defineSymbol(math, math, op, "\u2210", "\\coprod"); -defineSymbol(math, math, op, "\u22c1", "\\bigvee"); -defineSymbol(math, math, op, "\u22c0", "\\bigwedge"); -defineSymbol(math, math, op, "\u2a04", "\\biguplus"); -defineSymbol(math, math, op, "\u22c2", "\\bigcap"); -defineSymbol(math, math, op, "\u22c3", "\\bigcup"); -defineSymbol(math, math, op, "\u222b", "\\int"); -defineSymbol(math, math, op, "\u222b", "\\intop"); -defineSymbol(math, math, op, "\u222c", "\\iint"); -defineSymbol(math, math, op, "\u222d", "\\iiint"); -defineSymbol(math, math, op, "\u220f", "\\prod"); -defineSymbol(math, math, op, "\u2211", "\\sum"); -defineSymbol(math, math, op, "\u2a02", "\\bigotimes"); -defineSymbol(math, math, op, "\u2a01", "\\bigoplus"); -defineSymbol(math, math, op, "\u2a00", "\\bigodot"); -defineSymbol(math, math, op, "\u222e", "\\oint"); -defineSymbol(math, math, op, "\u2a06", "\\bigsqcup"); -defineSymbol(math, math, op, "\u222b", "\\smallint"); -defineSymbol(math, main, inner, "\u2026", "\\ldots"); -defineSymbol(math, main, inner, "\u22ef", "\\cdots"); -defineSymbol(math, main, inner, "\u22f1", "\\ddots"); -defineSymbol(math, main, textord, "\u22ee", "\\vdots"); -defineSymbol(math, main, accent, "\u00b4", "\\acute"); -defineSymbol(math, main, accent, "\u0060", "\\grave"); -defineSymbol(math, main, accent, "\u00a8", "\\ddot"); -defineSymbol(math, main, accent, "\u007e", "\\tilde"); -defineSymbol(math, main, accent, "\u00af", "\\bar"); -defineSymbol(math, main, accent, "\u02d8", "\\breve"); -defineSymbol(math, main, accent, "\u02c7", "\\check"); -defineSymbol(math, main, accent, "\u005e", "\\hat"); -defineSymbol(math, main, accent, "\u20d7", "\\vec"); -defineSymbol(math, main, accent, "\u02d9", "\\dot"); +defineSymbol(text, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); +defineSymbol(math, main, rel, "\u21D1", "\\Uparrow", true); +defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); +defineSymbol(math, main, rel, "\u21D3", "\\Downarrow", true); +defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true); +defineSymbol(math, main, rel, "\u21D5", "\\Updownarrow", true); +defineSymbol(math, main, op, "\u2210", "\\coprod"); +defineSymbol(math, main, op, "\u22C1", "\\bigvee"); +defineSymbol(math, main, op, "\u22C0", "\\bigwedge"); +defineSymbol(math, main, op, "\u2A04", "\\biguplus"); +defineSymbol(math, main, op, "\u22C2", "\\bigcap"); +defineSymbol(math, main, op, "\u22C3", "\\bigcup"); +defineSymbol(math, main, op, "\u222B", "\\int"); +defineSymbol(math, main, op, "\u222B", "\\intop"); +defineSymbol(math, main, op, "\u222C", "\\iint"); +defineSymbol(math, main, op, "\u222D", "\\iiint"); +defineSymbol(math, main, op, "\u220F", "\\prod"); +defineSymbol(math, main, op, "\u2211", "\\sum"); +defineSymbol(math, main, op, "\u2A02", "\\bigotimes"); +defineSymbol(math, main, op, "\u2A01", "\\bigoplus"); +defineSymbol(math, main, op, "\u2A00", "\\bigodot"); +defineSymbol(math, main, op, "\u222E", "\\oint"); +defineSymbol(math, main, op, "\u2A06", "\\bigsqcup"); +defineSymbol(math, main, op, "\u222B", "\\smallint"); +defineSymbol(text, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); +defineSymbol(text, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u22EF", "\\@cdots", true); +defineSymbol(math, main, inner, "\u22F1", "\\ddots", true); +defineSymbol(math, main, textord, "\u22EE", "\\vdots", true); +defineSymbol(math, main, accent, "\xB4", "\\acute"); +defineSymbol(math, main, accent, "`", "\\grave"); +defineSymbol(math, main, accent, "\xA8", "\\ddot"); +defineSymbol(math, main, accent, "~", "\\tilde"); +defineSymbol(math, main, accent, "\xAF", "\\bar"); +defineSymbol(math, main, accent, "\u02D8", "\\breve"); +defineSymbol(math, main, accent, "\u02C7", "\\check"); +defineSymbol(math, main, accent, "^", "\\hat"); +defineSymbol(math, main, accent, "\u20D7", "\\vec"); +defineSymbol(math, main, accent, "\u02D9", "\\dot"); defineSymbol(math, main, mathord, "\u0131", "\\imath"); defineSymbol(math, main, mathord, "\u0237", "\\jmath"); +defineSymbol(text, main, accent, "\u02CA", "\\'"); // acute +defineSymbol(text, main, accent, "\u02CB", "\\`"); // grave +defineSymbol(text, main, accent, "\u02C6", "\\^"); // circumflex +defineSymbol(text, main, accent, "\u02DC", "\\~"); // tilde +defineSymbol(text, main, accent, "\u02C9", "\\="); // macron +defineSymbol(text, main, accent, "\u02D8", "\\u"); // breve +defineSymbol(text, main, accent, "\u02D9", "\\."); // dot above +defineSymbol(text, main, accent, "\u02DA", "\\r"); // ring above +defineSymbol(text, main, accent, "\u02C7", "\\v"); // caron +defineSymbol(text, main, accent, "\xA8", '\\"'); // diaresis +defineSymbol(text, main, accent, "\u030B", "\\H"); // double acute defineSymbol(text, main, textord, "\u2013", "--"); +defineSymbol(text, main, textord, "\u2013", "\\textendash"); defineSymbol(text, main, textord, "\u2014", "---"); +defineSymbol(text, main, textord, "\u2014", "\\textemdash"); defineSymbol(text, main, textord, "\u2018", "`"); +defineSymbol(text, main, textord, "\u2018", "\\textquoteleft"); defineSymbol(text, main, textord, "\u2019", "'"); -defineSymbol(text, main, textord, "\u201c", "``"); -defineSymbol(text, main, textord, "\u201d", "''"); -defineSymbol(math, main, textord, "\u00b0", "\\degree"); -defineSymbol(text, main, textord, "\u00b0", "\\degree"); -defineSymbol(math, main, mathord, "\u00a3", "\\pounds"); +defineSymbol(text, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(text, main, textord, "\u201C", "``"); +defineSymbol(text, main, textord, "\u201C", "\\textquotedblleft"); +defineSymbol(text, main, textord, "\u201D", "''"); +defineSymbol(text, main, textord, "\u201D", "\\textquotedblright"); +defineSymbol(math, main, textord, "\xB0", "\\degree"); +defineSymbol(text, main, textord, "\xB0", "\\degree"); +// TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Italic defines this character "163". +defineSymbol(math, main, mathord, "\xA3", "\\pounds"); +defineSymbol(math, main, mathord, "\xA3", "\\mathsterling", true); +defineSymbol(text, main, mathord, "\xA3", "\\pounds"); +defineSymbol(text, main, mathord, "\xA3", "\\textsterling"); defineSymbol(math, ams, textord, "\u2720", "\\maltese"); defineSymbol(text, ams, textord, "\u2720", "\\maltese"); -defineSymbol(text, main, spacing, "\u00a0", "\\ "); -defineSymbol(text, main, spacing, "\u00a0", " "); -defineSymbol(text, main, spacing, "\u00a0", "~"); +defineSymbol(text, main, spacing, "\xA0", "\\ "); +defineSymbol(text, main, spacing, "\xA0", " "); +defineSymbol(text, main, spacing, "\xA0", "~"); // There are lots of symbols which are the same, so we add them in afterwards. -var i; -var ch; // All of these are textords in math mode var mathTextSymbols = "0123456789/@.\""; -for (i = 0; i < mathTextSymbols.length; i++) { - ch = mathTextSymbols.charAt(i); +for (var i = 0; i < mathTextSymbols.length; i++) { + var ch = mathTextSymbols.charAt(i); defineSymbol(math, main, textord, ch, ch); } // All of these are textords in text mode -var textSymbols = "0123456789!@*()-=+[]\";:?/.,"; -for (i = 0; i < textSymbols.length; i++) { - ch = textSymbols.charAt(i); - defineSymbol(text, main, textord, ch, ch); +var textSymbols = "0123456789!@*()-=+[]<>|\";:?/.,"; +for (var _i = 0; _i < textSymbols.length; _i++) { + var _ch = textSymbols.charAt(_i); + defineSymbol(text, main, textord, _ch, _ch); } // All of these are textords in text mode, and mathords in math mode var letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; -for (i = 0; i < letters.length; i++) { - ch = letters.charAt(i); - defineSymbol(math, main, mathord, ch, ch); - defineSymbol(text, main, textord, ch, ch); +for (var _i2 = 0; _i2 < letters.length; _i2++) { + var _ch2 = letters.charAt(_i2); + defineSymbol(math, main, mathord, _ch2, _ch2); + defineSymbol(text, main, textord, _ch2, _ch2); } // Latin-1 letters -for (i = 0x00C0; i <= 0x00D6; i++) { - ch = String.fromCharCode(i); - defineSymbol(text, main, textord, ch, ch); +for (var _i3 = 0x00C0; _i3 <= 0x00D6; _i3++) { + var _ch3 = String.fromCharCode(_i3); + defineSymbol(math, main, mathord, _ch3, _ch3); + defineSymbol(text, main, textord, _ch3, _ch3); } -for (i = 0x00D8; i <= 0x00F6; i++) { - ch = String.fromCharCode(i); - defineSymbol(text, main, textord, ch, ch); +for (var _i4 = 0x00D8; _i4 <= 0x00F6; _i4++) { + var _ch4 = String.fromCharCode(_i4); + defineSymbol(math, main, mathord, _ch4, _ch4); + defineSymbol(text, main, textord, _ch4, _ch4); } -for (i = 0x00F8; i <= 0x00FF; i++) { - ch = String.fromCharCode(i); - defineSymbol(text, main, textord, ch, ch); +for (var _i5 = 0x00F8; _i5 <= 0x00FF; _i5++) { + var _ch5 = String.fromCharCode(_i5); + defineSymbol(math, main, mathord, _ch5, _ch5); + defineSymbol(text, main, textord, _ch5, _ch5); } // Cyrillic -for (i = 0x0410; i <= 0x044F; i++) { - ch = String.fromCharCode(i); - defineSymbol(text, main, textord, ch, ch); +for (var _i6 = 0x0410; _i6 <= 0x044F; _i6++) { + var _ch6 = String.fromCharCode(_i6); + defineSymbol(text, main, textord, _ch6, _ch6); } -},{}],24:[function(require,module,exports){ -var hangulRegex = /[\uAC00-\uD7AF]/; +// Unicode versions of existing characters +defineSymbol(text, main, textord, "\u2013", "–"); +defineSymbol(text, main, textord, "\u2014", "—"); +defineSymbol(text, main, textord, "\u2018", "‘"); +defineSymbol(text, main, textord, "\u2019", "’"); +defineSymbol(text, main, textord, "\u201C", "“"); +defineSymbol(text, main, textord, "\u201D", "”"); + +},{}],126:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var hangulRegex = exports.hangulRegex = /[\uAC00-\uD7AF]/; // This regex combines +// - CJK symbols and punctuation: [\u3000-\u303F] // - Hiragana: [\u3040-\u309F] // - Katakana: [\u30A0-\u30FF] // - CJK ideograms: [\u4E00-\u9FAF] // - Hangul syllables: [\uAC00-\uD7AF] +// - Fullwidth punctuation: [\uFF00-\uFF60] // Notably missing are halfwidth Katakana and Romanji glyphs. -var cjkRegex = - /[\u3040-\u309F]|[\u30A0-\u30FF]|[\u4E00-\u9FAF]|[\uAC00-\uD7AF]/; +var cjkRegex = exports.cjkRegex = /[\u3000-\u30FF\u4E00-\u9FAF\uAC00-\uD7AF\uFF00-\uFF60]/; -module.exports = { - cjkRegex: cjkRegex, - hangulRegex: hangulRegex, +},{}],127:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.calculateSize = exports.validUnit = undefined; + +var _ParseError = require("./ParseError"); + +var _ParseError2 = _interopRequireDefault(_ParseError); + +var _Options = require("./Options"); + +var _Options2 = _interopRequireDefault(_Options); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// This table gives the number of TeX pts in one of each *absolute* TeX unit. +// Thus, multiplying a length by this number converts the length from units +// into pts. Dividing the result by ptPerEm gives the number of ems +// *assuming* a font size of ptPerEm (normal size, normal style). + + +/** + * This file does conversion between units. In particular, it provides + * calculateSize to convert other units into ems. + */ + +var ptPerUnit = { + // https://en.wikibooks.org/wiki/LaTeX/Lengths and + // https://tex.stackexchange.com/a/8263 + "pt": 1, // TeX point + "mm": 7227 / 2540, // millimeter + "cm": 7227 / 254, // centimeter + "in": 72.27, // inch + "bp": 803 / 800, // big (PostScript) points + "pc": 12, // pica + "dd": 1238 / 1157, // didot + "cc": 14856 / 1157, // cicero (12 didot) + "nd": 685 / 642, // new didot + "nc": 1370 / 107, // new cicero (12 new didot) + "sp": 1 / 65536, // scaled point (TeX's internal smallest unit) + // https://tex.stackexchange.com/a/41371 + "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX }; -},{}],25:[function(require,module,exports){ +// Dictionary of relative units, for fast validity testing. +var relativeUnit = { + "ex": true, + "em": true, + "mu": true +}; + +/** + * Determine whether the specified unit (either a string defining the unit + * or a "size" parse node containing a unit field) is valid. + */ +var validUnit = exports.validUnit = function validUnit(unit) { + if (typeof unit !== "string") { + unit = unit.unit; + } + return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; +}; + +/* + * Convert a "size" parse node (with numeric "number" and string "unit" fields, + * as parsed by functions.js argType "size") into a CSS em value for the + * current style/scale. `options` gives the current options. + */ +var calculateSize = exports.calculateSize = function calculateSize(sizeValue, options) { + var scale = void 0; + if (sizeValue.unit in ptPerUnit) { + // Absolute units + scale = ptPerUnit[sizeValue.unit] // Convert unit to pt + / options.fontMetrics().ptPerEm // Convert pt to CSS em + / options.sizeMultiplier; // Unscale to make absolute units + } else if (sizeValue.unit === "mu") { + // `mu` units scale with scriptstyle/scriptscriptstyle. + scale = options.fontMetrics().cssEmPerMu; + } else { + // Other relative units always refer to the *textstyle* font + // in the current size. + var unitOptions = void 0; + if (options.style.isTight()) { + // isTight() means current style is script/scriptscript. + unitOptions = options.havingStyle(options.style.text()); + } else { + unitOptions = options; + } + // TODO: In TeX these units are relative to the quad of the current + // *text* font, e.g. cmr10. KaTeX instead uses values from the + // comparably-sized *Computer Modern symbol* font. At 10pt, these + // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; + // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. + // TeX \showlists shows a kern of 1.13889 * fontsize; + // KaTeX shows a kern of 1.171 * fontsize. + if (sizeValue.unit === "ex") { + scale = unitOptions.fontMetrics().xHeight; + } else if (sizeValue.unit === "em") { + scale = unitOptions.fontMetrics().quad; + } else { + throw new _ParseError2.default("Invalid unit: '" + sizeValue.unit + "'"); + } + if (unitOptions !== options) { + scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; + } + } + return Math.min(sizeValue.number * scale, options.maxSize); +}; + +},{"./Options":83,"./ParseError":84}],128:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + /** * This file contains a list of utility functions which are useful in other * files. @@ -8584,16 +14311,15 @@ module.exports = { * possible. */ var nativeIndexOf = Array.prototype.indexOf; -var indexOf = function(list, elem) { +var indexOf = function indexOf(list, elem) { if (list == null) { return -1; } if (nativeIndexOf && list.indexOf === nativeIndexOf) { return list.indexOf(elem); } - var i = 0; var l = list.length; - for (; i < l; i++) { + for (var i = 0; i < l; i++) { if (list[i] === elem) { return i; } @@ -8604,21 +14330,22 @@ var indexOf = function(list, elem) { /** * Return whether an element is contained in a list */ -var contains = function(list, elem) { +var contains = function contains(list, elem) { return indexOf(list, elem) !== -1; }; /** * Provide a default value if a setting is undefined + * NOTE: Couldn't use `T` as the output type due to facebook/flow#5022. */ -var deflt = function(setting, defaultIfUndefined) { +var deflt = function deflt(setting, defaultIfUndefined) { return setting === undefined ? defaultIfUndefined : setting; }; // hyphenate and escape adapted from Facebook's React under Apache 2 license var uppercase = /([A-Z])/g; -var hyphenate = function(str) { +var hyphenate = function hyphenate(str) { return str.replace(uppercase, "-$1").toLowerCase(); }; @@ -8627,38 +14354,33 @@ var ESCAPE_LOOKUP = { ">": ">", "<": "<", "\"": """, - "'": "'", + "'": "'" }; var ESCAPE_REGEX = /[&><"']/g; -function escaper(match) { - return ESCAPE_LOOKUP[match]; -} - /** * Escapes text to prevent scripting attacks. - * - * @param {*} text Text value to escape. - * @return {string} An escaped string. */ function escape(text) { - return ("" + text).replace(ESCAPE_REGEX, escaper); + return String(text).replace(ESCAPE_REGEX, function (match) { + return ESCAPE_LOOKUP[match]; + }); } /** * A function to set the text content of a DOM element in all supported * browsers. Note that we don't define this if there is no document. */ -var setTextContent; +var setTextContent = void 0; if (typeof document !== "undefined") { var testNode = document.createElement("span"); if ("textContent" in testNode) { - setTextContent = function(node, text) { + setTextContent = function setTextContent(node, text) { node.textContent = text; }; } else { - setTextContent = function(node, text) { + setTextContent = function setTextContent(node, text) { node.innerText = text; }; } @@ -8671,14 +14393,14 @@ function clearNode(node) { setTextContent(node, ""); } -module.exports = { +exports.default = { contains: contains, deflt: deflt, escape: escape, hyphenate: hyphenate, indexOf: indexOf, setTextContent: setTextContent, - clearNode: clearNode, + clearNode: clearNode }; },{}]},{},[1])(1) diff --git a/vendor/assets/stylesheets/katex.scss b/vendor/assets/stylesheets/katex.scss index b45836716f2..937a67ddc42 100644 --- a/vendor/assets/stylesheets/katex.scss +++ b/vendor/assets/stylesheets/katex.scss @@ -1,32 +1,32 @@ /* -The MIT License (MIT) + The MIT License (MIT) -Copyright (c) 2015 Khan Academy + Copyright (c) 2015 Khan Academy -This software also uses portions of the underscore.js project, which is -MIT licensed with the following copyright: + This software also uses portions of the underscore.js project, which is + MIT licensed with the following copyright: -Copyright (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative -Reporters & Editors + Copyright (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative + Reporters & Editors -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + */ /* Here is how to build a version of KaTeX that works with gitlab. @@ -45,112 +45,112 @@ SOFTWARE. font-family: 'KaTeX_AMS'; src: url(font-path('KaTeX_AMS-Regular.eot')); src: url(font-path('KaTeX_AMS-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_AMS-Regular.woff2')) format('woff2'), url(font-path('KaTeX_AMS-Regular.woff')) format('woff'), url(font-path('KaTeX_AMS-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Caligraphic'; src: url(font-path('KaTeX_Caligraphic-Bold.eot')); src: url(font-path('KaTeX_Caligraphic-Bold.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Caligraphic-Bold.woff2')) format('woff2'), url(font-path('KaTeX_Caligraphic-Bold.woff')) format('woff'), url(font-path('KaTeX_Caligraphic-Bold.ttf')) format('truetype'); - font-weight: 600; + font-weight: bold; font-style: normal; } @font-face { font-family: 'KaTeX_Caligraphic'; src: url(font-path('KaTeX_Caligraphic-Regular.eot')); src: url(font-path('KaTeX_Caligraphic-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Caligraphic-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Caligraphic-Regular.woff')) format('woff'), url(font-path('KaTeX_Caligraphic-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Fraktur'; src: url(font-path('KaTeX_Fraktur-Bold.eot')); src: url(font-path('KaTeX_Fraktur-Bold.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Fraktur-Bold.woff2')) format('woff2'), url(font-path('KaTeX_Fraktur-Bold.woff')) format('woff'), url(font-path('KaTeX_Fraktur-Bold.ttf')) format('truetype'); - font-weight: 600; + font-weight: bold; font-style: normal; } @font-face { font-family: 'KaTeX_Fraktur'; src: url(font-path('KaTeX_Fraktur-Regular.eot')); src: url(font-path('KaTeX_Fraktur-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Fraktur-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Fraktur-Regular.woff')) format('woff'), url(font-path('KaTeX_Fraktur-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Main'; src: url(font-path('KaTeX_Main-Bold.eot')); src: url(font-path('KaTeX_Main-Bold.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Main-Bold.woff2')) format('woff2'), url(font-path('KaTeX_Main-Bold.woff')) format('woff'), url(font-path('KaTeX_Main-Bold.ttf')) format('truetype'); - font-weight: 600; + font-weight: bold; font-style: normal; } @font-face { font-family: 'KaTeX_Main'; src: url(font-path('KaTeX_Main-Italic.eot')); src: url(font-path('KaTeX_Main-Italic.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Main-Italic.woff2')) format('woff2'), url(font-path('KaTeX_Main-Italic.woff')) format('woff'), url(font-path('KaTeX_Main-Italic.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: italic; } @font-face { font-family: 'KaTeX_Main'; src: url(font-path('KaTeX_Main-Regular.eot')); src: url(font-path('KaTeX_Main-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Main-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Main-Regular.woff')) format('woff'), url(font-path('KaTeX_Main-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Math'; src: url(font-path('KaTeX_Math-Italic.eot')); src: url(font-path('KaTeX_Math-Italic.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Math-Italic.woff2')) format('woff2'), url(font-path('KaTeX_Math-Italic.woff')) format('woff'), url(font-path('KaTeX_Math-Italic.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: italic; } @font-face { font-family: 'KaTeX_SansSerif'; src: url(font-path('KaTeX_SansSerif-Regular.eot')); src: url(font-path('KaTeX_SansSerif-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_SansSerif-Regular.woff2')) format('woff2'), url(font-path('KaTeX_SansSerif-Regular.woff')) format('woff'), url(font-path('KaTeX_SansSerif-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Script'; src: url(font-path('KaTeX_Script-Regular.eot')); src: url(font-path('KaTeX_Script-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Script-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Script-Regular.woff')) format('woff'), url(font-path('KaTeX_Script-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Size1'; src: url(font-path('KaTeX_Size1-Regular.eot')); src: url(font-path('KaTeX_Size1-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Size1-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Size1-Regular.woff')) format('woff'), url(font-path('KaTeX_Size1-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Size2'; src: url(font-path('KaTeX_Size2-Regular.eot')); src: url(font-path('KaTeX_Size2-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Size2-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Size2-Regular.woff')) format('woff'), url(font-path('KaTeX_Size2-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Size3'; src: url(font-path('KaTeX_Size3-Regular.eot')); src: url(font-path('KaTeX_Size3-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Size3-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Size3-Regular.woff')) format('woff'), url(font-path('KaTeX_Size3-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Size4'; src: url(font-path('KaTeX_Size4-Regular.eot')); src: url(font-path('KaTeX_Size4-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Size4-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Size4-Regular.woff')) format('woff'), url(font-path('KaTeX_Size4-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } @font-face { font-family: 'KaTeX_Typewriter'; src: url(font-path('KaTeX_Typewriter-Regular.eot')); src: url(font-path('KaTeX_Typewriter-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Typewriter-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Typewriter-Regular.woff')) format('woff'), url(font-path('KaTeX_Typewriter-Regular.ttf')) format('truetype'); - font-weight: 400; + font-weight: normal; font-style: normal; } .katex-display { @@ -167,6 +167,10 @@ SOFTWARE. line-height: 1.2; white-space: nowrap; text-indent: 0; + text-rendering: auto; +} +.katex * { + -ms-high-contrast-adjust: none !important; } .katex .katex-html { display: inline-block; @@ -181,18 +185,25 @@ SOFTWARE. overflow: hidden; } .katex .base { + position: relative; display: inline-block; } .katex .strut { display: inline-block; } +.katex .mathrm { + font-style: normal; +} +.katex .textit { + font-style: italic; +} .katex .mathit { font-family: KaTeX_Math; font-style: italic; } .katex .mathbf { font-family: KaTeX_Main; - font-weight: 600; + font-weight: bold; } .katex .amsrm { font-family: KaTeX_AMS; @@ -219,155 +230,162 @@ SOFTWARE. font-family: KaTeX_Main; font-style: italic; } -.katex .textstyle > .mord + .mop { +.katex .mainrm { + font-family: KaTeX_Main; + font-style: normal; +} +.katex .mord + .mop { margin-left: 0.16667em; } -.katex .textstyle > .mord + .mbin { +.katex .mord + .mbin { margin-left: 0.22222em; } -.katex .textstyle > .mord + .mrel { +.katex .mord + .mrel { margin-left: 0.27778em; } -.katex .textstyle > .mord + .minner { +.katex .mord + .minner { margin-left: 0.16667em; } -.katex .textstyle > .mop + .mord { +.katex .mop + .mord { margin-left: 0.16667em; } -.katex .textstyle > .mop + .mop { +.katex .mop + .mop { margin-left: 0.16667em; } -.katex .textstyle > .mop + .mrel { +.katex .mop + .mrel { margin-left: 0.27778em; } -.katex .textstyle > .mop + .minner { +.katex .mop + .minner { margin-left: 0.16667em; } -.katex .textstyle > .mbin + .mord { +.katex .mbin + .mord { margin-left: 0.22222em; } -.katex .textstyle > .mbin + .mop { +.katex .mbin + .mop { margin-left: 0.22222em; } -.katex .textstyle > .mbin + .mopen { +.katex .mbin + .mopen { margin-left: 0.22222em; } -.katex .textstyle > .mbin + .minner { +.katex .mbin + .minner { margin-left: 0.22222em; } -.katex .textstyle > .mrel + .mord { +.katex .mrel + .mord { margin-left: 0.27778em; } -.katex .textstyle > .mrel + .mop { +.katex .mrel + .mop { margin-left: 0.27778em; } -.katex .textstyle > .mrel + .mopen { +.katex .mrel + .mopen { margin-left: 0.27778em; } -.katex .textstyle > .mrel + .minner { +.katex .mrel + .minner { margin-left: 0.27778em; } -.katex .textstyle > .mclose + .mop { +.katex .mclose + .mop { margin-left: 0.16667em; } -.katex .textstyle > .mclose + .mbin { +.katex .mclose + .mbin { margin-left: 0.22222em; } -.katex .textstyle > .mclose + .mrel { +.katex .mclose + .mrel { margin-left: 0.27778em; } -.katex .textstyle > .mclose + .minner { +.katex .mclose + .minner { margin-left: 0.16667em; } -.katex .textstyle > .mpunct + .mord { +.katex .mpunct + .mord { margin-left: 0.16667em; } -.katex .textstyle > .mpunct + .mop { +.katex .mpunct + .mop { margin-left: 0.16667em; } -.katex .textstyle > .mpunct + .mrel { +.katex .mpunct + .mrel { margin-left: 0.16667em; } -.katex .textstyle > .mpunct + .mopen { +.katex .mpunct + .mopen { margin-left: 0.16667em; } -.katex .textstyle > .mpunct + .mclose { +.katex .mpunct + .mclose { margin-left: 0.16667em; } -.katex .textstyle > .mpunct + .mpunct { +.katex .mpunct + .mpunct { margin-left: 0.16667em; } -.katex .textstyle > .mpunct + .minner { +.katex .mpunct + .minner { margin-left: 0.16667em; } -.katex .textstyle > .minner + .mord { +.katex .minner + .mord { margin-left: 0.16667em; } -.katex .textstyle > .minner + .mop { +.katex .minner + .mop { margin-left: 0.16667em; } -.katex .textstyle > .minner + .mbin { +.katex .minner + .mbin { margin-left: 0.22222em; } -.katex .textstyle > .minner + .mrel { +.katex .minner + .mrel { margin-left: 0.27778em; } -.katex .textstyle > .minner + .mopen { +.katex .minner + .mopen { margin-left: 0.16667em; } -.katex .textstyle > .minner + .mpunct { +.katex .minner + .mpunct { margin-left: 0.16667em; } -.katex .textstyle > .minner + .minner { +.katex .minner + .minner { margin-left: 0.16667em; } -.katex .mord + .mop { - margin-left: 0.16667em; +.katex .mord.mtight { + margin-left: 0; } -.katex .mop + .mord { - margin-left: 0.16667em; +.katex .mop.mtight { + margin-left: 0; } -.katex .mop + .mop { - margin-left: 0.16667em; +.katex .mbin.mtight { + margin-left: 0; } -.katex .mclose + .mop { - margin-left: 0.16667em; +.katex .mrel.mtight { + margin-left: 0; } -.katex .minner + .mop { - margin-left: 0.16667em; +.katex .mopen.mtight { + margin-left: 0; } -.katex .reset-textstyle.textstyle { - font-size: 1em; +.katex .mclose.mtight { + margin-left: 0; } -.katex .reset-textstyle.scriptstyle { - font-size: 0.7em; +.katex .mpunct.mtight { + margin-left: 0; } -.katex .reset-textstyle.scriptscriptstyle { - font-size: 0.5em; +.katex .minner.mtight { + margin-left: 0; } -.katex .reset-scriptstyle.textstyle { - font-size: 1.42857em; +.katex .mord + .mop.mtight { + margin-left: 0.16667em; } -.katex .reset-scriptstyle.scriptstyle { - font-size: 1em; +.katex .mop + .mord.mtight { + margin-left: 0.16667em; } -.katex .reset-scriptstyle.scriptscriptstyle { - font-size: 0.71429em; +.katex .mop + .mop.mtight { + margin-left: 0.16667em; } -.katex .reset-scriptscriptstyle.textstyle { - font-size: 2em; +.katex .mclose + .mop.mtight { + margin-left: 0.16667em; } -.katex .reset-scriptscriptstyle.scriptstyle { - font-size: 1.4em; +.katex .minner + .mop.mtight { + margin-left: 0.16667em; } -.katex .reset-scriptscriptstyle.scriptscriptstyle { - font-size: 1em; +.katex .vlist-t { + display: inline-table; + table-layout: fixed; } -.katex .style-wrap { - position: relative; +.katex .vlist-r { + display: table-row; } .katex .vlist { - display: inline-block; + display: table-cell; + vertical-align: bottom; + position: relative; } .katex .vlist > span { display: block; @@ -377,9 +395,18 @@ SOFTWARE. .katex .vlist > span > span { display: inline-block; } -.katex .vlist .baseline-fix { - display: inline-table; - table-layout: fixed; +.katex .vlist > span > .pstrut { + overflow: hidden; + width: 0; +} +.katex .vlist-t2 { + margin-right: -2px; +} +.katex .vlist-s { + display: table-cell; + vertical-align: bottom; + font-size: 1px; + width: 2px; } .katex .msupsub { text-align: left; @@ -388,20 +415,22 @@ SOFTWARE. text-align: center; } .katex .mfrac .frac-line { + display: inline-block; width: 100%; } -.katex .mfrac .frac-line:before { - border-bottom-style: solid; - border-bottom-width: 1px; - content: ""; - display: block; +@media screen { + .katex .mfrac .frac-line, + .katex .overline .overline-line, + .katex .underline .underline-line { + min-height: 1px; + } } -.katex .mfrac .frac-line:after { - border-bottom-style: solid; - border-bottom-width: 0.04em; - content: ""; - display: block; - margin-top: -1px; +@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (min-resolution: 192dpi) { + .katex .mfrac .frac-line, + .katex .overline .overline-line, + .katex .underline .underline-line { + min-height: 0.5px; + } } .katex .mspace { display: inline-block; @@ -409,18 +438,33 @@ SOFTWARE. .katex .mspace.negativethinspace { margin-left: -0.16667em; } +.katex .mspace.muspace { + width: 0.055556em; +} .katex .mspace.thinspace { width: 0.16667em; } +.katex .mspace.negativemediumspace { + margin-left: -0.22222em; +} .katex .mspace.mediumspace { width: 0.22222em; } .katex .mspace.thickspace { width: 0.27778em; } +.katex .mspace.sixmuspace { + width: 0.333333em; +} +.katex .mspace.eightmuspace { + width: 0.444444em; +} .katex .mspace.enspace { width: 0.5em; } +.katex .mspace.twelvemuspace { + width: 0.666667em; +} .katex .mspace.quad { width: 1em; } @@ -428,24 +472,32 @@ SOFTWARE. width: 2em; } .katex .llap, -.katex .rlap { +.katex .rlap, +.katex .clap { width: 0; position: relative; } .katex .llap > .inner, -.katex .rlap > .inner { +.katex .rlap > .inner, +.katex .clap > .inner { position: absolute; } .katex .llap > .fix, -.katex .rlap > .fix { +.katex .rlap > .fix, +.katex .clap > .fix { display: inline-block; } .katex .llap > .inner { right: 0; } -.katex .rlap > .inner { +.katex .rlap > .inner, +.katex .clap > .inner { left: 0; } +.katex .clap > .inner > span { + margin-left: -50%; + margin-right: 50%; +} .katex .katex-logo .a { font-size: 0.75em; margin-left: -0.32em; @@ -470,42 +522,9 @@ SOFTWARE. } .katex .overline .overline-line, .katex .underline .underline-line { + display: inline-block; width: 100%; } -.katex .overline .overline-line:before, -.katex .underline .underline-line:before { - border-bottom-style: solid; - border-bottom-width: 1px; - content: ""; - display: block; -} -.katex .overline .overline-line:after, -.katex .underline .underline-line:after { - border-bottom-style: solid; - border-bottom-width: 0.04em; - content: ""; - display: block; - margin-top: -1px; -} -.katex .sqrt > .sqrt-sign { - position: relative; -} -.katex .sqrt .sqrt-line { - width: 100%; -} -.katex .sqrt .sqrt-line:before { - border-bottom-style: solid; - border-bottom-width: 1px; - content: ""; - display: block; -} -.katex .sqrt .sqrt-line:after { - border-bottom-style: solid; - border-bottom-width: 0.04em; - content: ""; - display: block; - margin-top: -1px; -} .katex .sqrt > .root { margin-left: 0.27777778em; margin-right: -0.55555556em; @@ -520,43 +539,47 @@ SOFTWARE. } .katex .sizing.reset-size1.size2, .katex .fontsize-ensurer.reset-size1.size2 { - font-size: 1.4em; + font-size: 1.2em; } .katex .sizing.reset-size1.size3, .katex .fontsize-ensurer.reset-size1.size3 { - font-size: 1.6em; + font-size: 1.4em; } .katex .sizing.reset-size1.size4, .katex .fontsize-ensurer.reset-size1.size4 { - font-size: 1.8em; + font-size: 1.6em; } .katex .sizing.reset-size1.size5, .katex .fontsize-ensurer.reset-size1.size5 { - font-size: 2em; + font-size: 1.8em; } .katex .sizing.reset-size1.size6, .katex .fontsize-ensurer.reset-size1.size6 { - font-size: 2.4em; + font-size: 2em; } .katex .sizing.reset-size1.size7, .katex .fontsize-ensurer.reset-size1.size7 { - font-size: 2.88em; + font-size: 2.4em; } .katex .sizing.reset-size1.size8, .katex .fontsize-ensurer.reset-size1.size8 { - font-size: 3.46em; + font-size: 2.88em; } .katex .sizing.reset-size1.size9, .katex .fontsize-ensurer.reset-size1.size9 { - font-size: 4.14em; + font-size: 3.456em; } .katex .sizing.reset-size1.size10, .katex .fontsize-ensurer.reset-size1.size10 { - font-size: 4.98em; + font-size: 4.148em; +} +.katex .sizing.reset-size1.size11, +.katex .fontsize-ensurer.reset-size1.size11 { + font-size: 4.976em; } .katex .sizing.reset-size2.size1, .katex .fontsize-ensurer.reset-size2.size1 { - font-size: 0.71428571em; + font-size: 0.83333333em; } .katex .sizing.reset-size2.size2, .katex .fontsize-ensurer.reset-size2.size2 { @@ -564,43 +587,47 @@ SOFTWARE. } .katex .sizing.reset-size2.size3, .katex .fontsize-ensurer.reset-size2.size3 { - font-size: 1.14285714em; + font-size: 1.16666667em; } .katex .sizing.reset-size2.size4, .katex .fontsize-ensurer.reset-size2.size4 { - font-size: 1.28571429em; + font-size: 1.33333333em; } .katex .sizing.reset-size2.size5, .katex .fontsize-ensurer.reset-size2.size5 { - font-size: 1.42857143em; + font-size: 1.5em; } .katex .sizing.reset-size2.size6, .katex .fontsize-ensurer.reset-size2.size6 { - font-size: 1.71428571em; + font-size: 1.66666667em; } .katex .sizing.reset-size2.size7, .katex .fontsize-ensurer.reset-size2.size7 { - font-size: 2.05714286em; + font-size: 2em; } .katex .sizing.reset-size2.size8, .katex .fontsize-ensurer.reset-size2.size8 { - font-size: 2.47142857em; + font-size: 2.4em; } .katex .sizing.reset-size2.size9, .katex .fontsize-ensurer.reset-size2.size9 { - font-size: 2.95714286em; + font-size: 2.88em; } .katex .sizing.reset-size2.size10, .katex .fontsize-ensurer.reset-size2.size10 { - font-size: 3.55714286em; + font-size: 3.45666667em; +} +.katex .sizing.reset-size2.size11, +.katex .fontsize-ensurer.reset-size2.size11 { + font-size: 4.14666667em; } .katex .sizing.reset-size3.size1, .katex .fontsize-ensurer.reset-size3.size1 { - font-size: 0.625em; + font-size: 0.71428571em; } .katex .sizing.reset-size3.size2, .katex .fontsize-ensurer.reset-size3.size2 { - font-size: 0.875em; + font-size: 0.85714286em; } .katex .sizing.reset-size3.size3, .katex .fontsize-ensurer.reset-size3.size3 { @@ -608,43 +635,47 @@ SOFTWARE. } .katex .sizing.reset-size3.size4, .katex .fontsize-ensurer.reset-size3.size4 { - font-size: 1.125em; + font-size: 1.14285714em; } .katex .sizing.reset-size3.size5, .katex .fontsize-ensurer.reset-size3.size5 { - font-size: 1.25em; + font-size: 1.28571429em; } .katex .sizing.reset-size3.size6, .katex .fontsize-ensurer.reset-size3.size6 { - font-size: 1.5em; + font-size: 1.42857143em; } .katex .sizing.reset-size3.size7, .katex .fontsize-ensurer.reset-size3.size7 { - font-size: 1.8em; + font-size: 1.71428571em; } .katex .sizing.reset-size3.size8, .katex .fontsize-ensurer.reset-size3.size8 { - font-size: 2.1625em; + font-size: 2.05714286em; } .katex .sizing.reset-size3.size9, .katex .fontsize-ensurer.reset-size3.size9 { - font-size: 2.5875em; + font-size: 2.46857143em; } .katex .sizing.reset-size3.size10, .katex .fontsize-ensurer.reset-size3.size10 { - font-size: 3.1125em; + font-size: 2.96285714em; +} +.katex .sizing.reset-size3.size11, +.katex .fontsize-ensurer.reset-size3.size11 { + font-size: 3.55428571em; } .katex .sizing.reset-size4.size1, .katex .fontsize-ensurer.reset-size4.size1 { - font-size: 0.55555556em; + font-size: 0.625em; } .katex .sizing.reset-size4.size2, .katex .fontsize-ensurer.reset-size4.size2 { - font-size: 0.77777778em; + font-size: 0.75em; } .katex .sizing.reset-size4.size3, .katex .fontsize-ensurer.reset-size4.size3 { - font-size: 0.88888889em; + font-size: 0.875em; } .katex .sizing.reset-size4.size4, .katex .fontsize-ensurer.reset-size4.size4 { @@ -652,43 +683,47 @@ SOFTWARE. } .katex .sizing.reset-size4.size5, .katex .fontsize-ensurer.reset-size4.size5 { - font-size: 1.11111111em; + font-size: 1.125em; } .katex .sizing.reset-size4.size6, .katex .fontsize-ensurer.reset-size4.size6 { - font-size: 1.33333333em; + font-size: 1.25em; } .katex .sizing.reset-size4.size7, .katex .fontsize-ensurer.reset-size4.size7 { - font-size: 1.6em; + font-size: 1.5em; } .katex .sizing.reset-size4.size8, .katex .fontsize-ensurer.reset-size4.size8 { - font-size: 1.92222222em; + font-size: 1.8em; } .katex .sizing.reset-size4.size9, .katex .fontsize-ensurer.reset-size4.size9 { - font-size: 2.3em; + font-size: 2.16em; } .katex .sizing.reset-size4.size10, .katex .fontsize-ensurer.reset-size4.size10 { - font-size: 2.76666667em; + font-size: 2.5925em; +} +.katex .sizing.reset-size4.size11, +.katex .fontsize-ensurer.reset-size4.size11 { + font-size: 3.11em; } .katex .sizing.reset-size5.size1, .katex .fontsize-ensurer.reset-size5.size1 { - font-size: 0.5em; + font-size: 0.55555556em; } .katex .sizing.reset-size5.size2, .katex .fontsize-ensurer.reset-size5.size2 { - font-size: 0.7em; + font-size: 0.66666667em; } .katex .sizing.reset-size5.size3, .katex .fontsize-ensurer.reset-size5.size3 { - font-size: 0.8em; + font-size: 0.77777778em; } .katex .sizing.reset-size5.size4, .katex .fontsize-ensurer.reset-size5.size4 { - font-size: 0.9em; + font-size: 0.88888889em; } .katex .sizing.reset-size5.size5, .katex .fontsize-ensurer.reset-size5.size5 { @@ -696,43 +731,47 @@ SOFTWARE. } .katex .sizing.reset-size5.size6, .katex .fontsize-ensurer.reset-size5.size6 { - font-size: 1.2em; + font-size: 1.11111111em; } .katex .sizing.reset-size5.size7, .katex .fontsize-ensurer.reset-size5.size7 { - font-size: 1.44em; + font-size: 1.33333333em; } .katex .sizing.reset-size5.size8, .katex .fontsize-ensurer.reset-size5.size8 { - font-size: 1.73em; + font-size: 1.6em; } .katex .sizing.reset-size5.size9, .katex .fontsize-ensurer.reset-size5.size9 { - font-size: 2.07em; + font-size: 1.92em; } .katex .sizing.reset-size5.size10, .katex .fontsize-ensurer.reset-size5.size10 { - font-size: 2.49em; + font-size: 2.30444444em; +} +.katex .sizing.reset-size5.size11, +.katex .fontsize-ensurer.reset-size5.size11 { + font-size: 2.76444444em; } .katex .sizing.reset-size6.size1, .katex .fontsize-ensurer.reset-size6.size1 { - font-size: 0.41666667em; + font-size: 0.5em; } .katex .sizing.reset-size6.size2, .katex .fontsize-ensurer.reset-size6.size2 { - font-size: 0.58333333em; + font-size: 0.6em; } .katex .sizing.reset-size6.size3, .katex .fontsize-ensurer.reset-size6.size3 { - font-size: 0.66666667em; + font-size: 0.7em; } .katex .sizing.reset-size6.size4, .katex .fontsize-ensurer.reset-size6.size4 { - font-size: 0.75em; + font-size: 0.8em; } .katex .sizing.reset-size6.size5, .katex .fontsize-ensurer.reset-size6.size5 { - font-size: 0.83333333em; + font-size: 0.9em; } .katex .sizing.reset-size6.size6, .katex .fontsize-ensurer.reset-size6.size6 { @@ -744,35 +783,39 @@ SOFTWARE. } .katex .sizing.reset-size6.size8, .katex .fontsize-ensurer.reset-size6.size8 { - font-size: 1.44166667em; + font-size: 1.44em; } .katex .sizing.reset-size6.size9, .katex .fontsize-ensurer.reset-size6.size9 { - font-size: 1.725em; + font-size: 1.728em; } .katex .sizing.reset-size6.size10, .katex .fontsize-ensurer.reset-size6.size10 { - font-size: 2.075em; + font-size: 2.074em; +} +.katex .sizing.reset-size6.size11, +.katex .fontsize-ensurer.reset-size6.size11 { + font-size: 2.488em; } .katex .sizing.reset-size7.size1, .katex .fontsize-ensurer.reset-size7.size1 { - font-size: 0.34722222em; + font-size: 0.41666667em; } .katex .sizing.reset-size7.size2, .katex .fontsize-ensurer.reset-size7.size2 { - font-size: 0.48611111em; + font-size: 0.5em; } .katex .sizing.reset-size7.size3, .katex .fontsize-ensurer.reset-size7.size3 { - font-size: 0.55555556em; + font-size: 0.58333333em; } .katex .sizing.reset-size7.size4, .katex .fontsize-ensurer.reset-size7.size4 { - font-size: 0.625em; + font-size: 0.66666667em; } .katex .sizing.reset-size7.size5, .katex .fontsize-ensurer.reset-size7.size5 { - font-size: 0.69444444em; + font-size: 0.75em; } .katex .sizing.reset-size7.size6, .katex .fontsize-ensurer.reset-size7.size6 { @@ -784,43 +827,47 @@ SOFTWARE. } .katex .sizing.reset-size7.size8, .katex .fontsize-ensurer.reset-size7.size8 { - font-size: 1.20138889em; + font-size: 1.2em; } .katex .sizing.reset-size7.size9, .katex .fontsize-ensurer.reset-size7.size9 { - font-size: 1.4375em; + font-size: 1.44em; } .katex .sizing.reset-size7.size10, .katex .fontsize-ensurer.reset-size7.size10 { - font-size: 1.72916667em; + font-size: 1.72833333em; +} +.katex .sizing.reset-size7.size11, +.katex .fontsize-ensurer.reset-size7.size11 { + font-size: 2.07333333em; } .katex .sizing.reset-size8.size1, .katex .fontsize-ensurer.reset-size8.size1 { - font-size: 0.28901734em; + font-size: 0.34722222em; } .katex .sizing.reset-size8.size2, .katex .fontsize-ensurer.reset-size8.size2 { - font-size: 0.40462428em; + font-size: 0.41666667em; } .katex .sizing.reset-size8.size3, .katex .fontsize-ensurer.reset-size8.size3 { - font-size: 0.46242775em; + font-size: 0.48611111em; } .katex .sizing.reset-size8.size4, .katex .fontsize-ensurer.reset-size8.size4 { - font-size: 0.52023121em; + font-size: 0.55555556em; } .katex .sizing.reset-size8.size5, .katex .fontsize-ensurer.reset-size8.size5 { - font-size: 0.57803468em; + font-size: 0.625em; } .katex .sizing.reset-size8.size6, .katex .fontsize-ensurer.reset-size8.size6 { - font-size: 0.69364162em; + font-size: 0.69444444em; } .katex .sizing.reset-size8.size7, .katex .fontsize-ensurer.reset-size8.size7 { - font-size: 0.83236994em; + font-size: 0.83333333em; } .katex .sizing.reset-size8.size8, .katex .fontsize-ensurer.reset-size8.size8 { @@ -828,43 +875,47 @@ SOFTWARE. } .katex .sizing.reset-size8.size9, .katex .fontsize-ensurer.reset-size8.size9 { - font-size: 1.19653179em; + font-size: 1.2em; } .katex .sizing.reset-size8.size10, .katex .fontsize-ensurer.reset-size8.size10 { - font-size: 1.43930636em; + font-size: 1.44027778em; +} +.katex .sizing.reset-size8.size11, +.katex .fontsize-ensurer.reset-size8.size11 { + font-size: 1.72777778em; } .katex .sizing.reset-size9.size1, .katex .fontsize-ensurer.reset-size9.size1 { - font-size: 0.24154589em; + font-size: 0.28935185em; } .katex .sizing.reset-size9.size2, .katex .fontsize-ensurer.reset-size9.size2 { - font-size: 0.33816425em; + font-size: 0.34722222em; } .katex .sizing.reset-size9.size3, .katex .fontsize-ensurer.reset-size9.size3 { - font-size: 0.38647343em; + font-size: 0.40509259em; } .katex .sizing.reset-size9.size4, .katex .fontsize-ensurer.reset-size9.size4 { - font-size: 0.43478261em; + font-size: 0.46296296em; } .katex .sizing.reset-size9.size5, .katex .fontsize-ensurer.reset-size9.size5 { - font-size: 0.48309179em; + font-size: 0.52083333em; } .katex .sizing.reset-size9.size6, .katex .fontsize-ensurer.reset-size9.size6 { - font-size: 0.57971014em; + font-size: 0.5787037em; } .katex .sizing.reset-size9.size7, .katex .fontsize-ensurer.reset-size9.size7 { - font-size: 0.69565217em; + font-size: 0.69444444em; } .katex .sizing.reset-size9.size8, .katex .fontsize-ensurer.reset-size9.size8 { - font-size: 0.83574879em; + font-size: 0.83333333em; } .katex .sizing.reset-size9.size9, .katex .fontsize-ensurer.reset-size9.size9 { @@ -872,48 +923,100 @@ SOFTWARE. } .katex .sizing.reset-size9.size10, .katex .fontsize-ensurer.reset-size9.size10 { - font-size: 1.20289855em; + font-size: 1.20023148em; +} +.katex .sizing.reset-size9.size11, +.katex .fontsize-ensurer.reset-size9.size11 { + font-size: 1.43981481em; } .katex .sizing.reset-size10.size1, .katex .fontsize-ensurer.reset-size10.size1 { - font-size: 0.20080321em; + font-size: 0.24108004em; } .katex .sizing.reset-size10.size2, .katex .fontsize-ensurer.reset-size10.size2 { - font-size: 0.2811245em; + font-size: 0.28929605em; } .katex .sizing.reset-size10.size3, .katex .fontsize-ensurer.reset-size10.size3 { - font-size: 0.32128514em; + font-size: 0.33751205em; } .katex .sizing.reset-size10.size4, .katex .fontsize-ensurer.reset-size10.size4 { - font-size: 0.36144578em; + font-size: 0.38572806em; } .katex .sizing.reset-size10.size5, .katex .fontsize-ensurer.reset-size10.size5 { - font-size: 0.40160643em; + font-size: 0.43394407em; } .katex .sizing.reset-size10.size6, .katex .fontsize-ensurer.reset-size10.size6 { - font-size: 0.48192771em; + font-size: 0.48216008em; } .katex .sizing.reset-size10.size7, .katex .fontsize-ensurer.reset-size10.size7 { - font-size: 0.57831325em; + font-size: 0.57859209em; } .katex .sizing.reset-size10.size8, .katex .fontsize-ensurer.reset-size10.size8 { - font-size: 0.69477912em; + font-size: 0.69431051em; } .katex .sizing.reset-size10.size9, .katex .fontsize-ensurer.reset-size10.size9 { - font-size: 0.8313253em; + font-size: 0.83317261em; } .katex .sizing.reset-size10.size10, .katex .fontsize-ensurer.reset-size10.size10 { font-size: 1em; } +.katex .sizing.reset-size10.size11, +.katex .fontsize-ensurer.reset-size10.size11 { + font-size: 1.19961427em; +} +.katex .sizing.reset-size11.size1, +.katex .fontsize-ensurer.reset-size11.size1 { + font-size: 0.20096463em; +} +.katex .sizing.reset-size11.size2, +.katex .fontsize-ensurer.reset-size11.size2 { + font-size: 0.24115756em; +} +.katex .sizing.reset-size11.size3, +.katex .fontsize-ensurer.reset-size11.size3 { + font-size: 0.28135048em; +} +.katex .sizing.reset-size11.size4, +.katex .fontsize-ensurer.reset-size11.size4 { + font-size: 0.32154341em; +} +.katex .sizing.reset-size11.size5, +.katex .fontsize-ensurer.reset-size11.size5 { + font-size: 0.36173633em; +} +.katex .sizing.reset-size11.size6, +.katex .fontsize-ensurer.reset-size11.size6 { + font-size: 0.40192926em; +} +.katex .sizing.reset-size11.size7, +.katex .fontsize-ensurer.reset-size11.size7 { + font-size: 0.48231511em; +} +.katex .sizing.reset-size11.size8, +.katex .fontsize-ensurer.reset-size11.size8 { + font-size: 0.57877814em; +} +.katex .sizing.reset-size11.size9, +.katex .fontsize-ensurer.reset-size11.size9 { + font-size: 0.69453376em; +} +.katex .sizing.reset-size11.size10, +.katex .fontsize-ensurer.reset-size11.size10 { + font-size: 0.83360129em; +} +.katex .sizing.reset-size11.size11, +.katex .fontsize-ensurer.reset-size11.size11 { + font-size: 1em; +} .katex .delimsizing.size1 { font-family: KaTeX_Size1; } @@ -936,6 +1039,9 @@ SOFTWARE. display: inline-block; width: 0.12em; } +.katex .delimcenter { + position: relative; +} .katex .op-symbol { position: relative; } @@ -945,10 +1051,10 @@ SOFTWARE. .katex .op-symbol.large-op { font-family: KaTeX_Size2; } -.katex .op-limits > .vlist > span { +.katex .op-limits > .vlist-t { text-align: center; } -.katex .accent > .vlist > span { +.katex .accent > .vlist-t { text-align: center; } .katex .accent .accent-body > span { @@ -958,20 +1064,126 @@ SOFTWARE. position: relative; left: 0.326em; } +.katex .accent .accent-body.accent-hungarian > span { + position: relative; + left: 0.250em; +} .katex .mtable .vertical-separator { display: inline-block; margin: 0 -0.025em; - border-right: 0.05em solid black; + width: 0.05em; +} +@media screen { + .katex .mtable .vertical-separator { + min-width: 1px; + } +} +@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (min-resolution: 192dpi) { + .katex .mtable .vertical-separator { + min-width: 0.5px; + } } .katex .mtable .arraycolsep { display: inline-block; } -.katex .mtable .col-align-c > .vlist { +.katex .mtable .col-align-c > .vlist-t { text-align: center; } -.katex .mtable .col-align-l > .vlist { +.katex .mtable .col-align-l > .vlist-t { text-align: left; } -.katex .mtable .col-align-r > .vlist { +.katex .mtable .col-align-r > .vlist-t { text-align: right; } +.katex .svg-align { + text-align: left; +} +.katex svg { + display: block; + position: absolute; + width: 100%; +} +.katex svg path { + fill: currentColor; +} +.katex svg line { + stroke: currentColor; +} +.katex .stretchy { + width: 100%; + display: block; +} +.katex .stretchy:before, +.katex .stretchy:after { + content: ""; +} +.katex .hide-tail { + width: 100%; + position: relative; + overflow: hidden; +} +.katex .halfarrow-left { + position: absolute; + left: 0; + width: 50.1%; + overflow: hidden; +} +.katex .halfarrow-right { + position: absolute; + right: 0; + width: 50%; + overflow: hidden; +} +.katex .brace-left { + position: absolute; + left: 0; + width: 25.1%; + overflow: hidden; +} +.katex .brace-center { + position: absolute; + left: 25%; + width: 50%; + overflow: hidden; +} +.katex .brace-right { + position: absolute; + right: 0; + width: 25.1%; + overflow: hidden; +} +.katex .x-arrow-pad { + padding: 0 0.5em; +} +.katex .x-arrow, +.katex .mover, +.katex .munder { + text-align: center; +} +.katex .boxpad { + padding: 0 0.3em 0 0.3em; +} +.katex .fbox { + box-sizing: border-box; + border: 0.04em solid black; +} +.katex .fcolorbox { + box-sizing: border-box; + border: 0.04em solid; +} +.katex .cancel-pad { + padding: 0 0.2em 0 0.2em; +} +.katex .mord + .cancel-lap, +.katex .mbin + .cancel-lap { + margin-left: -0.2em; +} +.katex .cancel-lap + .mord, +.katex .cancel-lap + .mbin, +.katex .cancel-lap + .msupsub { + margin-left: -0.2em; +} +.katex .sout { + border-bottom-style: solid; + border-bottom-width: 0.08em; +} |