🏠 返回首頁 

Greasy Fork is available in English.

KaTeX

KaTeX 修改版, 可以工作与 兼容模式.可能会出现Bug.效果未知

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/34253/224512/KaTeX.js

  1. (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){
  2. "use strict";
  3. var _ParseError = require("./src/ParseError");
  4. var _ParseError2 = _interopRequireDefault(_ParseError);
  5. var _Settings = require("./src/Settings");
  6. var _Settings2 = _interopRequireDefault(_Settings);
  7. var _buildTree = require("./src/buildTree");
  8. var _buildTree2 = _interopRequireDefault(_buildTree);
  9. var _parseTree = require("./src/parseTree");
  10. var _parseTree2 = _interopRequireDefault(_parseTree);
  11. var _utils = require("./src/utils");
  12. var _utils2 = _interopRequireDefault(_utils);
  13. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14. /**
  15. * Parse and build an expression, and place that expression in the DOM node
  16. * given.
  17. */
  18. var render = function render(expression, baseNode, options) {
  19. _utils2.default.clearNode(baseNode);
  20. var settings = new _Settings2.default(options);
  21. var tree = (0, _parseTree2.default)(expression, settings);
  22. var node = (0, _buildTree2.default)(tree, expression, settings).toNode();
  23. baseNode.appendChild(node);
  24. };
  25. // KaTeX's styles don't work properly in quirks mode. Print out an error, and
  26. // disable rendering.
  27. /* eslint no-console:0 */
  28. /**
  29. * This is the main entry point for KaTeX. Here, we expose functions for
  30. * rendering expressions either to DOM nodes or to markup strings.
  31. *
  32. * We also expose the ParseError class to check if errors thrown from KaTeX are
  33. * errors in the expression, or errors in javascript handling.
  34. */
  35. /*///////////////////////////////////
  36. if (typeof document !== "undefined") {
  37. if (document.compatMode !== "CSS1Compat") {
  38. typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype.");
  39. render = function render() {
  40. throw new _ParseError2.default("KaTeX doesn't work in quirks mode.");
  41. };
  42. }
  43. }
  44. *///////////////////////////////
  45. /**
  46. * Parse and build an expression, and return the markup for that.
  47. */
  48. var renderToString = function renderToString(expression, options) {
  49. var settings = new _Settings2.default(options);
  50. var tree = (0, _parseTree2.default)(expression, settings);
  51. return (0, _buildTree2.default)(tree, expression, settings).toMarkup();
  52. };
  53. /**
  54. * Parse an expression and return the parse tree.
  55. */
  56. var generateParseTree = function generateParseTree(expression, options) {
  57. var settings = new _Settings2.default(options);
  58. return (0, _parseTree2.default)(expression, settings);
  59. };
  60. module.exports = {
  61. render: render,
  62. renderToString: renderToString,
  63. /**
  64. * NOTE: This method is not currently recommended for public use.
  65. * The internal tree representation is unstable and is very likely
  66. * to change. Use at your own risk.
  67. */
  68. __parse: generateParseTree,
  69. ParseError: _ParseError2.default
  70. };
  71. },{"./src/ParseError":84,"./src/Settings":87,"./src/buildTree":94,"./src/parseTree":109,"./src/utils":115}],2:[function(require,module,exports){
  72. module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true };
  73. },{"core-js/library/fn/array/from":12}],3:[function(require,module,exports){
  74. module.exports = { "default": require("core-js/library/fn/get-iterator"), __esModule: true };
  75. },{"core-js/library/fn/get-iterator":13}],4:[function(require,module,exports){
  76. module.exports = { "default": require("core-js/library/fn/is-iterable"), __esModule: true };
  77. },{"core-js/library/fn/is-iterable":14}],5:[function(require,module,exports){
  78. module.exports = { "default": require("core-js/library/fn/json/stringify"), __esModule: true };
  79. },{"core-js/library/fn/json/stringify":15}],6:[function(require,module,exports){
  80. module.exports = { "default": require("core-js/library/fn/object/define-property"), __esModule: true };
  81. },{"core-js/library/fn/object/define-property":16}],7:[function(require,module,exports){
  82. module.exports = { "default": require("core-js/library/fn/object/freeze"), __esModule: true };
  83. },{"core-js/library/fn/object/freeze":17}],8:[function(require,module,exports){
  84. "use strict";
  85. exports.__esModule = true;
  86. exports.default = function (instance, Constructor) {
  87. if (!(instance instanceof Constructor)) {
  88. throw new TypeError("Cannot call a class as a function");
  89. }
  90. };
  91. },{}],9:[function(require,module,exports){
  92. "use strict";
  93. exports.__esModule = true;
  94. var _defineProperty = require("../core-js/object/define-property");
  95. var _defineProperty2 = _interopRequireDefault(_defineProperty);
  96. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  97. exports.default = function () {
  98. function defineProperties(target, props) {
  99. for (var i = 0; i < props.length; i++) {
  100. var descriptor = props[i];
  101. descriptor.enumerable = descriptor.enumerable || false;
  102. descriptor.configurable = true;
  103. if ("value" in descriptor) descriptor.writable = true;
  104. (0, _defineProperty2.default)(target, descriptor.key, descriptor);
  105. }
  106. }
  107. return function (Constructor, protoProps, staticProps) {
  108. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  109. if (staticProps) defineProperties(Constructor, staticProps);
  110. return Constructor;
  111. };
  112. }();
  113. },{"../core-js/object/define-property":6}],10:[function(require,module,exports){
  114. "use strict";
  115. exports.__esModule = true;
  116. var _isIterable2 = require("../core-js/is-iterable");
  117. var _isIterable3 = _interopRequireDefault(_isIterable2);
  118. var _getIterator2 = require("../core-js/get-iterator");
  119. var _getIterator3 = _interopRequireDefault(_getIterator2);
  120. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  121. exports.default = function () {
  122. function sliceIterator(arr, i) {
  123. var _arr = [];
  124. var _n = true;
  125. var _d = false;
  126. var _e = undefined;
  127. try {
  128. for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) {
  129. _arr.push(_s.value);
  130. if (i && _arr.length === i) break;
  131. }
  132. } catch (err) {
  133. _d = true;
  134. _e = err;
  135. } finally {
  136. try {
  137. if (!_n && _i["return"]) _i["return"]();
  138. } finally {
  139. if (_d) throw _e;
  140. }
  141. }
  142. return _arr;
  143. }
  144. return function (arr, i) {
  145. if (Array.isArray(arr)) {
  146. return arr;
  147. } else if ((0, _isIterable3.default)(Object(arr))) {
  148. return sliceIterator(arr, i);
  149. } else {
  150. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  151. }
  152. };
  153. }();
  154. },{"../core-js/get-iterator":3,"../core-js/is-iterable":4}],11:[function(require,module,exports){
  155. "use strict";
  156. exports.__esModule = true;
  157. var _from = require("../core-js/array/from");
  158. var _from2 = _interopRequireDefault(_from);
  159. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  160. exports.default = function (arr) {
  161. if (Array.isArray(arr)) {
  162. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  163. arr2[i] = arr[i];
  164. }
  165. return arr2;
  166. } else {
  167. return (0, _from2.default)(arr);
  168. }
  169. };
  170. },{"../core-js/array/from":2}],12:[function(require,module,exports){
  171. require('../../modules/es6.string.iterator');
  172. require('../../modules/es6.array.from');
  173. module.exports = require('../../modules/_core').Array.from;
  174. },{"../../modules/_core":24,"../../modules/es6.array.from":73,"../../modules/es6.string.iterator":77}],13:[function(require,module,exports){
  175. require('../modules/web.dom.iterable');
  176. require('../modules/es6.string.iterator');
  177. module.exports = require('../modules/core.get-iterator');
  178. },{"../modules/core.get-iterator":71,"../modules/es6.string.iterator":77,"../modules/web.dom.iterable":78}],14:[function(require,module,exports){
  179. require('../modules/web.dom.iterable');
  180. require('../modules/es6.string.iterator');
  181. module.exports = require('../modules/core.is-iterable');
  182. },{"../modules/core.is-iterable":72,"../modules/es6.string.iterator":77,"../modules/web.dom.iterable":78}],15:[function(require,module,exports){
  183. var core = require('../../modules/_core');
  184. var $JSON = core.JSON || (core.JSON = { stringify: JSON.stringify });
  185. module.exports = function stringify(it) { // eslint-disable-line no-unused-vars
  186. return $JSON.stringify.apply($JSON, arguments);
  187. };
  188. },{"../../modules/_core":24}],16:[function(require,module,exports){
  189. require('../../modules/es6.object.define-property');
  190. var $Object = require('../../modules/_core').Object;
  191. module.exports = function defineProperty(it, key, desc) {
  192. return $Object.defineProperty(it, key, desc);
  193. };
  194. },{"../../modules/_core":24,"../../modules/es6.object.define-property":75}],17:[function(require,module,exports){
  195. require('../../modules/es6.object.freeze');
  196. module.exports = require('../../modules/_core').Object.freeze;
  197. },{"../../modules/_core":24,"../../modules/es6.object.freeze":76}],18:[function(require,module,exports){
  198. module.exports = function (it) {
  199. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  200. return it;
  201. };
  202. },{}],19:[function(require,module,exports){
  203. module.exports = function () { /* empty */ };
  204. },{}],20:[function(require,module,exports){
  205. var isObject = require('./_is-object');
  206. module.exports = function (it) {
  207. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  208. return it;
  209. };
  210. },{"./_is-object":40}],21:[function(require,module,exports){
  211. // false -> Array#indexOf
  212. // true -> Array#includes
  213. var toIObject = require('./_to-iobject');
  214. var toLength = require('./_to-length');
  215. var toAbsoluteIndex = require('./_to-absolute-index');
  216. module.exports = function (IS_INCLUDES) {
  217. return function ($this, el, fromIndex) {
  218. var O = toIObject($this);
  219. var length = toLength(O.length);
  220. var index = toAbsoluteIndex(fromIndex, length);
  221. var value;
  222. // Array#includes uses SameValueZero equality algorithm
  223. // eslint-disable-next-line no-self-compare
  224. if (IS_INCLUDES && el != el) while (length > index) {
  225. value = O[index++];
  226. // eslint-disable-next-line no-self-compare
  227. if (value != value) return true;
  228. // Array#indexOf ignores holes, Array#includes - not
  229. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  230. if (O[index] === el) return IS_INCLUDES || index || 0;
  231. } return !IS_INCLUDES && -1;
  232. };
  233. };
  234. },{"./_to-absolute-index":62,"./_to-iobject":64,"./_to-length":65}],22:[function(require,module,exports){
  235. // getting tag from 19.1.3.6 Object.prototype.toString()
  236. var cof = require('./_cof');
  237. var TAG = require('./_wks')('toStringTag');
  238. // ES3 wrong here
  239. var ARG = cof(function () { return arguments; }()) == 'Arguments';
  240. // fallback for IE11 Script Access Denied error
  241. var tryGet = function (it, key) {
  242. try {
  243. return it[key];
  244. } catch (e) { /* empty */ }
  245. };
  246. module.exports = function (it) {
  247. var O, T, B;
  248. return it === undefined ? 'Undefined' : it === null ? 'Null'
  249. // @@toStringTag case
  250. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  251. // builtinTag case
  252. : ARG ? cof(O)
  253. // ES3 arguments fallback
  254. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  255. };
  256. },{"./_cof":23,"./_wks":69}],23:[function(require,module,exports){
  257. var toString = {}.toString;
  258. module.exports = function (it) {
  259. return toString.call(it).slice(8, -1);
  260. };
  261. },{}],24:[function(require,module,exports){
  262. var core = module.exports = { version: '2.5.1' };
  263. if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
  264. },{}],25:[function(require,module,exports){
  265. 'use strict';
  266. var $defineProperty = require('./_object-dp');
  267. var createDesc = require('./_property-desc');
  268. module.exports = function (object, index, value) {
  269. if (index in object) $defineProperty.f(object, index, createDesc(0, value));
  270. else object[index] = value;
  271. };
  272. },{"./_object-dp":50,"./_property-desc":56}],26:[function(require,module,exports){
  273. // optional / simple context binding
  274. var aFunction = require('./_a-function');
  275. module.exports = function (fn, that, length) {
  276. aFunction(fn);
  277. if (that === undefined) return fn;
  278. switch (length) {
  279. case 1: return function (a) {
  280. return fn.call(that, a);
  281. };
  282. case 2: return function (a, b) {
  283. return fn.call(that, a, b);
  284. };
  285. case 3: return function (a, b, c) {
  286. return fn.call(that, a, b, c);
  287. };
  288. }
  289. return function (/* ...args */) {
  290. return fn.apply(that, arguments);
  291. };
  292. };
  293. },{"./_a-function":18}],27:[function(require,module,exports){
  294. // 7.2.1 RequireObjectCoercible(argument)
  295. module.exports = function (it) {
  296. if (it == undefined) throw TypeError("Can't call method on " + it);
  297. return it;
  298. };
  299. },{}],28:[function(require,module,exports){
  300. // Thank's IE8 for his funny defineProperty
  301. module.exports = !require('./_fails')(function () {
  302. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  303. });
  304. },{"./_fails":32}],29:[function(require,module,exports){
  305. var isObject = require('./_is-object');
  306. var document = require('./_global').document;
  307. // typeof document.createElement is 'object' in old IE
  308. var is = isObject(document) && isObject(document.createElement);
  309. module.exports = function (it) {
  310. return is ? document.createElement(it) : {};
  311. };
  312. },{"./_global":33,"./_is-object":40}],30:[function(require,module,exports){
  313. // IE 8- don't enum bug keys
  314. module.exports = (
  315. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  316. ).split(',');
  317. },{}],31:[function(require,module,exports){
  318. var global = require('./_global');
  319. var core = require('./_core');
  320. var ctx = require('./_ctx');
  321. var hide = require('./_hide');
  322. var PROTOTYPE = 'prototype';
  323. var $export = function (type, name, source) {
  324. var IS_FORCED = type & $export.F;
  325. var IS_GLOBAL = type & $export.G;
  326. var IS_STATIC = type & $export.S;
  327. var IS_PROTO = type & $export.P;
  328. var IS_BIND = type & $export.B;
  329. var IS_WRAP = type & $export.W;
  330. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  331. var expProto = exports[PROTOTYPE];
  332. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
  333. var key, own, out;
  334. if (IS_GLOBAL) source = name;
  335. for (key in source) {
  336. // contains in native
  337. own = !IS_FORCED && target && target[key] !== undefined;
  338. if (own && key in exports) continue;
  339. // export native or passed
  340. out = own ? target[key] : source[key];
  341. // prevent global pollution for namespaces
  342. exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
  343. // bind timers to global for call from export context
  344. : IS_BIND && own ? ctx(out, global)
  345. // wrap global constructors for prevent change them in library
  346. : IS_WRAP && target[key] == out ? (function (C) {
  347. var F = function (a, b, c) {
  348. if (this instanceof C) {
  349. switch (arguments.length) {
  350. case 0: return new C();
  351. case 1: return new C(a);
  352. case 2: return new C(a, b);
  353. } return new C(a, b, c);
  354. } return C.apply(this, arguments);
  355. };
  356. F[PROTOTYPE] = C[PROTOTYPE];
  357. return F;
  358. // make static versions for prototype methods
  359. })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  360. // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
  361. if (IS_PROTO) {
  362. (exports.virtual || (exports.virtual = {}))[key] = out;
  363. // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
  364. if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
  365. }
  366. }
  367. };
  368. // type bitmap
  369. $export.F = 1; // forced
  370. $export.G = 2; // global
  371. $export.S = 4; // static
  372. $export.P = 8; // proto
  373. $export.B = 16; // bind
  374. $export.W = 32; // wrap
  375. $export.U = 64; // safe
  376. $export.R = 128; // real proto method for `library`
  377. module.exports = $export;
  378. },{"./_core":24,"./_ctx":26,"./_global":33,"./_hide":35}],32:[function(require,module,exports){
  379. module.exports = function (exec) {
  380. try {
  381. return !!exec();
  382. } catch (e) {
  383. return true;
  384. }
  385. };
  386. },{}],33:[function(require,module,exports){
  387. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  388. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  389. ? window : typeof self != 'undefined' && self.Math == Math ? self
  390. // eslint-disable-next-line no-new-func
  391. : Function('return this')();
  392. if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
  393. },{}],34:[function(require,module,exports){
  394. var hasOwnProperty = {}.hasOwnProperty;
  395. module.exports = function (it, key) {
  396. return hasOwnProperty.call(it, key);
  397. };
  398. },{}],35:[function(require,module,exports){
  399. var dP = require('./_object-dp');
  400. var createDesc = require('./_property-desc');
  401. module.exports = require('./_descriptors') ? function (object, key, value) {
  402. return dP.f(object, key, createDesc(1, value));
  403. } : function (object, key, value) {
  404. object[key] = value;
  405. return object;
  406. };
  407. },{"./_descriptors":28,"./_object-dp":50,"./_property-desc":56}],36:[function(require,module,exports){
  408. var document = require('./_global').document;
  409. module.exports = document && document.documentElement;
  410. },{"./_global":33}],37:[function(require,module,exports){
  411. module.exports = !require('./_descriptors') && !require('./_fails')(function () {
  412. return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
  413. });
  414. },{"./_descriptors":28,"./_dom-create":29,"./_fails":32}],38:[function(require,module,exports){
  415. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  416. var cof = require('./_cof');
  417. // eslint-disable-next-line no-prototype-builtins
  418. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  419. return cof(it) == 'String' ? it.split('') : Object(it);
  420. };
  421. },{"./_cof":23}],39:[function(require,module,exports){
  422. // check on default Array iterator
  423. var Iterators = require('./_iterators');
  424. var ITERATOR = require('./_wks')('iterator');
  425. var ArrayProto = Array.prototype;
  426. module.exports = function (it) {
  427. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  428. };
  429. },{"./_iterators":46,"./_wks":69}],40:[function(require,module,exports){
  430. module.exports = function (it) {
  431. return typeof it === 'object' ? it !== null : typeof it === 'function';
  432. };
  433. },{}],41:[function(require,module,exports){
  434. // call something on iterator step with safe closing on error
  435. var anObject = require('./_an-object');
  436. module.exports = function (iterator, fn, value, entries) {
  437. try {
  438. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  439. // 7.4.6 IteratorClose(iterator, completion)
  440. } catch (e) {
  441. var ret = iterator['return'];
  442. if (ret !== undefined) anObject(ret.call(iterator));
  443. throw e;
  444. }
  445. };
  446. },{"./_an-object":20}],42:[function(require,module,exports){
  447. 'use strict';
  448. var create = require('./_object-create');
  449. var descriptor = require('./_property-desc');
  450. var setToStringTag = require('./_set-to-string-tag');
  451. var IteratorPrototype = {};
  452. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  453. require('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function () { return this; });
  454. module.exports = function (Constructor, NAME, next) {
  455. Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
  456. setToStringTag(Constructor, NAME + ' Iterator');
  457. };
  458. },{"./_hide":35,"./_object-create":49,"./_property-desc":56,"./_set-to-string-tag":58,"./_wks":69}],43:[function(require,module,exports){
  459. 'use strict';
  460. var LIBRARY = require('./_library');
  461. var $export = require('./_export');
  462. var redefine = require('./_redefine');
  463. var hide = require('./_hide');
  464. var has = require('./_has');
  465. var Iterators = require('./_iterators');
  466. var $iterCreate = require('./_iter-create');
  467. var setToStringTag = require('./_set-to-string-tag');
  468. var getPrototypeOf = require('./_object-gpo');
  469. var ITERATOR = require('./_wks')('iterator');
  470. var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
  471. var FF_ITERATOR = '@@iterator';
  472. var KEYS = 'keys';
  473. var VALUES = 'values';
  474. var returnThis = function () { return this; };
  475. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  476. $iterCreate(Constructor, NAME, next);
  477. var getMethod = function (kind) {
  478. if (!BUGGY && kind in proto) return proto[kind];
  479. switch (kind) {
  480. case KEYS: return function keys() { return new Constructor(this, kind); };
  481. case VALUES: return function values() { return new Constructor(this, kind); };
  482. } return function entries() { return new Constructor(this, kind); };
  483. };
  484. var TAG = NAME + ' Iterator';
  485. var DEF_VALUES = DEFAULT == VALUES;
  486. var VALUES_BUG = false;
  487. var proto = Base.prototype;
  488. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  489. var $default = $native || getMethod(DEFAULT);
  490. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  491. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  492. var methods, key, IteratorPrototype;
  493. // Fix native
  494. if ($anyNative) {
  495. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  496. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  497. // Set @@toStringTag to native iterators
  498. setToStringTag(IteratorPrototype, TAG, true);
  499. // fix for some old engines
  500. if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis);
  501. }
  502. }
  503. // fix Array#{values, @@iterator}.name in V8 / FF
  504. if (DEF_VALUES && $native && $native.name !== VALUES) {
  505. VALUES_BUG = true;
  506. $default = function values() { return $native.call(this); };
  507. }
  508. // Define iterator
  509. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  510. hide(proto, ITERATOR, $default);
  511. }
  512. // Plug for library
  513. Iterators[NAME] = $default;
  514. Iterators[TAG] = returnThis;
  515. if (DEFAULT) {
  516. methods = {
  517. values: DEF_VALUES ? $default : getMethod(VALUES),
  518. keys: IS_SET ? $default : getMethod(KEYS),
  519. entries: $entries
  520. };
  521. if (FORCED) for (key in methods) {
  522. if (!(key in proto)) redefine(proto, key, methods[key]);
  523. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  524. }
  525. return methods;
  526. };
  527. },{"./_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){
  528. var ITERATOR = require('./_wks')('iterator');
  529. var SAFE_CLOSING = false;
  530. try {
  531. var riter = [7][ITERATOR]();
  532. riter['return'] = function () { SAFE_CLOSING = true; };
  533. // eslint-disable-next-line no-throw-literal
  534. Array.from(riter, function () { throw 2; });
  535. } catch (e) { /* empty */ }
  536. module.exports = function (exec, skipClosing) {
  537. if (!skipClosing && !SAFE_CLOSING) return false;
  538. var safe = false;
  539. try {
  540. var arr = [7];
  541. var iter = arr[ITERATOR]();
  542. iter.next = function () { return { done: safe = true }; };
  543. arr[ITERATOR] = function () { return iter; };
  544. exec(arr);
  545. } catch (e) { /* empty */ }
  546. return safe;
  547. };
  548. },{"./_wks":69}],45:[function(require,module,exports){
  549. module.exports = function (done, value) {
  550. return { value: value, done: !!done };
  551. };
  552. },{}],46:[function(require,module,exports){
  553. module.exports = {};
  554. },{}],47:[function(require,module,exports){
  555. module.exports = true;
  556. },{}],48:[function(require,module,exports){
  557. var META = require('./_uid')('meta');
  558. var isObject = require('./_is-object');
  559. var has = require('./_has');
  560. var setDesc = require('./_object-dp').f;
  561. var id = 0;
  562. var isExtensible = Object.isExtensible || function () {
  563. return true;
  564. };
  565. var FREEZE = !require('./_fails')(function () {
  566. return isExtensible(Object.preventExtensions({}));
  567. });
  568. var setMeta = function (it) {
  569. setDesc(it, META, { value: {
  570. i: 'O' + ++id, // object ID
  571. w: {} // weak collections IDs
  572. } });
  573. };
  574. var fastKey = function (it, create) {
  575. // return primitive with prefix
  576. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  577. if (!has(it, META)) {
  578. // can't set metadata to uncaught frozen object
  579. if (!isExtensible(it)) return 'F';
  580. // not necessary to add metadata
  581. if (!create) return 'E';
  582. // add missing metadata
  583. setMeta(it);
  584. // return object ID
  585. } return it[META].i;
  586. };
  587. var getWeak = function (it, create) {
  588. if (!has(it, META)) {
  589. // can't set metadata to uncaught frozen object
  590. if (!isExtensible(it)) return true;
  591. // not necessary to add metadata
  592. if (!create) return false;
  593. // add missing metadata
  594. setMeta(it);
  595. // return hash weak collections IDs
  596. } return it[META].w;
  597. };
  598. // add metadata on freeze-family methods calling
  599. var onFreeze = function (it) {
  600. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  601. return it;
  602. };
  603. var meta = module.exports = {
  604. KEY: META,
  605. NEED: false,
  606. fastKey: fastKey,
  607. getWeak: getWeak,
  608. onFreeze: onFreeze
  609. };
  610. },{"./_fails":32,"./_has":34,"./_is-object":40,"./_object-dp":50,"./_uid":68}],49:[function(require,module,exports){
  611. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  612. var anObject = require('./_an-object');
  613. var dPs = require('./_object-dps');
  614. var enumBugKeys = require('./_enum-bug-keys');
  615. var IE_PROTO = require('./_shared-key')('IE_PROTO');
  616. var Empty = function () { /* empty */ };
  617. var PROTOTYPE = 'prototype';
  618. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  619. var createDict = function () {
  620. // Thrash, waste and sodomy: IE GC bug
  621. var iframe = require('./_dom-create')('iframe');
  622. var i = enumBugKeys.length;
  623. var lt = '<';
  624. var gt = '>';
  625. var iframeDocument;
  626. iframe.style.display = 'none';
  627. require('./_html').appendChild(iframe);
  628. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  629. // createDict = iframe.contentWindow.Object;
  630. // html.removeChild(iframe);
  631. iframeDocument = iframe.contentWindow.document;
  632. iframeDocument.open();
  633. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  634. iframeDocument.close();
  635. createDict = iframeDocument.F;
  636. while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
  637. return createDict();
  638. };
  639. module.exports = Object.create || function create(O, Properties) {
  640. var r###lt;
  641. if (O !== null) {
  642. Empty[PROTOTYPE] = anObject(O);
  643. r###lt = new Empty();
  644. Empty[PROTOTYPE] = null;
  645. // add "__proto__" for Object.getPrototypeOf polyfill
  646. r###lt[IE_PROTO] = O;
  647. } else r###lt = createDict();
  648. return Properties === undefined ? r###lt : dPs(r###lt, Properties);
  649. };
  650. },{"./_an-object":20,"./_dom-create":29,"./_enum-bug-keys":30,"./_html":36,"./_object-dps":51,"./_shared-key":59}],50:[function(require,module,exports){
  651. var anObject = require('./_an-object');
  652. var IE8_DOM_DEFINE = require('./_ie8-dom-define');
  653. var toPrimitive = require('./_to-primitive');
  654. var dP = Object.defineProperty;
  655. exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  656. anObject(O);
  657. P = toPrimitive(P, true);
  658. anObject(Attributes);
  659. if (IE8_DOM_DEFINE) try {
  660. return dP(O, P, Attributes);
  661. } catch (e) { /* empty */ }
  662. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  663. if ('value' in Attributes) O[P] = Attributes.value;
  664. return O;
  665. };
  666. },{"./_an-object":20,"./_descriptors":28,"./_ie8-dom-define":37,"./_to-primitive":67}],51:[function(require,module,exports){
  667. var dP = require('./_object-dp');
  668. var anObject = require('./_an-object');
  669. var getKeys = require('./_object-keys');
  670. module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
  671. anObject(O);
  672. var keys = getKeys(Properties);
  673. var length = keys.length;
  674. var i = 0;
  675. var P;
  676. while (length > i) dP.f(O, P = keys[i++], Properties[P]);
  677. return O;
  678. };
  679. },{"./_an-object":20,"./_descriptors":28,"./_object-dp":50,"./_object-keys":54}],52:[function(require,module,exports){
  680. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  681. var has = require('./_has');
  682. var toObject = require('./_to-object');
  683. var IE_PROTO = require('./_shared-key')('IE_PROTO');
  684. var ObjectProto = Object.prototype;
  685. module.exports = Object.getPrototypeOf || function (O) {
  686. O = toObject(O);
  687. if (has(O, IE_PROTO)) return O[IE_PROTO];
  688. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  689. return O.constructor.prototype;
  690. } return O instanceof Object ? ObjectProto : null;
  691. };
  692. },{"./_has":34,"./_shared-key":59,"./_to-object":66}],53:[function(require,module,exports){
  693. var has = require('./_has');
  694. var toIObject = require('./_to-iobject');
  695. var arrayIndexOf = require('./_array-includes')(false);
  696. var IE_PROTO = require('./_shared-key')('IE_PROTO');
  697. module.exports = function (object, names) {
  698. var O = toIObject(object);
  699. var i = 0;
  700. var r###lt = [];
  701. var key;
  702. for (key in O) if (key != IE_PROTO) has(O, key) && r###lt.push(key);
  703. // Don't enum bug & hidden keys
  704. while (names.length > i) if (has(O, key = names[i++])) {
  705. ~arrayIndexOf(r###lt, key) || r###lt.push(key);
  706. }
  707. return r###lt;
  708. };
  709. },{"./_array-includes":21,"./_has":34,"./_shared-key":59,"./_to-iobject":64}],54:[function(require,module,exports){
  710. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  711. var $keys = require('./_object-keys-internal');
  712. var enumBugKeys = require('./_enum-bug-keys');
  713. module.exports = Object.keys || function keys(O) {
  714. return $keys(O, enumBugKeys);
  715. };
  716. },{"./_enum-bug-keys":30,"./_object-keys-internal":53}],55:[function(require,module,exports){
  717. // most Object methods by ES6 should accept primitives
  718. var $export = require('./_export');
  719. var core = require('./_core');
  720. var fails = require('./_fails');
  721. module.exports = function (KEY, exec) {
  722. var fn = (core.Object || {})[KEY] || Object[KEY];
  723. var exp = {};
  724. exp[KEY] = exec(fn);
  725. $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
  726. };
  727. },{"./_core":24,"./_export":31,"./_fails":32}],56:[function(require,module,exports){
  728. module.exports = function (bitmap, value) {
  729. return {
  730. enumerable: !(bitmap & 1),
  731. configurable: !(bitmap & 2),
  732. writable: !(bitmap & 4),
  733. value: value
  734. };
  735. };
  736. },{}],57:[function(require,module,exports){
  737. module.exports = require('./_hide');
  738. },{"./_hide":35}],58:[function(require,module,exports){
  739. var def = require('./_object-dp').f;
  740. var has = require('./_has');
  741. var TAG = require('./_wks')('toStringTag');
  742. module.exports = function (it, tag, stat) {
  743. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
  744. };
  745. },{"./_has":34,"./_object-dp":50,"./_wks":69}],59:[function(require,module,exports){
  746. var shared = require('./_shared')('keys');
  747. var uid = require('./_uid');
  748. module.exports = function (key) {
  749. return shared[key] || (shared[key] = uid(key));
  750. };
  751. },{"./_shared":60,"./_uid":68}],60:[function(require,module,exports){
  752. var global = require('./_global');
  753. var SHARED = '__core-js_shared__';
  754. var store = global[SHARED] || (global[SHARED] = {});
  755. module.exports = function (key) {
  756. return store[key] || (store[key] = {});
  757. };
  758. },{"./_global":33}],61:[function(require,module,exports){
  759. var toInteger = require('./_to-integer');
  760. var defined = require('./_defined');
  761. // true -> String#at
  762. // false -> String#codePointAt
  763. module.exports = function (TO_STRING) {
  764. return function (that, pos) {
  765. var s = String(defined(that));
  766. var i = toInteger(pos);
  767. var l = s.length;
  768. var a, b;
  769. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  770. a = s.charCodeAt(i);
  771. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  772. ? TO_STRING ? s.charAt(i) : a
  773. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  774. };
  775. };
  776. },{"./_defined":27,"./_to-integer":63}],62:[function(require,module,exports){
  777. var toInteger = require('./_to-integer');
  778. var max = Math.max;
  779. var min = Math.min;
  780. module.exports = function (index, length) {
  781. index = toInteger(index);
  782. return index < 0 ? max(index + length, 0) : min(index, length);
  783. };
  784. },{"./_to-integer":63}],63:[function(require,module,exports){
  785. // 7.1.4 ToInteger
  786. var ceil = Math.ceil;
  787. var floor = Math.floor;
  788. module.exports = function (it) {
  789. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  790. };
  791. },{}],64:[function(require,module,exports){
  792. // to indexed object, toObject with fallback for non-array-like ES3 strings
  793. var IObject = require('./_iobject');
  794. var defined = require('./_defined');
  795. module.exports = function (it) {
  796. return IObject(defined(it));
  797. };
  798. },{"./_defined":27,"./_iobject":38}],65:[function(require,module,exports){
  799. // 7.1.15 ToLength
  800. var toInteger = require('./_to-integer');
  801. var min = Math.min;
  802. module.exports = function (it) {
  803. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  804. };
  805. },{"./_to-integer":63}],66:[function(require,module,exports){
  806. // 7.1.13 ToObject(argument)
  807. var defined = require('./_defined');
  808. module.exports = function (it) {
  809. return Object(defined(it));
  810. };
  811. },{"./_defined":27}],67:[function(require,module,exports){
  812. // 7.1.1 ToPrimitive(input [, PreferredType])
  813. var isObject = require('./_is-object');
  814. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  815. // and the second argument - flag - preferred type is a string
  816. module.exports = function (it, S) {
  817. if (!isObject(it)) return it;
  818. var fn, val;
  819. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  820. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  821. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  822. throw TypeError("Can't convert object to primitive value");
  823. };
  824. },{"./_is-object":40}],68:[function(require,module,exports){
  825. var id = 0;
  826. var px = Math.random();
  827. module.exports = function (key) {
  828. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  829. };
  830. },{}],69:[function(require,module,exports){
  831. var store = require('./_shared')('wks');
  832. var uid = require('./_uid');
  833. var Symbol = require('./_global').Symbol;
  834. var USE_SYMBOL = typeof Symbol == 'function';
  835. var $exports = module.exports = function (name) {
  836. return store[name] || (store[name] =
  837. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  838. };
  839. $exports.store = store;
  840. },{"./_global":33,"./_shared":60,"./_uid":68}],70:[function(require,module,exports){
  841. var classof = require('./_classof');
  842. var ITERATOR = require('./_wks')('iterator');
  843. var Iterators = require('./_iterators');
  844. module.exports = require('./_core').getIteratorMethod = function (it) {
  845. if (it != undefined) return it[ITERATOR]
  846. || it['@@iterator']
  847. || Iterators[classof(it)];
  848. };
  849. },{"./_classof":22,"./_core":24,"./_iterators":46,"./_wks":69}],71:[function(require,module,exports){
  850. var anObject = require('./_an-object');
  851. var get = require('./core.get-iterator-method');
  852. module.exports = require('./_core').getIterator = function (it) {
  853. var iterFn = get(it);
  854. if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!');
  855. return anObject(iterFn.call(it));
  856. };
  857. },{"./_an-object":20,"./_core":24,"./core.get-iterator-method":70}],72:[function(require,module,exports){
  858. var classof = require('./_classof');
  859. var ITERATOR = require('./_wks')('iterator');
  860. var Iterators = require('./_iterators');
  861. module.exports = require('./_core').isIterable = function (it) {
  862. var O = Object(it);
  863. return O[ITERATOR] !== undefined
  864. || '@@iterator' in O
  865. // eslint-disable-next-line no-prototype-builtins
  866. || Iterators.hasOwnProperty(classof(O));
  867. };
  868. },{"./_classof":22,"./_core":24,"./_iterators":46,"./_wks":69}],73:[function(require,module,exports){
  869. 'use strict';
  870. var ctx = require('./_ctx');
  871. var $export = require('./_export');
  872. var toObject = require('./_to-object');
  873. var call = require('./_iter-call');
  874. var isArrayIter = require('./_is-array-iter');
  875. var toLength = require('./_to-length');
  876. var createProperty = require('./_create-property');
  877. var getIterFn = require('./core.get-iterator-method');
  878. $export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Array.from(iter); }), 'Array', {
  879. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  880. from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  881. var O = toObject(arrayLike);
  882. var C = typeof this == 'function' ? this : Array;
  883. var aLen = arguments.length;
  884. var mapfn = aLen > 1 ? arguments[1] : undefined;
  885. var mapping = mapfn !== undefined;
  886. var index = 0;
  887. var iterFn = getIterFn(O);
  888. var length, r###lt, step, iterator;
  889. if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  890. // if object isn't iterable or it's array with default iterator - use simple case
  891. if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
  892. for (iterator = iterFn.call(O), r###lt = new C(); !(step = iterator.next()).done; index++) {
  893. createProperty(r###lt, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  894. }
  895. } else {
  896. length = toLength(O.length);
  897. for (r###lt = new C(length); length > index; index++) {
  898. createProperty(r###lt, index, mapping ? mapfn(O[index], index) : O[index]);
  899. }
  900. }
  901. r###lt.length = index;
  902. return r###lt;
  903. }
  904. });
  905. },{"./_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){
  906. 'use strict';
  907. var addToUnscopables = require('./_add-to-unscopables');
  908. var step = require('./_iter-step');
  909. var Iterators = require('./_iterators');
  910. var toIObject = require('./_to-iobject');
  911. // 22.1.3.4 Array.prototype.entries()
  912. // 22.1.3.13 Array.prototype.keys()
  913. // 22.1.3.29 Array.prototype.values()
  914. // 22.1.3.30 Array.prototype[@@iterator]()
  915. module.exports = require('./_iter-define')(Array, 'Array', function (iterated, kind) {
  916. this._t = toIObject(iterated); // target
  917. this._i = 0; // next index
  918. this._k = kind; // kind
  919. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  920. }, function () {
  921. var O = this._t;
  922. var kind = this._k;
  923. var index = this._i++;
  924. if (!O || index >= O.length) {
  925. this._t = undefined;
  926. return step(1);
  927. }
  928. if (kind == 'keys') return step(0, index);
  929. if (kind == 'values') return step(0, O[index]);
  930. return step(0, [index, O[index]]);
  931. }, 'values');
  932. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  933. Iterators.Arguments = Iterators.Array;
  934. addToUnscopables('keys');
  935. addToUnscopables('values');
  936. addToUnscopables('entries');
  937. },{"./_add-to-unscopables":19,"./_iter-define":43,"./_iter-step":45,"./_iterators":46,"./_to-iobject":64}],75:[function(require,module,exports){
  938. var $export = require('./_export');
  939. // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
  940. $export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f });
  941. },{"./_descriptors":28,"./_export":31,"./_object-dp":50}],76:[function(require,module,exports){
  942. // 19.1.2.5 Object.freeze(O)
  943. var isObject = require('./_is-object');
  944. var meta = require('./_meta').onFreeze;
  945. require('./_object-sap')('freeze', function ($freeze) {
  946. return function freeze(it) {
  947. return $freeze && isObject(it) ? $freeze(meta(it)) : it;
  948. };
  949. });
  950. },{"./_is-object":40,"./_meta":48,"./_object-sap":55}],77:[function(require,module,exports){
  951. 'use strict';
  952. var $at = require('./_string-at')(true);
  953. // 21.1.3.27 String.prototype[@@iterator]()
  954. require('./_iter-define')(String, 'String', function (iterated) {
  955. this._t = String(iterated); // target
  956. this._i = 0; // next index
  957. // 21.1.5.2.1 %StringIteratorPrototype%.next()
  958. }, function () {
  959. var O = this._t;
  960. var index = this._i;
  961. var point;
  962. if (index >= O.length) return { value: undefined, done: true };
  963. point = $at(O, index);
  964. this._i += point.length;
  965. return { value: point, done: false };
  966. });
  967. },{"./_iter-define":43,"./_string-at":61}],78:[function(require,module,exports){
  968. require('./es6.array.iterator');
  969. var global = require('./_global');
  970. var hide = require('./_hide');
  971. var Iterators = require('./_iterators');
  972. var TO_STRING_TAG = require('./_wks')('toStringTag');
  973. var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
  974. 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
  975. 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
  976. 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
  977. 'TextTrackList,TouchList').split(',');
  978. for (var i = 0; i < DOMIterables.length; i++) {
  979. var NAME = DOMIterables[i];
  980. var Collection = global[NAME];
  981. var proto = Collection && Collection.prototype;
  982. if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  983. Iterators[NAME] = Iterators.Array;
  984. }
  985. },{"./_global":33,"./_hide":35,"./_iterators":46,"./_wks":69,"./es6.array.iterator":74}],79:[function(require,module,exports){
  986. function getRelocatable(re) {
  987. // In the future, this could use a WeakMap instead of an expando.
  988. if (!re.__matchAtRelocatable) {
  989. // Disjunctions are the lowest-precedence operator, so we can make any
  990. // pattern match the empty string by appending `|()` to it:
  991. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-patterns
  992. var source = re.source + '|()';
  993. // We always make the new regex global.
  994. var flags = 'g' + (re.ignoreCase ? 'i' : '') + (re.multiline ? 'm' : '') + (re.unicode ? 'u' : '')
  995. // sticky (/.../y) doesn't make sense in conjunction with our relocation
  996. // logic, so we ignore it here.
  997. ;
  998. re.__matchAtRelocatable = new RegExp(source, flags);
  999. }
  1000. return re.__matchAtRelocatable;
  1001. }
  1002. function matchAt(re, str, pos) {
  1003. if (re.global || re.sticky) {
  1004. throw new Error('matchAt(...): Only non-global regexes are supported');
  1005. }
  1006. var reloc = getRelocatable(re);
  1007. reloc.lastIndex = pos;
  1008. var match = reloc.exec(str);
  1009. // Last capturing group is our sentinel that indicates whether the regex
  1010. // matched at the given location.
  1011. if (match[match.length - 1] == null) {
  1012. // Original regex matched.
  1013. match.length = match.length - 1;
  1014. return match;
  1015. } else {
  1016. return null;
  1017. }
  1018. }
  1019. module.exports = matchAt;
  1020. },{}],80:[function(require,module,exports){
  1021. /*
  1022. object-assign
  1023. (c) Sindre Sorhus
  1024. @license MIT
  1025. */
  1026. 'use strict';
  1027. /* eslint-disable no-unused-vars */
  1028. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  1029. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1030. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  1031. function toObject(val) {
  1032. if (val === null || val === undefined) {
  1033. throw new TypeError('Object.assign cannot be called with null or undefined');
  1034. }
  1035. return Object(val);
  1036. }
  1037. function shouldUseNative() {
  1038. try {
  1039. if (!Object.assign) {
  1040. return false;
  1041. }
  1042. // Detect buggy property enumeration order in older V8 versions.
  1043. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  1044. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  1045. test1[5] = 'de';
  1046. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  1047. return false;
  1048. }
  1049. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  1050. var test2 = {};
  1051. for (var i = 0; i < 10; i++) {
  1052. test2['_' + String.fromCharCode(i)] = i;
  1053. }
  1054. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  1055. return test2[n];
  1056. });
  1057. if (order2.join('') !== '0123456789') {
  1058. return false;
  1059. }
  1060. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  1061. var test3 = {};
  1062. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  1063. test3[letter] = letter;
  1064. });
  1065. if (Object.keys(Object.assign({}, test3)).join('') !==
  1066. 'abcdefghijklmnopqrst') {
  1067. return false;
  1068. }
  1069. return true;
  1070. } catch (err) {
  1071. // We don't expect any of the above to throw, but better to be safe.
  1072. return false;
  1073. }
  1074. }
  1075. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  1076. var from;
  1077. var to = toObject(target);
  1078. var symbols;
  1079. for (var s = 1; s < arguments.length; s++) {
  1080. from = Object(arguments[s]);
  1081. for (var key in from) {
  1082. if (hasOwnProperty.call(from, key)) {
  1083. to[key] = from[key];
  1084. }
  1085. }
  1086. if (getOwnPropertySymbols) {
  1087. symbols = getOwnPropertySymbols(from);
  1088. for (var i = 0; i < symbols.length; i++) {
  1089. if (propIsEnumerable.call(from, symbols[i])) {
  1090. to[symbols[i]] = from[symbols[i]];
  1091. }
  1092. }
  1093. }
  1094. }
  1095. return to;
  1096. };
  1097. },{}],81:[function(require,module,exports){
  1098. "use strict";
  1099. Object.defineProperty(exports, "__esModule", {
  1100. value: true
  1101. });
  1102. exports.controlWordRegex = undefined;
  1103. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  1104. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  1105. var _createClass2 = require("babel-runtime/helpers/createClass");
  1106. var _createClass3 = _interopRequireDefault(_createClass2);
  1107. var _matchAt = require("match-at");
  1108. var _matchAt2 = _interopRequireDefault(_matchAt);
  1109. var _ParseError = require("./ParseError");
  1110. var _ParseError2 = _interopRequireDefault(_ParseError);
  1111. var _SourceLocation = require("./SourceLocation");
  1112. var _SourceLocation2 = _interopRequireDefault(_SourceLocation);
  1113. var _Token = require("./Token");
  1114. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1115. /* The following tokenRegex
  1116. * - matches typical whitespace (but not NBSP etc.) using its first group
  1117. * - matches comments (must have trailing newlines)
  1118. * - does not match any control character \x00-\x1f except whitespace
  1119. * - does not match a bare backslash
  1120. * - matches any ASCII character except those just mentioned
  1121. * - does not match the BMP private use area \uE000-\uF8FF
  1122. * - does not match bare surrogate code units
  1123. * - matches any BMP character except for those just described
  1124. * - matches any valid Unicode surrogate pair
  1125. * - matches a backslash followed by one or more letters
  1126. * - matches a backslash followed by any BMP character, including newline
  1127. * Just because the Lexer matches something doesn't mean it's valid input:
  1128. * If there is no matching function or symbol definition, the Parser will
  1129. * still reject the input.
  1130. */
  1131. /**
  1132. * The Lexer class handles tokenizing the input in various ways. Since our
  1133. * parser expects us to be able to backtrack, the lexer allows lexing from any
  1134. * given starting point.
  1135. *
  1136. * Its main exposed function is the `lex` function, which takes a position to
  1137. * lex from and a type of token to lex. It defers to the appropriate `_innerLex`
  1138. * function.
  1139. *
  1140. * The various `_innerLex` functions perform the actual lexing of different
  1141. * kinds.
  1142. */
  1143. var commentRegexString = "%[^\n]*[\n]";
  1144. var controlWordRegexString = "\\\\[a-zA-Z@]+";
  1145. var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]";
  1146. var tokenRegex = new RegExp("([ \r\n\t]+)|" + ( // whitespace
  1147. "(" + commentRegexString + "|") + // comments
  1148. "[!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint
  1149. "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + // surrogate pair
  1150. "|\\\\verb\\*([^]).*?\\3" + // \verb*
  1151. "|\\\\verb([^*a-zA-Z]).*?\\4" + ( // \verb unstarred
  1152. "|" + controlWordRegexString) + ( // \macroName
  1153. "|" + controlSymbolRegexString) + // \\, \', etc.
  1154. ")");
  1155. // tokenRegex has no ^ marker, as required by matchAt.
  1156. // These regexs are for matching r###lts from tokenRegex,
  1157. // so they do have ^ markers.
  1158. var controlWordRegex = exports.controlWordRegex = new RegExp("^" + controlWordRegexString);
  1159. var commentRegex = new RegExp("^" + commentRegexString);
  1160. /** Main Lexer class */
  1161. var Lexer = function () {
  1162. function Lexer(input) {
  1163. (0, _classCallCheck3.default)(this, Lexer);
  1164. this.input = input;
  1165. this.pos = 0;
  1166. }
  1167. /**
  1168. * This function lexes a single token.
  1169. */
  1170. (0, _createClass3.default)(Lexer, [{
  1171. key: "lex",
  1172. value: function lex() {
  1173. var input = this.input;
  1174. var pos = this.pos;
  1175. if (pos === input.length) {
  1176. return new _Token.Token("EOF", new _SourceLocation2.default(this, pos, pos));
  1177. }
  1178. var match = (0, _matchAt2.default)(tokenRegex, input, pos);
  1179. if (match === null) {
  1180. throw new _ParseError2.default("Unexpected character: '" + input[pos] + "'", new _Token.Token(input[pos], new _SourceLocation2.default(this, pos, pos + 1)));
  1181. }
  1182. var text = match[2] || " ";
  1183. var start = this.pos;
  1184. this.pos += match[0].length;
  1185. var end = this.pos;
  1186. if (commentRegex.test(text)) {
  1187. return this.lex();
  1188. } else {
  1189. return new _Token.Token(text, new _SourceLocation2.default(this, start, end));
  1190. }
  1191. }
  1192. }]);
  1193. return Lexer;
  1194. }();
  1195. exports.default = Lexer;
  1196. },{"./ParseError":84,"./SourceLocation":88,"./Token":90,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9,"match-at":79}],82:[function(require,module,exports){
  1197. "use strict";
  1198. Object.defineProperty(exports, "__esModule", {
  1199. value: true
  1200. });
  1201. var _toConsumableArray2 = require("babel-runtime/helpers/toConsumableArray");
  1202. var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
  1203. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  1204. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  1205. var _createClass2 = require("babel-runtime/helpers/createClass");
  1206. var _createClass3 = _interopRequireDefault(_createClass2);
  1207. var _Lexer = require("./Lexer");
  1208. var _Lexer2 = _interopRequireDefault(_Lexer);
  1209. var _Token = require("./Token");
  1210. var _macros = require("./macros");
  1211. var _macros2 = _interopRequireDefault(_macros);
  1212. var _ParseError = require("./ParseError");
  1213. var _ParseError2 = _interopRequireDefault(_ParseError);
  1214. var _objectAssign = require("object-assign");
  1215. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  1216. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1217. var MacroExpander = function () {
  1218. function MacroExpander(input, macros) {
  1219. (0, _classCallCheck3.default)(this, MacroExpander);
  1220. this.lexer = new _Lexer2.default(input);
  1221. this.macros = (0, _objectAssign2.default)({}, _macros2.default, macros);
  1222. this.stack = []; // contains tokens in REVERSE order
  1223. }
  1224. /**
  1225. * Returns the topmost token on the stack, without expanding it.
  1226. * Similar in behavior to TeX's `\futurelet`.
  1227. */
  1228. (0, _createClass3.default)(MacroExpander, [{
  1229. key: "future",
  1230. value: function future() {
  1231. if (this.stack.length === 0) {
  1232. this.pushToken(this.lexer.lex());
  1233. }
  1234. return this.stack[this.stack.length - 1];
  1235. }
  1236. /**
  1237. * Remove and return the next unexpanded token.
  1238. */
  1239. }, {
  1240. key: "popToken",
  1241. value: function popToken() {
  1242. this.future(); // ensure non-empty stack
  1243. return this.stack.pop();
  1244. }
  1245. /**
  1246. * Consume all following space tokens, without expansion.
  1247. */
  1248. }, {
  1249. key: "consumeSpaces",
  1250. value: function consumeSpaces() {
  1251. for (;;) {
  1252. var token = this.future();
  1253. if (token.text === " ") {
  1254. this.stack.pop();
  1255. } else {
  1256. break;
  1257. }
  1258. }
  1259. }
  1260. /**
  1261. * Expand the next token only once if possible.
  1262. *
  1263. * If the token is expanded, the r###lting tokens will be pushed onto
  1264. * the stack in reverse order and will be returned as an array,
  1265. * also in reverse order.
  1266. *
  1267. * If not, the next token will be returned without removing it
  1268. * from the stack. This case can be detected by a `Token` return value
  1269. * instead of an `Array` return value.
  1270. *
  1271. * In either case, the next token will be on the top of the stack,
  1272. * or the stack will be empty.
  1273. *
  1274. * Used to implement `expandAfterFuture` and `expandNextToken`.
  1275. *
  1276. * At the moment, macro expansion doesn't handle delimited macros,
  1277. * i.e. things like those defined by \def\foo#1\end{…}.
  1278. * See the TeX book page 202ff. for details on how those should behave.
  1279. */
  1280. }, {
  1281. key: "expandOnce",
  1282. value: function expandOnce() {
  1283. var _stack;
  1284. var topToken = this.popToken();
  1285. var name = topToken.text;
  1286. var isMacro = name.charAt(0) === "\\";
  1287. if (isMacro && _Lexer.controlWordRegex.test(name)) {
  1288. // Consume all spaces after \macro (but not \\, \', etc.)
  1289. this.consumeSpaces();
  1290. }
  1291. if (!(isMacro && this.macros.hasOwnProperty(name))) {
  1292. // Fully expanded
  1293. this.pushToken(topToken);
  1294. return topToken;
  1295. }
  1296. var _getExpansion2 = this._getExpansion(name),
  1297. tokens = _getExpansion2.tokens,
  1298. numArgs = _getExpansion2.numArgs;
  1299. var expansion = tokens;
  1300. if (numArgs) {
  1301. var args = [];
  1302. // obtain arguments, either single token or balanced {…} group
  1303. for (var i = 0; i < numArgs; ++i) {
  1304. this.consumeSpaces(); // ignore spaces before each argument
  1305. var startOfArg = this.popToken();
  1306. if (startOfArg.text === "{") {
  1307. var arg = [];
  1308. var depth = 1;
  1309. while (depth !== 0) {
  1310. var tok = this.popToken();
  1311. arg.push(tok);
  1312. if (tok.text === "{") {
  1313. ++depth;
  1314. } else if (tok.text === "}") {
  1315. --depth;
  1316. } else if (tok.text === "EOF") {
  1317. throw new _ParseError2.default("End of input in macro argument", startOfArg);
  1318. }
  1319. }
  1320. arg.pop(); // remove last }
  1321. arg.reverse(); // like above, to fit in with stack order
  1322. args[i] = arg;
  1323. } else if (startOfArg.text === "EOF") {
  1324. throw new _ParseError2.default("End of input expecting macro argument", topToken);
  1325. } else {
  1326. args[i] = [startOfArg];
  1327. }
  1328. }
  1329. // paste arguments in place of the placeholders
  1330. expansion = expansion.slice(); // make a shallow copy
  1331. for (var _i = expansion.length - 1; _i >= 0; --_i) {
  1332. var _tok = expansion[_i];
  1333. if (_tok.text === "#") {
  1334. if (_i === 0) {
  1335. throw new _ParseError2.default("Incomplete placeholder at end of macro body", _tok);
  1336. }
  1337. _tok = expansion[--_i]; // next token on stack
  1338. if (_tok.text === "#") {
  1339. // ## → #
  1340. expansion.splice(_i + 1, 1); // drop first #
  1341. } else if (/^[1-9]$/.test(_tok.text)) {
  1342. var _expansion;
  1343. // replace the placeholder with the indicated argument
  1344. (_expansion = expansion).splice.apply(_expansion, [_i, 2].concat((0, _toConsumableArray3.default)(args[+_tok.text - 1])));
  1345. } else {
  1346. throw new _ParseError2.default("Not a valid argument number", _tok);
  1347. }
  1348. }
  1349. }
  1350. }
  1351. // Concatenate expansion onto top of stack.
  1352. (_stack = this.stack).push.apply(_stack, (0, _toConsumableArray3.default)(expansion));
  1353. return expansion;
  1354. }
  1355. /**
  1356. * Expand the next token only once (if possible), and return the r###lting
  1357. * top token on the stack (without removing anything from the stack).
  1358. * Similar in behavior to TeX's `\expandafter\futurelet`.
  1359. * Equivalent to expandOnce() followed by future().
  1360. */
  1361. }, {
  1362. key: "expandAfterFuture",
  1363. value: function expandAfterFuture() {
  1364. this.expandOnce();
  1365. return this.future();
  1366. }
  1367. /**
  1368. * Recursively expand first token, then return first non-expandable token.
  1369. */
  1370. }, {
  1371. key: "expandNextToken",
  1372. value: function expandNextToken() {
  1373. for (;;) {
  1374. var expanded = this.expandOnce();
  1375. // expandOnce returns Token if and only if it's fully expanded.
  1376. if (expanded instanceof _Token.Token) {
  1377. // \relax stops the expansion, but shouldn't get returned (a
  1378. // null return value couldn't get implemented as a function).
  1379. if (expanded.text === "\\relax") {
  1380. this.stack.pop();
  1381. } else {
  1382. return this.stack.pop(); // === expanded
  1383. }
  1384. }
  1385. }
  1386. // Flow unable to figure out that this pathway is impossible.
  1387. // https://github.com/facebook/flow/issues/4808
  1388. throw new Error(); // eslint-disable-line no-unreachable
  1389. }
  1390. /**
  1391. * Returns the expanded macro as a reversed array of tokens and a macro
  1392. * argument count.
  1393. * Caches macro expansions for those that were defined simple TeX strings.
  1394. */
  1395. }, {
  1396. key: "_getExpansion",
  1397. value: function _getExpansion(name) {
  1398. var definition = this.macros[name];
  1399. var expansion = typeof definition === "function" ? definition(this) : definition;
  1400. if (typeof expansion === "string") {
  1401. var numArgs = 0;
  1402. if (expansion.indexOf("#") !== -1) {
  1403. var stripped = expansion.replace(/##/g, "");
  1404. while (stripped.indexOf("#" + (numArgs + 1)) !== -1) {
  1405. ++numArgs;
  1406. }
  1407. }
  1408. var bodyLexer = new _Lexer2.default(expansion);
  1409. var tokens = [];
  1410. var tok = bodyLexer.lex();
  1411. while (tok.text !== "EOF") {
  1412. tokens.push(tok);
  1413. tok = bodyLexer.lex();
  1414. }
  1415. tokens.reverse(); // to fit in with stack using push and pop
  1416. var expanded = { tokens: tokens, numArgs: numArgs };
  1417. // Cannot cache a macro defined using a function since it relies on
  1418. // parser context.
  1419. if (typeof definition !== "function") {
  1420. this.macros[name] = expanded;
  1421. }
  1422. return expanded;
  1423. }
  1424. return expansion;
  1425. }
  1426. /**
  1427. * Add a given token to the token stack. In particular, this get be used
  1428. * to put back a token returned from one of the other methods.
  1429. */
  1430. }, {
  1431. key: "pushToken",
  1432. value: function pushToken(token) {
  1433. this.stack.push(token);
  1434. }
  1435. }]);
  1436. return MacroExpander;
  1437. }();
  1438. /**
  1439. * This file contains the “gullet” where macros are expanded
  1440. * until only non-macro tokens remain.
  1441. */
  1442. exports.default = MacroExpander;
  1443. },{"./Lexer":81,"./ParseError":84,"./Token":90,"./macros":107,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9,"babel-runtime/helpers/toConsumableArray":11,"object-assign":80}],83:[function(require,module,exports){
  1444. "use strict";
  1445. Object.defineProperty(exports, "__esModule", {
  1446. value: true
  1447. });
  1448. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  1449. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  1450. var _createClass2 = require("babel-runtime/helpers/createClass");
  1451. var _createClass3 = _interopRequireDefault(_createClass2);
  1452. var _fontMetrics2 = require("./fontMetrics");
  1453. var _fontMetrics3 = _interopRequireDefault(_fontMetrics2);
  1454. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1455. var sizeStyleMap = [
  1456. // Each element contains [textsize, scriptsize, scriptscriptsize].
  1457. // The size mappings are taken from TeX with \normalsize=10pt.
  1458. [1, 1, 1], // size1: [5, 5, 5] \tiny
  1459. [2, 1, 1], // size2: [6, 5, 5]
  1460. [3, 1, 1], // size3: [7, 5, 5] \scriptsize
  1461. [4, 2, 1], // size4: [8, 6, 5] \footnotesize
  1462. [5, 2, 1], // size5: [9, 6, 5] \small
  1463. [6, 3, 1], // size6: [10, 7, 5] \normalsize
  1464. [7, 4, 2], // size7: [12, 8, 6] \large
  1465. [8, 6, 3], // size8: [14.4, 10, 7] \Large
  1466. [9, 7, 6], // size9: [17.28, 12, 10] \LARGE
  1467. [10, 8, 7], // size10: [20.74, 14.4, 12] \huge
  1468. [11, 10, 9]];
  1469. /**
  1470. * This file contains information about the options that the Parser carries
  1471. * around with it while parsing. Data is held in an `Options` object, and when
  1472. * recursing, a new `Options` object can be created with the `.with*` and
  1473. * `.reset` functions.
  1474. */
  1475. var sizeMultipliers = [
  1476. // fontMetrics.js:getFontMetrics also uses size indexes, so if
  1477. // you change size indexes, change that function.
  1478. 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
  1479. var sizeAtStyle = function sizeAtStyle(size, style) {
  1480. return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
  1481. };
  1482. /**
  1483. * This is the main options class. It contains the current style, size, color,
  1484. * and font.
  1485. *
  1486. * Options objects should not be modified. To create a new Options with
  1487. * different properties, call a `.having*` method.
  1488. */
  1489. var Options = function () {
  1490. function Options(data) {
  1491. (0, _classCallCheck3.default)(this, Options);
  1492. this.style = data.style;
  1493. this.color = data.color;
  1494. this.size = data.size || Options.BASESIZE;
  1495. this.textSize = data.textSize || this.size;
  1496. this.phantom = !!data.phantom;
  1497. this.font = data.font;
  1498. this.sizeMultiplier = sizeMultipliers[this.size - 1];
  1499. this.maxSize = data.maxSize;
  1500. this._fontMetrics = undefined;
  1501. }
  1502. /**
  1503. * Returns a new options object with the same properties as "this". Properties
  1504. * from "extension" will be copied to the new options object.
  1505. */
  1506. /**
  1507. * The base size index.
  1508. */
  1509. (0, _createClass3.default)(Options, [{
  1510. key: "extend",
  1511. value: function extend(extension) {
  1512. var data = {
  1513. style: this.style,
  1514. size: this.size,
  1515. textSize: this.textSize,
  1516. color: this.color,
  1517. phantom: this.phantom,
  1518. font: this.font,
  1519. maxSize: this.maxSize
  1520. };
  1521. for (var key in extension) {
  1522. if (extension.hasOwnProperty(key)) {
  1523. data[key] = extension[key];
  1524. }
  1525. }
  1526. return new Options(data);
  1527. }
  1528. /**
  1529. * Return an options object with the given style. If `this.style === style`,
  1530. * returns `this`.
  1531. */
  1532. }, {
  1533. key: "havingStyle",
  1534. value: function havingStyle(style) {
  1535. if (this.style === style) {
  1536. return this;
  1537. } else {
  1538. return this.extend({
  1539. style: style,
  1540. size: sizeAtStyle(this.textSize, style)
  1541. });
  1542. }
  1543. }
  1544. /**
  1545. * Return an options object with a cramped version of the current style. If
  1546. * the current style is cramped, returns `this`.
  1547. */
  1548. }, {
  1549. key: "havingCrampedStyle",
  1550. value: function havingCrampedStyle() {
  1551. return this.havingStyle(this.style.cramp());
  1552. }
  1553. /**
  1554. * Return an options object with the given size and in at least `\textstyle`.
  1555. * Returns `this` if appropriate.
  1556. */
  1557. }, {
  1558. key: "havingSize",
  1559. value: function havingSize(size) {
  1560. if (this.size === size && this.textSize === size) {
  1561. return this;
  1562. } else {
  1563. return this.extend({
  1564. style: this.style.text(),
  1565. size: size,
  1566. textSize: size
  1567. });
  1568. }
  1569. }
  1570. /**
  1571. * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
  1572. * changes to at least `\textstyle`.
  1573. */
  1574. }, {
  1575. key: "havingBaseStyle",
  1576. value: function havingBaseStyle(style) {
  1577. style = style || this.style.text();
  1578. var wantSize = sizeAtStyle(Options.BASESIZE, style);
  1579. if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) {
  1580. return this;
  1581. } else {
  1582. return this.extend({
  1583. style: style,
  1584. size: wantSize
  1585. });
  1586. }
  1587. }
  1588. /**
  1589. * Create a new options object with the given color.
  1590. */
  1591. }, {
  1592. key: "withColor",
  1593. value: function withColor(color) {
  1594. return this.extend({
  1595. color: color
  1596. });
  1597. }
  1598. /**
  1599. * Create a new options object with "phantom" set to true.
  1600. */
  1601. }, {
  1602. key: "withPhantom",
  1603. value: function withPhantom() {
  1604. return this.extend({
  1605. phantom: true
  1606. });
  1607. }
  1608. /**
  1609. * Create a new options objects with the give font.
  1610. */
  1611. }, {
  1612. key: "withFont",
  1613. value: function withFont(font) {
  1614. return this.extend({
  1615. font: font || this.font
  1616. });
  1617. }
  1618. /**
  1619. * Return the CSS sizing classes required to switch from enclosing options
  1620. * `oldOptions` to `this`. Returns an array of classes.
  1621. */
  1622. }, {
  1623. key: "sizingClasses",
  1624. value: function sizingClasses(oldOptions) {
  1625. if (oldOptions.size !== this.size) {
  1626. return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
  1627. } else {
  1628. return [];
  1629. }
  1630. }
  1631. /**
  1632. * Return the CSS sizing classes required to switch to the base size. Like
  1633. * `this.havingSize(BASESIZE).sizingClasses(this)`.
  1634. */
  1635. }, {
  1636. key: "baseSizingClasses",
  1637. value: function baseSizingClasses() {
  1638. if (this.size !== Options.BASESIZE) {
  1639. return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
  1640. } else {
  1641. return [];
  1642. }
  1643. }
  1644. /**
  1645. * Return the font metrics for this size.
  1646. */
  1647. }, {
  1648. key: "fontMetrics",
  1649. value: function fontMetrics() {
  1650. if (!this._fontMetrics) {
  1651. this._fontMetrics = _fontMetrics3.default.getFontMetrics(this.size);
  1652. }
  1653. return this._fontMetrics;
  1654. }
  1655. /**
  1656. * A map of color names to CSS colors.
  1657. * TODO(emily): Remove this when we have real macros
  1658. */
  1659. }, {
  1660. key: "getColor",
  1661. /**
  1662. * Gets the CSS color of the current options object, accounting for the
  1663. * `colorMap`.
  1664. */
  1665. value: function getColor() {
  1666. if (this.phantom) {
  1667. return "transparent";
  1668. } else if (this.color != null && Options.colorMap.hasOwnProperty(this.color)) {
  1669. return Options.colorMap[this.color];
  1670. } else {
  1671. return this.color;
  1672. }
  1673. }
  1674. }]);
  1675. return Options;
  1676. }();
  1677. Options.BASESIZE = 6;
  1678. Options.colorMap = {
  1679. "katex-blue": "#6495ed",
  1680. "katex-orange": "#ffa500",
  1681. "katex-pink": "#ff00af",
  1682. "katex-red": "#df0030",
  1683. "katex-green": "#28ae7b",
  1684. "katex-gray": "gray",
  1685. "katex-purple": "#9d38bd",
  1686. "katex-blueA": "#ccfaff",
  1687. "katex-blueB": "#80f6ff",
  1688. "katex-blueC": "#63d9ea",
  1689. "katex-blueD": "#11accd",
  1690. "katex-blueE": "#0c7f99",
  1691. "katex-tealA": "#94fff5",
  1692. "katex-tealB": "#26edd5",
  1693. "katex-tealC": "#01d1c1",
  1694. "katex-tealD": "#01a995",
  1695. "katex-tealE": "#208170",
  1696. "katex-greenA": "#b6ffb0",
  1697. "katex-greenB": "#8af281",
  1698. "katex-greenC": "#74cf70",
  1699. "katex-greenD": "#1fab54",
  1700. "katex-greenE": "#0d923f",
  1701. "katex-goldA": "#ffd0a9",
  1702. "katex-goldB": "#ffbb71",
  1703. "katex-goldC": "#ff9c39",
  1704. "katex-goldD": "#e07d10",
  1705. "katex-goldE": "#a75a05",
  1706. "katex-redA": "#fca9a9",
  1707. "katex-redB": "#ff8482",
  1708. "katex-redC": "#f9685d",
  1709. "katex-redD": "#e84d39",
  1710. "katex-redE": "#bc2612",
  1711. "katex-maroonA": "#ffbde0",
  1712. "katex-maroonB": "#ff92c6",
  1713. "katex-maroonC": "#ed5fa6",
  1714. "katex-maroonD": "#ca337c",
  1715. "katex-maroonE": "#9e034e",
  1716. "katex-purpleA": "#ddd7ff",
  1717. "katex-purpleB": "#c6b9fc",
  1718. "katex-purpleC": "#aa87ff",
  1719. "katex-purpleD": "#7854ab",
  1720. "katex-purpleE": "#543b78",
  1721. "katex-mintA": "#f5f9e8",
  1722. "katex-mintB": "#edf2df",
  1723. "katex-mintC": "#e0e5cc",
  1724. "katex-grayA": "#f6f7f7",
  1725. "katex-grayB": "#f0f1f2",
  1726. "katex-grayC": "#e3e5e6",
  1727. "katex-grayD": "#d6d8da",
  1728. "katex-grayE": "#babec2",
  1729. "katex-grayF": "#888d93",
  1730. "katex-grayG": "#626569",
  1731. "katex-grayH": "#3b3e40",
  1732. "katex-grayI": "#21242c",
  1733. "katex-kaBlue": "#314453",
  1734. "katex-kaGreen": "#71B307"
  1735. };
  1736. exports.default = Options;
  1737. },{"./fontMetrics":101,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],84:[function(require,module,exports){
  1738. "use strict";
  1739. Object.defineProperty(exports, "__esModule", {
  1740. value: true
  1741. });
  1742. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  1743. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  1744. var _ParseNode = require("./ParseNode");
  1745. var _ParseNode2 = _interopRequireDefault(_ParseNode);
  1746. var _Token = require("./Token");
  1747. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1748. /**
  1749. * This is the ParseError class, which is the main error thrown by KaTeX
  1750. * functions when something has gone wrong. This is used to distinguish internal
  1751. * errors from errors in the expression that the user provided.
  1752. *
  1753. * If possible, a caller should provide a Token or ParseNode with information
  1754. * about where in the source string the problem occurred.
  1755. */
  1756. var ParseError =
  1757. // Error position based on passed-in Token or ParseNode.
  1758. function ParseError(message, // The error message
  1759. token) // An object providing position information
  1760. {
  1761. (0, _classCallCheck3.default)(this, ParseError);
  1762. var error = "KaTeX parse error: " + message;
  1763. var start = void 0;
  1764. var loc = token && token.loc;
  1765. if (loc && loc.start <= loc.end) {
  1766. // If we have the input and a position, make the error a bit fancier
  1767. // Get the input
  1768. var input = loc.lexer.input;
  1769. // Prepend some information
  1770. start = loc.start;
  1771. var end = loc.end;
  1772. if (start === input.length) {
  1773. error += " at end of input: ";
  1774. } else {
  1775. error += " at position " + (start + 1) + ": ";
  1776. }
  1777. // Underline token in question using combining underscores
  1778. var underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332");
  1779. // Extract some context from the input and add it to the error
  1780. var left = void 0;
  1781. if (start > 15) {
  1782. left = "…" + input.slice(start - 15, start);
  1783. } else {
  1784. left = input.slice(0, start);
  1785. }
  1786. var right = void 0;
  1787. if (end + 15 < input.length) {
  1788. right = input.slice(end, end + 15) + "…";
  1789. } else {
  1790. right = input.slice(end);
  1791. }
  1792. error += left + underlined + right;
  1793. }
  1794. // Some hackery to make ParseError a prototype of Error
  1795. // See http://stackoverflow.com/a/8460753
  1796. var self = new Error(error);
  1797. self.name = "ParseError";
  1798. // $FlowFixMe
  1799. self.__proto__ = ParseError.prototype;
  1800. // $FlowFixMe
  1801. self.position = start;
  1802. return self;
  1803. };
  1804. // $FlowFixMe More hackery
  1805. ParseError.prototype.__proto__ = Error.prototype;
  1806. exports.default = ParseError;
  1807. },{"./ParseNode":85,"./Token":90,"babel-runtime/helpers/classCallCheck":8}],85:[function(require,module,exports){
  1808. "use strict";
  1809. Object.defineProperty(exports, "__esModule", {
  1810. value: true
  1811. });
  1812. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  1813. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  1814. var _Token = require("./Token");
  1815. var _SourceLocation = require("./SourceLocation");
  1816. var _SourceLocation2 = _interopRequireDefault(_SourceLocation);
  1817. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1818. /**
  1819. * The r###lting parse tree nodes of the parse tree.
  1820. *
  1821. * It is possible to provide position information, so that a `ParseNode` can
  1822. * fulfill a role similar to a `Token` in error reporting.
  1823. * For details on the corresponding properties see `Token` constructor.
  1824. * Providing such information can lead to better error reporting.
  1825. */
  1826. var ParseNode = function ParseNode(type, // type of node, like e.g. "ordgroup"
  1827. value, // type-specific representation of the node
  1828. mode, // parse mode in action for this node, "math" or "text"
  1829. firstToken, // first token of the input for this node,
  1830. lastToken) // last token of the input for this node,
  1831. // will default to firstToken if unset
  1832. {
  1833. (0, _classCallCheck3.default)(this, ParseNode);
  1834. this.type = type;
  1835. this.value = value;
  1836. this.mode = mode;
  1837. this.loc = _SourceLocation2.default.range(firstToken, lastToken);
  1838. };
  1839. exports.default = ParseNode;
  1840. },{"./SourceLocation":88,"./Token":90,"babel-runtime/helpers/classCallCheck":8}],86:[function(require,module,exports){
  1841. "use strict";
  1842. Object.defineProperty(exports, "__esModule", {
  1843. value: true
  1844. });
  1845. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  1846. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  1847. var _createClass2 = require("babel-runtime/helpers/createClass");
  1848. var _createClass3 = _interopRequireDefault(_createClass2);
  1849. var _functions = require("./functions");
  1850. var _functions2 = _interopRequireDefault(_functions);
  1851. var _environments = require("./environments");
  1852. var _environments2 = _interopRequireDefault(_environments);
  1853. var _MacroExpander = require("./MacroExpander");
  1854. var _MacroExpander2 = _interopRequireDefault(_MacroExpander);
  1855. var _symbols = require("./symbols");
  1856. var _symbols2 = _interopRequireDefault(_symbols);
  1857. var _utils = require("./utils");
  1858. var _utils2 = _interopRequireDefault(_utils);
  1859. var _units = require("./units");
  1860. var _unicodeRegexes = require("./unicodeRegexes");
  1861. var _ParseNode = require("./ParseNode");
  1862. var _ParseNode2 = _interopRequireDefault(_ParseNode);
  1863. var _ParseError = require("./ParseError");
  1864. var _ParseError2 = _interopRequireDefault(_ParseError);
  1865. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1866. /**
  1867. * This file contains the parser used to parse out a TeX expression from the
  1868. * input. Since TeX isn't context-free, standard parsers don't work particularly
  1869. * well.
  1870. *
  1871. * The strategy of this parser is as such:
  1872. *
  1873. * The main functions (the `.parse...` ones) take a position in the current
  1874. * parse string to parse tokens from. The lexer (found in Lexer.js, stored at
  1875. * this.lexer) also supports pulling out tokens at arbitrary places. When
  1876. * individual tokens are needed at a position, the lexer is called to pull out a
  1877. * token, which is then used.
  1878. *
  1879. * The parser has a property called "mode" indicating the mode that
  1880. * the parser is currently in. Currently it has to be one of "math" or
  1881. * "text", which denotes whether the current environment is a math-y
  1882. * one or a text-y one (e.g. inside \text). Currently, this serves to
  1883. * limit the functions which can be used in text mode.
  1884. *
  1885. * The main functions then return an object which contains the useful data that
  1886. * was parsed at its given point, and a new position at the end of the parsed
  1887. * data. The main functions can call each other and continue the parsing by
  1888. * using the returned position as a new starting point.
  1889. *
  1890. * There are also extra `.handle...` functions, which pull out some reused
  1891. * functionality into self-contained functions.
  1892. *
  1893. * The earlier functions return ParseNodes.
  1894. * The later functions (which are called deeper in the parse) sometimes return
  1895. * ParsedFuncOrArgOrDollar, which contain a ParseNode as well as some data about
  1896. * whether the parsed object is a function which is missing some arguments, or a
  1897. * standalone object which can be used as an argument to another function.
  1898. */
  1899. /* TODO: Uncomment when porting to flow.
  1900. type ParsedType = "fn" | "arg" | "$"
  1901. type ParsedFunc = {|
  1902. type: "fn",
  1903. r###lt: string, // Function name defined via defineFunction (e.g. "\\frac").
  1904. token: Token,
  1905. |};
  1906. type ParsedArg = {|
  1907. type: "arg",
  1908. r###lt: ParseNode,
  1909. token: Token,
  1910. |};
  1911. type ParsedDollar = {|
  1912. // Math mode switch
  1913. type: "$",
  1914. r###lt: "$",
  1915. token: Token,
  1916. |};
  1917. type ParsedFuncOrArgOrDollar = ParsedFunc | ParsedArg | ParsedDollar;
  1918. */
  1919. /**
  1920. * @param {ParseNode} r###lt
  1921. * @param {Token} token
  1922. * @return {ParsedArg}
  1923. */
  1924. function newArgument(r###lt, token) {
  1925. return { type: "arg", r###lt: r###lt, token: token };
  1926. }
  1927. /**
  1928. * @param {Token} token
  1929. * @return {ParsedFunc}
  1930. */
  1931. /* eslint no-constant-condition:0 */
  1932. function newFunction(token) {
  1933. return { type: "fn", r###lt: token.text, token: token };
  1934. }
  1935. /**
  1936. * @param {Token} token
  1937. * @return {ParsedDollar}
  1938. */
  1939. function newDollar(token) {
  1940. return { type: "$", r###lt: "$", token: token };
  1941. }
  1942. /**
  1943. * @param {ParsedFuncOrArgOrDollar} parsed
  1944. * @return {ParsedFuncOrArg}
  1945. */
  1946. function assertFuncOrArg(parsed) {
  1947. if (parsed.type === "$") {
  1948. throw new _ParseError2.default("Unexpected $", parsed.token);
  1949. }
  1950. return parsed;
  1951. }
  1952. var Parser = function () {
  1953. function Parser(input, settings) {
  1954. (0, _classCallCheck3.default)(this, Parser);
  1955. // Create a new macro expander (gullet) and (indirectly via that) also a
  1956. // new lexer (mouth) for this parser (stomach, in the language of TeX)
  1957. this.gullet = new _MacroExpander2.default(input, settings.macros);
  1958. // Use old \color behavior (same as LaTeX's \textcolor) if requested.
  1959. // We do this after the macros object has been copied by MacroExpander.
  1960. if (settings.colorIsTextColor) {
  1961. this.gullet.macros["\\color"] = "\\textcolor";
  1962. }
  1963. // Store the settings for use in parsing
  1964. this.settings = settings;
  1965. // Count leftright depth (for \middle errors)
  1966. this.leftrightDepth = 0;
  1967. }
  1968. /**
  1969. * Checks a r###lt to make sure it has the right type, and throws an
  1970. * appropriate error otherwise.
  1971. *
  1972. * @param {boolean=} consume whether to consume the expected token,
  1973. * defaults to true
  1974. */
  1975. (0, _createClass3.default)(Parser, [{
  1976. key: "expect",
  1977. value: function expect(text, consume) {
  1978. if (this.nextToken.text !== text) {
  1979. throw new _ParseError2.default("Expected '" + text + "', got '" + this.nextToken.text + "'", this.nextToken);
  1980. }
  1981. if (consume !== false) {
  1982. this.consume();
  1983. }
  1984. }
  1985. /**
  1986. * Considers the current look ahead token as consumed,
  1987. * and fetches the one after that as the new look ahead.
  1988. */
  1989. }, {
  1990. key: "consume",
  1991. value: function consume() {
  1992. this.nextToken = this.gullet.expandNextToken();
  1993. }
  1994. /**
  1995. * Switches between "text" and "math" modes.
  1996. */
  1997. }, {
  1998. key: "switchMode",
  1999. value: function switchMode(newMode) {
  2000. this.mode = newMode;
  2001. }
  2002. /**
  2003. * Main parsing function, which parses an entire input.
  2004. *
  2005. * @return {Array.<ParseNode>}
  2006. */
  2007. }, {
  2008. key: "parse",
  2009. value: function parse() {
  2010. // Try to parse the input
  2011. this.mode = "math";
  2012. this.consume();
  2013. var parse = this.parseInput();
  2014. return parse;
  2015. }
  2016. /**
  2017. * Parses an entire input tree.
  2018. */
  2019. }, {
  2020. key: "parseInput",
  2021. value: function parseInput() {
  2022. // Parse an expression
  2023. var expression = this.parseExpression(false);
  2024. // If we succeeded, make sure there's an EOF at the end
  2025. this.expect("EOF", false);
  2026. return expression;
  2027. }
  2028. }, {
  2029. key: "parseExpression",
  2030. /**
  2031. * Parses an "expression", which is a list of atoms.
  2032. *
  2033. * @param {boolean} breakOnInfix Should the parsing stop when we hit infix
  2034. * nodes? This happens when functions have higher precendence
  2035. * than infix nodes in implicit parses.
  2036. *
  2037. * @param {?string} breakOnTokenText The text of the token that the expression
  2038. * should end with, or `null` if something else should end the
  2039. * expression.
  2040. *
  2041. * @return {Array<ParseNode>}
  2042. */
  2043. value: function parseExpression(breakOnInfix, breakOnTokenText) {
  2044. var body = [];
  2045. // Keep adding atoms to the body until we can't parse any more atoms (either
  2046. // we reached the end, a }, or a \right)
  2047. while (true) {
  2048. // Ignore spaces in math mode
  2049. if (this.mode === "math") {
  2050. this.consumeSpaces();
  2051. }
  2052. var lex = this.nextToken;
  2053. if (Parser.endOfExpression.indexOf(lex.text) !== -1) {
  2054. break;
  2055. }
  2056. if (breakOnTokenText && lex.text === breakOnTokenText) {
  2057. break;
  2058. }
  2059. if (breakOnInfix && _functions2.default[lex.text] && _functions2.default[lex.text].infix) {
  2060. break;
  2061. }
  2062. var atom = this.parseAtom(breakOnTokenText);
  2063. if (!atom) {
  2064. if (!this.settings.throwOnError && lex.text[0] === "\\") {
  2065. var errorNode = this.handleUnsupportedCmd();
  2066. body.push(errorNode);
  2067. continue;
  2068. }
  2069. break;
  2070. }
  2071. body.push(atom);
  2072. }
  2073. return this.handleInfixNodes(body);
  2074. }
  2075. /**
  2076. * Rewrites infix operators such as \over with corresponding commands such
  2077. * as \frac.
  2078. *
  2079. * There can only be one infix operator per group. If there's more than one
  2080. * then the expression is ambiguous. This can be resolved by adding {}.
  2081. *
  2082. * @param {Array<ParseNode>} body
  2083. * @return {Array<ParseNode>}
  2084. */
  2085. }, {
  2086. key: "handleInfixNodes",
  2087. value: function handleInfixNodes(body) {
  2088. var overIndex = -1;
  2089. var funcName = void 0;
  2090. for (var i = 0; i < body.length; i++) {
  2091. var node = body[i];
  2092. if (node.type === "infix") {
  2093. if (overIndex !== -1) {
  2094. throw new _ParseError2.default("only one infix operator per group", node.value.token);
  2095. }
  2096. overIndex = i;
  2097. funcName = node.value.replaceWith;
  2098. }
  2099. }
  2100. if (overIndex !== -1) {
  2101. var numerNode = void 0;
  2102. var denomNode = void 0;
  2103. var numerBody = body.slice(0, overIndex);
  2104. var denomBody = body.slice(overIndex + 1);
  2105. if (numerBody.length === 1 && numerBody[0].type === "ordgroup") {
  2106. numerNode = numerBody[0];
  2107. } else {
  2108. numerNode = new _ParseNode2.default("ordgroup", numerBody, this.mode);
  2109. }
  2110. if (denomBody.length === 1 && denomBody[0].type === "ordgroup") {
  2111. denomNode = denomBody[0];
  2112. } else {
  2113. denomNode = new _ParseNode2.default("ordgroup", denomBody, this.mode);
  2114. }
  2115. var value = this.callFunction(funcName, [numerNode, denomNode], []);
  2116. return [new _ParseNode2.default(value.type, value, this.mode)];
  2117. } else {
  2118. return body;
  2119. }
  2120. }
  2121. // The greediness of a superscript or subscript
  2122. }, {
  2123. key: "handl###pSubscript",
  2124. /**
  2125. * Handle a subscript or superscript with nice errors.
  2126. * @param {string} name For error reporting.
  2127. * @return {ParsedNode}
  2128. */
  2129. value: function handl###pSubscript(name) {
  2130. var symbolToken = this.nextToken;
  2131. var symbol = symbolToken.text;
  2132. this.consume();
  2133. this.consumeSpaces(); // ignore spaces before sup/subscript argument
  2134. var group = this.parseGroup();
  2135. if (!group) {
  2136. if (!this.settings.throwOnError && this.nextToken.text[0] === "\\") {
  2137. return this.handleUnsupportedCmd();
  2138. } else {
  2139. throw new _ParseError2.default("Expected group after '" + symbol + "'", symbolToken);
  2140. }
  2141. }
  2142. var arg = assertFuncOrArg(group);
  2143. if (arg.type === "fn") {
  2144. // ^ and _ have a greediness, so handle interactions with functions'
  2145. // greediness
  2146. var funcGreediness = _functions2.default[group.r###lt].greediness;
  2147. if (funcGreediness > Parser.SUPSUB_GREEDINESS) {
  2148. return this.parseGivenFunction(group);
  2149. } else {
  2150. throw new _ParseError2.default("Got function '" + group.r###lt + "' with no arguments " + "as " + name, symbolToken);
  2151. }
  2152. } else {
  2153. return group.r###lt;
  2154. }
  2155. }
  2156. /**
  2157. * Converts the textual input of an unsupported command into a text node
  2158. * contained within a color node whose color is determined by errorColor
  2159. */
  2160. }, {
  2161. key: "handleUnsupportedCmd",
  2162. value: function handleUnsupportedCmd() {
  2163. var text = this.nextToken.text;
  2164. var textordArray = [];
  2165. for (var i = 0; i < text.length; i++) {
  2166. textordArray.push(new _ParseNode2.default("textord", text[i], "text"));
  2167. }
  2168. var textNode = new _ParseNode2.default("text", {
  2169. body: textordArray,
  2170. type: "text"
  2171. }, this.mode);
  2172. var colorNode = new _ParseNode2.default("color", {
  2173. color: this.settings.errorColor,
  2174. value: [textNode],
  2175. type: "color"
  2176. }, this.mode);
  2177. this.consume();
  2178. return colorNode;
  2179. }
  2180. /**
  2181. * Parses a group with optional super/subscripts.
  2182. *
  2183. * @param {"]" | "}"} breakOnTokenText - character to stop parsing the group on.
  2184. * @return {?ParseNode}
  2185. */
  2186. }, {
  2187. key: "parseAtom",
  2188. value: function parseAtom(breakOnTokenText) {
  2189. // The body of an atom is an implicit group, so that things like
  2190. // \left(x\right)^2 work correctly.
  2191. var base = this.parseImplicitGroup(breakOnTokenText);
  2192. // In text mode, we don't have superscripts or subscripts
  2193. if (this.mode === "text") {
  2194. return base;
  2195. }
  2196. // Note that base may be empty (i.e. null) at this point.
  2197. var superscript = void 0;
  2198. var subscript = void 0;
  2199. while (true) {
  2200. // Guaranteed in math mode, so eat any spaces first.
  2201. this.consumeSpaces();
  2202. // Lex the first token
  2203. var lex = this.nextToken;
  2204. if (lex.text === "\\limits" || lex.text === "\\nolimits") {
  2205. // We got a limit control
  2206. if (!base || base.type !== "op") {
  2207. throw new _ParseError2.default("Limit controls must follow a math operator", lex);
  2208. } else {
  2209. var limits = lex.text === "\\limits";
  2210. base.value.limits = limits;
  2211. base.value.alwaysHandl###pSub = true;
  2212. }
  2213. this.consume();
  2214. } else if (lex.text === "^") {
  2215. // We got a superscript start
  2216. if (superscript) {
  2217. throw new _ParseError2.default("Double superscript", lex);
  2218. }
  2219. superscript = this.handl###pSubscript("superscript");
  2220. } else if (lex.text === "_") {
  2221. // We got a subscript start
  2222. if (subscript) {
  2223. throw new _ParseError2.default("Double subscript", lex);
  2224. }
  2225. subscript = this.handl###pSubscript("subscript");
  2226. } else if (lex.text === "'") {
  2227. // We got a prime
  2228. if (superscript) {
  2229. throw new _ParseError2.default("Double superscript", lex);
  2230. }
  2231. var prime = new _ParseNode2.default("textord", "\\prime", this.mode);
  2232. // Many primes can be grouped together, so we handle this here
  2233. var primes = [prime];
  2234. this.consume();
  2235. // Keep lexing tokens until we get something that's not a prime
  2236. while (this.nextToken.text === "'") {
  2237. // For each one, add another prime to the list
  2238. primes.push(prime);
  2239. this.consume();
  2240. }
  2241. // If there's a superscript following the primes, combine that
  2242. // superscript in with the primes.
  2243. if (this.nextToken.text === "^") {
  2244. primes.push(this.handl###pSubscript("superscript"));
  2245. }
  2246. // Put everything into an ordgroup as the superscript
  2247. superscript = new _ParseNode2.default("ordgroup", primes, this.mode);
  2248. } else {
  2249. // If it wasn't ^, _, or ', stop parsing super/subscripts
  2250. break;
  2251. }
  2252. }
  2253. if (superscript || subscript) {
  2254. // If we got either a superscript or subscript, create a supsub
  2255. return new _ParseNode2.default("supsub", {
  2256. base: base,
  2257. sup: superscript,
  2258. sub: subscript
  2259. }, this.mode);
  2260. } else {
  2261. // Otherwise return the original body
  2262. return base;
  2263. }
  2264. }
  2265. // A list of the size-changing functions, for use in parseImplicitGroup
  2266. // A list of the style-changing functions, for use in parseImplicitGroup
  2267. // Old font functions
  2268. }, {
  2269. key: "parseImplicitGroup",
  2270. /**
  2271. * Parses an implicit group, which is a group that starts at the end of a
  2272. * specified, and ends right before a higher explicit group ends, or at EOL. It
  2273. * is used for functions that appear to affect the current style, like \Large or
  2274. * \textrm, where instead of keeping a style we just pretend that there is an
  2275. * implicit grouping after it until the end of the group. E.g.
  2276. * small text {\Large large text} small text again
  2277. * It is also used for \left and \right to get the correct grouping.
  2278. *
  2279. * @param {"]" | "}"} breakOnTokenText - character to stop parsing the group on.
  2280. * @return {?ParseNode}
  2281. */
  2282. value: function parseImplicitGroup(breakOnTokenText) {
  2283. var start = this.parseSymbol();
  2284. if (start == null) {
  2285. // If we didn't get anything we handle, fall back to parseFunction
  2286. return this.parseFunction();
  2287. }
  2288. var func = start.r###lt;
  2289. if (func === "\\left") {
  2290. // If we see a left:
  2291. // Parse the entire left function (including the delimiter)
  2292. var left = this.parseGivenFunction(start);
  2293. // Parse out the implicit body
  2294. ++this.leftrightDepth;
  2295. var body = this.parseExpression(false);
  2296. --this.leftrightDepth;
  2297. // Check the next token
  2298. this.expect("\\right", false);
  2299. var right = this.parseFunction();
  2300. return new _ParseNode2.default("leftright", {
  2301. body: body,
  2302. left: left.value.value,
  2303. right: right.value.value
  2304. }, this.mode);
  2305. } else if (func === "\\begin") {
  2306. // begin...end is similar to left...right
  2307. var begin = this.parseGivenFunction(start);
  2308. var envName = begin.value.name;
  2309. if (!_environments2.default.has(envName)) {
  2310. throw new _ParseError2.default("No such environment: " + envName, begin.value.nameGroup);
  2311. }
  2312. // Build the environment object. Arguments and other information will
  2313. // be made available to the begin and end methods using properties.
  2314. var env = _environments2.default.get(envName);
  2315. var _parseArguments = this.parseArguments("\\begin{" + envName + "}", env),
  2316. args = _parseArguments.args,
  2317. optArgs = _parseArguments.optArgs;
  2318. var context = {
  2319. mode: this.mode,
  2320. envName: envName,
  2321. parser: this
  2322. };
  2323. var r###lt = env.handler(context, args, optArgs);
  2324. this.expect("\\end", false);
  2325. var endNameToken = this.nextToken;
  2326. var end = this.parseFunction();
  2327. if (end.value.name !== envName) {
  2328. throw new _ParseError2.default("Mismatch: \\begin{" + envName + "} matched " + "by \\end{" + end.value.name + "}", endNameToken);
  2329. }
  2330. r###lt.position = end.position;
  2331. return r###lt;
  2332. } else if (_utils2.default.contains(Parser.sizeFuncs, func)) {
  2333. // If we see a sizing function, parse out the implicit body
  2334. this.consumeSpaces();
  2335. var _body = this.parseExpression(false, breakOnTokenText);
  2336. return new _ParseNode2.default("sizing", {
  2337. // Figure out what size to use based on the list of functions above
  2338. size: _utils2.default.indexOf(Parser.sizeFuncs, func) + 1,
  2339. value: _body
  2340. }, this.mode);
  2341. } else if (_utils2.default.contains(Parser.styleFuncs, func)) {
  2342. // If we see a styling function, parse out the implicit body
  2343. this.consumeSpaces();
  2344. var _body2 = this.parseExpression(true, breakOnTokenText);
  2345. return new _ParseNode2.default("styling", {
  2346. // Figure out what style to use by pulling out the style from
  2347. // the function name
  2348. style: func.slice(1, func.length - 5),
  2349. value: _body2
  2350. }, this.mode);
  2351. } else if (func in Parser.oldFontFuncs) {
  2352. var style = Parser.oldFontFuncs[func];
  2353. // If we see an old font function, parse out the implicit body
  2354. this.consumeSpaces();
  2355. var _body3 = this.parseExpression(true, breakOnTokenText);
  2356. if (style.slice(0, 4) === 'text') {
  2357. return new _ParseNode2.default("text", {
  2358. style: style,
  2359. body: new _ParseNode2.default("ordgroup", _body3, this.mode)
  2360. }, this.mode);
  2361. } else {
  2362. return new _ParseNode2.default("font", {
  2363. font: style,
  2364. body: new _ParseNode2.default("ordgroup", _body3, this.mode)
  2365. }, this.mode);
  2366. }
  2367. } else if (func === "\\color") {
  2368. // If we see a styling function, parse out the implicit body
  2369. var color = this.parseColorGroup(false);
  2370. if (!color) {
  2371. throw new _ParseError2.default("\\color not followed by color");
  2372. }
  2373. var _body4 = this.parseExpression(true, breakOnTokenText);
  2374. return new _ParseNode2.default("color", {
  2375. type: "color",
  2376. color: color.r###lt.value,
  2377. value: _body4
  2378. }, this.mode);
  2379. } else if (func === "$") {
  2380. if (this.mode === "math") {
  2381. throw new _ParseError2.default("$ within math mode");
  2382. }
  2383. this.consume();
  2384. var outerMode = this.mode;
  2385. this.switchMode("math");
  2386. var _body5 = this.parseExpression(false, "$");
  2387. this.expect("$", true);
  2388. this.switchMode(outerMode);
  2389. return new _ParseNode2.default("styling", {
  2390. style: "text",
  2391. value: _body5
  2392. }, "math");
  2393. } else {
  2394. // Defer to parseGivenFunction if it's not a function we handle
  2395. return this.parseGivenFunction(start);
  2396. }
  2397. }
  2398. /**
  2399. * Parses an entire function, including its base and all of its arguments.
  2400. * It also handles the case where the parsed node is not a function.
  2401. *
  2402. * @return {?ParseNode}
  2403. */
  2404. }, {
  2405. key: "parseFunction",
  2406. value: function parseFunction() {
  2407. var baseGroup = this.parseGroup();
  2408. return baseGroup ? this.parseGivenFunction(baseGroup) : null;
  2409. }
  2410. /**
  2411. * Same as parseFunction(), except that the base is provided, guaranteeing a
  2412. * non-nullable r###lt.
  2413. *
  2414. * @param {ParsedFuncOrArgOrDollar} baseGroup
  2415. * @return {ParseNode}
  2416. */
  2417. }, {
  2418. key: "parseGivenFunction",
  2419. value: function parseGivenFunction(baseGroup) {
  2420. baseGroup = assertFuncOrArg(baseGroup);
  2421. if (baseGroup.type === "fn") {
  2422. var func = baseGroup.r###lt;
  2423. var funcData = _functions2.default[func];
  2424. if (this.mode === "text" && !funcData.allowedInText) {
  2425. throw new _ParseError2.default("Can't use function '" + func + "' in text mode", baseGroup.token);
  2426. } else if (this.mode === "math" && funcData.allowedInMath === false) {
  2427. throw new _ParseError2.default("Can't use function '" + func + "' in math mode", baseGroup.token);
  2428. }
  2429. var _parseArguments2 = this.parseArguments(func, funcData),
  2430. args = _parseArguments2.args,
  2431. optArgs = _parseArguments2.optArgs;
  2432. var token = baseGroup.token;
  2433. var r###lt = this.callFunction(func, args, optArgs, token);
  2434. return new _ParseNode2.default(r###lt.type, r###lt, this.mode);
  2435. } else {
  2436. return baseGroup.r###lt;
  2437. }
  2438. }
  2439. /**
  2440. * Call a function handler with a suitable context and arguments.
  2441. * @param {string} name
  2442. * @param {Array<ParseNode>} args
  2443. * @param {Array<?ParseNode>} optArgs
  2444. * @param {Token=} token
  2445. */
  2446. }, {
  2447. key: "callFunction",
  2448. value: function callFunction(name, args, optArgs, token) {
  2449. var context = {
  2450. funcName: name,
  2451. parser: this,
  2452. token: token
  2453. };
  2454. return _functions2.default[name].handler(context, args, optArgs);
  2455. }
  2456. /**
  2457. * Parses the arguments of a function or environment
  2458. *
  2459. * @param {string} func "\name" or "\begin{name}"
  2460. * @param {{
  2461. * numArgs: number,
  2462. * numOptionalArgs: (number|undefined),
  2463. * }} funcData
  2464. * @return {{
  2465. * args: Array<ParseNode>,
  2466. * optArgs: Array<?ParseNode>,
  2467. * }}
  2468. */
  2469. }, {
  2470. key: "parseArguments",
  2471. value: function parseArguments(func, funcData) {
  2472. var totalArgs = funcData.numArgs + funcData.numOptionalArgs;
  2473. if (totalArgs === 0) {
  2474. return { args: [], optArgs: [] };
  2475. }
  2476. var baseGreediness = funcData.greediness;
  2477. var args = [];
  2478. var optArgs = [];
  2479. for (var i = 0; i < totalArgs; i++) {
  2480. var argType = funcData.argTypes && funcData.argTypes[i];
  2481. var isOptional = i < funcData.numOptionalArgs;
  2482. // Ignore spaces between arguments. As the TeXbook says:
  2483. // "After you have said ‘\def\row#1#2{...}’, you are allowed to
  2484. // put spaces between the arguments (e.g., ‘\row x n’), because
  2485. // TeX doesn’t use single spaces as undelimited arguments."
  2486. if (i > 0 && !isOptional) {
  2487. this.consumeSpaces();
  2488. }
  2489. // Also consume leading spaces in math mode, as parseSymbol
  2490. // won't know what to do with them. This can only happen with
  2491. // macros, e.g. \frac\foo\foo where \foo expands to a space symbol.
  2492. // In LaTeX, the \foo's get treated as (blank) arguments).
  2493. // In KaTeX, for now, both spaces will get consumed.
  2494. // TODO(edemaine)
  2495. if (i === 0 && !isOptional && this.mode === "math") {
  2496. this.consumeSpaces();
  2497. }
  2498. var nextToken = this.nextToken;
  2499. var arg = argType ? this.parseGroupOfType(argType, isOptional) : this.parseGroup(isOptional);
  2500. if (!arg) {
  2501. if (isOptional) {
  2502. optArgs.push(null);
  2503. continue;
  2504. }
  2505. if (!this.settings.throwOnError && this.nextToken.text[0] === "\\") {
  2506. arg = newArgument(this.handleUnsupportedCmd(), nextToken);
  2507. } else {
  2508. throw new _ParseError2.default("Expected group after '" + func + "'", nextToken);
  2509. }
  2510. }
  2511. var argNode = void 0;
  2512. arg = assertFuncOrArg(arg);
  2513. if (arg.type === "fn") {
  2514. var argGreediness = _functions2.default[arg.r###lt].greediness;
  2515. if (argGreediness > baseGreediness) {
  2516. argNode = this.parseGivenFunction(arg);
  2517. } else {
  2518. throw new _ParseError2.default("Got function '" + arg.r###lt + "' as " + "argument to '" + func + "'", nextToken);
  2519. }
  2520. } else {
  2521. argNode = arg.r###lt;
  2522. }
  2523. (isOptional ? optArgs : args).push(argNode);
  2524. }
  2525. return { args: args, optArgs: optArgs };
  2526. }
  2527. /**
  2528. * Parses a group when the mode is changing.
  2529. *
  2530. * @return {?ParsedFuncOrArgOrDollar}
  2531. */
  2532. }, {
  2533. key: "parseGroupOfType",
  2534. value: function parseGroupOfType(innerMode, optional) {
  2535. var outerMode = this.mode;
  2536. // Handle `original` argTypes
  2537. if (innerMode === "original") {
  2538. innerMode = outerMode;
  2539. }
  2540. if (innerMode === "color") {
  2541. return this.parseColorGroup(optional);
  2542. }
  2543. if (innerMode === "size") {
  2544. return this.parseSizeGroup(optional);
  2545. }
  2546. // By the time we get here, innerMode is one of "text" or "math".
  2547. // We switch the mode of the parser, recurse, then restore the old mode.
  2548. this.switchMode(innerMode);
  2549. var res = this.parseGroup(optional);
  2550. this.switchMode(outerMode);
  2551. return res;
  2552. }
  2553. }, {
  2554. key: "consumeSpaces",
  2555. value: function consumeSpaces() {
  2556. while (this.nextToken.text === " ") {
  2557. this.consume();
  2558. }
  2559. }
  2560. /**
  2561. * Parses a group, essentially returning the string formed by the
  2562. * brace-enclosed tokens plus some position information.
  2563. *
  2564. * @param {string} modeName Used to describe the mode in error messages
  2565. * @param {boolean=} optional Whether the group is optional or required
  2566. * @return {?Token}
  2567. */
  2568. }, {
  2569. key: "parseStringGroup",
  2570. value: function parseStringGroup(modeName, optional) {
  2571. if (optional && this.nextToken.text !== "[") {
  2572. return null;
  2573. }
  2574. var outerMode = this.mode;
  2575. this.mode = "text";
  2576. this.expect(optional ? "[" : "{");
  2577. var str = "";
  2578. var firstToken = this.nextToken;
  2579. var lastToken = firstToken;
  2580. while (this.nextToken.text !== (optional ? "]" : "}")) {
  2581. if (this.nextToken.text === "EOF") {
  2582. throw new _ParseError2.default("Unexpected end of input in " + modeName, firstToken.range(this.nextToken, str));
  2583. }
  2584. lastToken = this.nextToken;
  2585. str += lastToken.text;
  2586. this.consume();
  2587. }
  2588. this.mode = outerMode;
  2589. this.expect(optional ? "]" : "}");
  2590. return firstToken.range(lastToken, str);
  2591. }
  2592. /**
  2593. * Parses a regex-delimited group: the largest sequence of tokens
  2594. * whose concatenated strings match `regex`. Returns the string
  2595. * formed by the tokens plus some position information.
  2596. *
  2597. * @param {RegExp} regex
  2598. * @param {string} modeName Used to describe the mode in error messages
  2599. * @return {Token}
  2600. */
  2601. }, {
  2602. key: "parseRegexGroup",
  2603. value: function parseRegexGroup(regex, modeName) {
  2604. var outerMode = this.mode;
  2605. this.mode = "text";
  2606. var firstToken = this.nextToken;
  2607. var lastToken = firstToken;
  2608. var str = "";
  2609. while (this.nextToken.text !== "EOF" && regex.test(str + this.nextToken.text)) {
  2610. lastToken = this.nextToken;
  2611. str += lastToken.text;
  2612. this.consume();
  2613. }
  2614. if (str === "") {
  2615. throw new _ParseError2.default("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken);
  2616. }
  2617. this.mode = outerMode;
  2618. return firstToken.range(lastToken, str);
  2619. }
  2620. /**
  2621. * Parses a color description.
  2622. */
  2623. }, {
  2624. key: "parseColorGroup",
  2625. value: function parseColorGroup(optional) {
  2626. var res = this.parseStringGroup("color", optional);
  2627. if (!res) {
  2628. return null;
  2629. }
  2630. var match = /^(#[a-f0-9]{3}|#[a-f0-9]{6}|[a-z]+)$/i.exec(res.text);
  2631. if (!match) {
  2632. throw new _ParseError2.default("Invalid color: '" + res.text + "'", res);
  2633. }
  2634. return newArgument(new _ParseNode2.default("color", match[0], this.mode), res);
  2635. }
  2636. /**
  2637. * Parses a size specification, consisting of magnitude and unit.
  2638. */
  2639. }, {
  2640. key: "parseSizeGroup",
  2641. value: function parseSizeGroup(optional) {
  2642. var res = void 0;
  2643. if (!optional && this.nextToken.text !== "{") {
  2644. res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size");
  2645. } else {
  2646. res = this.parseStringGroup("size", optional);
  2647. }
  2648. if (!res) {
  2649. return null;
  2650. }
  2651. var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text);
  2652. if (!match) {
  2653. throw new _ParseError2.default("Invalid size: '" + res.text + "'", res);
  2654. }
  2655. var data = {
  2656. number: +(match[1] + match[2]), // sign + magnitude, cast to number
  2657. unit: match[3]
  2658. };
  2659. if (!(0, _units.validUnit)(data)) {
  2660. throw new _ParseError2.default("Invalid unit: '" + data.unit + "'", res);
  2661. }
  2662. return newArgument(new _ParseNode2.default("size", data, this.mode), res);
  2663. }
  2664. /**
  2665. * If the argument is false or absent, this parses an ordinary group,
  2666. * which is either a single nucleus (like "x") or an expression
  2667. * in braces (like "{x+y}").
  2668. * If the argument is true, it parses either a bracket-delimited expression
  2669. * (like "[x+y]") or returns null to indicate the absence of a
  2670. * bracket-enclosed group.
  2671. *
  2672. * @param {boolean=} optional Whether the group is optional or required
  2673. * @return {?ParsedFuncOrArgOrDollar}
  2674. */
  2675. }, {
  2676. key: "parseGroup",
  2677. value: function parseGroup(optional) {
  2678. var firstToken = this.nextToken;
  2679. // Try to parse an open brace
  2680. if (this.nextToken.text === (optional ? "[" : "{")) {
  2681. // If we get a brace, parse an expression
  2682. this.consume();
  2683. var expression = this.parseExpression(false, optional ? "]" : "}");
  2684. var lastToken = this.nextToken;
  2685. // Make sure we get a close brace
  2686. this.expect(optional ? "]" : "}");
  2687. if (this.mode === "text") {
  2688. this.formLigatures(expression);
  2689. }
  2690. return newArgument(new _ParseNode2.default("ordgroup", expression, this.mode, firstToken, lastToken), firstToken.range(lastToken, firstToken.text));
  2691. } else {
  2692. // Otherwise, just return a nucleus, or nothing for an optional group
  2693. return optional ? null : this.parseSymbol();
  2694. }
  2695. }
  2696. /**
  2697. * Form ligature-like combinations of characters for text mode.
  2698. * This includes inputs like "--", "---", "``" and "''".
  2699. * The r###lt will simply replace multiple textord nodes with a single
  2700. * character in each value by a single textord node having multiple
  2701. * characters in its value. The representation is still ASCII source.
  2702. *
  2703. * @param {Array.<ParseNode>} group the nodes of this group,
  2704. * list will be moified in place
  2705. */
  2706. }, {
  2707. key: "formLigatures",
  2708. value: function formLigatures(group) {
  2709. var n = group.length - 1;
  2710. for (var i = 0; i < n; ++i) {
  2711. var a = group[i];
  2712. var v = a.value;
  2713. if (v === "-" && group[i + 1].value === "-") {
  2714. if (i + 1 < n && group[i + 2].value === "-") {
  2715. group.splice(i, 3, new _ParseNode2.default("textord", "---", "text", a, group[i + 2]));
  2716. n -= 2;
  2717. } else {
  2718. group.splice(i, 2, new _ParseNode2.default("textord", "--", "text", a, group[i + 1]));
  2719. n -= 1;
  2720. }
  2721. }
  2722. if ((v === "'" || v === "`") && group[i + 1].value === v) {
  2723. group.splice(i, 2, new _ParseNode2.default("textord", v + v, "text", a, group[i + 1]));
  2724. n -= 1;
  2725. }
  2726. }
  2727. }
  2728. /**
  2729. * Parse a single symbol out of the string. Here, we handle both the functions
  2730. * we have defined, as well as the single character symbols
  2731. *
  2732. * @return {?ParsedFuncOrArgOrDollar}
  2733. */
  2734. }, {
  2735. key: "parseSymbol",
  2736. value: function parseSymbol() {
  2737. var nucleus = this.nextToken;
  2738. if (_functions2.default[nucleus.text]) {
  2739. this.consume();
  2740. // If there exists a function with this name, we return the function and
  2741. // say that it is a function.
  2742. return newFunction(nucleus);
  2743. } else if (_symbols2.default[this.mode][nucleus.text]) {
  2744. this.consume();
  2745. // Otherwise if this is a no-argument function, find the type it
  2746. // corresponds to in the symbols map
  2747. return newArgument(new _ParseNode2.default(_symbols2.default[this.mode][nucleus.text].group, nucleus.text, this.mode, nucleus), nucleus);
  2748. } else if (this.mode === "text" && _unicodeRegexes.cjkRegex.test(nucleus.text)) {
  2749. this.consume();
  2750. return newArgument(new _ParseNode2.default("textord", nucleus.text, this.mode, nucleus), nucleus);
  2751. } else if (nucleus.text === "$") {
  2752. return newDollar(nucleus);
  2753. } else if (/^\\verb[^a-zA-Z]/.test(nucleus.text)) {
  2754. this.consume();
  2755. var arg = nucleus.text.slice(5);
  2756. var star = arg.charAt(0) === "*";
  2757. if (star) {
  2758. arg = arg.slice(1);
  2759. }
  2760. // Lexer's tokenRegex is constructed to always have matching
  2761. // first/last characters.
  2762. if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) {
  2763. throw new _ParseError2.default("\\verb assertion failed --\n please report what input caused this bug");
  2764. }
  2765. arg = arg.slice(1, -1); // remove first and last char
  2766. return newArgument(new _ParseNode2.default("verb", {
  2767. body: arg,
  2768. star: star
  2769. }, "text"), nucleus);
  2770. } else {
  2771. return null;
  2772. }
  2773. }
  2774. }]);
  2775. return Parser;
  2776. }();
  2777. Parser.endOfExpression = ["}", "\\end", "\\right", "&", "\\\\", "\\cr"];
  2778. Parser.SUPSUB_GREEDINESS = 1;
  2779. Parser.sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"];
  2780. Parser.styleFuncs = ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"];
  2781. Parser.oldFontFuncs = {
  2782. "\\rm": "mathrm",
  2783. "\\sf": "mathsf",
  2784. "\\tt": "mathtt",
  2785. "\\bf": "mathbf",
  2786. "\\it": "mathit"
  2787. //"\\sl": "textsl",
  2788. //"\\sc": "textsc",
  2789. };
  2790. exports.default = Parser;
  2791. },{"./MacroExpander":82,"./ParseError":84,"./ParseNode":85,"./environments":99,"./functions":103,"./symbols":112,"./unicodeRegexes":113,"./units":114,"./utils":115,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],87:[function(require,module,exports){
  2792. "use strict";
  2793. Object.defineProperty(exports, "__esModule", {
  2794. value: true
  2795. });
  2796. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  2797. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  2798. var _utils = require("./utils");
  2799. var _utils2 = _interopRequireDefault(_utils);
  2800. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2801. /**
  2802. * The main Settings object
  2803. *
  2804. * The current options stored are:
  2805. * - displayMode: Whether the expression should be typeset as inline math
  2806. * (false, the default), meaning that the math starts in
  2807. * \textstyle and is placed in an inline-block); or as display
  2808. * math (true), meaning that the math starts in \displaystyle
  2809. * and is placed in a block with vertical margin.
  2810. */
  2811. var Settings = function Settings(options) {
  2812. (0, _classCallCheck3.default)(this, Settings);
  2813. // allow null options
  2814. options = options || {};
  2815. this.displayMode = _utils2.default.deflt(options.displayMode, false);
  2816. this.throwOnError = _utils2.default.deflt(options.throwOnError, true);
  2817. this.errorColor = _utils2.default.deflt(options.errorColor, "#cc0000");
  2818. this.macros = options.macros || {};
  2819. this.colorIsTextColor = _utils2.default.deflt(options.colorIsTextColor, false);
  2820. this.maxSize = Math.max(0, _utils2.default.deflt(options.maxSize, Infinity));
  2821. };
  2822. /**
  2823. * This is a module for storing settings passed into KaTeX. It correctly handles
  2824. * default settings.
  2825. */
  2826. exports.default = Settings;
  2827. },{"./utils":115,"babel-runtime/helpers/classCallCheck":8}],88:[function(require,module,exports){
  2828. "use strict";
  2829. Object.defineProperty(exports, "__esModule", {
  2830. value: true
  2831. });
  2832. var _freeze = require("babel-runtime/core-js/object/freeze");
  2833. var _freeze2 = _interopRequireDefault(_freeze);
  2834. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  2835. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  2836. var _createClass2 = require("babel-runtime/helpers/createClass");
  2837. var _createClass3 = _interopRequireDefault(_createClass2);
  2838. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2839. /**
  2840. * Lexing or parsing positional information for error reporting.
  2841. * This object is immutable.
  2842. */
  2843. var SourceLocation = function () {
  2844. // End offset, zero-based exclusive.
  2845. // Lexer holding the input string.
  2846. function SourceLocation(lexer, start, end) {
  2847. (0, _classCallCheck3.default)(this, SourceLocation);
  2848. this.lexer = lexer;
  2849. this.start = start;
  2850. this.end = end;
  2851. (0, _freeze2.default)(this); // Immutable to allow sharing in range().
  2852. }
  2853. /**
  2854. * Merges two `SourceLocation`s from location providers, given they are
  2855. * provided in order of appearance.
  2856. * - Returns the first one's location if only the first is provided.
  2857. * - Returns a merged range of the first and the last if both are provided
  2858. * and their lexers match.
  2859. * - Otherwise, returns null.
  2860. */
  2861. // Start offset, zero-based inclusive.
  2862. (0, _createClass3.default)(SourceLocation, null, [{
  2863. key: "range",
  2864. value: function range(first, second) {
  2865. if (!second) {
  2866. return first && first.loc;
  2867. } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) {
  2868. return null;
  2869. } else {
  2870. return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end);
  2871. }
  2872. }
  2873. }]);
  2874. return SourceLocation;
  2875. }();
  2876. exports.default = SourceLocation;
  2877. },{"babel-runtime/core-js/object/freeze":7,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],89:[function(require,module,exports){
  2878. "use strict";
  2879. Object.defineProperty(exports, "__esModule", {
  2880. value: true
  2881. });
  2882. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  2883. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  2884. var _createClass2 = require("babel-runtime/helpers/createClass");
  2885. var _createClass3 = _interopRequireDefault(_createClass2);
  2886. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2887. /**
  2888. * This file contains information and classes for the various kinds of styles
  2889. * used in TeX. It provides a generic `Style` class, which holds information
  2890. * about a specific style. It then provides instances of all the different kinds
  2891. * of styles possible, and provides functions to move between them and get
  2892. * information about them.
  2893. */
  2894. /**
  2895. * The main style class. Contains a unique id for the style, a size (which is
  2896. * the same for cramped and uncramped version of a style), and a cramped flag.
  2897. */
  2898. var Style = function () {
  2899. function Style(id, size, cramped) {
  2900. (0, _classCallCheck3.default)(this, Style);
  2901. this.id = id;
  2902. this.size = size;
  2903. this.cramped = cramped;
  2904. }
  2905. /**
  2906. * Get the style of a superscript given a base in the current style.
  2907. */
  2908. (0, _createClass3.default)(Style, [{
  2909. key: "sup",
  2910. value: function sup() {
  2911. return styles[_sup[this.id]];
  2912. }
  2913. /**
  2914. * Get the style of a subscript given a base in the current style.
  2915. */
  2916. }, {
  2917. key: "sub",
  2918. value: function sub() {
  2919. return styles[_sub[this.id]];
  2920. }
  2921. /**
  2922. * Get the style of a fraction numerator given the fraction in the current
  2923. * style.
  2924. */
  2925. }, {
  2926. key: "fracNum",
  2927. value: function fracNum() {
  2928. return styles[_fracNum[this.id]];
  2929. }
  2930. /**
  2931. * Get the style of a fraction denominator given the fraction in the current
  2932. * style.
  2933. */
  2934. }, {
  2935. key: "fracDen",
  2936. value: function fracDen() {
  2937. return styles[_fracDen[this.id]];
  2938. }
  2939. /**
  2940. * Get the cramped version of a style (in particular, cramping a cramped style
  2941. * doesn't change the style).
  2942. */
  2943. }, {
  2944. key: "cramp",
  2945. value: function cramp() {
  2946. return styles[_cramp[this.id]];
  2947. }
  2948. /**
  2949. * Get a text or display version of this style.
  2950. */
  2951. }, {
  2952. key: "text",
  2953. value: function text() {
  2954. return styles[_text[this.id]];
  2955. }
  2956. /**
  2957. * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle)
  2958. */
  2959. }, {
  2960. key: "isTight",
  2961. value: function isTight() {
  2962. return this.size >= 2;
  2963. }
  2964. }]);
  2965. return Style;
  2966. }();
  2967. // Export an interface for type checking, but don't expose the implementation.
  2968. // This way, no more styles can be generated.
  2969. // IDs of the different styles
  2970. var D = 0;
  2971. var Dc = 1;
  2972. var T = 2;
  2973. var Tc = 3;
  2974. var S = 4;
  2975. var Sc = 5;
  2976. var SS = 6;
  2977. var SSc = 7;
  2978. // Instances of the different styles
  2979. 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)];
  2980. // Lookup tables for switching from one style to another
  2981. var _sup = [S, Sc, S, Sc, SS, SSc, SS, SSc];
  2982. var _sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc];
  2983. var _fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc];
  2984. var _fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc];
  2985. var _cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc];
  2986. var _text = [D, Dc, T, Tc, T, Tc, T, Tc];
  2987. // We only export some of the styles.
  2988. exports.default = {
  2989. DISPLAY: styles[D],
  2990. TEXT: styles[T],
  2991. SCRIPT: styles[S],
  2992. SCRIPTSCRIPT: styles[SS]
  2993. };
  2994. },{"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],90:[function(require,module,exports){
  2995. "use strict";
  2996. Object.defineProperty(exports, "__esModule", {
  2997. value: true
  2998. });
  2999. exports.Token = undefined;
  3000. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  3001. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  3002. var _createClass2 = require("babel-runtime/helpers/createClass");
  3003. var _createClass3 = _interopRequireDefault(_createClass2);
  3004. var _SourceLocation = require("./SourceLocation");
  3005. var _SourceLocation2 = _interopRequireDefault(_SourceLocation);
  3006. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3007. /**
  3008. * The r###lting token returned from `lex`.
  3009. *
  3010. * It consists of the token text plus some position information.
  3011. * The position information is essentially a range in an input string,
  3012. * but instead of referencing the bare input string, we refer to the lexer.
  3013. * That way it is possible to attach extra metadata to the input string,
  3014. * like for example a file name or similar.
  3015. *
  3016. * The position information is optional, so it is OK to construct synthetic
  3017. * tokens if appropriate. Not providing available position information may
  3018. * lead to degraded error reporting, though.
  3019. */
  3020. /**
  3021. * Interface required to break circular dependency between Token, Lexer, and
  3022. * ParseError.
  3023. */
  3024. var Token = exports.Token = function () {
  3025. function Token(text, // the text of this token
  3026. loc) {
  3027. (0, _classCallCheck3.default)(this, Token);
  3028. this.text = text;
  3029. this.loc = loc;
  3030. }
  3031. /**
  3032. * Given a pair of tokens (this and endToken), compute a `Token` encompassing
  3033. * the whole input range enclosed by these two.
  3034. */
  3035. (0, _createClass3.default)(Token, [{
  3036. key: "range",
  3037. value: function range(endToken, // last token of the range, inclusive
  3038. text) // the text of the newly constructed token
  3039. {
  3040. return new Token(text, _SourceLocation2.default.range(this, endToken));
  3041. }
  3042. }]);
  3043. return Token;
  3044. }();
  3045. },{"./SourceLocation":88,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],91:[function(require,module,exports){
  3046. "use strict";
  3047. Object.defineProperty(exports, "__esModule", {
  3048. value: true
  3049. });
  3050. var _domTree = require("./domTree");
  3051. var _domTree2 = _interopRequireDefault(_domTree);
  3052. var _fontMetrics = require("./fontMetrics");
  3053. var _fontMetrics2 = _interopRequireDefault(_fontMetrics);
  3054. var _symbols = require("./symbols");
  3055. var _symbols2 = _interopRequireDefault(_symbols);
  3056. var _utils = require("./utils");
  3057. var _utils2 = _interopRequireDefault(_utils);
  3058. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3059. // The following have to be loaded from Main-Italic font, using class mainit
  3060. /* eslint no-console:0 */
  3061. /**
  3062. * This module contains general functions that can be used for building
  3063. * different kinds of domTree nodes in a consistent manner.
  3064. */
  3065. var mainitLetters = ["\\imath", // dotless i
  3066. "\\jmath", // dotless j
  3067. "\\pounds"];
  3068. /**
  3069. * Looks up the given symbol in fontMetrics, after applying any symbol
  3070. * replacements defined in symbol.js
  3071. */
  3072. var lookupSymbol = function lookupSymbol(value, fontFamily, mode) {
  3073. // Replace the value with its replaced value from symbol.js
  3074. if (_symbols2.default[mode][value] && _symbols2.default[mode][value].replace) {
  3075. value = _symbols2.default[mode][value].replace;
  3076. }
  3077. return {
  3078. value: value,
  3079. metrics: _fontMetrics2.default.getCharacterMetrics(value, fontFamily)
  3080. };
  3081. };
  3082. /**
  3083. * Makes a symbolNode after translation via the list of symbols in symbols.js.
  3084. * Correctly pulls out metrics for the character, and optionally takes a list of
  3085. * classes to be attached to the node.
  3086. *
  3087. * TODO: make argument order closer to makeSpan
  3088. * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
  3089. * should if present come first in `classes`.
  3090. */
  3091. var makeSymbol = function makeSymbol(value, fontFamily, mode, options, classes) {
  3092. var lookup = lookupSymbol(value, fontFamily, mode);
  3093. var metrics = lookup.metrics;
  3094. value = lookup.value;
  3095. var symbolNode = void 0;
  3096. if (metrics) {
  3097. var italic = metrics.italic;
  3098. if (mode === "text") {
  3099. italic = 0;
  3100. }
  3101. symbolNode = new _domTree2.default.symbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, classes);
  3102. } else {
  3103. // TODO(emily): Figure out a good way to only print this in development
  3104. typeof console !== "undefined" && console.warn("No character metrics for '" + value + "' in style '" + fontFamily + "'");
  3105. symbolNode = new _domTree2.default.symbolNode(value, 0, 0, 0, 0, classes);
  3106. }
  3107. if (options) {
  3108. symbolNode.maxFontSize = options.sizeMultiplier;
  3109. if (options.style.isTight()) {
  3110. symbolNode.classes.push("mtight");
  3111. }
  3112. if (options.getColor()) {
  3113. symbolNode.style.color = options.getColor();
  3114. }
  3115. }
  3116. return symbolNode;
  3117. };
  3118. /**
  3119. * Makes a symbol in Main-Regular or AMS-Regular.
  3120. * Used for rel, bin, open, close, inner, and punct.
  3121. */
  3122. var mathsym = function mathsym(value, mode, options, classes) {
  3123. // Decide what font to render the symbol in by its entry in the symbols
  3124. // table.
  3125. // Have a special case for when the value = \ because the \ is used as a
  3126. // textord in unsupported command errors but cannot be parsed as a regular
  3127. // text ordinal and is therefore not present as a symbol in the symbols
  3128. // table for text
  3129. if (value === "\\" || _symbols2.default[mode][value].font === "main") {
  3130. return makeSymbol(value, "Main-Regular", mode, options, classes);
  3131. } else {
  3132. return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"]));
  3133. }
  3134. };
  3135. /**
  3136. * Makes a symbol in the default font for mathords and textords.
  3137. */
  3138. var mathDefault = function mathDefault(value, mode, options, classes, type) {
  3139. if (type === "mathord") {
  3140. var fontLookup = mathit(value, mode, options, classes);
  3141. return makeSymbol(value, fontLookup.fontName, mode, options, classes.concat([fontLookup.fontClass]));
  3142. } else if (type === "textord") {
  3143. var font = _symbols2.default[mode][value] && _symbols2.default[mode][value].font;
  3144. if (font === "ams") {
  3145. return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"]));
  3146. } else {
  3147. // if (font === "main") {
  3148. return makeSymbol(value, "Main-Regular", mode, options, classes.concat(["mathrm"]));
  3149. }
  3150. } else {
  3151. throw new Error("unexpected type: " + type + " in mathDefault");
  3152. }
  3153. };
  3154. /**
  3155. * Determines which of the two font names (Main-Italic and Math-Italic) and
  3156. * corresponding style tags (mainit or mathit) to use for font "mathit",
  3157. * depending on the symbol. Use this function instead of fontMap for font
  3158. * "mathit".
  3159. */
  3160. var mathit = function mathit(value, mode, options, classes) {
  3161. if (/[0-9]/.test(value.charAt(0)) ||
  3162. // glyphs for \imath and \jmath do not exist in Math-Italic so we
  3163. // need to use Main-Italic instead
  3164. _utils2.default.contains(mainitLetters, value)) {
  3165. return {
  3166. fontName: "Main-Italic",
  3167. fontClass: "mainit"
  3168. };
  3169. } else {
  3170. return {
  3171. fontName: "Math-Italic",
  3172. fontClass: "mathit"
  3173. };
  3174. }
  3175. };
  3176. /**
  3177. * Makes either a mathord or textord in the correct font and color.
  3178. */
  3179. var makeOrd = function makeOrd(group, options, type) {
  3180. var mode = group.mode;
  3181. var value = group.value;
  3182. var classes = ["mord"];
  3183. var font = options.font;
  3184. if (font) {
  3185. var fontLookup = void 0;
  3186. if (font === "mathit" || _utils2.default.contains(mainitLetters, value)) {
  3187. fontLookup = mathit(value, mode, options, classes);
  3188. } else {
  3189. fontLookup = fontMap[font];
  3190. }
  3191. if (lookupSymbol(value, fontLookup.fontName, mode).metrics) {
  3192. return makeSymbol(value, fontLookup.fontName, mode, options, classes.concat([fontLookup.fontClass || font]));
  3193. } else {
  3194. return mathDefault(value, mode, options, classes, type);
  3195. }
  3196. } else {
  3197. return mathDefault(value, mode, options, classes, type);
  3198. }
  3199. };
  3200. /**
  3201. * Combine as many characters as possible in the given array of characters
  3202. * via their tryCombine method.
  3203. */
  3204. var tryCombineChars = function tryCombineChars(chars) {
  3205. for (var i = 0; i < chars.length - 1; i++) {
  3206. if (chars[i].tryCombine(chars[i + 1])) {
  3207. chars.splice(i + 1, 1);
  3208. i--;
  3209. }
  3210. }
  3211. return chars;
  3212. };
  3213. /**
  3214. * Calculate the height, depth, and maxFontSize of an element based on its
  3215. * children.
  3216. */
  3217. var sizeElementFromChildren = function sizeElementFromChildren(elem) {
  3218. var height = 0;
  3219. var depth = 0;
  3220. var maxFontSize = 0;
  3221. if (elem.children) {
  3222. for (var i = 0; i < elem.children.length; i++) {
  3223. if (elem.children[i].height > height) {
  3224. height = elem.children[i].height;
  3225. }
  3226. if (elem.children[i].depth > depth) {
  3227. depth = elem.children[i].depth;
  3228. }
  3229. if (elem.children[i].maxFontSize > maxFontSize) {
  3230. maxFontSize = elem.children[i].maxFontSize;
  3231. }
  3232. }
  3233. }
  3234. elem.height = height;
  3235. elem.depth = depth;
  3236. elem.maxFontSize = maxFontSize;
  3237. };
  3238. /**
  3239. * Makes a span with the given list of classes, list of children, and options.
  3240. *
  3241. * TODO: Ensure that `options` is always provided (currently some call sites
  3242. * don't pass it).
  3243. * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
  3244. * should if present come first in `classes`.
  3245. */
  3246. var makeSpan = function makeSpan(classes, children, options) {
  3247. var span = new _domTree2.default.span(classes, children, options);
  3248. sizeElementFromChildren(span);
  3249. return span;
  3250. };
  3251. /**
  3252. * Prepends the given children to the given span, updating height, depth, and
  3253. * maxFontSize.
  3254. */
  3255. var prependChildren = function prependChildren(span, children) {
  3256. span.children = children.concat(span.children);
  3257. sizeElementFromChildren(span);
  3258. };
  3259. /**
  3260. * Makes a document fragment with the given list of children.
  3261. */
  3262. var makeFragment = function makeFragment(children) {
  3263. var fragment = new _domTree2.default.documentFragment(children);
  3264. sizeElementFromChildren(fragment);
  3265. return fragment;
  3266. };
  3267. /**
  3268. * Makes a vertical list by stacking elements and kerns on top of each other.
  3269. * Allows for many different ways of specifying the positioning method.
  3270. *
  3271. * Arguments:
  3272. * - children: A list of child or kern nodes to be stacked on top of each other
  3273. * (i.e. the first element will be at the bottom, and the last at
  3274. * the top). Element nodes are specified as
  3275. * {type: "elem", elem: node}
  3276. * while kern nodes are specified as
  3277. * {type: "kern", size: size}
  3278. * - positionType: The method by which the vlist should be positioned. Valid
  3279. * values are:
  3280. * - "individualShift": The children list only contains elem
  3281. * nodes, and each node contains an extra
  3282. * "shift" value of how much it should be
  3283. * shifted (note that shifting is always
  3284. * moving downwards). positionData is
  3285. * ignored.
  3286. * - "top": The positionData specifies the topmost point of
  3287. * the vlist (note this is expected to be a height,
  3288. * so positive values move up)
  3289. * - "bottom": The positionData specifies the bottommost point
  3290. * of the vlist (note this is expected to be a
  3291. * depth, so positive values move down
  3292. * - "shift": The vlist will be positioned such that its
  3293. * baseline is positionData away from the baseline
  3294. * of the first child. Positive values move
  3295. * downwards.
  3296. * - "firstBaseline": The vlist will be positioned such that
  3297. * its baseline is aligned with the
  3298. * baseline of the first child.
  3299. * positionData is ignored. (this is
  3300. * equivalent to "shift" with
  3301. * positionData=0)
  3302. * - positionData: Data used in different ways depending on positionType
  3303. * - options: An Options object
  3304. *
  3305. */
  3306. var makeVList = function makeVList(children, positionType, positionData, options) {
  3307. var depth = void 0;
  3308. var currPos = void 0;
  3309. var i = void 0;
  3310. if (positionType === "individualShift") {
  3311. var oldChildren = children;
  3312. children = [oldChildren[0]];
  3313. // Add in kerns to the list of children to get each element to be
  3314. // shifted to the correct specified shift
  3315. depth = -oldChildren[0].shift - oldChildren[0].elem.depth;
  3316. currPos = depth;
  3317. for (i = 1; i < oldChildren.length; i++) {
  3318. var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth;
  3319. var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth);
  3320. currPos = currPos + diff;
  3321. children.push({ type: "kern", size: size });
  3322. children.push(oldChildren[i]);
  3323. }
  3324. } else if (positionType === "top") {
  3325. // We always start at the bottom, so calculate the bottom by adding up
  3326. // all the sizes
  3327. var bottom = positionData;
  3328. for (i = 0; i < children.length; i++) {
  3329. if (children[i].type === "kern") {
  3330. bottom -= children[i].size;
  3331. } else {
  3332. bottom -= children[i].elem.height + children[i].elem.depth;
  3333. }
  3334. }
  3335. depth = bottom;
  3336. } else if (positionType === "bottom") {
  3337. depth = -positionData;
  3338. } else if (positionType === "shift") {
  3339. depth = -children[0].elem.depth - positionData;
  3340. } else if (positionType === "firstBaseline") {
  3341. depth = -children[0].elem.depth;
  3342. } else {
  3343. depth = 0;
  3344. }
  3345. // Create a strut that is taller than any list item. The strut is added to
  3346. // each item, where it will determine the item's baseline. Since it has
  3347. // `overflow:hidden`, the strut's top edge will sit on the item's line box's
  3348. // top edge and the strut's bottom edge will sit on the item's baseline,
  3349. // with no additional line-height spacing. This allows the item baseline to
  3350. // be positioned precisely without worrying about font ascent and
  3351. // line-height.
  3352. var pstrutSize = 0;
  3353. for (i = 0; i < children.length; i++) {
  3354. if (children[i].type === "elem") {
  3355. var child = children[i].elem;
  3356. pstrutSize = Math.max(pstrutSize, child.maxFontSize, child.height);
  3357. }
  3358. }
  3359. pstrutSize += 2;
  3360. var pstrut = makeSpan(["pstrut"], []);
  3361. pstrut.style.height = pstrutSize + "em";
  3362. // Create a new list of actual children at the correct offsets
  3363. var realChildren = [];
  3364. var minPos = depth;
  3365. var maxPos = depth;
  3366. currPos = depth;
  3367. for (i = 0; i < children.length; i++) {
  3368. if (children[i].type === "kern") {
  3369. currPos += children[i].size;
  3370. } else {
  3371. var _child = children[i].elem;
  3372. var childWrap = makeSpan([], [pstrut, _child]);
  3373. childWrap.style.top = -pstrutSize - currPos - _child.depth + "em";
  3374. if (children[i].marginLeft) {
  3375. childWrap.style.marginLeft = children[i].marginLeft;
  3376. }
  3377. if (children[i].marginRight) {
  3378. childWrap.style.marginRight = children[i].marginRight;
  3379. }
  3380. realChildren.push(childWrap);
  3381. currPos += _child.height + _child.depth;
  3382. }
  3383. minPos = Math.min(minPos, currPos);
  3384. maxPos = Math.max(maxPos, currPos);
  3385. }
  3386. // The vlist contents go in a table-cell with `vertical-align:bottom`.
  3387. // This cell's bottom edge will determine the containing table's baseline
  3388. // without overly expanding the containing line-box.
  3389. var vlist = makeSpan(["vlist"], realChildren);
  3390. vlist.style.height = maxPos + "em";
  3391. // A second row is used if necessary to represent the vlist's depth.
  3392. var rows = void 0;
  3393. if (minPos < 0) {
  3394. var depthStrut = makeSpan(["vlist"], []);
  3395. depthStrut.style.height = -minPos + "em";
  3396. // Safari wants the first row to have inline content; otherwise it
  3397. // puts the bottom of the *second* row on the baseline.
  3398. var topStrut = makeSpan(["vlist-s"], [new _domTree2.default.symbolNode("\u200B")]);
  3399. rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])];
  3400. } else {
  3401. rows = [makeSpan(["vlist-r"], [vlist])];
  3402. }
  3403. var vtable = makeSpan(["vlist-t"], rows);
  3404. if (rows.length === 2) {
  3405. vtable.classes.push("vlist-t2");
  3406. }
  3407. vtable.height = maxPos;
  3408. vtable.depth = -minPos;
  3409. return vtable;
  3410. };
  3411. // Converts verb group into body string, dealing with \verb* form
  3412. var makeVerb = function makeVerb(group, options) {
  3413. var text = group.value.body;
  3414. if (group.value.star) {
  3415. text = text.replace(/ /g, "\u2423"); // Open Box
  3416. } else {
  3417. text = text.replace(/ /g, '\xA0'); // No-Break Space
  3418. // (so that, in particular, spaces don't coalesce)
  3419. }
  3420. return text;
  3421. };
  3422. // A map of spacing functions to their attributes, like size and corresponding
  3423. // CSS class
  3424. var spacingFunctions = {
  3425. "\\qquad": {
  3426. size: "2em",
  3427. className: "qquad"
  3428. },
  3429. "\\quad": {
  3430. size: "1em",
  3431. className: "quad"
  3432. },
  3433. "\\enspace": {
  3434. size: "0.5em",
  3435. className: "enspace"
  3436. },
  3437. "\\;": {
  3438. size: "0.277778em",
  3439. className: "thickspace"
  3440. },
  3441. "\\:": {
  3442. size: "0.22222em",
  3443. className: "mediumspace"
  3444. },
  3445. "\\,": {
  3446. size: "0.16667em",
  3447. className: "thinspace"
  3448. },
  3449. "\\!": {
  3450. size: "-0.16667em",
  3451. className: "negativethinspace"
  3452. }
  3453. };
  3454. /**
  3455. * Maps TeX font commands to objects containing:
  3456. * - variant: string used for "mathvariant" attribute in buildMathML.js
  3457. * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics
  3458. */
  3459. // A map between tex font commands an MathML mathvariant attribute values
  3460. var fontMap = {
  3461. // styles
  3462. "mathbf": {
  3463. variant: "bold",
  3464. fontName: "Main-Bold"
  3465. },
  3466. "mathrm": {
  3467. variant: "normal",
  3468. fontName: "Main-Regular"
  3469. },
  3470. "textit": {
  3471. variant: "italic",
  3472. fontName: "Main-Italic"
  3473. },
  3474. // "mathit" is missing because it requires the use of two fonts: Main-Italic
  3475. // and Math-Italic. This is handled by a special case in makeOrd which ends
  3476. // up calling mathit.
  3477. // families
  3478. "mathbb": {
  3479. variant: "double-struck",
  3480. fontName: "AMS-Regular"
  3481. },
  3482. "mathcal": {
  3483. variant: "script",
  3484. fontName: "Caligraphic-Regular"
  3485. },
  3486. "mathfrak": {
  3487. variant: "fraktur",
  3488. fontName: "Fraktur-Regular"
  3489. },
  3490. "mathscr": {
  3491. variant: "script",
  3492. fontName: "Script-Regular"
  3493. },
  3494. "mathsf": {
  3495. variant: "sans-serif",
  3496. fontName: "SansSerif-Regular"
  3497. },
  3498. "mathtt": {
  3499. variant: "monospace",
  3500. fontName: "Typewriter-Regular"
  3501. }
  3502. };
  3503. exports.default = {
  3504. fontMap: fontMap,
  3505. makeSymbol: makeSymbol,
  3506. mathsym: mathsym,
  3507. makeSpan: makeSpan,
  3508. makeFragment: makeFragment,
  3509. makeVList: makeVList,
  3510. makeOrd: makeOrd,
  3511. makeVerb: makeVerb,
  3512. tryCombineChars: tryCombineChars,
  3513. prependChildren: prependChildren,
  3514. spacingFunctions: spacingFunctions
  3515. };
  3516. },{"./domTree":98,"./fontMetrics":101,"./symbols":112,"./utils":115}],92:[function(require,module,exports){
  3517. "use strict";
  3518. Object.defineProperty(exports, "__esModule", {
  3519. value: true
  3520. });
  3521. exports.buildGroup = exports.groupTypes = exports.makeNullDelimiter = exports.buildExpression = exports.spliceSpaces = undefined;
  3522. var _stringify = require("babel-runtime/core-js/json/stringify");
  3523. var _stringify2 = _interopRequireDefault(_stringify);
  3524. exports.default = buildHTML;
  3525. var _ParseError = require("./ParseError");
  3526. var _ParseError2 = _interopRequireDefault(_ParseError);
  3527. var _Style = require("./Style");
  3528. var _Style2 = _interopRequireDefault(_Style);
  3529. var _buildCommon = require("./buildCommon");
  3530. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  3531. var _delimiter = require("./delimiter");
  3532. var _delimiter2 = _interopRequireDefault(_delimiter);
  3533. var _domTree = require("./domTree");
  3534. var _domTree2 = _interopRequireDefault(_domTree);
  3535. var _units = require("./units");
  3536. var _utils = require("./utils");
  3537. var _utils2 = _interopRequireDefault(_utils);
  3538. var _stretchy = require("./stretchy");
  3539. var _stretchy2 = _interopRequireDefault(_stretchy);
  3540. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3541. /**
  3542. * WARNING: New methods on groupTypes should be added to src/functions.
  3543. *
  3544. * This file does the main work of building a domTree structure from a parse
  3545. * tree. The entry point is the `buildHTML` function, which takes a parse tree.
  3546. * Then, the buildExpression, buildGroup, and various groupTypes functions are
  3547. * called, to produce a final HTML tree.
  3548. */
  3549. var makeSpan = _buildCommon2.default.makeSpan;
  3550. var isSpace = function isSpace(node) {
  3551. return node instanceof _domTree2.default.span && node.classes[0] === "mspace";
  3552. };
  3553. // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
  3554. // depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
  3555. // and the text before Rule 19.
  3556. var isBin = function isBin(node) {
  3557. return node && node.classes[0] === "mbin";
  3558. };
  3559. var isBinLeftCanceller = function isBinLeftCanceller(node, isRealGroup) {
  3560. // TODO: This code assumes that a node's math class is the first element
  3561. // of its `classes` array. A later cleanup should ensure this, for
  3562. // instance by changing the signature of `makeSpan`.
  3563. if (node) {
  3564. return _utils2.default.contains(["mbin", "mopen", "mrel", "mop", "mpunct"], node.classes[0]);
  3565. } else {
  3566. return isRealGroup;
  3567. }
  3568. };
  3569. var isBinRightCanceller = function isBinRightCanceller(node, isRealGroup) {
  3570. if (node) {
  3571. return _utils2.default.contains(["mrel", "mclose", "mpunct"], node.classes[0]);
  3572. } else {
  3573. return isRealGroup;
  3574. }
  3575. };
  3576. /**
  3577. * Splice out any spaces from `children` starting at position `i`, and return
  3578. * the spliced-out array. Returns null if `children[i]` does not exist or is not
  3579. * a space.
  3580. */
  3581. var spliceSpaces = exports.spliceSpaces = function spliceSpaces(children, i) {
  3582. var j = i;
  3583. while (j < children.length && isSpace(children[j])) {
  3584. j++;
  3585. }
  3586. if (j === i) {
  3587. return null;
  3588. } else {
  3589. return children.splice(i, j - i);
  3590. }
  3591. };
  3592. /**
  3593. * Take a list of nodes, build them in order, and return a list of the built
  3594. * nodes. documentFragments are flattened into their contents, so the
  3595. * returned list contains no fragments. `isRealGroup` is true if `expression`
  3596. * is a real group (no atoms will be added on either side), as opposed to
  3597. * a partial group (e.g. one created by \color).
  3598. */
  3599. var buildExpression = exports.buildExpression = function buildExpression(expression, options, isRealGroup) {
  3600. // Parse expressions into `groups`.
  3601. var groups = [];
  3602. for (var i = 0; i < expression.length; i++) {
  3603. var group = expression[i];
  3604. var output = buildGroup(group, options);
  3605. if (output instanceof _domTree2.default.documentFragment) {
  3606. Array.prototype.push.apply(groups, output.children);
  3607. } else {
  3608. groups.push(output);
  3609. }
  3610. }
  3611. // At this point `groups` consists entirely of `symbolNode`s and `span`s.
  3612. // Explicit spaces (e.g., \;, \,) should be ignored with respect to atom
  3613. // spacing (e.g., "add thick space between mord and mrel"). Since CSS
  3614. // adjacency rules implement atom spacing, spaces should be invisible to
  3615. // CSS. So we splice them out of `groups` and into the atoms themselves.
  3616. for (var _i = 0; _i < groups.length; _i++) {
  3617. var spaces = spliceSpaces(groups, _i);
  3618. if (spaces) {
  3619. // Splicing of spaces may have removed all remaining groups.
  3620. if (_i < groups.length) {
  3621. // If there is a following group, move space within it.
  3622. if (groups[_i] instanceof _domTree2.default.symbolNode) {
  3623. groups[_i] = makeSpan([].concat(groups[_i].classes), [groups[_i]]);
  3624. }
  3625. _buildCommon2.default.prependChildren(groups[_i], spaces);
  3626. } else {
  3627. // Otherwise, put any spaces back at the end of the groups.
  3628. Array.prototype.push.apply(groups, spaces);
  3629. break;
  3630. }
  3631. }
  3632. }
  3633. // Binary operators change to ordinary symbols in some contexts.
  3634. for (var _i2 = 0; _i2 < groups.length; _i2++) {
  3635. if (isBin(groups[_i2]) && (isBinLeftCanceller(groups[_i2 - 1], isRealGroup) || isBinRightCanceller(groups[_i2 + 1], isRealGroup))) {
  3636. groups[_i2].classes[0] = "mord";
  3637. }
  3638. }
  3639. // Process \\not commands within the group.
  3640. // TODO(kevinb): Handle multiple \\not commands in a row.
  3641. // TODO(kevinb): Handle \\not{abc} correctly. The \\not should appear over
  3642. // the 'a' instead of the 'c'.
  3643. for (var _i3 = 0; _i3 < groups.length; _i3++) {
  3644. if (groups[_i3].value === "\u0338" && _i3 + 1 < groups.length) {
  3645. var children = groups.slice(_i3, _i3 + 2);
  3646. children[0].classes = ["mainrm"];
  3647. // \u0338 is a combining glyph so we could reorder the children so
  3648. // that it comes after the other glyph. This works correctly on
  3649. // most browsers except for Safari. Instead we absolutely position
  3650. // the glyph and set its right side to match that of the other
  3651. // glyph which is visually equivalent.
  3652. children[0].style.position = "absolute";
  3653. children[0].style.right = "0";
  3654. // Copy the classes from the second glyph to the new container.
  3655. // This is so it behaves the same as though there was no \\not.
  3656. var classes = groups[_i3 + 1].classes;
  3657. var container = makeSpan(classes, children);
  3658. // LaTeX adds a space between ords separated by a \\not.
  3659. if (classes.indexOf("mord") !== -1) {
  3660. // \glue(\thickmuskip) 2.77771 plus 2.77771
  3661. container.style.paddingLeft = "0.277771em";
  3662. }
  3663. // Ensure that the \u0338 is positioned relative to the container.
  3664. container.style.position = "relative";
  3665. groups.splice(_i3, 2, container);
  3666. }
  3667. }
  3668. return groups;
  3669. };
  3670. // Return math atom class (mclass) of a domTree.
  3671. var getTypeOfDomTree = function getTypeOfDomTree(node) {
  3672. if (node instanceof _domTree2.default.documentFragment) {
  3673. if (node.children.length) {
  3674. return getTypeOfDomTree(node.children[node.children.length - 1]);
  3675. }
  3676. } else {
  3677. if (_utils2.default.contains(["mord", "mop", "mbin", "mrel", "mopen", "mclose", "mpunct", "minner"], node.classes[0])) {
  3678. return node.classes[0];
  3679. }
  3680. }
  3681. return null;
  3682. };
  3683. /**
  3684. * Sometimes, groups perform special rules when they have superscripts or
  3685. * subscripts attached to them. This function lets the `supsub` group know that
  3686. * its inner element should handle the superscripts and subscripts instead of
  3687. * handling them itself.
  3688. */
  3689. var shouldHandl###pSub = function shouldHandl###pSub(group, options) {
  3690. if (!group.value.base) {
  3691. return false;
  3692. } else {
  3693. var base = group.value.base;
  3694. if (base.type === "op") {
  3695. // Operators handle supsubs differently when they have limits
  3696. // (e.g. `\displaystyle\sum_2^3`)
  3697. return base.value.limits && (options.style.size === _Style2.default.DISPLAY.size || base.value.alwaysHandl###pSub);
  3698. } else if (base.type === "accent") {
  3699. return isCharacterBox(base.value.base);
  3700. } else if (base.type === "horizBrace") {
  3701. var isSup = group.value.sub ? false : true;
  3702. return isSup === base.value.isOver;
  3703. } else {
  3704. return null;
  3705. }
  3706. }
  3707. };
  3708. /**
  3709. * Sometimes we want to pull out the innermost element of a group. In most
  3710. * cases, this will just be the group itself, but when ordgroups and colors have
  3711. * a single element, we want to pull that out.
  3712. */
  3713. var getBaseElem = function getBaseElem(group) {
  3714. if (!group) {
  3715. return false;
  3716. } else if (group.type === "ordgroup") {
  3717. if (group.value.length === 1) {
  3718. return getBaseElem(group.value[0]);
  3719. } else {
  3720. return group;
  3721. }
  3722. } else if (group.type === "color") {
  3723. if (group.value.value.length === 1) {
  3724. return getBaseElem(group.value.value[0]);
  3725. } else {
  3726. return group;
  3727. }
  3728. } else if (group.type === "font") {
  3729. return getBaseElem(group.value.body);
  3730. } else {
  3731. return group;
  3732. }
  3733. };
  3734. /**
  3735. * TeXbook algorithms often reference "character boxes", which are simply groups
  3736. * with a single character in them. To decide if something is a character box,
  3737. * we find its innermost group, and see if it is a single character.
  3738. */
  3739. var isCharacterBox = function isCharacterBox(group) {
  3740. var baseElem = getBaseElem(group);
  3741. // These are all they types of groups which hold single characters
  3742. 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";
  3743. };
  3744. var makeNullDelimiter = exports.makeNullDelimiter = function makeNullDelimiter(options, classes) {
  3745. var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses());
  3746. return makeSpan(classes.concat(moreClasses));
  3747. };
  3748. /**
  3749. * This is a map of group types to the function used to handle that type.
  3750. * Simpler types come at the beginning, while complicated types come afterwards.
  3751. */
  3752. var groupTypes = exports.groupTypes = {};
  3753. groupTypes.mathord = function (group, options) {
  3754. return _buildCommon2.default.makeOrd(group, options, "mathord");
  3755. };
  3756. groupTypes.textord = function (group, options) {
  3757. return _buildCommon2.default.makeOrd(group, options, "textord");
  3758. };
  3759. groupTypes.bin = function (group, options) {
  3760. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mbin"]);
  3761. };
  3762. groupTypes.rel = function (group, options) {
  3763. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mrel"]);
  3764. };
  3765. groupTypes.open = function (group, options) {
  3766. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mopen"]);
  3767. };
  3768. groupTypes.close = function (group, options) {
  3769. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mclose"]);
  3770. };
  3771. groupTypes.inner = function (group, options) {
  3772. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["minner"]);
  3773. };
  3774. groupTypes.punct = function (group, options) {
  3775. return _buildCommon2.default.mathsym(group.value, group.mode, options, ["mpunct"]);
  3776. };
  3777. groupTypes.ordgroup = function (group, options) {
  3778. return makeSpan(["mord"], buildExpression(group.value, options, true), options);
  3779. };
  3780. groupTypes.text = function (group, options) {
  3781. var newOptions = options.withFont(group.value.font);
  3782. var inner = buildExpression(group.value.body, newOptions, true);
  3783. _buildCommon2.default.tryCombineChars(inner);
  3784. return makeSpan(["mord", "text"], inner, newOptions);
  3785. };
  3786. groupTypes.color = function (group, options) {
  3787. var elements = buildExpression(group.value.value, options.withColor(group.value.color), false);
  3788. // \color isn't supposed to affect the type of the elements it contains.
  3789. // To accomplish this, we wrap the r###lts in a fragment, so the inner
  3790. // elements will be able to directly interact with their neighbors. For
  3791. // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3`
  3792. return new _buildCommon2.default.makeFragment(elements);
  3793. };
  3794. groupTypes.supsub = function (group, options) {
  3795. // Superscript and subscripts are handled in the TeXbook on page
  3796. // 445-446, rules 18(a-f).
  3797. // Here is where we defer to the inner group if it should handle
  3798. // superscripts and subscripts itself.
  3799. if (shouldHandl###pSub(group, options)) {
  3800. return groupTypes[group.value.base.type](group, options);
  3801. }
  3802. var base = buildGroup(group.value.base, options);
  3803. var supm = void 0;
  3804. var subm = void 0;
  3805. var metrics = options.fontMetrics();
  3806. var newOptions = void 0;
  3807. // Rule 18a
  3808. var supShift = 0;
  3809. var subShift = 0;
  3810. if (group.value.sup) {
  3811. newOptions = options.havingStyle(options.style.sup());
  3812. supm = buildGroup(group.value.sup, newOptions, options);
  3813. if (!isCharacterBox(group.value.base)) {
  3814. supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier;
  3815. }
  3816. }
  3817. if (group.value.sub) {
  3818. newOptions = options.havingStyle(options.style.sub());
  3819. subm = buildGroup(group.value.sub, newOptions, options);
  3820. if (!isCharacterBox(group.value.base)) {
  3821. subShift = base.depth + newOptions.fontMetrics().subDrop * newOptions.sizeMultiplier / options.sizeMultiplier;
  3822. }
  3823. }
  3824. // Rule 18c
  3825. var minSupShift = void 0;
  3826. if (options.style === _Style2.default.DISPLAY) {
  3827. minSupShift = metrics.sup1;
  3828. } else if (options.style.cramped) {
  3829. minSupShift = metrics.sup3;
  3830. } else {
  3831. minSupShift = metrics.sup2;
  3832. }
  3833. // scriptspace is a font-size-independent size, so scale it
  3834. // appropriately
  3835. var multiplier = options.sizeMultiplier;
  3836. var scriptspace = 0.5 / metrics.ptPerEm / multiplier + "em";
  3837. var supsub = void 0;
  3838. if (!group.value.sup) {
  3839. // Rule 18b
  3840. subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight);
  3841. var vlistElem = [{ type: "elem", elem: subm, marginRight: scriptspace }];
  3842. // Subscripts shouldn't be shifted by the base's italic correction.
  3843. // Account for that by shifting the subscript back the appropriate
  3844. // amount. Note we only do this when the base is a single symbol.
  3845. if (base instanceof _domTree2.default.symbolNode) {
  3846. vlistElem[0].marginLeft = -base.italic + "em";
  3847. }
  3848. supsub = _buildCommon2.default.makeVList(vlistElem, "shift", subShift, options);
  3849. } else if (!group.value.sub) {
  3850. // Rule 18c, d
  3851. supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight);
  3852. supsub = _buildCommon2.default.makeVList([{ type: "elem", elem: supm, marginRight: scriptspace }], "shift", -supShift, options);
  3853. } else {
  3854. supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight);
  3855. subShift = Math.max(subShift, metrics.sub2);
  3856. var ruleWidth = metrics.defaultRuleThickness;
  3857. // Rule 18e
  3858. if (supShift - supm.depth - (subm.height - subShift) < 4 * ruleWidth) {
  3859. subShift = 4 * ruleWidth - (supShift - supm.depth) + subm.height;
  3860. var psi = 0.8 * metrics.xHeight - (supShift - supm.depth);
  3861. if (psi > 0) {
  3862. supShift += psi;
  3863. subShift -= psi;
  3864. }
  3865. }
  3866. var _vlistElem = [{ type: "elem", elem: subm, shift: subShift, marginRight: scriptspace }, { type: "elem", elem: supm, shift: -supShift, marginRight: scriptspace }];
  3867. // See comment above about subscripts not being shifted
  3868. if (base instanceof _domTree2.default.symbolNode) {
  3869. _vlistElem[0].marginLeft = -base.italic + "em";
  3870. }
  3871. supsub = _buildCommon2.default.makeVList(_vlistElem, "individualShift", null, options);
  3872. }
  3873. // We ensure to wrap the supsub vlist in a span.msupsub to reset text-align
  3874. var mclass = getTypeOfDomTree(base) || "mord";
  3875. return makeSpan([mclass], [base, makeSpan(["msupsub"], [supsub])], options);
  3876. };
  3877. groupTypes.genfrac = function (group, options) {
  3878. // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e).
  3879. // Figure out what style this fraction should be in based on the
  3880. // function used
  3881. var style = options.style;
  3882. if (group.value.size === "display") {
  3883. style = _Style2.default.DISPLAY;
  3884. } else if (group.value.size === "text") {
  3885. style = _Style2.default.TEXT;
  3886. }
  3887. var nstyle = style.fracNum();
  3888. var dstyle = style.fracDen();
  3889. var newOptions = void 0;
  3890. newOptions = options.havingStyle(nstyle);
  3891. var numerm = buildGroup(group.value.numer, newOptions, options);
  3892. newOptions = options.havingStyle(dstyle);
  3893. var denomm = buildGroup(group.value.denom, newOptions, options);
  3894. var rule = void 0;
  3895. var ruleWidth = void 0;
  3896. var ruleSpacing = void 0;
  3897. if (group.value.hasBarLine) {
  3898. rule = makeLineSpan("frac-line", options);
  3899. ruleWidth = rule.height;
  3900. ruleSpacing = rule.height;
  3901. } else {
  3902. rule = null;
  3903. ruleWidth = 0;
  3904. ruleSpacing = options.fontMetrics().defaultRuleThickness;
  3905. }
  3906. // Rule 15b
  3907. var numShift = void 0;
  3908. var clearance = void 0;
  3909. var denomShift = void 0;
  3910. if (style.size === _Style2.default.DISPLAY.size) {
  3911. numShift = options.fontMetrics().num1;
  3912. if (ruleWidth > 0) {
  3913. clearance = 3 * ruleSpacing;
  3914. } else {
  3915. clearance = 7 * ruleSpacing;
  3916. }
  3917. denomShift = options.fontMetrics().denom1;
  3918. } else {
  3919. if (ruleWidth > 0) {
  3920. numShift = options.fontMetrics().num2;
  3921. clearance = ruleSpacing;
  3922. } else {
  3923. numShift = options.fontMetrics().num3;
  3924. clearance = 3 * ruleSpacing;
  3925. }
  3926. denomShift = options.fontMetrics().denom2;
  3927. }
  3928. var frac = void 0;
  3929. if (ruleWidth === 0) {
  3930. // Rule 15c
  3931. var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift);
  3932. if (candidateClearance < clearance) {
  3933. numShift += 0.5 * (clearance - candidateClearance);
  3934. denomShift += 0.5 * (clearance - candidateClearance);
  3935. }
  3936. frac = _buildCommon2.default.makeVList([{ type: "elem", elem: denomm, shift: denomShift }, { type: "elem", elem: numerm, shift: -numShift }], "individualShift", null, options);
  3937. } else {
  3938. // Rule 15d
  3939. var axisHeight = options.fontMetrics().axisHeight;
  3940. if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) {
  3941. numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth));
  3942. }
  3943. if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) {
  3944. denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift));
  3945. }
  3946. var midShift = -(axisHeight - 0.5 * ruleWidth);
  3947. frac = _buildCommon2.default.makeVList([{ type: "elem", elem: denomm, shift: denomShift }, { type: "elem", elem: rule, shift: midShift }, { type: "elem", elem: numerm, shift: -numShift }], "individualShift", null, options);
  3948. }
  3949. // Since we manually change the style sometimes (with \dfrac or \tfrac),
  3950. // account for the possible size change here.
  3951. newOptions = options.havingStyle(style);
  3952. frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier;
  3953. frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier;
  3954. // Rule 15e
  3955. var delimSize = void 0;
  3956. if (style.size === _Style2.default.DISPLAY.size) {
  3957. delimSize = options.fontMetrics().delim1;
  3958. } else {
  3959. delimSize = options.fontMetrics().delim2;
  3960. }
  3961. var leftDelim = void 0;
  3962. var rightDelim = void 0;
  3963. if (group.value.leftDelim == null) {
  3964. leftDelim = makeNullDelimiter(options, ["mopen"]);
  3965. } else {
  3966. leftDelim = _delimiter2.default.customSizedDelim(group.value.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]);
  3967. }
  3968. if (group.value.rightDelim == null) {
  3969. rightDelim = makeNullDelimiter(options, ["mclose"]);
  3970. } else {
  3971. rightDelim = _delimiter2.default.customSizedDelim(group.value.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]);
  3972. }
  3973. return makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, makeSpan(["mfrac"], [frac]), rightDelim], options);
  3974. };
  3975. groupTypes.spacing = function (group, options) {
  3976. if (group.value === "\\ " || group.value === "\\space" || group.value === " " || group.value === "~") {
  3977. // Spaces are generated by adding an actual space. Each of these
  3978. // things has an entry in the symbols table, so these will be turned
  3979. // into appropriate outputs.
  3980. if (group.mode === "text") {
  3981. return _buildCommon2.default.makeOrd(group, options, "textord");
  3982. } else {
  3983. return makeSpan(["mspace"], [_buildCommon2.default.mathsym(group.value, group.mode, options)], options);
  3984. }
  3985. } else {
  3986. // Other kinds of spaces are of arbitrary width. We use CSS to
  3987. // generate these.
  3988. return makeSpan(["mspace", _buildCommon2.default.spacingFunctions[group.value].className], [], options);
  3989. }
  3990. };
  3991. groupTypes.lap = function (group, options) {
  3992. // mathllap, mathrlap, mathclap
  3993. var inner = void 0;
  3994. if (group.value.alignment === "clap") {
  3995. // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/
  3996. inner = makeSpan([], [buildGroup(group.value.body, options)]);
  3997. // wrap, since CSS will center a .clap > .inner > span
  3998. inner = makeSpan(["inner"], [inner], options);
  3999. } else {
  4000. inner = makeSpan(["inner"], [buildGroup(group.value.body, options)]);
  4001. }
  4002. var fix = makeSpan(["fix"], []);
  4003. return makeSpan(["mord", group.value.alignment], [inner, fix], options);
  4004. };
  4005. groupTypes.smash = function (group, options) {
  4006. var node = makeSpan(["mord"], [buildGroup(group.value.body, options)]);
  4007. if (!group.value.smashHeight && !group.value.smashDepth) {
  4008. return node;
  4009. }
  4010. if (group.value.smashHeight) {
  4011. node.height = 0;
  4012. // In order to influence makeVList, we have to reset the children.
  4013. if (node.children) {
  4014. for (var i = 0; i < node.children.length; i++) {
  4015. node.children[i].height = 0;
  4016. }
  4017. }
  4018. }
  4019. if (group.value.smashDepth) {
  4020. node.depth = 0;
  4021. if (node.children) {
  4022. for (var _i4 = 0; _i4 < node.children.length; _i4++) {
  4023. node.children[_i4].depth = 0;
  4024. }
  4025. }
  4026. }
  4027. // At this point, we've reset the TeX-like height and depth values.
  4028. // But the span still has an HTML line height.
  4029. // makeVList applies "display: table-cell", which prevents the browser
  4030. // from acting on that line height. So we'll call makeVList now.
  4031. return _buildCommon2.default.makeVList([{ type: "elem", elem: node }], "firstBaseline", null, options);
  4032. };
  4033. groupTypes.op = function (group, options) {
  4034. // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
  4035. var supGroup = void 0;
  4036. var subGroup = void 0;
  4037. var hasLimits = false;
  4038. if (group.type === "supsub") {
  4039. // If we have limits, supsub will pass us its group to handle. Pull
  4040. // out the superscript and subscript and set the group to the op in
  4041. // its base.
  4042. supGroup = group.value.sup;
  4043. subGroup = group.value.sub;
  4044. group = group.value.base;
  4045. hasLimits = true;
  4046. }
  4047. var style = options.style;
  4048. // Most operators have a large successor symbol, but these don't.
  4049. var noSuccessor = ["\\smallint"];
  4050. var large = false;
  4051. if (style.size === _Style2.default.DISPLAY.size && group.value.symbol && !_utils2.default.contains(noSuccessor, group.value.body)) {
  4052. // Most symbol operators get larger in displaystyle (rule 13)
  4053. large = true;
  4054. }
  4055. var base = void 0;
  4056. if (group.value.symbol) {
  4057. // If this is a symbol, create the symbol.
  4058. var fontName = large ? "Size2-Regular" : "Size1-Regular";
  4059. base = _buildCommon2.default.makeSymbol(group.value.body, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]);
  4060. } else if (group.value.value) {
  4061. // If this is a list, compose that list.
  4062. var inner = buildExpression(group.value.value, options, true);
  4063. if (inner.length === 1 && inner[0] instanceof _domTree2.default.symbolNode) {
  4064. base = inner[0];
  4065. base.classes[0] = "mop"; // replace old mclass
  4066. } else {
  4067. base = makeSpan(["mop"], inner, options);
  4068. }
  4069. } else {
  4070. // Otherwise, this is a text operator. Build the text from the
  4071. // operator's name.
  4072. // TODO(emily): Add a space in the middle of some of these
  4073. // operators, like \limsup
  4074. var output = [];
  4075. for (var i = 1; i < group.value.body.length; i++) {
  4076. output.push(_buildCommon2.default.mathsym(group.value.body[i], group.mode));
  4077. }
  4078. base = makeSpan(["mop"], output, options);
  4079. }
  4080. // If content of op is a single symbol, shift it vertically.
  4081. var baseShift = 0;
  4082. var slant = 0;
  4083. if (base instanceof _domTree2.default.symbolNode) {
  4084. // Shift the symbol so its center lies on the axis (rule 13). It
  4085. // appears that our fonts have the centers of the symbols already
  4086. // almost on the axis, so these numbers are very small. Note we
  4087. // don't actually apply this here, but instead it is used either in
  4088. // the vlist creation or separately when there are no limits.
  4089. baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight;
  4090. // The slant of the symbol is just its italic correction.
  4091. slant = base.italic;
  4092. }
  4093. if (hasLimits) {
  4094. // IE 8 clips \int if it is in a display: inline-block. We wrap it
  4095. // in a new span so it is an inline, and works.
  4096. base = makeSpan([], [base]);
  4097. var supm = void 0;
  4098. var supKern = void 0;
  4099. var subm = void 0;
  4100. var subKern = void 0;
  4101. var newOptions = void 0;
  4102. // We manually have to handle the superscripts and subscripts. This,
  4103. // aside from the kern calculations, is copied from supsub.
  4104. if (supGroup) {
  4105. newOptions = options.havingStyle(style.sup());
  4106. supm = buildGroup(supGroup, newOptions, options);
  4107. supKern = Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - supm.depth);
  4108. }
  4109. if (subGroup) {
  4110. newOptions = options.havingStyle(style.sub());
  4111. subm = buildGroup(subGroup, newOptions, options);
  4112. subKern = Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - subm.height);
  4113. }
  4114. // Build the final group as a vlist of the possible subscript, base,
  4115. // and possible superscript.
  4116. var finalGroup = void 0;
  4117. var top = void 0;
  4118. var bottom = void 0;
  4119. if (!supGroup) {
  4120. top = base.height - baseShift;
  4121. // Shift the limits by the slant of the symbol. Note
  4122. // that we are supposed to shift the limits by 1/2 of the slant,
  4123. // but since we are centering the limits adding a full slant of
  4124. // margin will shift by 1/2 that.
  4125. finalGroup = _buildCommon2.default.makeVList([{ type: "kern", size: options.fontMetrics().bigOpSpacing5 }, { type: "elem", elem: subm, marginLeft: -slant + "em" }, { type: "kern", size: subKern }, { type: "elem", elem: base }], "top", top, options);
  4126. } else if (!subGroup) {
  4127. bottom = base.depth + baseShift;
  4128. finalGroup = _buildCommon2.default.makeVList([{ type: "elem", elem: base }, { type: "kern", size: supKern }, { type: "elem", elem: supm, marginLeft: slant + "em" }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 }], "bottom", bottom, options);
  4129. } else if (!supGroup && !subGroup) {
  4130. // This case probably shouldn't occur (this would mean the
  4131. // supsub was sending us a group with no superscript or
  4132. // subscript) but be safe.
  4133. return base;
  4134. } else {
  4135. bottom = options.fontMetrics().bigOpSpacing5 + subm.height + subm.depth + subKern + base.depth + baseShift;
  4136. finalGroup = _buildCommon2.default.makeVList([{ type: "kern", size: options.fontMetrics().bigOpSpacing5 }, { type: "elem", elem: subm, marginLeft: -slant + "em" }, { type: "kern", size: subKern }, { type: "elem", elem: base }, { type: "kern", size: supKern }, { type: "elem", elem: supm, marginLeft: slant + "em" }, { type: "kern", size: options.fontMetrics().bigOpSpacing5 }], "bottom", bottom, options);
  4137. }
  4138. return makeSpan(["mop", "op-limits"], [finalGroup], options);
  4139. } else {
  4140. if (baseShift) {
  4141. base.style.position = "relative";
  4142. base.style.top = baseShift + "em";
  4143. }
  4144. return base;
  4145. }
  4146. };
  4147. groupTypes.mod = function (group, options) {
  4148. var inner = [];
  4149. if (group.value.modType === "bmod") {
  4150. // “\nonscript\mskip-\medmuskip\mkern5mu”
  4151. if (!options.style.isTight()) {
  4152. inner.push(makeSpan(["mspace", "negativemediumspace"], [], options));
  4153. }
  4154. inner.push(makeSpan(["mspace", "thickspace"], [], options));
  4155. } else if (options.style.size === _Style2.default.DISPLAY.size) {
  4156. inner.push(makeSpan(["mspace", "quad"], [], options));
  4157. } else if (group.value.modType === "mod") {
  4158. inner.push(makeSpan(["mspace", "twelvemuspace"], [], options));
  4159. } else {
  4160. inner.push(makeSpan(["mspace", "eightmuspace"], [], options));
  4161. }
  4162. if (group.value.modType === "pod" || group.value.modType === "pmod") {
  4163. inner.push(_buildCommon2.default.mathsym("(", group.mode));
  4164. }
  4165. if (group.value.modType !== "pod") {
  4166. var modInner = [_buildCommon2.default.mathsym("m", group.mode), _buildCommon2.default.mathsym("o", group.mode), _buildCommon2.default.mathsym("d", group.mode)];
  4167. if (group.value.modType === "bmod") {
  4168. inner.push(makeSpan(["mbin"], modInner, options));
  4169. // “\mkern5mu\nonscript\mskip-\medmuskip”
  4170. inner.push(makeSpan(["mspace", "thickspace"], [], options));
  4171. if (!options.style.isTight()) {
  4172. inner.push(makeSpan(["mspace", "negativemediumspace"], [], options));
  4173. }
  4174. } else {
  4175. Array.prototype.push.apply(inner, modInner);
  4176. inner.push(makeSpan(["mspace", "sixmuspace"], [], options));
  4177. }
  4178. }
  4179. if (group.value.value) {
  4180. Array.prototype.push.apply(inner, buildExpression(group.value.value, options, false));
  4181. }
  4182. if (group.value.modType === "pod" || group.value.modType === "pmod") {
  4183. inner.push(_buildCommon2.default.mathsym(")", group.mode));
  4184. }
  4185. return _buildCommon2.default.makeFragment(inner);
  4186. };
  4187. groupTypes.katex = function (group, options) {
  4188. // The KaTeX logo. The offsets for the K and a were chosen to look
  4189. // good, but the offsets for the T, E, and X were taken from the
  4190. // definition of \TeX in TeX (see TeXbook pg. 356)
  4191. var k = makeSpan(["k"], [_buildCommon2.default.mathsym("K", group.mode)], options);
  4192. var a = makeSpan(["a"], [_buildCommon2.default.mathsym("A", group.mode)], options);
  4193. a.height = (a.height + 0.2) * 0.75;
  4194. a.depth = (a.height - 0.2) * 0.75;
  4195. var t = makeSpan(["t"], [_buildCommon2.default.mathsym("T", group.mode)], options);
  4196. var e = makeSpan(["e"], [_buildCommon2.default.mathsym("E", group.mode)], options);
  4197. e.height = e.height - 0.2155;
  4198. e.depth = e.depth + 0.2155;
  4199. var x = makeSpan(["x"], [_buildCommon2.default.mathsym("X", group.mode)], options);
  4200. return makeSpan(["mord", "katex-logo"], [k, a, t, e, x], options);
  4201. };
  4202. var makeLineSpan = function makeLineSpan(className, options, thickness) {
  4203. var line = makeSpan([className], [], options);
  4204. line.height = thickness || options.fontMetrics().defaultRuleThickness;
  4205. line.style.borderBottomWidth = line.height + "em";
  4206. line.maxFontSize = 1.0;
  4207. return line;
  4208. };
  4209. groupTypes.overline = function (group, options) {
  4210. // Overlines are handled in the TeXbook pg 443, Rule 9.
  4211. // Build the inner group in the cramped style.
  4212. var innerGroup = buildGroup(group.value.body, options.havingCrampedStyle());
  4213. // Create the line above the body
  4214. var line = makeLineSpan("overline-line", options);
  4215. // Generate the vlist, with the appropriate kerns
  4216. var vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: innerGroup }, { type: "kern", size: 3 * line.height }, { type: "elem", elem: line }, { type: "kern", size: line.height }], "firstBaseline", null, options);
  4217. return makeSpan(["mord", "overline"], [vlist], options);
  4218. };
  4219. groupTypes.underline = function (group, options) {
  4220. // Underlines are handled in the TeXbook pg 443, Rule 10.
  4221. // Build the inner group.
  4222. var innerGroup = buildGroup(group.value.body, options);
  4223. // Create the line above the body
  4224. var line = makeLineSpan("underline-line", options);
  4225. // Generate the vlist, with the appropriate kerns
  4226. var vlist = _buildCommon2.default.makeVList([{ type: "kern", size: line.height }, { type: "elem", elem: line }, { type: "kern", size: 3 * line.height }, { type: "elem", elem: innerGroup }], "top", innerGroup.height, options);
  4227. return makeSpan(["mord", "underline"], [vlist], options);
  4228. };
  4229. groupTypes.sqrt = function (group, options) {
  4230. // Square roots are handled in the TeXbook pg. 443, Rule 11.
  4231. // First, we do the same steps as in overline to build the inner group
  4232. // and line
  4233. var inner = buildGroup(group.value.body, options.havingCrampedStyle());
  4234. if (inner.height === 0) {
  4235. // Render a small surd.
  4236. inner.height = options.fontMetrics().xHeight;
  4237. }
  4238. // Some groups can return document fragments. Handle those by wrapping
  4239. // them in a span.
  4240. if (inner instanceof _domTree2.default.documentFragment) {
  4241. inner = makeSpan([], [inner], options);
  4242. }
  4243. // Calculate the minimum size for the \surd delimiter
  4244. var metrics = options.fontMetrics();
  4245. var theta = metrics.defaultRuleThickness;
  4246. var phi = theta;
  4247. if (options.style.id < _Style2.default.TEXT.id) {
  4248. phi = options.fontMetrics().xHeight;
  4249. }
  4250. // Calculate the clearance between the body and line
  4251. var lineClearance = theta + phi / 4;
  4252. var minDelimiterHeight = (inner.height + inner.depth + lineClearance + theta) * options.sizeMultiplier;
  4253. // Create a sqrt SVG of the required minimum size
  4254. var img = _delimiter2.default.customSizedDelim("\\surd", minDelimiterHeight, false, options, group.mode);
  4255. // Calculate the actual line width.
  4256. // This actually should depend on the chosen font -- e.g. \boldmath
  4257. // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and
  4258. // have thicker rules.
  4259. var ruleWidth = options.fontMetrics().sqrtRuleThickness * img.sizeMultiplier;
  4260. var delimDepth = img.height - ruleWidth;
  4261. // Adjust the clearance based on the delimiter size
  4262. if (delimDepth > inner.height + inner.depth + lineClearance) {
  4263. lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2;
  4264. }
  4265. // Shift the sqrt image
  4266. var imgShift = img.height - inner.height - lineClearance - ruleWidth;
  4267. inner.style.paddingLeft = img.advanceWidth + "em";
  4268. // Overlay the image and the argument.
  4269. var body = _buildCommon2.default.makeVList([{ type: "elem", elem: inner }, { type: "kern", size: -(inner.height + imgShift) }, { type: "elem", elem: img }, { type: "kern", size: ruleWidth }], "firstBaseline", null, options);
  4270. body.children[0].children[0].classes.push("svg-align");
  4271. if (!group.value.index) {
  4272. return makeSpan(["mord", "sqrt"], [body], options);
  4273. } else {
  4274. // Handle the optional root index
  4275. // The index is always in scriptscript style
  4276. var newOptions = options.havingStyle(_Style2.default.SCRIPTSCRIPT);
  4277. var rootm = buildGroup(group.value.index, newOptions, options);
  4278. // The amount the index is shifted by. This is taken from the TeX
  4279. // source, in the definition of `\r@@t`.
  4280. var toShift = 0.6 * (body.height - body.depth);
  4281. // Build a VList with the superscript shifted up correctly
  4282. var rootVList = _buildCommon2.default.makeVList([{ type: "elem", elem: rootm }], "shift", -toShift, options);
  4283. // Add a class surrounding it so we can add on the appropriate
  4284. // kerning
  4285. var rootVListWrap = makeSpan(["root"], [rootVList]);
  4286. return makeSpan(["mord", "sqrt"], [rootVListWrap, body], options);
  4287. }
  4288. };
  4289. function sizingGroup(value, options, baseOptions) {
  4290. var inner = buildExpression(value, options, false);
  4291. var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier;
  4292. // Add size-resetting classes to the inner list and set maxFontSize
  4293. // manually. Handle nested size changes.
  4294. for (var i = 0; i < inner.length; i++) {
  4295. var pos = _utils2.default.indexOf(inner[i].classes, "sizing");
  4296. if (pos < 0) {
  4297. Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions));
  4298. } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) {
  4299. // This is a nested size change: e.g., inner[i] is the "b" in
  4300. // `\Huge a \small b`. Override the old size (the `reset-` class)
  4301. // but not the new size.
  4302. inner[i].classes[pos + 1] = "reset-size" + baseOptions.size;
  4303. }
  4304. inner[i].height *= multiplier;
  4305. inner[i].depth *= multiplier;
  4306. }
  4307. return _buildCommon2.default.makeFragment(inner);
  4308. }
  4309. groupTypes.sizing = function (group, options) {
  4310. // Handle sizing operators like \Huge. Real TeX doesn't actually allow
  4311. // these functions inside of math expressions, so we do some special
  4312. // handling.
  4313. var newOptions = options.havingSize(group.value.size);
  4314. return sizingGroup(group.value.value, newOptions, options);
  4315. };
  4316. groupTypes.styling = function (group, options) {
  4317. // Style changes are handled in the TeXbook on pg. 442, Rule 3.
  4318. // Figure out what style we're changing to.
  4319. var styleMap = {
  4320. "display": _Style2.default.DISPLAY,
  4321. "text": _Style2.default.TEXT,
  4322. "script": _Style2.default.SCRIPT,
  4323. "scriptscript": _Style2.default.SCRIPTSCRIPT
  4324. };
  4325. var newStyle = styleMap[group.value.style];
  4326. var newOptions = options.havingStyle(newStyle);
  4327. return sizingGroup(group.value.value, newOptions, options);
  4328. };
  4329. groupTypes.font = function (group, options) {
  4330. var font = group.value.font;
  4331. return buildGroup(group.value.body, options.withFont(font));
  4332. };
  4333. groupTypes.verb = function (group, options) {
  4334. var text = _buildCommon2.default.makeVerb(group, options);
  4335. var body = [];
  4336. // \verb enters text mode and therefore is sized like \textstyle
  4337. var newOptions = options.havingStyle(options.style.text());
  4338. for (var i = 0; i < text.length; i++) {
  4339. if (text[i] === '\xA0') {
  4340. // spaces appear as nonbreaking space
  4341. // The space character isn't in the Typewriter-Regular font,
  4342. // so we implement it as a kern of the same size as a character.
  4343. // 0.525 is the width of a texttt character in LaTeX.
  4344. // It automatically gets scaled by the font size.
  4345. var rule = makeSpan(["mord", "rule"], [], newOptions);
  4346. rule.style.marginLeft = "0.525em";
  4347. body.push(rule);
  4348. } else {
  4349. body.push(_buildCommon2.default.makeSymbol(text[i], "Typewriter-Regular", group.mode, newOptions, ["mathtt"]));
  4350. }
  4351. }
  4352. _buildCommon2.default.tryCombineChars(body);
  4353. return makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), body, newOptions);
  4354. };
  4355. groupTypes.rule = function (group, options) {
  4356. // Make an empty span for the rule
  4357. var rule = makeSpan(["mord", "rule"], [], options);
  4358. // Calculate the shift, width, and height of the rule, and account for units
  4359. var shift = 0;
  4360. if (group.value.shift) {
  4361. shift = (0, _units.calculateSize)(group.value.shift, options);
  4362. }
  4363. var width = (0, _units.calculateSize)(group.value.width, options);
  4364. var height = (0, _units.calculateSize)(group.value.height, options);
  4365. // Style the rule to the right size
  4366. rule.style.borderRightWidth = width + "em";
  4367. rule.style.borderTopWidth = height + "em";
  4368. rule.style.bottom = shift + "em";
  4369. // Record the height and width
  4370. rule.width = width;
  4371. rule.height = height + shift;
  4372. rule.depth = -shift;
  4373. // Font size is the number large enough that the browser will
  4374. // reserve at least `absHeight` space above the baseline.
  4375. // The 1.125 factor was empirically determined
  4376. rule.maxFontSize = height * 1.125 * options.sizeMultiplier;
  4377. return rule;
  4378. };
  4379. groupTypes.kern = function (group, options) {
  4380. // Make an empty span for the rule
  4381. var rule = makeSpan(["mord", "rule"], [], options);
  4382. if (group.value.dimension) {
  4383. var dimension = (0, _units.calculateSize)(group.value.dimension, options);
  4384. rule.style.marginLeft = dimension + "em";
  4385. }
  4386. return rule;
  4387. };
  4388. groupTypes.accent = function (group, options) {
  4389. // Accents are handled in the TeXbook pg. 443, rule 12.
  4390. var base = group.value.base;
  4391. var supsubGroup = void 0;
  4392. if (group.type === "supsub") {
  4393. // If our base is a character box, and we have superscripts and
  4394. // subscripts, the supsub will defer to us. In particular, we want
  4395. // to attach the superscripts and subscripts to the inner body (so
  4396. // that the position of the superscripts and subscripts won't be
  4397. // affected by the height of the accent). We accomplish this by
  4398. // sticking the base of the accent into the base of the supsub, and
  4399. // rendering that, while keeping track of where the accent is.
  4400. // The supsub group is the group that was passed in
  4401. var supsub = group;
  4402. // The real accent group is the base of the supsub group
  4403. group = supsub.value.base;
  4404. // The character box is the base of the accent group
  4405. base = group.value.base;
  4406. // Stick the character box into the base of the supsub group
  4407. supsub.value.base = base;
  4408. // Rerender the supsub group with its new base, and store that
  4409. // r###lt.
  4410. supsubGroup = buildGroup(supsub, options);
  4411. }
  4412. // Build the base group
  4413. var body = buildGroup(base, options.havingCrampedStyle());
  4414. // Does the accent need to shift for the skew of a character?
  4415. var mustShift = group.value.isShifty && isCharacterBox(base);
  4416. // Calculate the skew of the accent. This is based on the line "If the
  4417. // nucleus is not a single character, let s = 0; otherwise set s to the
  4418. // kern amount for the nucleus followed by the \skewchar of its font."
  4419. // Note that our skew metrics are just the kern between each character
  4420. // and the skewchar.
  4421. var skew = 0;
  4422. if (mustShift) {
  4423. // If the base is a character box, then we want the skew of the
  4424. // innermost character. To do that, we find the innermost character:
  4425. var baseChar = getBaseElem(base);
  4426. // Then, we render its group to get the symbol inside it
  4427. var baseGroup = buildGroup(baseChar, options.havingCrampedStyle());
  4428. // Finally, we pull the skew off of the symbol.
  4429. skew = baseGroup.skew;
  4430. // Note that we now throw away baseGroup, because the layers we
  4431. // removed with getBaseElem might contain things like \color which
  4432. // we can't get rid of.
  4433. // TODO(emily): Find a better way to get the skew
  4434. }
  4435. // calculate the amount of space between the body and the accent
  4436. var clearance = Math.min(body.height, options.fontMetrics().xHeight);
  4437. // Build the accent
  4438. var accentBody = void 0;
  4439. if (!group.value.isStretchy) {
  4440. var accent = _buildCommon2.default.makeSymbol(group.value.label, "Main-Regular", group.mode, options);
  4441. // Remove the italic correction of the accent, because it only serves to
  4442. // shift the accent over to a place we don't want.
  4443. accent.italic = 0;
  4444. // The \vec character that the fonts use is a combining character, and
  4445. // thus shows up much too far to the left. To account for this, we add a
  4446. // specific class which shifts the accent over to where we want it.
  4447. // TODO(emily): Fix this in a better way, like by changing the font
  4448. // Similarly, text accent \H is a combining character and
  4449. // requires a different adjustment.
  4450. var accentClass = null;
  4451. if (group.value.label === "\\vec") {
  4452. accentClass = "accent-vec";
  4453. } else if (group.value.label === '\\H') {
  4454. accentClass = "accent-hungarian";
  4455. }
  4456. accentBody = makeSpan([], [accent]);
  4457. accentBody = makeSpan(["accent-body", accentClass], [accentBody]);
  4458. // Shift the accent over by the skew. Note we shift by twice the skew
  4459. // because we are centering the accent, so by adding 2*skew to the left,
  4460. // we shift it to the right by 1*skew.
  4461. accentBody.style.marginLeft = 2 * skew + "em";
  4462. accentBody = _buildCommon2.default.makeVList([{ type: "elem", elem: body }, { type: "kern", size: -clearance }, { type: "elem", elem: accentBody }], "firstBaseline", null, options);
  4463. } else {
  4464. accentBody = _stretchy2.default.svgSpan(group, options);
  4465. accentBody = _buildCommon2.default.makeVList([{ type: "elem", elem: body }, { type: "elem", elem: accentBody }], "firstBaseline", null, options);
  4466. var styleSpan = accentBody.children[0].children[0].children[1];
  4467. styleSpan.classes.push("svg-align"); // text-align: left;
  4468. if (skew > 0) {
  4469. // Shorten the accent and nudge it to the right.
  4470. styleSpan.style.width = "calc(100% - " + 2 * skew + "em)";
  4471. styleSpan.style.marginLeft = 2 * skew + "em";
  4472. }
  4473. }
  4474. var accentWrap = makeSpan(["mord", "accent"], [accentBody], options);
  4475. if (supsubGroup) {
  4476. // Here, we replace the "base" child of the supsub with our newly
  4477. // generated accent.
  4478. supsubGroup.children[0] = accentWrap;
  4479. // Since we don't rerun the height calculation after replacing the
  4480. // accent, we manually recalculate height.
  4481. supsubGroup.height = Math.max(accentWrap.height, supsubGroup.height);
  4482. // Accents should always be ords, even when their innards are not.
  4483. supsubGroup.classes[0] = "mord";
  4484. return supsubGroup;
  4485. } else {
  4486. return accentWrap;
  4487. }
  4488. };
  4489. groupTypes.horizBrace = function (group, options) {
  4490. var style = options.style;
  4491. var hasSupSub = group.type === "supsub";
  4492. var supSubGroup = void 0;
  4493. var newOptions = void 0;
  4494. if (hasSupSub) {
  4495. // Ref: LaTeX source2e: }}}}\limits}
  4496. // i.e. LaTeX treats the brace similar to an op and passes it
  4497. // with \limits, so we need to assign supsub style.
  4498. if (group.value.sup) {
  4499. newOptions = options.havingStyle(style.sup());
  4500. supSubGroup = buildGroup(group.value.sup, newOptions, options);
  4501. } else {
  4502. newOptions = options.havingStyle(style.sub());
  4503. supSubGroup = buildGroup(group.value.sub, newOptions, options);
  4504. }
  4505. group = group.value.base;
  4506. }
  4507. // Build the base group
  4508. var body = buildGroup(group.value.base, options.havingBaseStyle(_Style2.default.DISPLAY));
  4509. // Create the stretchy element
  4510. var braceBody = _stretchy2.default.svgSpan(group, options);
  4511. // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓
  4512. // This first vlist contains the subject matter and the brace: equation
  4513. var vlist = void 0;
  4514. if (group.value.isOver) {
  4515. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: body }, { type: "kern", size: 0.1 }, { type: "elem", elem: braceBody }], "firstBaseline", null, options);
  4516. vlist.children[0].children[0].children[1].classes.push("svg-align");
  4517. } else {
  4518. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: braceBody }, { type: "kern", size: 0.1 }, { type: "elem", elem: body }], "bottom", body.depth + 0.1 + braceBody.height, options);
  4519. vlist.children[0].children[0].children[0].classes.push("svg-align");
  4520. }
  4521. if (hasSupSub) {
  4522. // In order to write the supsub, wrap the first vlist in another vlist:
  4523. // They can't all go in the same vlist, because the note might be wider
  4524. // than the equation. We want the equation to control the brace width.
  4525. // note long note long note
  4526. // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓
  4527. // equation eqn eqn
  4528. var vSpan = makeSpan(["mord", group.value.isOver ? "mover" : "munder"], [vlist], options);
  4529. if (group.value.isOver) {
  4530. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: vSpan }, { type: "kern", size: 0.2 }, { type: "elem", elem: supSubGroup }], "firstBaseline", null, options);
  4531. } else {
  4532. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: supSubGroup }, { type: "kern", size: 0.2 }, { type: "elem", elem: vSpan }], "bottom", vSpan.depth + 0.2 + supSubGroup.height, options);
  4533. }
  4534. }
  4535. return makeSpan(["mord", group.value.isOver ? "mover" : "munder"], [vlist], options);
  4536. };
  4537. groupTypes.accentUnder = function (group, options) {
  4538. // Treat under accents much like underlines.
  4539. var innerGroup = buildGroup(group.value.base, options);
  4540. var accentBody = _stretchy2.default.svgSpan(group, options);
  4541. var kern = /tilde/.test(group.value.label) ? 0.12 : 0;
  4542. // Generate the vlist, with the appropriate kerns
  4543. var vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: accentBody }, { type: "kern", size: kern }, { type: "elem", elem: innerGroup }], "bottom", accentBody.height + kern, options);
  4544. vlist.children[0].children[0].children[0].classes.push("svg-align");
  4545. return makeSpan(["mord", "accentunder"], [vlist], options);
  4546. };
  4547. groupTypes.enclose = function (group, options) {
  4548. // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox
  4549. var inner = buildGroup(group.value.body, options);
  4550. var label = group.value.label.substr(1);
  4551. var scale = options.sizeMultiplier;
  4552. var img = void 0;
  4553. var imgShift = 0;
  4554. var isColorbox = /color/.test(label);
  4555. if (label === "sout") {
  4556. img = makeSpan(["stretchy", "sout"]);
  4557. img.height = options.fontMetrics().defaultRuleThickness / scale;
  4558. imgShift = -0.5 * options.fontMetrics().xHeight;
  4559. } else {
  4560. // Add horizontal padding
  4561. inner.classes.push(/cancel/.test(label) ? "cancel-pad" : "boxpad");
  4562. // Add vertical padding
  4563. var vertPad = 0;
  4564. // ref: LaTeX source2e: \fboxsep = 3pt; \fboxrule = .4pt
  4565. // ref: cancel package: \advance\totalheight2\p@ % "+2"
  4566. if (/box/.test(label)) {
  4567. vertPad = label === "colorbox" ? 0.3 : 0.34;
  4568. } else {
  4569. vertPad = isCharacterBox(group.value.body) ? 0.2 : 0;
  4570. }
  4571. img = _stretchy2.default.encloseSpan(inner, label, vertPad, options);
  4572. imgShift = inner.depth + vertPad;
  4573. if (isColorbox) {
  4574. img.style.backgroundColor = group.value.backgroundColor.value;
  4575. if (label === "fcolorbox") {
  4576. img.style.borderColor = group.value.borderColor.value;
  4577. }
  4578. }
  4579. }
  4580. var vlist = void 0;
  4581. if (isColorbox) {
  4582. vlist = _buildCommon2.default.makeVList([
  4583. // Put the color background behind inner;
  4584. { type: "elem", elem: img, shift: imgShift }, { type: "elem", elem: inner, shift: 0 }], "individualShift", null, options);
  4585. } else {
  4586. vlist = _buildCommon2.default.makeVList([
  4587. // Write the \cancel stroke on top of inner.
  4588. { type: "elem", elem: inner, shift: 0 }, { type: "elem", elem: img, shift: imgShift }], "individualShift", null, options);
  4589. }
  4590. if (/cancel/.test(label)) {
  4591. vlist.children[0].children[0].children[1].classes.push("svg-align");
  4592. // cancel does not create horiz space for its line extension.
  4593. // That is, not when adjacent to a mord.
  4594. return makeSpan(["mord", "cancel-lap"], [vlist], options);
  4595. } else {
  4596. return makeSpan(["mord"], [vlist], options);
  4597. }
  4598. };
  4599. groupTypes.xArrow = function (group, options) {
  4600. var style = options.style;
  4601. // Build the argument groups in the appropriate style.
  4602. // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
  4603. var newOptions = options.havingStyle(style.sup());
  4604. var upperGroup = buildGroup(group.value.body, newOptions, options);
  4605. upperGroup.classes.push("x-arrow-pad");
  4606. var lowerGroup = void 0;
  4607. if (group.value.below) {
  4608. // Build the lower group
  4609. newOptions = options.havingStyle(style.sub());
  4610. lowerGroup = buildGroup(group.value.below, newOptions, options);
  4611. lowerGroup.classes.push("x-arrow-pad");
  4612. }
  4613. var arrowBody = _stretchy2.default.svgSpan(group, options);
  4614. // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0.
  4615. // The point we want on the math axis is at 0.5 * arrowBody.height.
  4616. var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height;
  4617. // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi
  4618. var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111;
  4619. // Generate the vlist
  4620. var vlist = void 0;
  4621. if (group.value.below) {
  4622. var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111;
  4623. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: upperGroup, shift: upperShift }, { type: "elem", elem: arrowBody, shift: arrowShift }, { type: "elem", elem: lowerGroup, shift: lowerShift }], "individualShift", null, options);
  4624. } else {
  4625. vlist = _buildCommon2.default.makeVList([{ type: "elem", elem: upperGroup, shift: upperShift }, { type: "elem", elem: arrowBody, shift: arrowShift }], "individualShift", null, options);
  4626. }
  4627. vlist.children[0].children[0].children[1].classes.push("svg-align");
  4628. return makeSpan(["mrel", "x-arrow"], [vlist], options);
  4629. };
  4630. groupTypes.mclass = function (group, options) {
  4631. var elements = buildExpression(group.value.value, options, true);
  4632. return makeSpan([group.value.mclass], elements, options);
  4633. };
  4634. groupTypes.raisebox = function (group, options) {
  4635. var body = groupTypes.sizing({ value: {
  4636. value: [{
  4637. type: "text",
  4638. value: {
  4639. body: group.value.value,
  4640. font: "mathrm" // simulate \textrm
  4641. }
  4642. }],
  4643. size: 6 // simulate \normalsize
  4644. } }, options);
  4645. var dy = (0, _units.calculateSize)(group.value.dy.value, options);
  4646. return _buildCommon2.default.makeVList([{
  4647. type: "elem",
  4648. elem: body
  4649. }], "shift", -dy, options);
  4650. };
  4651. /**
  4652. * buildGroup is the function that takes a group and calls the correct groupType
  4653. * function for it. It also handles the interaction of size and style changes
  4654. * between parents and children.
  4655. */
  4656. var buildGroup = exports.buildGroup = function buildGroup(group, options, baseOptions) {
  4657. if (!group) {
  4658. return makeSpan();
  4659. }
  4660. if (groupTypes[group.type]) {
  4661. // Call the groupTypes function
  4662. var groupNode = groupTypes[group.type](group, options);
  4663. // If the size changed between the parent and the current group, account
  4664. // for that size difference.
  4665. if (baseOptions && options.size !== baseOptions.size) {
  4666. groupNode = makeSpan(options.sizingClasses(baseOptions), [groupNode], options);
  4667. var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier;
  4668. groupNode.height *= multiplier;
  4669. groupNode.depth *= multiplier;
  4670. }
  4671. return groupNode;
  4672. } else {
  4673. throw new _ParseError2.default("Got group of unknown type: '" + group.type + "'");
  4674. }
  4675. };
  4676. /**
  4677. * Take an entire parse tree, and build it into an appropriate set of HTML
  4678. * nodes.
  4679. */
  4680. function buildHTML(tree, options) {
  4681. // buildExpression is destructive, so we need to make a clone
  4682. // of the incoming tree so that it isn't accidentally changed
  4683. tree = JSON.parse((0, _stringify2.default)(tree));
  4684. // Build the expression contained in the tree
  4685. var expression = buildExpression(tree, options, true);
  4686. var body = makeSpan(["base"], expression, options);
  4687. // Add struts, which ensure that the top of the HTML element falls at the
  4688. // height of the expression, and the bottom of the HTML element falls at the
  4689. // depth of the expression.
  4690. var topStrut = makeSpan(["strut"]);
  4691. var bottomStrut = makeSpan(["strut", "bottom"]);
  4692. topStrut.style.height = body.height + "em";
  4693. bottomStrut.style.height = body.height + body.depth + "em";
  4694. // We'd like to use `vertical-align: top` but in IE 9 this lowers the
  4695. // baseline of the box to the bottom of this strut (instead staying in the
  4696. // normal place) so we use an absolute value for vertical-align instead
  4697. bottomStrut.style.verticalAlign = -body.depth + "em";
  4698. // Wrap the struts and body together
  4699. var htmlNode = makeSpan(["katex-html"], [topStrut, bottomStrut, body]);
  4700. htmlNode.setAttribute("aria-hidden", "true");
  4701. return htmlNode;
  4702. }
  4703. },{"./ParseError":84,"./Style":89,"./buildCommon":91,"./delimiter":97,"./domTree":98,"./stretchy":110,"./units":114,"./utils":115,"babel-runtime/core-js/json/stringify":5}],93:[function(require,module,exports){
  4704. "use strict";
  4705. Object.defineProperty(exports, "__esModule", {
  4706. value: true
  4707. });
  4708. exports.buildGroup = exports.buildExpression = exports.groupTypes = exports.makeText = undefined;
  4709. exports.default = buildMathML;
  4710. var _buildCommon = require("./buildCommon");
  4711. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  4712. var _fontMetrics = require("./fontMetrics");
  4713. var _fontMetrics2 = _interopRequireDefault(_fontMetrics);
  4714. var _mathMLTree = require("./mathMLTree");
  4715. var _mathMLTree2 = _interopRequireDefault(_mathMLTree);
  4716. var _ParseError = require("./ParseError");
  4717. var _ParseError2 = _interopRequireDefault(_ParseError);
  4718. var _Style = require("./Style");
  4719. var _Style2 = _interopRequireDefault(_Style);
  4720. var _symbols = require("./symbols");
  4721. var _symbols2 = _interopRequireDefault(_symbols);
  4722. var _utils = require("./utils");
  4723. var _utils2 = _interopRequireDefault(_utils);
  4724. var _stretchy = require("./stretchy");
  4725. var _stretchy2 = _interopRequireDefault(_stretchy);
  4726. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4727. /**
  4728. * Takes a symbol and converts it into a MathML text node after performing
  4729. * optional replacement from symbols.js.
  4730. */
  4731. /**
  4732. * WARNING: New methods on groupTypes should be added to src/functions.
  4733. *
  4734. * This file converts a parse tree into a cooresponding MathML tree. The main
  4735. * entry point is the `buildMathML` function, which takes a parse tree from the
  4736. * parser.
  4737. */
  4738. var makeText = exports.makeText = function makeText(text, mode) {
  4739. if (_symbols2.default[mode][text] && _symbols2.default[mode][text].replace) {
  4740. text = _symbols2.default[mode][text].replace;
  4741. }
  4742. return new _mathMLTree2.default.TextNode(text);
  4743. };
  4744. /**
  4745. * Returns the math variant as a string or null if none is required.
  4746. */
  4747. var getVariant = function getVariant(group, options) {
  4748. var font = options.font;
  4749. if (!font) {
  4750. return null;
  4751. }
  4752. var mode = group.mode;
  4753. if (font === "mathit") {
  4754. return "italic";
  4755. }
  4756. var value = group.value;
  4757. if (_utils2.default.contains(["\\imath", "\\jmath"], value)) {
  4758. return null;
  4759. }
  4760. if (_symbols2.default[mode][value] && _symbols2.default[mode][value].replace) {
  4761. value = _symbols2.default[mode][value].replace;
  4762. }
  4763. var fontName = _buildCommon2.default.fontMap[font].fontName;
  4764. if (_fontMetrics2.default.getCharacterMetrics(value, fontName)) {
  4765. return _buildCommon2.default.fontMap[options.font].variant;
  4766. }
  4767. return null;
  4768. };
  4769. /**
  4770. * Functions for handling the different types of groups found in the parse
  4771. * tree. Each function should take a parse group and return a MathML node.
  4772. */
  4773. var groupTypes = exports.groupTypes = {};
  4774. var defaultVariant = {
  4775. "mi": "italic",
  4776. "mn": "normal",
  4777. "mtext": "normal"
  4778. };
  4779. groupTypes.mathord = function (group, options) {
  4780. var node = new _mathMLTree2.default.MathNode("mi", [makeText(group.value, group.mode)]);
  4781. var variant = getVariant(group, options) || "italic";
  4782. if (variant !== defaultVariant[node.type]) {
  4783. node.setAttribute("mathvariant", variant);
  4784. }
  4785. return node;
  4786. };
  4787. groupTypes.textord = function (group, options) {
  4788. var text = makeText(group.value, group.mode);
  4789. var variant = getVariant(group, options) || "normal";
  4790. var node = void 0;
  4791. if (group.mode === 'text') {
  4792. node = new _mathMLTree2.default.MathNode("mtext", [text]);
  4793. } else if (/[0-9]/.test(group.value)) {
  4794. // TODO(kevinb) merge adjacent <mn> nodes
  4795. // do it as a post processing step
  4796. node = new _mathMLTree2.default.MathNode("mn", [text]);
  4797. } else if (group.value === "\\prime") {
  4798. node = new _mathMLTree2.default.MathNode("mo", [text]);
  4799. } else {
  4800. node = new _mathMLTree2.default.MathNode("mi", [text]);
  4801. }
  4802. if (variant !== defaultVariant[node.type]) {
  4803. node.setAttribute("mathvariant", variant);
  4804. }
  4805. return node;
  4806. };
  4807. groupTypes.bin = function (group) {
  4808. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  4809. return node;
  4810. };
  4811. groupTypes.rel = function (group) {
  4812. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  4813. return node;
  4814. };
  4815. groupTypes.open = function (group) {
  4816. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  4817. return node;
  4818. };
  4819. groupTypes.close = function (group) {
  4820. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  4821. return node;
  4822. };
  4823. groupTypes.inner = function (group) {
  4824. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  4825. return node;
  4826. };
  4827. groupTypes.punct = function (group) {
  4828. var node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value, group.mode)]);
  4829. node.setAttribute("separator", "true");
  4830. return node;
  4831. };
  4832. groupTypes.ordgroup = function (group, options) {
  4833. var inner = buildExpression(group.value, options);
  4834. var node = new _mathMLTree2.default.MathNode("mrow", inner);
  4835. return node;
  4836. };
  4837. groupTypes.text = function (group, options) {
  4838. var body = group.value.body;
  4839. // Convert each element of the body into MathML, and combine consecutive
  4840. // <mtext> outputs into a single <mtext> tag. In this way, we don't
  4841. // nest non-text items (e.g., $nested-math$) within an <mtext>.
  4842. var inner = [];
  4843. var currentText = null;
  4844. for (var i = 0; i < body.length; i++) {
  4845. var _group = buildGroup(body[i], options);
  4846. if (_group.type === 'mtext' && currentText != null) {
  4847. Array.prototype.push.apply(currentText.children, _group.children);
  4848. } else {
  4849. inner.push(_group);
  4850. if (_group.type === 'mtext') {
  4851. currentText = _group;
  4852. }
  4853. }
  4854. }
  4855. // If there is a single tag in the end (pr###mably <mtext>),
  4856. // just return it. Otherwise, wrap them in an <mrow>.
  4857. if (inner.length === 1) {
  4858. return inner[0];
  4859. } else {
  4860. return new _mathMLTree2.default.MathNode("mrow", inner);
  4861. }
  4862. };
  4863. groupTypes.color = function (group, options) {
  4864. var inner = buildExpression(group.value.value, options);
  4865. var node = new _mathMLTree2.default.MathNode("mstyle", inner);
  4866. node.setAttribute("mathcolor", group.value.color);
  4867. return node;
  4868. };
  4869. groupTypes.supsub = function (group, options) {
  4870. // Is the inner group a relevant horizonal brace?
  4871. var isBrace = false;
  4872. var isOver = void 0;
  4873. var isSup = void 0;
  4874. if (group.value.base) {
  4875. if (group.value.base.value.type === "horizBrace") {
  4876. isSup = group.value.sup ? true : false;
  4877. if (isSup === group.value.base.value.isOver) {
  4878. isBrace = true;
  4879. isOver = group.value.base.value.isOver;
  4880. }
  4881. }
  4882. }
  4883. var removeUnnecessaryRow = true;
  4884. var children = [buildGroup(group.value.base, options, removeUnnecessaryRow)];
  4885. if (group.value.sub) {
  4886. children.push(buildGroup(group.value.sub, options, removeUnnecessaryRow));
  4887. }
  4888. if (group.value.sup) {
  4889. children.push(buildGroup(group.value.sup, options, removeUnnecessaryRow));
  4890. }
  4891. var nodeType = void 0;
  4892. if (isBrace) {
  4893. nodeType = isOver ? "mover" : "munder";
  4894. } else if (!group.value.sub) {
  4895. nodeType = "msup";
  4896. } else if (!group.value.sup) {
  4897. nodeType = "msub";
  4898. } else {
  4899. var base = group.value.base;
  4900. if (base && base.value.limits && options.style === _Style2.default.DISPLAY) {
  4901. nodeType = "munderover";
  4902. } else {
  4903. nodeType = "msubsup";
  4904. }
  4905. }
  4906. var node = new _mathMLTree2.default.MathNode(nodeType, children);
  4907. return node;
  4908. };
  4909. groupTypes.genfrac = function (group, options) {
  4910. var node = new _mathMLTree2.default.MathNode("mfrac", [buildGroup(group.value.numer, options), buildGroup(group.value.denom, options)]);
  4911. if (!group.value.hasBarLine) {
  4912. node.setAttribute("linethickness", "0px");
  4913. }
  4914. if (group.value.leftDelim != null || group.value.rightDelim != null) {
  4915. var withDelims = [];
  4916. if (group.value.leftDelim != null) {
  4917. var leftOp = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode(group.value.leftDelim)]);
  4918. leftOp.setAttribute("fence", "true");
  4919. withDelims.push(leftOp);
  4920. }
  4921. withDelims.push(node);
  4922. if (group.value.rightDelim != null) {
  4923. var rightOp = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode(group.value.rightDelim)]);
  4924. rightOp.setAttribute("fence", "true");
  4925. withDelims.push(rightOp);
  4926. }
  4927. var outerNode = new _mathMLTree2.default.MathNode("mrow", withDelims);
  4928. return outerNode;
  4929. }
  4930. return node;
  4931. };
  4932. groupTypes.sqrt = function (group, options) {
  4933. var node = void 0;
  4934. if (group.value.index) {
  4935. node = new _mathMLTree2.default.MathNode("mroot", [buildGroup(group.value.body, options), buildGroup(group.value.index, options)]);
  4936. } else {
  4937. node = new _mathMLTree2.default.MathNode("msqrt", [buildGroup(group.value.body, options)]);
  4938. }
  4939. return node;
  4940. };
  4941. groupTypes.accent = function (group, options) {
  4942. var accentNode = void 0;
  4943. if (group.value.isStretchy) {
  4944. accentNode = _stretchy2.default.mathMLnode(group.value.label);
  4945. } else {
  4946. accentNode = new _mathMLTree2.default.MathNode("mo", [makeText(group.value.label, group.mode)]);
  4947. }
  4948. var node = new _mathMLTree2.default.MathNode("mover", [buildGroup(group.value.base, options), accentNode]);
  4949. node.setAttribute("accent", "true");
  4950. return node;
  4951. };
  4952. groupTypes.spacing = function (group) {
  4953. var node = void 0;
  4954. if (group.value === "\\ " || group.value === "\\space" || group.value === " " || group.value === "~") {
  4955. node = new _mathMLTree2.default.MathNode("mtext", [new _mathMLTree2.default.TextNode("\xA0")]);
  4956. } else {
  4957. node = new _mathMLTree2.default.MathNode("mspace");
  4958. node.setAttribute("width", _buildCommon2.default.spacingFunctions[group.value].size);
  4959. }
  4960. return node;
  4961. };
  4962. groupTypes.op = function (group, options) {
  4963. var node = void 0;
  4964. // TODO(emily): handle big operators using the `largeop` attribute
  4965. if (group.value.symbol) {
  4966. // This is a symbol. Just add the symbol.
  4967. node = new _mathMLTree2.default.MathNode("mo", [makeText(group.value.body, group.mode)]);
  4968. } else if (group.value.value) {
  4969. // This is an operator with children. Add them.
  4970. node = new _mathMLTree2.default.MathNode("mo", buildExpression(group.value.value, options));
  4971. } else {
  4972. // This is a text operator. Add all of the characters from the
  4973. // operator's name.
  4974. // TODO(emily): Add a space in the middle of some of these
  4975. // operators, like \limsup.
  4976. node = new _mathMLTree2.default.MathNode("mi", [new _mathMLTree2.default.TextNode(group.value.body.slice(1))]);
  4977. // TODO(ron): Append an <mo>&ApplyFunction;</mo> as in \operatorname
  4978. // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.2
  4979. }
  4980. return node;
  4981. };
  4982. groupTypes.mod = function (group, options) {
  4983. var inner = [];
  4984. if (group.value.modType === "pod" || group.value.modType === "pmod") {
  4985. inner.push(new _mathMLTree2.default.MathNode("mo", [makeText("(", group.mode)]));
  4986. }
  4987. if (group.value.modType !== "pod") {
  4988. inner.push(new _mathMLTree2.default.MathNode("mo", [makeText("mod", group.mode)]));
  4989. }
  4990. if (group.value.value) {
  4991. var space = new _mathMLTree2.default.MathNode("mspace");
  4992. space.setAttribute("width", "0.333333em");
  4993. inner.push(space);
  4994. inner = inner.concat(buildExpression(group.value.value, options));
  4995. }
  4996. if (group.value.modType === "pod" || group.value.modType === "pmod") {
  4997. inner.push(new _mathMLTree2.default.MathNode("mo", [makeText(")", group.mode)]));
  4998. }
  4999. return new _mathMLTree2.default.MathNode("mo", inner);
  5000. };
  5001. groupTypes.katex = function (group) {
  5002. var node = new _mathMLTree2.default.MathNode("mtext", [new _mathMLTree2.default.TextNode("KaTeX")]);
  5003. return node;
  5004. };
  5005. groupTypes.font = function (group, options) {
  5006. var font = group.value.font;
  5007. return buildGroup(group.value.body, options.withFont(font));
  5008. };
  5009. groupTypes.styling = function (group, options) {
  5010. // Figure out what style we're changing to.
  5011. // TODO(kevinb): dedupe this with buildHTML.js
  5012. // This will be easier of handling of styling nodes is in the same file.
  5013. var styleMap = {
  5014. "display": _Style2.default.DISPLAY,
  5015. "text": _Style2.default.TEXT,
  5016. "script": _Style2.default.SCRIPT,
  5017. "scriptscript": _Style2.default.SCRIPTSCRIPT
  5018. };
  5019. var newStyle = styleMap[group.value.style];
  5020. var newOptions = options.havingStyle(newStyle);
  5021. var inner = buildExpression(group.value.value, newOptions);
  5022. var node = new _mathMLTree2.default.MathNode("mstyle", inner);
  5023. var styleAttributes = {
  5024. "display": ["0", "true"],
  5025. "text": ["0", "false"],
  5026. "script": ["1", "false"],
  5027. "scriptscript": ["2", "false"]
  5028. };
  5029. var attr = styleAttributes[group.value.style];
  5030. node.setAttribute("scriptlevel", attr[0]);
  5031. node.setAttribute("displaystyle", attr[1]);
  5032. return node;
  5033. };
  5034. groupTypes.sizing = function (group, options) {
  5035. var newOptions = options.havingSize(group.value.size);
  5036. var inner = buildExpression(group.value.value, newOptions);
  5037. var node = new _mathMLTree2.default.MathNode("mstyle", inner);
  5038. // TODO(emily): This doesn't produce the correct size for nested size
  5039. // changes, because we don't keep state of what style we're currently
  5040. // in, so we can't reset the size to normal before changing it. Now
  5041. // that we're passing an options parameter we should be able to fix
  5042. // this.
  5043. node.setAttribute("mathsize", newOptions.sizeMultiplier + "em");
  5044. return node;
  5045. };
  5046. groupTypes.verb = function (group, options) {
  5047. var text = new _mathMLTree2.default.TextNode(_buildCommon2.default.makeVerb(group, options));
  5048. var node = new _mathMLTree2.default.MathNode("mtext", [text]);
  5049. node.setAttribute("mathvariant", _buildCommon2.default.fontMap["mathtt"].variant);
  5050. return node;
  5051. };
  5052. groupTypes.overline = function (group, options) {
  5053. var operator = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode("\u203E")]);
  5054. operator.setAttribute("stretchy", "true");
  5055. var node = new _mathMLTree2.default.MathNode("mover", [buildGroup(group.value.body, options), operator]);
  5056. node.setAttribute("accent", "true");
  5057. return node;
  5058. };
  5059. groupTypes.underline = function (group, options) {
  5060. var operator = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode("\u203E")]);
  5061. operator.setAttribute("stretchy", "true");
  5062. var node = new _mathMLTree2.default.MathNode("munder", [buildGroup(group.value.body, options), operator]);
  5063. node.setAttribute("accentunder", "true");
  5064. return node;
  5065. };
  5066. groupTypes.accentUnder = function (group, options) {
  5067. var accentNode = _stretchy2.default.mathMLnode(group.value.label);
  5068. var node = new _mathMLTree2.default.MathNode("munder", [buildGroup(group.value.body, options), accentNode]);
  5069. node.setAttribute("accentunder", "true");
  5070. return node;
  5071. };
  5072. groupTypes.enclose = function (group, options) {
  5073. var node = new _mathMLTree2.default.MathNode("menclose", [buildGroup(group.value.body, options)]);
  5074. switch (group.value.label) {
  5075. case "\\cancel":
  5076. node.setAttribute("notation", "updiagonalstrike");
  5077. break;
  5078. case "\\bcancel":
  5079. node.setAttribute("notation", "downdiagonalstrike");
  5080. break;
  5081. case "\\sout":
  5082. node.setAttribute("notation", "horizontalstrike");
  5083. break;
  5084. case "\\fbox":
  5085. node.setAttribute("notation", "box");
  5086. break;
  5087. case "\\colorbox":
  5088. node.setAttribute("mathbackground", group.value.backgroundColor.value);
  5089. break;
  5090. case "\\fcolorbox":
  5091. node.setAttribute("mathbackground", group.value.backgroundColor.value);
  5092. // TODO(ron): I don't know any way to set the border color.
  5093. node.setAttribute("notation", "box");
  5094. break;
  5095. default:
  5096. // xcancel
  5097. node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
  5098. }
  5099. return node;
  5100. };
  5101. groupTypes.horizBrace = function (group, options) {
  5102. var accentNode = _stretchy2.default.mathMLnode(group.value.label);
  5103. return new _mathMLTree2.default.MathNode(group.value.isOver ? "mover" : "munder", [buildGroup(group.value.base, options), accentNode]);
  5104. };
  5105. groupTypes.xArrow = function (group, options) {
  5106. var arrowNode = _stretchy2.default.mathMLnode(group.value.label);
  5107. var node = void 0;
  5108. var lowerNode = void 0;
  5109. if (group.value.body) {
  5110. var upperNode = buildGroup(group.value.body, options);
  5111. if (group.value.below) {
  5112. lowerNode = buildGroup(group.value.below, options);
  5113. node = new _mathMLTree2.default.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
  5114. } else {
  5115. node = new _mathMLTree2.default.MathNode("mover", [arrowNode, upperNode]);
  5116. }
  5117. } else if (group.value.below) {
  5118. lowerNode = buildGroup(group.value.below, options);
  5119. node = new _mathMLTree2.default.MathNode("munder", [arrowNode, lowerNode]);
  5120. } else {
  5121. node = new _mathMLTree2.default.MathNode("mover", [arrowNode]);
  5122. }
  5123. return node;
  5124. };
  5125. groupTypes.rule = function (group) {
  5126. // TODO(emily): Figure out if there's an actual way to draw black boxes
  5127. // in MathML.
  5128. var node = new _mathMLTree2.default.MathNode("mrow");
  5129. return node;
  5130. };
  5131. groupTypes.kern = function (group) {
  5132. // TODO(kevin): Figure out if there's a way to add space in MathML
  5133. var node = new _mathMLTree2.default.MathNode("mrow");
  5134. return node;
  5135. };
  5136. groupTypes.lap = function (group, options) {
  5137. // mathllap, mathrlap, mathclap
  5138. var node = new _mathMLTree2.default.MathNode("mpadded", [buildGroup(group.value.body, options)]);
  5139. if (group.value.alignment !== "rlap") {
  5140. var offset = group.value.alignment === "llap" ? "-1" : "-0.5";
  5141. node.setAttribute("lspace", offset + "width");
  5142. }
  5143. node.setAttribute("width", "0px");
  5144. return node;
  5145. };
  5146. groupTypes.smash = function (group, options) {
  5147. var node = new _mathMLTree2.default.MathNode("mpadded", [buildGroup(group.value.body, options)]);
  5148. if (group.value.smashHeight) {
  5149. node.setAttribute("height", "0px");
  5150. }
  5151. if (group.value.smashDepth) {
  5152. node.setAttribute("depth", "0px");
  5153. }
  5154. return node;
  5155. };
  5156. groupTypes.mclass = function (group, options) {
  5157. var inner = buildExpression(group.value.value, options);
  5158. return new _mathMLTree2.default.MathNode("mstyle", inner);
  5159. };
  5160. groupTypes.raisebox = function (group, options) {
  5161. var node = new _mathMLTree2.default.MathNode("mpadded", [buildGroup(group.value.body, options)]);
  5162. var dy = group.value.dy.value.number + group.value.dy.value.unit;
  5163. node.setAttribute("voffset", dy);
  5164. return node;
  5165. };
  5166. /**
  5167. * Takes a list of nodes, builds them, and returns a list of the generated
  5168. * MathML nodes. A little simpler than the HTML version because we don't do any
  5169. * previous-node handling.
  5170. */
  5171. var buildExpression = exports.buildExpression = function buildExpression(expression, options) {
  5172. var groups = [];
  5173. for (var i = 0; i < expression.length; i++) {
  5174. var group = expression[i];
  5175. groups.push(buildGroup(group, options));
  5176. }
  5177. // TODO(kevinb): combine \\not with mrels and mords
  5178. return groups;
  5179. };
  5180. /**
  5181. * Takes a group from the parser and calls the appropriate groupTypes function
  5182. * on it to produce a MathML node.
  5183. */
  5184. var buildGroup = exports.buildGroup = function buildGroup(group, options) {
  5185. var removeUnnecessaryRow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5186. if (!group) {
  5187. return new _mathMLTree2.default.MathNode("mrow");
  5188. }
  5189. if (groupTypes[group.type]) {
  5190. // Call the groupTypes function
  5191. var r###lt = groupTypes[group.type](group, options);
  5192. if (removeUnnecessaryRow) {
  5193. if (r###lt.type === "mrow" && r###lt.children.length === 1) {
  5194. return r###lt.children[0];
  5195. }
  5196. }
  5197. return r###lt;
  5198. } else {
  5199. throw new _ParseError2.default("Got group of unknown type: '" + group.type + "'");
  5200. }
  5201. };
  5202. /**
  5203. * Takes a full parse tree and settings and builds a MathML representation of
  5204. * it. In particular, we put the elements from building the parse tree into a
  5205. * <semantics> tag so we can also include that TeX source as an annotation.
  5206. *
  5207. * Note that we actually return a domTree element with a `<math>` inside it so
  5208. * we can do appropriate styling.
  5209. */
  5210. function buildMathML(tree, texExpression, options) {
  5211. var expression = buildExpression(tree, options);
  5212. // Wrap up the expression in an mrow so it is presented in the semantics
  5213. // tag correctly.
  5214. var wrapper = new _mathMLTree2.default.MathNode("mrow", expression);
  5215. // Build a TeX annotation of the source
  5216. var annotation = new _mathMLTree2.default.MathNode("annotation", [new _mathMLTree2.default.TextNode(texExpression)]);
  5217. annotation.setAttribute("encoding", "application/x-tex");
  5218. var semantics = new _mathMLTree2.default.MathNode("semantics", [wrapper, annotation]);
  5219. var math = new _mathMLTree2.default.MathNode("math", [semantics]);
  5220. // You can't style <math> nodes, so we wrap the node in a span.
  5221. return _buildCommon2.default.makeSpan(["katex-mathml"], [math]);
  5222. }
  5223. },{"./ParseError":84,"./Style":89,"./buildCommon":91,"./fontMetrics":101,"./mathMLTree":108,"./stretchy":110,"./symbols":112,"./utils":115}],94:[function(require,module,exports){
  5224. "use strict";
  5225. Object.defineProperty(exports, "__esModule", {
  5226. value: true
  5227. });
  5228. var _buildHTML = require("./buildHTML");
  5229. var _buildHTML2 = _interopRequireDefault(_buildHTML);
  5230. var _buildMathML = require("./buildMathML");
  5231. var _buildMathML2 = _interopRequireDefault(_buildMathML);
  5232. var _buildCommon = require("./buildCommon");
  5233. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  5234. var _Options = require("./Options");
  5235. var _Options2 = _interopRequireDefault(_Options);
  5236. var _Settings = require("./Settings");
  5237. var _Settings2 = _interopRequireDefault(_Settings);
  5238. var _Style = require("./Style");
  5239. var _Style2 = _interopRequireDefault(_Style);
  5240. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5241. var buildTree = function buildTree(tree, expression, settings) {
  5242. settings = settings || new _Settings2.default({});
  5243. var startStyle = _Style2.default.TEXT;
  5244. if (settings.displayMode) {
  5245. startStyle = _Style2.default.DISPLAY;
  5246. }
  5247. // Setup the default options
  5248. var options = new _Options2.default({
  5249. style: startStyle,
  5250. maxSize: settings.maxSize
  5251. });
  5252. // `buildHTML` sometimes messes with the parse tree (like turning bins ->
  5253. // ords), so we build the MathML version first.
  5254. var mathMLNode = (0, _buildMathML2.default)(tree, expression, options);
  5255. var htmlNode = (0, _buildHTML2.default)(tree, options);
  5256. var katexNode = _buildCommon2.default.makeSpan(["katex"], [mathMLNode, htmlNode]);
  5257. if (settings.displayMode) {
  5258. return _buildCommon2.default.makeSpan(["katex-display"], [katexNode]);
  5259. } else {
  5260. return katexNode;
  5261. }
  5262. };
  5263. exports.default = buildTree;
  5264. },{"./Options":83,"./Settings":87,"./Style":89,"./buildCommon":91,"./buildHTML":92,"./buildMathML":93}],95:[function(require,module,exports){
  5265. "use strict";
  5266. Object.defineProperty(exports, "__esModule", {
  5267. value: true
  5268. });
  5269. exports._environments = undefined;
  5270. exports.default = defineEnvironment;
  5271. var _buildHTML = require("./buildHTML");
  5272. var _buildMathML = require("./buildMathML");
  5273. var _Options = require("./Options");
  5274. var _Options2 = _interopRequireDefault(_Options);
  5275. var _ParseNode = require("./ParseNode");
  5276. var _ParseNode2 = _interopRequireDefault(_ParseNode);
  5277. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5278. /**
  5279. * All registered environments.
  5280. * `environments.js` exports this same dictionary again and makes it public.
  5281. * `Parser.js` requires this dictionary via `environments.js`.
  5282. */
  5283. /**
  5284. * The context contains the following properties:
  5285. * - mode: current parsing mode.
  5286. * - envName: the name of the environment, one of the listed names.
  5287. * - parser: the parser object.
  5288. */
  5289. /**
  5290. * - context: information and references provided by the parser
  5291. * - args: an array of arguments passed to \begin{name}
  5292. * - optArgs: an array of optional arguments passed to \begin{name}
  5293. */
  5294. /**
  5295. * - numArgs: (default 0) The number of arguments after the \begin{name} function.
  5296. * - argTypes: (optional) Just like for a function
  5297. * - allowedInText: (default false) Whether or not the environment is allowed
  5298. * inside text mode (not enforced yet).
  5299. * - numOptionalArgs: (default 0) Just like for a function
  5300. */
  5301. /**
  5302. * Final enviornment spec for use at parse time.
  5303. * This is almost identical to `EnvDefSpec`, except it
  5304. * 1. includes the function handler
  5305. * 2. requires all arguments except argType
  5306. * It is generated by `defineEnvironment()` below.
  5307. */
  5308. var _environments = exports._environments = {};
  5309. function defineEnvironment(_ref) {
  5310. var type = _ref.type,
  5311. names = _ref.names,
  5312. props = _ref.props,
  5313. handler = _ref.handler,
  5314. htmlBuilder = _ref.htmlBuilder,
  5315. mathmlBuilder = _ref.mathmlBuilder;
  5316. // Set default values of environments
  5317. var data = {
  5318. numArgs: props.numArgs || 0,
  5319. greediness: 1,
  5320. allowedInText: false,
  5321. numOptionalArgs: 0,
  5322. handler: handler
  5323. };
  5324. for (var i = 0; i < names.length; ++i) {
  5325. _environments[names[i]] = data;
  5326. }
  5327. if (htmlBuilder) {
  5328. _buildHTML.groupTypes[type] = htmlBuilder;
  5329. }
  5330. if (mathmlBuilder) {
  5331. _buildMathML.groupTypes[type] = mathmlBuilder;
  5332. }
  5333. }
  5334. },{"./Options":83,"./ParseNode":85,"./buildHTML":92,"./buildMathML":93}],96:[function(require,module,exports){
  5335. "use strict";
  5336. Object.defineProperty(exports, "__esModule", {
  5337. value: true
  5338. });
  5339. exports.ordargument = exports._functions = undefined;
  5340. exports.default = defineFunction;
  5341. var _buildHTML = require("./buildHTML");
  5342. var _buildMathML = require("./buildMathML");
  5343. /**
  5344. * All registered functions.
  5345. * `functions.js` just exports this same dictionary again and makes it public.
  5346. * `Parser.js` requires this dictionary.
  5347. */
  5348. /** Context provided to function handlers for error messages. */
  5349. // TODO: Enumerate all allowed output types.
  5350. /**
  5351. * Final function spec for use at parse time.
  5352. * This is almost identical to `FunctionPropSpec`, except it
  5353. * 1. includes the function handler, and
  5354. * 2. requires all arguments except argTypes.
  5355. * It is generated by `defineFunction()` below.
  5356. */
  5357. var _functions = exports._functions = {};
  5358. function defineFunction(_ref) {
  5359. var type = _ref.type,
  5360. names = _ref.names,
  5361. props = _ref.props,
  5362. handler = _ref.handler,
  5363. htmlBuilder = _ref.htmlBuilder,
  5364. mathmlBuilder = _ref.mathmlBuilder;
  5365. // Set default values of functions
  5366. var data = {
  5367. numArgs: props.numArgs,
  5368. argTypes: props.argTypes,
  5369. greediness: props.greediness === undefined ? 1 : props.greediness,
  5370. allowedInText: !!props.allowedInText,
  5371. allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath,
  5372. numOptionalArgs: props.numOptionalArgs || 0,
  5373. infix: !!props.infix,
  5374. handler: handler
  5375. };
  5376. for (var i = 0; i < names.length; ++i) {
  5377. _functions[names[i]] = data;
  5378. }
  5379. if (type) {
  5380. if (htmlBuilder) {
  5381. _buildHTML.groupTypes[type] = htmlBuilder;
  5382. }
  5383. if (mathmlBuilder) {
  5384. _buildMathML.groupTypes[type] = mathmlBuilder;
  5385. }
  5386. }
  5387. }
  5388. // Since the corresponding buildHTML/buildMathML function expects a
  5389. // list of elements, we normalize for different kinds of arguments
  5390. var ordargument = exports.ordargument = function ordargument(arg) {
  5391. if (arg.type === "ordgroup") {
  5392. return arg.value;
  5393. } else {
  5394. return [arg];
  5395. }
  5396. };
  5397. },{"./buildHTML":92,"./buildMathML":93}],97:[function(require,module,exports){
  5398. "use strict";
  5399. Object.defineProperty(exports, "__esModule", {
  5400. value: true
  5401. });
  5402. var _ParseError = require("./ParseError");
  5403. var _ParseError2 = _interopRequireDefault(_ParseError);
  5404. var _Style = require("./Style");
  5405. var _Style2 = _interopRequireDefault(_Style);
  5406. var _domTree = require("./domTree");
  5407. var _domTree2 = _interopRequireDefault(_domTree);
  5408. var _buildCommon = require("./buildCommon");
  5409. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  5410. var _fontMetrics = require("./fontMetrics");
  5411. var _fontMetrics2 = _interopRequireDefault(_fontMetrics);
  5412. var _symbols = require("./symbols");
  5413. var _symbols2 = _interopRequireDefault(_symbols);
  5414. var _utils = require("./utils");
  5415. var _utils2 = _interopRequireDefault(_utils);
  5416. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5417. /**
  5418. * Get the metrics for a given symbol and font, after transformation (i.e.
  5419. * after following replacement from symbols.js)
  5420. */
  5421. var getMetrics = function getMetrics(symbol, font) {
  5422. if (_symbols2.default.math[symbol] && _symbols2.default.math[symbol].replace) {
  5423. return _fontMetrics2.default.getCharacterMetrics(_symbols2.default.math[symbol].replace, font);
  5424. } else {
  5425. return _fontMetrics2.default.getCharacterMetrics(symbol, font);
  5426. }
  5427. };
  5428. /**
  5429. * Puts a delimiter span in a given style, and adds appropriate height, depth,
  5430. * and maxFontSizes.
  5431. */
  5432. /**
  5433. * This file deals with creating delimiters of various sizes. The TeXbook
  5434. * discusses these routines on page 441-442, in the "Another subroutine sets box
  5435. * x to a specified variable delimiter" paragraph.
  5436. *
  5437. * There are three main routines here. `makeSmallDelim` makes a delimiter in the
  5438. * normal font, but in either text, script, or scriptscript style.
  5439. * `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1,
  5440. * Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of
  5441. * smaller pieces that are stacked on top of one another.
  5442. *
  5443. * The functions take a parameter `center`, which determines if the delimiter
  5444. * should be centered around the axis.
  5445. *
  5446. * Then, there are three exposed functions. `sizedDelim` makes a delimiter in
  5447. * one of the given sizes. This is used for things like `\bigl`.
  5448. * `customSizedDelim` makes a delimiter with a given total height+depth. It is
  5449. * called in places like `\sqrt`. `leftRightDelim` makes an appropriate
  5450. * delimiter which surrounds an expression of a given height an depth. It is
  5451. * used in `\left` and `\right`.
  5452. */
  5453. var styleWrap = function styleWrap(delim, toStyle, options, classes) {
  5454. var newOptions = options.havingBaseStyle(toStyle);
  5455. var span = _buildCommon2.default.makeSpan((classes || []).concat(newOptions.sizingClasses(options)), [delim], options);
  5456. span.delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier;
  5457. span.height *= span.delimSizeMultiplier;
  5458. span.depth *= span.delimSizeMultiplier;
  5459. span.maxFontSize = newOptions.sizeMultiplier;
  5460. return span;
  5461. };
  5462. var centerSpan = function centerSpan(span, options, style) {
  5463. var newOptions = options.havingBaseStyle(style);
  5464. var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight;
  5465. span.classes.push("delimcenter");
  5466. span.style.top = shift + "em";
  5467. span.height -= shift;
  5468. span.depth += shift;
  5469. };
  5470. /**
  5471. * Makes a small delimiter. This is a delimiter that comes in the Main-Regular
  5472. * font, but is restyled to either be in textstyle, scriptstyle, or
  5473. * scriptscriptstyle.
  5474. */
  5475. var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) {
  5476. var text = _buildCommon2.default.makeSymbol(delim, "Main-Regular", mode, options);
  5477. var span = styleWrap(text, style, options, classes);
  5478. if (center) {
  5479. centerSpan(span, options, style);
  5480. }
  5481. return span;
  5482. };
  5483. /**
  5484. * Builds a symbol in the given font size (note size is an integer)
  5485. */
  5486. var mathrmSize = function mathrmSize(value, size, mode, options) {
  5487. return _buildCommon2.default.makeSymbol(value, "Size" + size + "-Regular", mode, options);
  5488. };
  5489. /**
  5490. * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2,
  5491. * Size3, or Size4 fonts. It is always rendered in textstyle.
  5492. */
  5493. var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) {
  5494. var inner = mathrmSize(delim, size, mode, options);
  5495. var span = styleWrap(_buildCommon2.default.makeSpan(["delimsizing", "size" + size], [inner], options), _Style2.default.TEXT, options, classes);
  5496. if (center) {
  5497. centerSpan(span, options, _Style2.default.TEXT);
  5498. }
  5499. return span;
  5500. };
  5501. /**
  5502. * Make an inner span with the given offset and in the given font. This is used
  5503. * in `makeStackedDelim` to make the stacking pieces for the delimiter.
  5504. */
  5505. var makeInner = function makeInner(symbol, font, mode) {
  5506. var sizeClass = void 0;
  5507. // Apply the correct CSS class to choose the right font.
  5508. if (font === "Size1-Regular") {
  5509. sizeClass = "delim-size1";
  5510. } else if (font === "Size4-Regular") {
  5511. sizeClass = "delim-size4";
  5512. }
  5513. var inner = _buildCommon2.default.makeSpan(["delimsizinginner", sizeClass], [_buildCommon2.default.makeSpan([], [_buildCommon2.default.makeSymbol(symbol, font, mode)])]);
  5514. // Since this will be passed into `makeVList` in the end, wrap the element
  5515. // in the appropriate tag that VList uses.
  5516. return { type: "elem", elem: inner };
  5517. };
  5518. /**
  5519. * Make a stacked delimiter out of a given delimiter, with the total height at
  5520. * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook.
  5521. */
  5522. var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) {
  5523. // There are four parts, the top, an optional middle, a repeated part, and a
  5524. // bottom.
  5525. var top = void 0;
  5526. var middle = void 0;
  5527. var repeat = void 0;
  5528. var bottom = void 0;
  5529. top = repeat = bottom = delim;
  5530. middle = null;
  5531. // Also keep track of what font the delimiters are in
  5532. var font = "Size1-Regular";
  5533. // We set the parts and font based on the symbol. Note that we use
  5534. // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the
  5535. // repeats of the arrows
  5536. if (delim === "\\uparrow") {
  5537. repeat = bottom = "\u23D0";
  5538. } else if (delim === "\\Uparrow") {
  5539. repeat = bottom = "\u2016";
  5540. } else if (delim === "\\downarrow") {
  5541. top = repeat = "\u23D0";
  5542. } else if (delim === "\\Downarrow") {
  5543. top = repeat = "\u2016";
  5544. } else if (delim === "\\updownarrow") {
  5545. top = "\\uparrow";
  5546. repeat = "\u23D0";
  5547. bottom = "\\downarrow";
  5548. } else if (delim === "\\Updownarrow") {
  5549. top = "\\Uparrow";
  5550. repeat = "\u2016";
  5551. bottom = "\\Downarrow";
  5552. } else if (delim === "[" || delim === "\\lbrack") {
  5553. top = "\u23A1";
  5554. repeat = "\u23A2";
  5555. bottom = "\u23A3";
  5556. font = "Size4-Regular";
  5557. } else if (delim === "]" || delim === "\\rbrack") {
  5558. top = "\u23A4";
  5559. repeat = "\u23A5";
  5560. bottom = "\u23A6";
  5561. font = "Size4-Regular";
  5562. } else if (delim === "\\lfloor") {
  5563. repeat = top = "\u23A2";
  5564. bottom = "\u23A3";
  5565. font = "Size4-Regular";
  5566. } else if (delim === "\\lceil") {
  5567. top = "\u23A1";
  5568. repeat = bottom = "\u23A2";
  5569. font = "Size4-Regular";
  5570. } else if (delim === "\\rfloor") {
  5571. repeat = top = "\u23A5";
  5572. bottom = "\u23A6";
  5573. font = "Size4-Regular";
  5574. } else if (delim === "\\rceil") {
  5575. top = "\u23A4";
  5576. repeat = bottom = "\u23A5";
  5577. font = "Size4-Regular";
  5578. } else if (delim === "(") {
  5579. top = "\u239B";
  5580. repeat = "\u239C";
  5581. bottom = "\u239D";
  5582. font = "Size4-Regular";
  5583. } else if (delim === ")") {
  5584. top = "\u239E";
  5585. repeat = "\u239F";
  5586. bottom = "\u23A0";
  5587. font = "Size4-Regular";
  5588. } else if (delim === "\\{" || delim === "\\lbrace") {
  5589. top = "\u23A7";
  5590. middle = "\u23A8";
  5591. bottom = "\u23A9";
  5592. repeat = "\u23AA";
  5593. font = "Size4-Regular";
  5594. } else if (delim === "\\}" || delim === "\\rbrace") {
  5595. top = "\u23AB";
  5596. middle = "\u23AC";
  5597. bottom = "\u23AD";
  5598. repeat = "\u23AA";
  5599. font = "Size4-Regular";
  5600. } else if (delim === "\\lgroup") {
  5601. top = "\u23A7";
  5602. bottom = "\u23A9";
  5603. repeat = "\u23AA";
  5604. font = "Size4-Regular";
  5605. } else if (delim === "\\rgroup") {
  5606. top = "\u23AB";
  5607. bottom = "\u23AD";
  5608. repeat = "\u23AA";
  5609. font = "Size4-Regular";
  5610. } else if (delim === "\\lmoustache") {
  5611. top = "\u23A7";
  5612. bottom = "\u23AD";
  5613. repeat = "\u23AA";
  5614. font = "Size4-Regular";
  5615. } else if (delim === "\\rmoustache") {
  5616. top = "\u23AB";
  5617. bottom = "\u23A9";
  5618. repeat = "\u23AA";
  5619. font = "Size4-Regular";
  5620. }
  5621. // Get the metrics of the four sections
  5622. var topMetrics = getMetrics(top, font);
  5623. var topHeightTotal = topMetrics.height + topMetrics.depth;
  5624. var repeatMetrics = getMetrics(repeat, font);
  5625. var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth;
  5626. var bottomMetrics = getMetrics(bottom, font);
  5627. var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth;
  5628. var middleHeightTotal = 0;
  5629. var middleFactor = 1;
  5630. if (middle !== null) {
  5631. var middleMetrics = getMetrics(middle, font);
  5632. middleHeightTotal = middleMetrics.height + middleMetrics.depth;
  5633. middleFactor = 2; // repeat symmetrically above and below middle
  5634. }
  5635. // Calcuate the minimal height that the delimiter can have.
  5636. // It is at least the size of the top, bottom, and optional middle combined.
  5637. var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal;
  5638. // Compute the number of copies of the repeat symbol we will need
  5639. var repeatCount = Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal));
  5640. // Compute the total height of the delimiter including all the symbols
  5641. var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal;
  5642. // The center of the delimiter is placed at the center of the axis. Note
  5643. // that in this context, "center" means that the delimiter should be
  5644. // centered around the axis in the current style, while normally it is
  5645. // centered around the axis in textstyle.
  5646. var axisHeight = options.fontMetrics().axisHeight;
  5647. if (center) {
  5648. axisHeight *= options.sizeMultiplier;
  5649. }
  5650. // Calculate the depth
  5651. var depth = realHeightTotal / 2 - axisHeight;
  5652. // Now, we start building the pieces that will go into the vlist
  5653. // Keep a list of the inner pieces
  5654. var inners = [];
  5655. // Add the bottom symbol
  5656. inners.push(makeInner(bottom, font, mode));
  5657. if (middle === null) {
  5658. // Add that many symbols
  5659. for (var i = 0; i < repeatCount; i++) {
  5660. inners.push(makeInner(repeat, font, mode));
  5661. }
  5662. } else {
  5663. // When there is a middle bit, we need the middle part and two repeated
  5664. // sections
  5665. for (var _i = 0; _i < repeatCount; _i++) {
  5666. inners.push(makeInner(repeat, font, mode));
  5667. }
  5668. inners.push(makeInner(middle, font, mode));
  5669. for (var _i2 = 0; _i2 < repeatCount; _i2++) {
  5670. inners.push(makeInner(repeat, font, mode));
  5671. }
  5672. }
  5673. // Add the top symbol
  5674. inners.push(makeInner(top, font, mode));
  5675. // Finally, build the vlist
  5676. var newOptions = options.havingBaseStyle(_Style2.default.TEXT);
  5677. var inner = _buildCommon2.default.makeVList(inners, "bottom", depth, newOptions);
  5678. return styleWrap(_buildCommon2.default.makeSpan(["delimsizing", "mult"], [inner], newOptions), _Style2.default.TEXT, options, classes);
  5679. };
  5680. var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, options) {
  5681. var alternate = void 0;
  5682. if (sqrtName === "sqrtTall") {
  5683. // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular
  5684. // One path edge has a variable length. It runs from the viniculumn
  5685. // to a point near (14 units) the bottom of the surd. The viniculum
  5686. // is 40 units thick. So the length of the line in question is:
  5687. var vertSegment = viewBoxHeight - 54;
  5688. 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";
  5689. }
  5690. var pathNode = new _domTree2.default.pathNode(sqrtName, alternate);
  5691. // Note: 1000:1 ratio of viewBox to document em width.
  5692. var attributes = [["width", "400em"], ["height", height + "em"]];
  5693. attributes.push(["viewBox", "0 0 400000 " + viewBoxHeight]);
  5694. attributes.push(["preserveAspectRatio", "xMinYMin slice"]);
  5695. var svg = new _domTree2.default.svgNode([pathNode], attributes);
  5696. return _buildCommon2.default.makeSpan(["hide-tail"], [svg], options);
  5697. };
  5698. var sqrtSpan = function sqrtSpan(height, delim, options) {
  5699. // Create a span containing an SVG image of a sqrt symbol.
  5700. var span = void 0;
  5701. var sizeMultiplier = options.sizeMultiplier; // default
  5702. var spanHeight = void 0;
  5703. var viewBoxHeight = void 0;
  5704. if (delim.type === "small") {
  5705. // Get an SVG that is derived from glyph U+221A in font KaTeX-Main.
  5706. viewBoxHeight = 1000; // from font
  5707. var newOptions = options.havingBaseStyle(delim.style);
  5708. sizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier;
  5709. spanHeight = 1 * sizeMultiplier;
  5710. span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, options);
  5711. span.style.minWidth = "0.853em";
  5712. span.advanceWidth = 0.833 * sizeMultiplier; // from the font.
  5713. } else if (delim.type === "large") {
  5714. // These SVGs come from fonts: KaTeX_Size1, _Size2, etc.
  5715. viewBoxHeight = 1000 * sizeToMaxHeight[delim.size];
  5716. spanHeight = sizeToMaxHeight[delim.size] / sizeMultiplier;
  5717. span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, options);
  5718. span.style.minWidth = "1.02em";
  5719. span.advanceWidth = 1.0 / sizeMultiplier; // from the font
  5720. } else {
  5721. // Tall sqrt. In TeX, this would be stacked using multiple glyphs.
  5722. // We'll use a single SVG to accomplish the same thing.
  5723. spanHeight = height / sizeMultiplier;
  5724. viewBoxHeight = Math.floor(1000 * height);
  5725. span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, options);
  5726. span.style.minWidth = "0.742em";
  5727. span.advanceWidth = 1.056 / sizeMultiplier;
  5728. }
  5729. span.height = spanHeight;
  5730. span.style.height = spanHeight + "em";
  5731. span.sizeMultiplier = sizeMultiplier;
  5732. return span;
  5733. };
  5734. // There are three kinds of delimiters, delimiters that stack when they become
  5735. // too large
  5736. var stackLargeDelimiters = ["(", ")", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\\lceil", "\\rceil", "\\surd"];
  5737. // delimiters that always stack
  5738. var stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache"];
  5739. // and delimiters that never stack
  5740. var stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"];
  5741. // Metrics of the different sizes. Found by looking at TeX's output of
  5742. // $\bigl| // \Bigl| \biggl| \Biggl| \showlists$
  5743. // Used to create stacked delimiters of appropriate sizes in makeSizedDelim.
  5744. var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0];
  5745. /**
  5746. * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4.
  5747. */
  5748. var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) {
  5749. // < and > turn into \langle and \rangle in delimiters
  5750. if (delim === "<" || delim === "\\lt") {
  5751. delim = "\\langle";
  5752. } else if (delim === ">" || delim === "\\gt") {
  5753. delim = "\\rangle";
  5754. }
  5755. // Sized delimiters are never centered.
  5756. if (_utils2.default.contains(stackLargeDelimiters, delim) || _utils2.default.contains(stackNeverDelimiters, delim)) {
  5757. return makeLargeDelim(delim, size, false, options, mode, classes);
  5758. } else if (_utils2.default.contains(stackAlwaysDelimiters, delim)) {
  5759. return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes);
  5760. } else {
  5761. throw new _ParseError2.default("Illegal delimiter: '" + delim + "'");
  5762. }
  5763. };
  5764. /**
  5765. * There are three different sequences of delimiter sizes that the delimiters
  5766. * follow depending on the kind of delimiter. This is used when creating custom
  5767. * sized delimiters to decide whether to create a small, large, or stacked
  5768. * delimiter.
  5769. *
  5770. * In real TeX, these sequences aren't explicitly defined, but are instead
  5771. * defined inside the font metrics. Since there are only three sequences that
  5772. * are possible for the delimiters that TeX defines, it is easier to just encode
  5773. * them explicitly here.
  5774. */
  5775. // Delimiters that never stack try small delimiters and large delimiters only
  5776. 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 }];
  5777. // Delimiters that always stack try the small delimiters first, then stack
  5778. var stackAlwaysDelimiterSequence = [{ type: "small", style: _Style2.default.SCRIPTSCRIPT }, { type: "small", style: _Style2.default.SCRIPT }, { type: "small", style: _Style2.default.TEXT }, { type: "stack" }];
  5779. // Delimiters that stack when large try the small and then large delimiters, and
  5780. // stack afterwards
  5781. 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" }];
  5782. /**
  5783. * Get the font used in a delimiter based on what kind of delimiter it is.
  5784. */
  5785. var delimTypeToFont = function delimTypeToFont(type) {
  5786. if (type.type === "small") {
  5787. return "Main-Regular";
  5788. } else if (type.type === "large") {
  5789. return "Size" + type.size + "-Regular";
  5790. } else if (type.type === "stack") {
  5791. return "Size4-Regular";
  5792. }
  5793. };
  5794. /**
  5795. * Traverse a sequence of types of delimiters to decide what kind of delimiter
  5796. * should be used to create a delimiter of the given height+depth.
  5797. */
  5798. var traverseSequence = function traverseSequence(delim, height, sequence, options) {
  5799. // Here, we choose the index we should start at in the sequences. In smaller
  5800. // sizes (which correspond to larger numbers in style.size) we start earlier
  5801. // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts
  5802. // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2
  5803. var start = Math.min(2, 3 - options.style.size);
  5804. for (var i = start; i < sequence.length; i++) {
  5805. if (sequence[i].type === "stack") {
  5806. // This is always the last delimiter, so we just break the loop now.
  5807. break;
  5808. }
  5809. var metrics = getMetrics(delim, delimTypeToFont(sequence[i]));
  5810. var heightDepth = metrics.height + metrics.depth;
  5811. // Small delimiters are scaled down versions of the same font, so we
  5812. // account for the style change size.
  5813. if (sequence[i].type === "small") {
  5814. var newOptions = options.havingBaseStyle(sequence[i].style);
  5815. heightDepth *= newOptions.sizeMultiplier;
  5816. }
  5817. // Check if the delimiter at this size works for the given height.
  5818. if (heightDepth > height) {
  5819. return sequence[i];
  5820. }
  5821. }
  5822. // If we reached the end of the sequence, return the last sequence element.
  5823. return sequence[sequence.length - 1];
  5824. };
  5825. /**
  5826. * Make a delimiter of a given height+depth, with optional centering. Here, we
  5827. * traverse the sequences, and create a delimiter that the sequence tells us to.
  5828. */
  5829. var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) {
  5830. if (delim === "<" || delim === "\\lt") {
  5831. delim = "\\langle";
  5832. } else if (delim === ">" || delim === "\\gt") {
  5833. delim = "\\rangle";
  5834. }
  5835. // Decide what sequence to use
  5836. var sequence = void 0;
  5837. if (_utils2.default.contains(stackNeverDelimiters, delim)) {
  5838. sequence = stackNeverDelimiterSequence;
  5839. } else if (_utils2.default.contains(stackLargeDelimiters, delim)) {
  5840. sequence = stackLargeDelimiterSequence;
  5841. } else {
  5842. sequence = stackAlwaysDelimiterSequence;
  5843. }
  5844. // Look through the sequence
  5845. var delimType = traverseSequence(delim, height, sequence, options);
  5846. if (delim === "\\surd") {
  5847. // Get an SVG image
  5848. return sqrtSpan(height, delimType, options);
  5849. } else {
  5850. // Get the delimiter from font glyphs.
  5851. // Depending on the sequence element we decided on, call the
  5852. // appropriate function.
  5853. if (delimType.type === "small") {
  5854. return makeSmallDelim(delim, delimType.style, center, options, mode, classes);
  5855. } else if (delimType.type === "large") {
  5856. return makeLargeDelim(delim, delimType.size, center, options, mode, classes);
  5857. } else if (delimType.type === "stack") {
  5858. return makeStackedDelim(delim, height, center, options, mode, classes);
  5859. }
  5860. }
  5861. };
  5862. /**
  5863. * Make a delimiter for use with `\left` and `\right`, given a height and depth
  5864. * of an expression that the delimiters surround.
  5865. */
  5866. var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) {
  5867. // We always center \left/\right delimiters, so the axis is always shifted
  5868. var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier;
  5869. // Taken from TeX source, tex.web, function make_left_right
  5870. var delimiterFactor = 901;
  5871. var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm;
  5872. var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight);
  5873. var totalHeight = Math.max(
  5874. // In real TeX, calculations are done using integral values which are
  5875. // 65536 per pt, or 655360 per em. So, the division here truncates in
  5876. // TeX but doesn't here, producing different r###lts. If we wanted to
  5877. // exactly match TeX's calculation, we could do
  5878. // Math.floor(655360 * maxDistFromAxis / 500) *
  5879. // delimiterFactor / 655360
  5880. // (To see the difference, compare
  5881. // x^{x^{\left(\rule{0.1em}{0.68em}\right)}}
  5882. // in TeX and KaTeX)
  5883. maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend);
  5884. // Finally, we defer to `makeCustomSizedDelim` with our calculated total
  5885. // height
  5886. return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes);
  5887. };
  5888. exports.default = {
  5889. sizedDelim: makeSizedDelim,
  5890. customSizedDelim: makeCustomSizedDelim,
  5891. leftRightDelim: makeLeftRightDelim
  5892. };
  5893. },{"./ParseError":84,"./Style":89,"./buildCommon":91,"./domTree":98,"./fontMetrics":101,"./symbols":112,"./utils":115}],98:[function(require,module,exports){
  5894. "use strict";
  5895. Object.defineProperty(exports, "__esModule", {
  5896. value: true
  5897. });
  5898. var _slicedToArray2 = require("babel-runtime/helpers/slicedToArray");
  5899. var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
  5900. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  5901. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  5902. var _createClass2 = require("babel-runtime/helpers/createClass");
  5903. var _createClass3 = _interopRequireDefault(_createClass2);
  5904. var _unicodeRegexes = require("./unicodeRegexes");
  5905. var _utils = require("./utils");
  5906. var _utils2 = _interopRequireDefault(_utils);
  5907. var _svgGeometry = require("./svgGeometry");
  5908. var _svgGeometry2 = _interopRequireDefault(_svgGeometry);
  5909. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5910. /**
  5911. * Create an HTML className based on a list of classes. In addition to joining
  5912. * with spaces, we also remove null or empty classes.
  5913. */
  5914. var createClass = function createClass(classes) {
  5915. classes = classes.slice();
  5916. for (var i = classes.length - 1; i >= 0; i--) {
  5917. if (!classes[i]) {
  5918. classes.splice(i, 1);
  5919. }
  5920. }
  5921. return classes.join(" ");
  5922. };
  5923. /**
  5924. * This node represents a span node, with a className, a list of children, and
  5925. * an inline style. It also contains information about its height, depth, and
  5926. * maxFontSize.
  5927. */
  5928. /**
  5929. * These objects store the data about the DOM nodes we create, as well as some
  5930. * extra data. They can then be transformed into real DOM nodes with the
  5931. * `toNode` function or HTML markup using `toMarkup`. They are useful for both
  5932. * storing extra properties on the nodes, as well as providing a way to easily
  5933. * work with the DOM.
  5934. *
  5935. * Similar functions for working with MathML nodes exist in mathMLTree.js.
  5936. */
  5937. var span = function () {
  5938. function span(classes, children, options) {
  5939. (0, _classCallCheck3.default)(this, span);
  5940. this.classes = classes || [];
  5941. this.children = children || [];
  5942. this.height = 0;
  5943. this.depth = 0;
  5944. this.maxFontSize = 0;
  5945. this.style = {};
  5946. this.attributes = {};
  5947. if (options) {
  5948. if (options.style.isTight()) {
  5949. this.classes.push("mtight");
  5950. }
  5951. if (options.getColor()) {
  5952. this.style.color = options.getColor();
  5953. }
  5954. }
  5955. }
  5956. /**
  5957. * Sets an arbitrary attribute on the span. Warning: use this wisely. Not all
  5958. * browsers support attributes the same, and having too many custom attributes
  5959. * is probably bad.
  5960. */
  5961. (0, _createClass3.default)(span, [{
  5962. key: "setAttribute",
  5963. value: function setAttribute(attribute, value) {
  5964. this.attributes[attribute] = value;
  5965. }
  5966. }, {
  5967. key: "tryCombine",
  5968. value: function tryCombine(sibling) {
  5969. return false;
  5970. }
  5971. /**
  5972. * Convert the span into an HTML node
  5973. */
  5974. }, {
  5975. key: "toNode",
  5976. value: function toNode() {
  5977. var span = document.createElement("span");
  5978. // Apply the class
  5979. span.className = createClass(this.classes);
  5980. // Apply inline styles
  5981. for (var style in this.style) {
  5982. if (Object.prototype.hasOwnProperty.call(this.style, style)) {
  5983. span.style[style] = this.style[style];
  5984. }
  5985. }
  5986. // Apply attributes
  5987. for (var attr in this.attributes) {
  5988. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  5989. span.setAttribute(attr, this.attributes[attr]);
  5990. }
  5991. }
  5992. // Append the children, also as HTML nodes
  5993. for (var i = 0; i < this.children.length; i++) {
  5994. span.appendChild(this.children[i].toNode());
  5995. }
  5996. return span;
  5997. }
  5998. /**
  5999. * Convert the span into an HTML markup string
  6000. */
  6001. }, {
  6002. key: "toMarkup",
  6003. value: function toMarkup() {
  6004. var markup = "<span";
  6005. // Add the class
  6006. if (this.classes.length) {
  6007. markup += " class=\"";
  6008. markup += _utils2.default.escape(createClass(this.classes));
  6009. markup += "\"";
  6010. }
  6011. var styles = "";
  6012. // Add the styles, after hyphenation
  6013. for (var style in this.style) {
  6014. if (this.style.hasOwnProperty(style)) {
  6015. styles += _utils2.default.hyphenate(style) + ":" + this.style[style] + ";";
  6016. }
  6017. }
  6018. if (styles) {
  6019. markup += " style=\"" + _utils2.default.escape(styles) + "\"";
  6020. }
  6021. // Add the attributes
  6022. for (var attr in this.attributes) {
  6023. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  6024. markup += " " + attr + "=\"";
  6025. markup += _utils2.default.escape(this.attributes[attr]);
  6026. markup += "\"";
  6027. }
  6028. }
  6029. markup += ">";
  6030. // Add the markup of the children, also as markup
  6031. for (var i = 0; i < this.children.length; i++) {
  6032. markup += this.children[i].toMarkup();
  6033. }
  6034. markup += "</span>";
  6035. return markup;
  6036. }
  6037. }]);
  6038. return span;
  6039. }();
  6040. /**
  6041. * This node represents a document fragment, which contains elements, but when
  6042. * placed into the DOM doesn't have any representation itself. Thus, it only
  6043. * contains children and doesn't have any HTML properties. It also keeps track
  6044. * of a height, depth, and maxFontSize.
  6045. */
  6046. var documentFragment = function () {
  6047. function documentFragment(children) {
  6048. (0, _classCallCheck3.default)(this, documentFragment);
  6049. this.children = children || [];
  6050. this.height = 0;
  6051. this.depth = 0;
  6052. this.maxFontSize = 0;
  6053. }
  6054. /**
  6055. * Convert the fragment into a node
  6056. */
  6057. (0, _createClass3.default)(documentFragment, [{
  6058. key: "toNode",
  6059. value: function toNode() {
  6060. // Create a fragment
  6061. var frag = document.createDocumentFragment();
  6062. // Append the children
  6063. for (var i = 0; i < this.children.length; i++) {
  6064. frag.appendChild(this.children[i].toNode());
  6065. }
  6066. return frag;
  6067. }
  6068. /**
  6069. * Convert the fragment into HTML markup
  6070. */
  6071. }, {
  6072. key: "toMarkup",
  6073. value: function toMarkup() {
  6074. var markup = "";
  6075. // Simply concatenate the markup for the children together
  6076. for (var i = 0; i < this.children.length; i++) {
  6077. markup += this.children[i].toMarkup();
  6078. }
  6079. return markup;
  6080. }
  6081. }]);
  6082. return documentFragment;
  6083. }();
  6084. var iCombinations = {
  6085. 'î': "\u0131\u0302",
  6086. 'ï': "\u0131\u0308",
  6087. 'í': "\u0131\u0301",
  6088. // 'ī': '\u0131\u0304', // enable when we add Extended Latin
  6089. 'ì': "\u0131\u0300"
  6090. };
  6091. /**
  6092. * A symbol node contains information about a single symbol. It either renders
  6093. * to a single text node, or a span with a single text node in it, depending on
  6094. * whether it has CSS classes, styles, or needs italic correction.
  6095. */
  6096. var symbolNode = function () {
  6097. function symbolNode(value, height, depth, italic, skew, classes, style) {
  6098. (0, _classCallCheck3.default)(this, symbolNode);
  6099. this.value = value || "";
  6100. this.height = height || 0;
  6101. this.depth = depth || 0;
  6102. this.italic = italic || 0;
  6103. this.skew = skew || 0;
  6104. this.classes = classes || [];
  6105. this.style = style || {};
  6106. this.maxFontSize = 0;
  6107. // Mark CJK characters with specific classes so that we can specify which
  6108. // fonts to use. This allows us to render these characters with a serif
  6109. // font in situations where the browser would either default to a sans serif
  6110. // or render a placeholder character.
  6111. if (_unicodeRegexes.cjkRegex.test(value)) {
  6112. // I couldn't find any fonts that contained Hangul as well as all of
  6113. // the other characters we wanted to test there for it gets its own
  6114. // CSS class.
  6115. if (_unicodeRegexes.hangulRegex.test(value)) {
  6116. this.classes.push('hangul_fallback');
  6117. } else {
  6118. this.classes.push('cjk_fallback');
  6119. }
  6120. }
  6121. if (/[îïíì]/.test(this.value)) {
  6122. // add ī when we add Extended Latin
  6123. this.value = iCombinations[this.value];
  6124. }
  6125. }
  6126. (0, _createClass3.default)(symbolNode, [{
  6127. key: "tryCombine",
  6128. value: function tryCombine(sibling) {
  6129. if (!sibling || !(sibling instanceof symbolNode) || this.italic > 0 || createClass(this.classes) !== createClass(sibling.classes) || this.skew !== sibling.skew || this.maxFontSize !== sibling.maxFontSize) {
  6130. return false;
  6131. }
  6132. for (var style in this.style) {
  6133. if (this.style.hasOwnProperty(style) && this.style[style] !== sibling.style[style]) {
  6134. return false;
  6135. }
  6136. }
  6137. for (var _style in sibling.style) {
  6138. if (sibling.style.hasOwnProperty(_style) && this.style[_style] !== sibling.style[_style]) {
  6139. return false;
  6140. }
  6141. }
  6142. this.value += sibling.value;
  6143. this.height = Math.max(this.height, sibling.height);
  6144. this.depth = Math.max(this.depth, sibling.depth);
  6145. this.italic = sibling.italic;
  6146. return true;
  6147. }
  6148. /**
  6149. * Creates a text node or span from a symbol node. Note that a span is only
  6150. * created if it is needed.
  6151. */
  6152. }, {
  6153. key: "toNode",
  6154. value: function toNode() {
  6155. var node = document.createTextNode(this.value);
  6156. var span = null;
  6157. if (this.italic > 0) {
  6158. span = document.createElement("span");
  6159. span.style.marginRight = this.italic + "em";
  6160. }
  6161. if (this.classes.length > 0) {
  6162. span = span || document.createElement("span");
  6163. span.className = createClass(this.classes);
  6164. }
  6165. for (var style in this.style) {
  6166. if (this.style.hasOwnProperty(style)) {
  6167. span = span || document.createElement("span");
  6168. span.style[style] = this.style[style];
  6169. }
  6170. }
  6171. if (span) {
  6172. span.appendChild(node);
  6173. return span;
  6174. } else {
  6175. return node;
  6176. }
  6177. }
  6178. /**
  6179. * Creates markup for a symbol node.
  6180. */
  6181. }, {
  6182. key: "toMarkup",
  6183. value: function toMarkup() {
  6184. // TODO(alpert): More duplication than I'd like from
  6185. // span.prototype.toMarkup and symbolNode.prototype.toNode...
  6186. var needsSpan = false;
  6187. var markup = "<span";
  6188. if (this.classes.length) {
  6189. needsSpan = true;
  6190. markup += " class=\"";
  6191. markup += _utils2.default.escape(createClass(this.classes));
  6192. markup += "\"";
  6193. }
  6194. var styles = "";
  6195. if (this.italic > 0) {
  6196. styles += "margin-right:" + this.italic + "em;";
  6197. }
  6198. for (var style in this.style) {
  6199. if (this.style.hasOwnProperty(style)) {
  6200. styles += _utils2.default.hyphenate(style) + ":" + this.style[style] + ";";
  6201. }
  6202. }
  6203. if (styles) {
  6204. needsSpan = true;
  6205. markup += " style=\"" + _utils2.default.escape(styles) + "\"";
  6206. }
  6207. var escaped = _utils2.default.escape(this.value);
  6208. if (needsSpan) {
  6209. markup += ">";
  6210. markup += escaped;
  6211. markup += "</span>";
  6212. return markup;
  6213. } else {
  6214. return escaped;
  6215. }
  6216. }
  6217. }]);
  6218. return symbolNode;
  6219. }();
  6220. /**
  6221. * SVG nodes are used to render stretchy wide elements.
  6222. */
  6223. var svgNode = function () {
  6224. function svgNode(children, attributes) {
  6225. (0, _classCallCheck3.default)(this, svgNode);
  6226. this.children = children || [];
  6227. this.attributes = attributes || [];
  6228. }
  6229. (0, _createClass3.default)(svgNode, [{
  6230. key: "toNode",
  6231. value: function toNode() {
  6232. var svgNS = "http://www.w3.org/2000/svg";
  6233. var node = document.createElementNS(svgNS, "svg");
  6234. // Apply attributes
  6235. for (var i = 0; i < this.attributes.length; i++) {
  6236. var _attributes$i = (0, _slicedToArray3.default)(this.attributes[i], 2),
  6237. name = _attributes$i[0],
  6238. value = _attributes$i[1];
  6239. node.setAttribute(name, value);
  6240. }
  6241. for (var _i = 0; _i < this.children.length; _i++) {
  6242. node.appendChild(this.children[_i].toNode());
  6243. }
  6244. return node;
  6245. }
  6246. }, {
  6247. key: "toMarkup",
  6248. value: function toMarkup() {
  6249. var markup = "<svg";
  6250. // Apply attributes
  6251. for (var i = 0; i < this.attributes.length; i++) {
  6252. var _attributes$i2 = (0, _slicedToArray3.default)(this.attributes[i], 2),
  6253. name = _attributes$i2[0],
  6254. value = _attributes$i2[1];
  6255. markup += " " + name + "='" + value + "'";
  6256. }
  6257. markup += ">";
  6258. for (var _i2 = 0; _i2 < this.children.length; _i2++) {
  6259. markup += this.children[_i2].toMarkup();
  6260. }
  6261. markup += "</svg>";
  6262. return markup;
  6263. }
  6264. }]);
  6265. return svgNode;
  6266. }();
  6267. var pathNode = function () {
  6268. function pathNode(pathName, alternate) {
  6269. (0, _classCallCheck3.default)(this, pathNode);
  6270. this.pathName = pathName;
  6271. this.alternate = alternate; // Used only for tall \sqrt
  6272. }
  6273. (0, _createClass3.default)(pathNode, [{
  6274. key: "toNode",
  6275. value: function toNode() {
  6276. var svgNS = "http://www.w3.org/2000/svg";
  6277. var node = document.createElementNS(svgNS, "path");
  6278. if (this.pathName !== "sqrtTall") {
  6279. node.setAttribute("d", _svgGeometry2.default.path[this.pathName]);
  6280. } else {
  6281. node.setAttribute("d", this.alternate);
  6282. }
  6283. return node;
  6284. }
  6285. }, {
  6286. key: "toMarkup",
  6287. value: function toMarkup() {
  6288. if (this.pathName !== "sqrtTall") {
  6289. return "<path d='" + _svgGeometry2.default.path[this.pathName] + "'/>";
  6290. } else {
  6291. return "<path d='" + this.alternate + "'/>";
  6292. }
  6293. }
  6294. }]);
  6295. return pathNode;
  6296. }();
  6297. var lineNode = function () {
  6298. function lineNode(attributes) {
  6299. (0, _classCallCheck3.default)(this, lineNode);
  6300. this.attributes = attributes || [];
  6301. }
  6302. (0, _createClass3.default)(lineNode, [{
  6303. key: "toNode",
  6304. value: function toNode() {
  6305. var svgNS = "http://www.w3.org/2000/svg";
  6306. var node = document.createElementNS(svgNS, "line");
  6307. // Apply attributes
  6308. for (var i = 0; i < this.attributes.length; i++) {
  6309. var _attributes$i3 = (0, _slicedToArray3.default)(this.attributes[i], 2),
  6310. name = _attributes$i3[0],
  6311. value = _attributes$i3[1];
  6312. node.setAttribute(name, value);
  6313. }
  6314. return node;
  6315. }
  6316. }, {
  6317. key: "toMarkup",
  6318. value: function toMarkup() {
  6319. var markup = "<line";
  6320. for (var i = 0; i < this.attributes.length; i++) {
  6321. var _attributes$i4 = (0, _slicedToArray3.default)(this.attributes[i], 2),
  6322. name = _attributes$i4[0],
  6323. value = _attributes$i4[1];
  6324. markup += " " + name + "='" + value + "'";
  6325. }
  6326. markup += "/>";
  6327. return markup;
  6328. }
  6329. }]);
  6330. return lineNode;
  6331. }();
  6332. exports.default = {
  6333. span: span,
  6334. documentFragment: documentFragment,
  6335. symbolNode: symbolNode,
  6336. svgNode: svgNode,
  6337. pathNode: pathNode,
  6338. lineNode: lineNode
  6339. };
  6340. },{"./svgGeometry":111,"./unicodeRegexes":113,"./utils":115,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9,"babel-runtime/helpers/slicedToArray":10}],99:[function(require,module,exports){
  6341. "use strict";
  6342. Object.defineProperty(exports, "__esModule", {
  6343. value: true
  6344. });
  6345. var _defineEnvironment = require("./defineEnvironment");
  6346. require("./environments/array.js");
  6347. var environments = {
  6348. has: function has(envName) {
  6349. return _defineEnvironment._environments.hasOwnProperty(envName);
  6350. },
  6351. get: function get(envName) {
  6352. return _defineEnvironment._environments[envName];
  6353. }
  6354. };
  6355. exports.default = environments;
  6356. // All environment definitions should be imported below
  6357. },{"./defineEnvironment":95,"./environments/array.js":100}],100:[function(require,module,exports){
  6358. "use strict";
  6359. var _buildCommon = require("../buildCommon");
  6360. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  6361. var _defineEnvironment = require("../defineEnvironment");
  6362. var _defineEnvironment2 = _interopRequireDefault(_defineEnvironment);
  6363. var _mathMLTree = require("../mathMLTree");
  6364. var _mathMLTree2 = _interopRequireDefault(_mathMLTree);
  6365. var _ParseError = require("../ParseError");
  6366. var _ParseError2 = _interopRequireDefault(_ParseError);
  6367. var _ParseNode = require("../ParseNode");
  6368. var _ParseNode2 = _interopRequireDefault(_ParseNode);
  6369. var _units = require("../units");
  6370. var _utils = require("../utils");
  6371. var _utils2 = _interopRequireDefault(_utils);
  6372. var _buildHTML = require("../buildHTML");
  6373. var html = _interopRequireWildcard(_buildHTML);
  6374. var _buildMathML = require("../buildMathML");
  6375. var mml = _interopRequireWildcard(_buildMathML);
  6376. 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; } }
  6377. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6378. /**
  6379. * Parse the body of the environment, with rows delimited by \\ and
  6380. * columns delimited by &, and create a nested list in row-major order
  6381. * with one group per cell. If given an optional argument style
  6382. * ("text", "display", etc.), then each cell is cast into that style.
  6383. */
  6384. // Data stored in the ParseNode associated with the environment.
  6385. function parseArray(parser, r###lt, style) {
  6386. var row = [];
  6387. var body = [row];
  6388. var rowGaps = [];
  6389. while (true) {
  6390. // eslint-disable-line no-constant-condition
  6391. var cell = parser.parseExpression(false, null);
  6392. cell = new _ParseNode2.default("ordgroup", cell, parser.mode);
  6393. if (style) {
  6394. cell = new _ParseNode2.default("styling", {
  6395. style: style,
  6396. value: [cell]
  6397. }, parser.mode);
  6398. }
  6399. row.push(cell);
  6400. var next = parser.nextToken.text;
  6401. if (next === "&") {
  6402. parser.consume();
  6403. } else if (next === "\\end") {
  6404. // Arrays terminate newlines with `\crcr` which consumes a `\cr` if
  6405. // the last line is empty.
  6406. var lastRow = body[body.length - 1][0].value;
  6407. if (body.length > 1 && lastRow.value.length === 1 && lastRow.value[0].value.length === 0) {
  6408. body.pop();
  6409. }
  6410. break;
  6411. } else if (next === "\\\\" || next === "\\cr") {
  6412. var cr = parser.parseFunction();
  6413. rowGaps.push(cr.value.size);
  6414. row = [];
  6415. body.push(row);
  6416. } else {
  6417. throw new _ParseError2.default("Expected & or \\\\ or \\end", parser.nextToken);
  6418. }
  6419. }
  6420. r###lt.body = body;
  6421. r###lt.rowGaps = rowGaps;
  6422. return new _ParseNode2.default(r###lt.type, r###lt, parser.mode);
  6423. }
  6424. // Decides on a style for cells in an array according to whether the given
  6425. // environment name starts with the letter 'd'.
  6426. function dCellStyle(envName) {
  6427. if (envName.substr(0, 1) === "d") {
  6428. return "display";
  6429. } else {
  6430. return "text";
  6431. }
  6432. }
  6433. var htmlBuilder = function htmlBuilder(group, options) {
  6434. var r = void 0;
  6435. var c = void 0;
  6436. var nr = group.value.body.length;
  6437. var nc = 0;
  6438. var body = new Array(nr);
  6439. // Horizontal spacing
  6440. var pt = 1 / options.fontMetrics().ptPerEm;
  6441. var arraycolsep = 5 * pt; // \arraycolsep in article.cls
  6442. // Vertical spacing
  6443. var baselineskip = 12 * pt; // see size10.clo
  6444. // Default \jot from ltmath.dtx
  6445. // TODO(edemaine): allow overriding \jot via \setlength (#687)
  6446. var jot = 3 * pt;
  6447. // Default \arraystretch from lttab.dtx
  6448. // TODO(gagern): may get redefined once we have user-defined macros
  6449. var arraystretch = _utils2.default.deflt(group.value.arraystretch, 1);
  6450. var arrayskip = arraystretch * baselineskip;
  6451. var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and
  6452. var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx
  6453. var totalHeight = 0;
  6454. for (r = 0; r < group.value.body.length; ++r) {
  6455. var inrow = group.value.body[r];
  6456. var _height = arstrutHeight; // \@array adds an \@arstrut
  6457. var _depth = arstrutDepth; // to each tow (via the template)
  6458. if (nc < inrow.length) {
  6459. nc = inrow.length;
  6460. }
  6461. var outrow = new Array(inrow.length);
  6462. for (c = 0; c < inrow.length; ++c) {
  6463. var elt = html.buildGroup(inrow[c], options);
  6464. if (_depth < elt.depth) {
  6465. _depth = elt.depth;
  6466. }
  6467. if (_height < elt.height) {
  6468. _height = elt.height;
  6469. }
  6470. outrow[c] = elt;
  6471. }
  6472. var gap = 0;
  6473. if (group.value.rowGaps[r]) {
  6474. gap = (0, _units.calculateSize)(group.value.rowGaps[r].value, options);
  6475. if (gap > 0) {
  6476. // \@argarraycr
  6477. gap += arstrutDepth;
  6478. if (_depth < gap) {
  6479. _depth = gap; // \@xargarraycr
  6480. }
  6481. gap = 0;
  6482. }
  6483. }
  6484. // In AMS multiline environments such as aligned and gathered, rows
  6485. // correspond to lines that have additional \jot added to the
  6486. // \baselineskip via \openup.
  6487. if (group.value.addJot) {
  6488. _depth += jot;
  6489. }
  6490. outrow.height = _height;
  6491. outrow.depth = _depth;
  6492. totalHeight += _height;
  6493. outrow.pos = totalHeight;
  6494. totalHeight += _depth + gap; // \@yargarraycr
  6495. body[r] = outrow;
  6496. }
  6497. var offset = totalHeight / 2 + options.fontMetrics().axisHeight;
  6498. var colDescriptions = group.value.cols || [];
  6499. var cols = [];
  6500. var colSep = void 0;
  6501. var colDescrNum = void 0;
  6502. for (c = 0, colDescrNum = 0;
  6503. // Continue while either there are more columns or more column
  6504. // descriptions, so trailing separators don't get lost.
  6505. c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) {
  6506. var colDescr = colDescriptions[colDescrNum] || {};
  6507. var firstSeparator = true;
  6508. while (colDescr.type === "separator") {
  6509. // If there is more than one separator in a row, add a space
  6510. // between them.
  6511. if (!firstSeparator) {
  6512. colSep = _buildCommon2.default.makeSpan(["arraycolsep"], []);
  6513. colSep.style.width = options.fontMetrics().doubleRuleSep + "em";
  6514. cols.push(colSep);
  6515. }
  6516. if (colDescr.separator === "|") {
  6517. var _separator = _buildCommon2.default.makeSpan(["vertical-separator"], []);
  6518. _separator.style.height = totalHeight + "em";
  6519. _separator.style.verticalAlign = -(totalHeight - offset) + "em";
  6520. cols.push(_separator);
  6521. } else {
  6522. throw new _ParseError2.default("Invalid separator type: " + colDescr.separator);
  6523. }
  6524. colDescrNum++;
  6525. colDescr = colDescriptions[colDescrNum] || {};
  6526. firstSeparator = false;
  6527. }
  6528. if (c >= nc) {
  6529. continue;
  6530. }
  6531. var sepwidth = void 0;
  6532. if (c > 0 || group.value.hskipBeforeAndAfter) {
  6533. sepwidth = _utils2.default.deflt(colDescr.pregap, arraycolsep);
  6534. if (sepwidth !== 0) {
  6535. colSep = _buildCommon2.default.makeSpan(["arraycolsep"], []);
  6536. colSep.style.width = sepwidth + "em";
  6537. cols.push(colSep);
  6538. }
  6539. }
  6540. var col = [];
  6541. for (r = 0; r < nr; ++r) {
  6542. var row = body[r];
  6543. var elem = row[c];
  6544. if (!elem) {
  6545. continue;
  6546. }
  6547. var shift = row.pos - offset;
  6548. elem.depth = row.depth;
  6549. elem.height = row.height;
  6550. col.push({ type: "elem", elem: elem, shift: shift });
  6551. }
  6552. col = _buildCommon2.default.makeVList(col, "individualShift", null, options);
  6553. col = _buildCommon2.default.makeSpan(["col-align-" + (colDescr.align || "c")], [col]);
  6554. cols.push(col);
  6555. if (c < nc - 1 || group.value.hskipBeforeAndAfter) {
  6556. sepwidth = _utils2.default.deflt(colDescr.postgap, arraycolsep);
  6557. if (sepwidth !== 0) {
  6558. colSep = _buildCommon2.default.makeSpan(["arraycolsep"], []);
  6559. colSep.style.width = sepwidth + "em";
  6560. cols.push(colSep);
  6561. }
  6562. }
  6563. }
  6564. body = _buildCommon2.default.makeSpan(["mtable"], cols);
  6565. return _buildCommon2.default.makeSpan(["mord"], [body], options);
  6566. };
  6567. var mathmlBuilder = function mathmlBuilder(group, options) {
  6568. return new _mathMLTree2.default.MathNode("mtable", group.value.body.map(function (row) {
  6569. return new _mathMLTree2.default.MathNode("mtr", row.map(function (cell) {
  6570. return new _mathMLTree2.default.MathNode("mtd", [mml.buildGroup(cell, options)]);
  6571. }));
  6572. }));
  6573. };
  6574. // Arrays are part of LaTeX, defined in lttab.dtx so its documentation
  6575. // is part of the source2e.pdf file of LaTeX2e source documentation.
  6576. // {darray} is an {array} environment where cells are set in \displaystyle,
  6577. // as defined in nccmath.sty.
  6578. (0, _defineEnvironment2.default)({
  6579. type: "array",
  6580. names: ["array", "darray"],
  6581. props: {
  6582. numArgs: 1
  6583. },
  6584. handler: function handler(context, args) {
  6585. var colalign = args[0];
  6586. colalign = colalign.value.map ? colalign.value : [colalign];
  6587. var cols = colalign.map(function (node) {
  6588. var ca = node.value;
  6589. if ("lcr".indexOf(ca) !== -1) {
  6590. return {
  6591. type: "align",
  6592. align: ca
  6593. };
  6594. } else if (ca === "|") {
  6595. return {
  6596. type: "separator",
  6597. separator: "|"
  6598. };
  6599. }
  6600. throw new _ParseError2.default("Unknown column alignment: " + node.value, node);
  6601. });
  6602. var res = {
  6603. type: "array",
  6604. cols: cols,
  6605. hskipBeforeAndAfter: true // \@preamble in lttab.dtx
  6606. };
  6607. res = parseArray(context.parser, res, dCellStyle(context.envName));
  6608. return res;
  6609. },
  6610. htmlBuilder: htmlBuilder,
  6611. mathmlBuilder: mathmlBuilder
  6612. });
  6613. // The matrix environments of amsmath builds on the array environment
  6614. // of LaTeX, which is discussed above.
  6615. (0, _defineEnvironment2.default)({
  6616. type: "array",
  6617. names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix"],
  6618. props: {
  6619. numArgs: 0
  6620. },
  6621. handler: function handler(context) {
  6622. var delimiters = {
  6623. "matrix": null,
  6624. "pmatrix": ["(", ")"],
  6625. "bmatrix": ["[", "]"],
  6626. "Bmatrix": ["\\{", "\\}"],
  6627. "vmatrix": ["|", "|"],
  6628. "Vmatrix": ["\\Vert", "\\Vert"]
  6629. }[context.envName];
  6630. var res = {
  6631. type: "array",
  6632. hskipBeforeAndAfter: false // \hskip -\arraycolsep in amsmath
  6633. };
  6634. res = parseArray(context.parser, res, dCellStyle(context.envName));
  6635. if (delimiters) {
  6636. res = new _ParseNode2.default("leftright", {
  6637. body: [res],
  6638. left: delimiters[0],
  6639. right: delimiters[1]
  6640. }, context.mode);
  6641. }
  6642. return res;
  6643. },
  6644. htmlBuilder: htmlBuilder,
  6645. mathmlBuilder: mathmlBuilder
  6646. });
  6647. // A cases environment (in amsmath.sty) is almost equivalent to
  6648. // \def\arraystretch{1.2}%
  6649. // \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
  6650. // {dcases} is a {cases} environment where cells are set in \displaystyle,
  6651. // as defined in mathtools.sty.
  6652. (0, _defineEnvironment2.default)({
  6653. type: "array",
  6654. names: ["cases", "dcases"],
  6655. props: {
  6656. numArgs: 0
  6657. },
  6658. handler: function handler(context) {
  6659. var res = {
  6660. type: "array",
  6661. arraystretch: 1.2,
  6662. cols: [{
  6663. type: "align",
  6664. align: "l",
  6665. pregap: 0,
  6666. // TODO(kevinb) get the current style.
  6667. // For now we use the metrics for TEXT style which is what we were
  6668. // doing before. Before attempting to get the current style we
  6669. // should look at TeX's behavior especially for \over and matrices.
  6670. postgap: 1.0 /* 1em quad */
  6671. }, {
  6672. type: "align",
  6673. align: "l",
  6674. pregap: 0,
  6675. postgap: 0
  6676. }]
  6677. };
  6678. res = parseArray(context.parser, res, dCellStyle(context.envName));
  6679. res = new _ParseNode2.default("leftright", {
  6680. body: [res],
  6681. left: "\\{",
  6682. right: "."
  6683. }, context.mode);
  6684. return res;
  6685. },
  6686. htmlBuilder: htmlBuilder,
  6687. mathmlBuilder: mathmlBuilder
  6688. });
  6689. // An aligned environment is like the align* environment
  6690. // except it operates within math mode.
  6691. // Note that we assume \nomallineskiplimit to be zero,
  6692. // so that \strut@ is the same as \strut.
  6693. (0, _defineEnvironment2.default)({
  6694. type: "array",
  6695. names: ["aligned"],
  6696. props: {
  6697. numArgs: 0
  6698. },
  6699. handler: function handler(context) {
  6700. var res = {
  6701. type: "array",
  6702. cols: [],
  6703. addJot: true
  6704. };
  6705. res = parseArray(context.parser, res, "display");
  6706. // Count number of columns = maximum number of cells in each row.
  6707. // At the same time, prepend empty group {} at beginning of every second
  6708. // cell in each row (starting with second cell) so that operators become
  6709. // binary. This behavior is implemented in amsmath's \start@aligned.
  6710. var emptyGroup = new _ParseNode2.default("ordgroup", [], context.mode);
  6711. var numCols = 0;
  6712. res.value.body.forEach(function (row) {
  6713. for (var i = 1; i < row.length; i += 2) {
  6714. // Modify ordgroup node within styling node
  6715. var ordgroup = row[i].value.value[0];
  6716. ordgroup.value.unshift(emptyGroup);
  6717. }
  6718. if (numCols < row.length) {
  6719. numCols = row.length;
  6720. }
  6721. });
  6722. for (var i = 0; i < numCols; ++i) {
  6723. var _align = "r";
  6724. var _pregap = 0;
  6725. if (i % 2 === 1) {
  6726. _align = "l";
  6727. } else if (i > 0) {
  6728. _pregap = 2; // one \qquad between columns
  6729. }
  6730. res.value.cols[i] = {
  6731. type: "align",
  6732. align: _align,
  6733. pregap: _pregap,
  6734. postgap: 0
  6735. };
  6736. }
  6737. return res;
  6738. },
  6739. htmlBuilder: htmlBuilder,
  6740. mathmlBuilder: mathmlBuilder
  6741. });
  6742. // A gathered environment is like an array environment with one centered
  6743. // column, but where rows are considered lines so get \jot line spacing
  6744. // and contents are set in \displaystyle.
  6745. (0, _defineEnvironment2.default)({
  6746. type: "array",
  6747. names: ["gathered"],
  6748. props: {
  6749. numArgs: 0
  6750. },
  6751. handler: function handler(context) {
  6752. var res = {
  6753. type: "array",
  6754. cols: [{
  6755. type: "align",
  6756. align: "c"
  6757. }],
  6758. addJot: true
  6759. };
  6760. res = parseArray(context.parser, res, "display");
  6761. return res;
  6762. },
  6763. htmlBuilder: htmlBuilder,
  6764. mathmlBuilder: mathmlBuilder
  6765. });
  6766. },{"../ParseError":84,"../ParseNode":85,"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineEnvironment":95,"../mathMLTree":108,"../units":114,"../utils":115}],101:[function(require,module,exports){
  6767. "use strict";
  6768. Object.defineProperty(exports, "__esModule", {
  6769. value: true
  6770. });
  6771. var _unicodeRegexes = require("./unicodeRegexes");
  6772. var _fontMetricsData = require("./fontMetricsData");
  6773. var _fontMetricsData2 = _interopRequireDefault(_fontMetricsData);
  6774. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6775. /**
  6776. * This file contains metrics regarding fonts and individual symbols. The sigma
  6777. * and xi variables, as well as the metricMap map contain data extracted from
  6778. * TeX, TeX font metrics, and the TTF files. These data are then exposed via the
  6779. * `metrics` variable and the getCharacterMetrics function.
  6780. */
  6781. // In TeX, there are actually three sets of dimensions, one for each of
  6782. // textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
  6783. // 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
  6784. // provided in the the arrays below, in that order.
  6785. //
  6786. // The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
  6787. // This was determined by running the following script:
  6788. //
  6789. // latex -interaction=nonstopmode \
  6790. // '\documentclass{article}\usepackage{amsmath}\begin{document}' \
  6791. // '$a$ \expandafter\show\the\textfont2' \
  6792. // '\expandafter\show\the\scriptfont2' \
  6793. // '\expandafter\show\the\scriptscriptfont2' \
  6794. // '\stop'
  6795. //
  6796. // The metrics themselves were retreived using the following commands:
  6797. //
  6798. // tftopl cmsy10
  6799. // tftopl cmsy7
  6800. // tftopl cmsy5
  6801. //
  6802. // The output of each of these commands is quite lengthy. The only part we
  6803. // care about is the FONTDIMEN section. Each value is measured in EMs.
  6804. var sigmasAndXis = {
  6805. slant: [0.250, 0.250, 0.250], // sigma1
  6806. space: [0.000, 0.000, 0.000], // sigma2
  6807. stretch: [0.000, 0.000, 0.000], // sigma3
  6808. shrink: [0.000, 0.000, 0.000], // sigma4
  6809. xHeight: [0.431, 0.431, 0.431], // sigma5
  6810. quad: [1.000, 1.171, 1.472], // sigma6
  6811. extraSpace: [0.000, 0.000, 0.000], // sigma7
  6812. num1: [0.677, 0.732, 0.925], // sigma8
  6813. num2: [0.394, 0.384, 0.387], // sigma9
  6814. num3: [0.444, 0.471, 0.504], // sigma10
  6815. denom1: [0.686, 0.752, 1.025], // sigma11
  6816. denom2: [0.345, 0.344, 0.532], // sigma12
  6817. sup1: [0.413, 0.503, 0.504], // sigma13
  6818. sup2: [0.363, 0.431, 0.404], // sigma14
  6819. sup3: [0.289, 0.286, 0.294], // sigma15
  6820. sub1: [0.150, 0.143, 0.200], // sigma16
  6821. sub2: [0.247, 0.286, 0.400], // sigma17
  6822. supDrop: [0.386, 0.353, 0.494], // sigma18
  6823. subDrop: [0.050, 0.071, 0.100], // sigma19
  6824. delim1: [2.390, 1.700, 1.980], // sigma20
  6825. delim2: [1.010, 1.157, 1.420], // sigma21
  6826. axisHeight: [0.250, 0.250, 0.250], // sigma22
  6827. // These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
  6828. // they correspond to the font parameters of the extension fonts (family 3).
  6829. // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
  6830. // match cmex7, we'd use cmex7.tfm values for script and scriptscript
  6831. // values.
  6832. defaultRuleThickness: [0.04, 0.049, 0.049], // xi8; cmex7: 0.049
  6833. bigOpSpacing1: [0.111, 0.111, 0.111], // xi9
  6834. bigOpSpacing2: [0.166, 0.166, 0.166], // xi10
  6835. bigOpSpacing3: [0.2, 0.2, 0.2], // xi11
  6836. bigOpSpacing4: [0.6, 0.611, 0.611], // xi12; cmex7: 0.611
  6837. bigOpSpacing5: [0.1, 0.143, 0.143], // xi13; cmex7: 0.143
  6838. // The \sqrt rule width is taken from the height of the surd character.
  6839. // Since we use the same font at all sizes, this thickness doesn't scale.
  6840. sqrtRuleThickness: [0.04, 0.04, 0.04],
  6841. // This value determines how large a pt is, for metrics which are defined
  6842. // in terms of pts.
  6843. // This value is also used in katex.less; if you change it make sure the
  6844. // values match.
  6845. ptPerEm: [10.0, 10.0, 10.0],
  6846. // The space between adjacent `|` columns in an array definition. From
  6847. // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
  6848. doubleRuleSep: [0.2, 0.2, 0.2]
  6849. };
  6850. // This map contains a mapping from font name and character code to character
  6851. // metrics, including height, depth, italic correction, and skew (kern from the
  6852. // character to the corresponding \skewchar)
  6853. // This map is generated via `make metrics`. It should not be changed manually.
  6854. // These are very rough approximations. We default to Times New Roman which
  6855. // should have Latin-1 and Cyrillic characters, but may not depending on the
  6856. // operating system. The metrics do not account for extra height from the
  6857. // accents. In the case of Cyrillic characters which have both ascenders and
  6858. // descenders we prefer approximations with ascenders, primarily to prevent
  6859. // the fraction bar or root line from intersecting the glyph.
  6860. // TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
  6861. var extraCharacterMap = {
  6862. // Latin-1
  6863. 'À': 'A',
  6864. 'Á': 'A',
  6865. 'Â': 'A',
  6866. 'Ã': 'A',
  6867. 'Ä': 'A',
  6868. 'Å': 'A',
  6869. 'Æ': 'A',
  6870. 'Ç': 'C',
  6871. 'È': 'E',
  6872. 'É': 'E',
  6873. 'Ê': 'E',
  6874. 'Ë': 'E',
  6875. 'Ì': 'I',
  6876. 'Í': 'I',
  6877. 'Î': 'I',
  6878. 'Ï': 'I',
  6879. 'Ð': 'D',
  6880. 'Ñ': 'N',
  6881. 'Ò': 'O',
  6882. 'Ó': 'O',
  6883. 'Ô': 'O',
  6884. 'Õ': 'O',
  6885. 'Ö': 'O',
  6886. 'Ø': 'O',
  6887. 'Ù': 'U',
  6888. 'Ú': 'U',
  6889. 'Û': 'U',
  6890. 'Ü': 'U',
  6891. 'Ý': 'Y',
  6892. 'Þ': 'o',
  6893. 'ß': 'B',
  6894. 'à': 'a',
  6895. 'á': 'a',
  6896. 'â': 'a',
  6897. 'ã': 'a',
  6898. 'ä': 'a',
  6899. 'å': 'a',
  6900. 'æ': 'a',
  6901. 'ç': 'c',
  6902. 'è': 'e',
  6903. 'é': 'e',
  6904. 'ê': 'e',
  6905. 'ë': 'e',
  6906. 'ì': 'i',
  6907. 'í': 'i',
  6908. 'î': 'i',
  6909. 'ï': 'i',
  6910. 'ð': 'd',
  6911. 'ñ': 'n',
  6912. 'ò': 'o',
  6913. 'ó': 'o',
  6914. 'ô': 'o',
  6915. 'õ': 'o',
  6916. 'ö': 'o',
  6917. 'ø': 'o',
  6918. 'ù': 'u',
  6919. 'ú': 'u',
  6920. 'û': 'u',
  6921. 'ü': 'u',
  6922. 'ý': 'y',
  6923. 'þ': 'o',
  6924. 'ÿ': 'y',
  6925. // Cyrillic
  6926. 'А': 'A',
  6927. 'Б': 'B',
  6928. 'В': 'B',
  6929. 'Г': 'F',
  6930. 'Д': 'A',
  6931. 'Е': 'E',
  6932. 'Ж': 'K',
  6933. 'З': '3',
  6934. 'И': 'N',
  6935. 'Й': 'N',
  6936. 'К': 'K',
  6937. 'Л': 'N',
  6938. 'М': 'M',
  6939. 'Н': 'H',
  6940. 'О': 'O',
  6941. 'П': 'N',
  6942. 'Р': 'P',
  6943. 'С': 'C',
  6944. 'Т': 'T',
  6945. 'У': 'y',
  6946. 'Ф': 'O',
  6947. 'Х': 'X',
  6948. 'Ц': 'U',
  6949. 'Ч': 'h',
  6950. 'Ш': 'W',
  6951. 'Щ': 'W',
  6952. 'Ъ': 'B',
  6953. 'Ы': 'X',
  6954. 'Ь': 'B',
  6955. 'Э': '3',
  6956. 'Ю': 'X',
  6957. 'Я': 'R',
  6958. 'а': 'a',
  6959. 'б': 'b',
  6960. 'в': 'a',
  6961. 'г': 'r',
  6962. 'д': 'y',
  6963. 'е': 'e',
  6964. 'ж': 'm',
  6965. 'з': 'e',
  6966. 'и': 'n',
  6967. 'й': 'n',
  6968. 'к': 'n',
  6969. 'л': 'n',
  6970. 'м': 'm',
  6971. 'н': 'n',
  6972. 'о': 'o',
  6973. 'п': 'n',
  6974. 'р': 'p',
  6975. 'с': 'c',
  6976. 'т': 'o',
  6977. 'у': 'y',
  6978. 'ф': 'b',
  6979. 'х': 'x',
  6980. 'ц': 'n',
  6981. 'ч': 'n',
  6982. 'ш': 'w',
  6983. 'щ': 'w',
  6984. 'ъ': 'a',
  6985. 'ы': 'm',
  6986. 'ь': 'a',
  6987. 'э': 'e',
  6988. 'ю': 'm',
  6989. 'я': 'r'
  6990. };
  6991. /**
  6992. * This function is a convenience function for looking up information in the
  6993. * metricMap table. It takes a character as a string, and a font.
  6994. *
  6995. * Note: the `width` property may be undefined if fontMetricsData.js wasn't
  6996. * built using `Make extended_metrics`.
  6997. */
  6998. var getCharacterMetrics = function getCharacterMetrics(character, font) {
  6999. var ch = character.charCodeAt(0);
  7000. if (character[0] in extraCharacterMap) {
  7001. ch = extraCharacterMap[character[0]].charCodeAt(0);
  7002. } else if (_unicodeRegexes.cjkRegex.test(character[0])) {
  7003. ch = 'M'.charCodeAt(0);
  7004. }
  7005. var metrics = _fontMetricsData2.default[font]['' + ch];
  7006. if (metrics) {
  7007. return {
  7008. depth: metrics[0],
  7009. height: metrics[1],
  7010. italic: metrics[2],
  7011. skew: metrics[3],
  7012. width: metrics[4]
  7013. };
  7014. }
  7015. };
  7016. var fontMetricsBySizeIndex = {};
  7017. /**
  7018. * Get the font metrics for a given size.
  7019. */
  7020. var getFontMetrics = function getFontMetrics(size) {
  7021. var sizeIndex = void 0;
  7022. if (size >= 5) {
  7023. sizeIndex = 0;
  7024. } else if (size >= 3) {
  7025. sizeIndex = 1;
  7026. } else {
  7027. sizeIndex = 2;
  7028. }
  7029. if (!fontMetricsBySizeIndex[sizeIndex]) {
  7030. var metrics = fontMetricsBySizeIndex[sizeIndex] = {
  7031. cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
  7032. };
  7033. for (var key in sigmasAndXis) {
  7034. if (sigmasAndXis.hasOwnProperty(key)) {
  7035. metrics[key] = sigmasAndXis[key][sizeIndex];
  7036. }
  7037. }
  7038. }
  7039. return fontMetricsBySizeIndex[sizeIndex];
  7040. };
  7041. exports.default = {
  7042. getFontMetrics: getFontMetrics,
  7043. getCharacterMetrics: getCharacterMetrics
  7044. };
  7045. },{"./fontMetricsData":102,"./unicodeRegexes":113}],102:[function(require,module,exports){
  7046. "use strict";
  7047. Object.defineProperty(exports, "__esModule", {
  7048. value: true
  7049. });
  7050. var fontMetricsData = {
  7051. "AMS-Regular": {
  7052. "65": [0, 0.68889, 0, 0],
  7053. "66": [0, 0.68889, 0, 0],
  7054. "67": [0, 0.68889, 0, 0],
  7055. "68": [0, 0.68889, 0, 0],
  7056. "69": [0, 0.68889, 0, 0],
  7057. "70": [0, 0.68889, 0, 0],
  7058. "71": [0, 0.68889, 0, 0],
  7059. "72": [0, 0.68889, 0, 0],
  7060. "73": [0, 0.68889, 0, 0],
  7061. "74": [0.16667, 0.68889, 0, 0],
  7062. "75": [0, 0.68889, 0, 0],
  7063. "76": [0, 0.68889, 0, 0],
  7064. "77": [0, 0.68889, 0, 0],
  7065. "78": [0, 0.68889, 0, 0],
  7066. "79": [0.16667, 0.68889, 0, 0],
  7067. "80": [0, 0.68889, 0, 0],
  7068. "81": [0.16667, 0.68889, 0, 0],
  7069. "82": [0, 0.68889, 0, 0],
  7070. "83": [0, 0.68889, 0, 0],
  7071. "84": [0, 0.68889, 0, 0],
  7072. "85": [0, 0.68889, 0, 0],
  7073. "86": [0, 0.68889, 0, 0],
  7074. "87": [0, 0.68889, 0, 0],
  7075. "88": [0, 0.68889, 0, 0],
  7076. "89": [0, 0.68889, 0, 0],
  7077. "90": [0, 0.68889, 0, 0],
  7078. "107": [0, 0.68889, 0, 0],
  7079. "165": [0, 0.675, 0.025, 0],
  7080. "174": [0.15559, 0.69224, 0, 0],
  7081. "240": [0, 0.68889, 0, 0],
  7082. "295": [0, 0.68889, 0, 0],
  7083. "710": [0, 0.825, 0, 0],
  7084. "732": [0, 0.9, 0, 0],
  7085. "770": [0, 0.825, 0, 0],
  7086. "771": [0, 0.9, 0, 0],
  7087. "989": [0.08167, 0.58167, 0, 0],
  7088. "1008": [0, 0.43056, 0.04028, 0],
  7089. "8245": [0, 0.54986, 0, 0],
  7090. "8463": [0, 0.68889, 0, 0],
  7091. "8487": [0, 0.68889, 0, 0],
  7092. "8498": [0, 0.68889, 0, 0],
  7093. "8502": [0, 0.68889, 0, 0],
  7094. "8503": [0, 0.68889, 0, 0],
  7095. "8504": [0, 0.68889, 0, 0],
  7096. "8513": [0, 0.68889, 0, 0],
  7097. "8592": [-0.03598, 0.46402, 0, 0],
  7098. "8594": [-0.03598, 0.46402, 0, 0],
  7099. "8602": [-0.13313, 0.36687, 0, 0],
  7100. "8603": [-0.13313, 0.36687, 0, 0],
  7101. "8606": [0.01354, 0.52239, 0, 0],
  7102. "8608": [0.01354, 0.52239, 0, 0],
  7103. "8610": [0.01354, 0.52239, 0, 0],
  7104. "8611": [0.01354, 0.52239, 0, 0],
  7105. "8619": [0, 0.54986, 0, 0],
  7106. "8620": [0, 0.54986, 0, 0],
  7107. "8621": [-0.13313, 0.37788, 0, 0],
  7108. "8622": [-0.13313, 0.36687, 0, 0],
  7109. "8624": [0, 0.69224, 0, 0],
  7110. "8625": [0, 0.69224, 0, 0],
  7111. "8630": [0, 0.43056, 0, 0],
  7112. "8631": [0, 0.43056, 0, 0],
  7113. "8634": [0.08198, 0.58198, 0, 0],
  7114. "8635": [0.08198, 0.58198, 0, 0],
  7115. "8638": [0.19444, 0.69224, 0, 0],
  7116. "8639": [0.19444, 0.69224, 0, 0],
  7117. "8642": [0.19444, 0.69224, 0, 0],
  7118. "8643": [0.19444, 0.69224, 0, 0],
  7119. "8644": [0.1808, 0.675, 0, 0],
  7120. "8646": [0.1808, 0.675, 0, 0],
  7121. "8647": [0.1808, 0.675, 0, 0],
  7122. "8648": [0.19444, 0.69224, 0, 0],
  7123. "8649": [0.1808, 0.675, 0, 0],
  7124. "8650": [0.19444, 0.69224, 0, 0],
  7125. "8651": [0.01354, 0.52239, 0, 0],
  7126. "8652": [0.01354, 0.52239, 0, 0],
  7127. "8653": [-0.13313, 0.36687, 0, 0],
  7128. "8654": [-0.13313, 0.36687, 0, 0],
  7129. "8655": [-0.13313, 0.36687, 0, 0],
  7130. "8666": [0.13667, 0.63667, 0, 0],
  7131. "8667": [0.13667, 0.63667, 0, 0],
  7132. "8669": [-0.13313, 0.37788, 0, 0],
  7133. "8672": [-0.064, 0.437, 0, 0],
  7134. "8674": [-0.064, 0.437, 0, 0],
  7135. "8705": [0, 0.825, 0, 0],
  7136. "8708": [0, 0.68889, 0, 0],
  7137. "8709": [0.08167, 0.58167, 0, 0],
  7138. "8717": [0, 0.43056, 0, 0],
  7139. "8722": [-0.03598, 0.46402, 0, 0],
  7140. "8724": [0.08198, 0.69224, 0, 0],
  7141. "8726": [0.08167, 0.58167, 0, 0],
  7142. "8733": [0, 0.69224, 0, 0],
  7143. "8736": [0, 0.69224, 0, 0],
  7144. "8737": [0, 0.69224, 0, 0],
  7145. "8738": [0.03517, 0.52239, 0, 0],
  7146. "8739": [0.08167, 0.58167, 0, 0],
  7147. "8740": [0.25142, 0.74111, 0, 0],
  7148. "8741": [0.08167, 0.58167, 0, 0],
  7149. "8742": [0.25142, 0.74111, 0, 0],
  7150. "8756": [0, 0.69224, 0, 0],
  7151. "8757": [0, 0.69224, 0, 0],
  7152. "8764": [-0.13313, 0.36687, 0, 0],
  7153. "8765": [-0.13313, 0.37788, 0, 0],
  7154. "8769": [-0.13313, 0.36687, 0, 0],
  7155. "8770": [-0.03625, 0.46375, 0, 0],
  7156. "8774": [0.30274, 0.79383, 0, 0],
  7157. "8776": [-0.01688, 0.48312, 0, 0],
  7158. "8778": [0.08167, 0.58167, 0, 0],
  7159. "8782": [0.06062, 0.54986, 0, 0],
  7160. "8783": [0.06062, 0.54986, 0, 0],
  7161. "8785": [0.08198, 0.58198, 0, 0],
  7162. "8786": [0.08198, 0.58198, 0, 0],
  7163. "8787": [0.08198, 0.58198, 0, 0],
  7164. "8790": [0, 0.69224, 0, 0],
  7165. "8791": [0.22958, 0.72958, 0, 0],
  7166. "8796": [0.08198, 0.91667, 0, 0],
  7167. "8806": [0.25583, 0.75583, 0, 0],
  7168. "8807": [0.25583, 0.75583, 0, 0],
  7169. "8808": [0.25142, 0.75726, 0, 0],
  7170. "8809": [0.25142, 0.75726, 0, 0],
  7171. "8812": [0.25583, 0.75583, 0, 0],
  7172. "8814": [0.20576, 0.70576, 0, 0],
  7173. "8815": [0.20576, 0.70576, 0, 0],
  7174. "8816": [0.30274, 0.79383, 0, 0],
  7175. "8817": [0.30274, 0.79383, 0, 0],
  7176. "8818": [0.22958, 0.72958, 0, 0],
  7177. "8819": [0.22958, 0.72958, 0, 0],
  7178. "8822": [0.1808, 0.675, 0, 0],
  7179. "8823": [0.1808, 0.675, 0, 0],
  7180. "8828": [0.13667, 0.63667, 0, 0],
  7181. "8829": [0.13667, 0.63667, 0, 0],
  7182. "8830": [0.22958, 0.72958, 0, 0],
  7183. "8831": [0.22958, 0.72958, 0, 0],
  7184. "8832": [0.20576, 0.70576, 0, 0],
  7185. "8833": [0.20576, 0.70576, 0, 0],
  7186. "8840": [0.30274, 0.79383, 0, 0],
  7187. "8841": [0.30274, 0.79383, 0, 0],
  7188. "8842": [0.13597, 0.63597, 0, 0],
  7189. "8843": [0.13597, 0.63597, 0, 0],
  7190. "8847": [0.03517, 0.54986, 0, 0],
  7191. "8848": [0.03517, 0.54986, 0, 0],
  7192. "8858": [0.08198, 0.58198, 0, 0],
  7193. "8859": [0.08198, 0.58198, 0, 0],
  7194. "8861": [0.08198, 0.58198, 0, 0],
  7195. "8862": [0, 0.675, 0, 0],
  7196. "8863": [0, 0.675, 0, 0],
  7197. "8864": [0, 0.675, 0, 0],
  7198. "8865": [0, 0.675, 0, 0],
  7199. "8872": [0, 0.69224, 0, 0],
  7200. "8873": [0, 0.69224, 0, 0],
  7201. "8874": [0, 0.69224, 0, 0],
  7202. "8876": [0, 0.68889, 0, 0],
  7203. "8877": [0, 0.68889, 0, 0],
  7204. "8878": [0, 0.68889, 0, 0],
  7205. "8879": [0, 0.68889, 0, 0],
  7206. "8882": [0.03517, 0.54986, 0, 0],
  7207. "8883": [0.03517, 0.54986, 0, 0],
  7208. "8884": [0.13667, 0.63667, 0, 0],
  7209. "8885": [0.13667, 0.63667, 0, 0],
  7210. "8888": [0, 0.54986, 0, 0],
  7211. "8890": [0.19444, 0.43056, 0, 0],
  7212. "8891": [0.19444, 0.69224, 0, 0],
  7213. "8892": [0.19444, 0.69224, 0, 0],
  7214. "8901": [0, 0.54986, 0, 0],
  7215. "8903": [0.08167, 0.58167, 0, 0],
  7216. "8905": [0.08167, 0.58167, 0, 0],
  7217. "8906": [0.08167, 0.58167, 0, 0],
  7218. "8907": [0, 0.69224, 0, 0],
  7219. "8908": [0, 0.69224, 0, 0],
  7220. "8909": [-0.03598, 0.46402, 0, 0],
  7221. "8910": [0, 0.54986, 0, 0],
  7222. "8911": [0, 0.54986, 0, 0],
  7223. "8912": [0.03517, 0.54986, 0, 0],
  7224. "8913": [0.03517, 0.54986, 0, 0],
  7225. "8914": [0, 0.54986, 0, 0],
  7226. "8915": [0, 0.54986, 0, 0],
  7227. "8916": [0, 0.69224, 0, 0],
  7228. "8918": [0.0391, 0.5391, 0, 0],
  7229. "8919": [0.0391, 0.5391, 0, 0],
  7230. "8920": [0.03517, 0.54986, 0, 0],
  7231. "8921": [0.03517, 0.54986, 0, 0],
  7232. "8922": [0.38569, 0.88569, 0, 0],
  7233. "8923": [0.38569, 0.88569, 0, 0],
  7234. "8926": [0.13667, 0.63667, 0, 0],
  7235. "8927": [0.13667, 0.63667, 0, 0],
  7236. "8928": [0.30274, 0.79383, 0, 0],
  7237. "8929": [0.30274, 0.79383, 0, 0],
  7238. "8934": [0.23222, 0.74111, 0, 0],
  7239. "8935": [0.23222, 0.74111, 0, 0],
  7240. "8936": [0.23222, 0.74111, 0, 0],
  7241. "8937": [0.23222, 0.74111, 0, 0],
  7242. "8938": [0.20576, 0.70576, 0, 0],
  7243. "8939": [0.20576, 0.70576, 0, 0],
  7244. "8940": [0.30274, 0.79383, 0, 0],
  7245. "8941": [0.30274, 0.79383, 0, 0],
  7246. "8994": [0.19444, 0.69224, 0, 0],
  7247. "8995": [0.19444, 0.69224, 0, 0],
  7248. "9416": [0.15559, 0.69224, 0, 0],
  7249. "9484": [0, 0.69224, 0, 0],
  7250. "9488": [0, 0.69224, 0, 0],
  7251. "9492": [0, 0.37788, 0, 0],
  7252. "9496": [0, 0.37788, 0, 0],
  7253. "9585": [0.19444, 0.68889, 0, 0],
  7254. "9586": [0.19444, 0.74111, 0, 0],
  7255. "9632": [0, 0.675, 0, 0],
  7256. "9633": [0, 0.675, 0, 0],
  7257. "9650": [0, 0.54986, 0, 0],
  7258. "9651": [0, 0.54986, 0, 0],
  7259. "9654": [0.03517, 0.54986, 0, 0],
  7260. "9660": [0, 0.54986, 0, 0],
  7261. "9661": [0, 0.54986, 0, 0],
  7262. "9664": [0.03517, 0.54986, 0, 0],
  7263. "9674": [0.11111, 0.69224, 0, 0],
  7264. "9733": [0.19444, 0.69224, 0, 0],
  7265. "10003": [0, 0.69224, 0, 0],
  7266. "10016": [0, 0.69224, 0, 0],
  7267. "10731": [0.11111, 0.69224, 0, 0],
  7268. "10846": [0.19444, 0.75583, 0, 0],
  7269. "10877": [0.13667, 0.63667, 0, 0],
  7270. "10878": [0.13667, 0.63667, 0, 0],
  7271. "10885": [0.25583, 0.75583, 0, 0],
  7272. "10886": [0.25583, 0.75583, 0, 0],
  7273. "10887": [0.13597, 0.63597, 0, 0],
  7274. "10888": [0.13597, 0.63597, 0, 0],
  7275. "10889": [0.26167, 0.75726, 0, 0],
  7276. "10890": [0.26167, 0.75726, 0, 0],
  7277. "10891": [0.48256, 0.98256, 0, 0],
  7278. "10892": [0.48256, 0.98256, 0, 0],
  7279. "10901": [0.13667, 0.63667, 0, 0],
  7280. "10902": [0.13667, 0.63667, 0, 0],
  7281. "10933": [0.25142, 0.75726, 0, 0],
  7282. "10934": [0.25142, 0.75726, 0, 0],
  7283. "10935": [0.26167, 0.75726, 0, 0],
  7284. "10936": [0.26167, 0.75726, 0, 0],
  7285. "10937": [0.26167, 0.75726, 0, 0],
  7286. "10938": [0.26167, 0.75726, 0, 0],
  7287. "10949": [0.25583, 0.75583, 0, 0],
  7288. "10950": [0.25583, 0.75583, 0, 0],
  7289. "10955": [0.28481, 0.79383, 0, 0],
  7290. "10956": [0.28481, 0.79383, 0, 0],
  7291. "57350": [0.08167, 0.58167, 0, 0],
  7292. "57351": [0.08167, 0.58167, 0, 0],
  7293. "57352": [0.08167, 0.58167, 0, 0],
  7294. "57353": [0, 0.43056, 0.04028, 0],
  7295. "57356": [0.25142, 0.75726, 0, 0],
  7296. "57357": [0.25142, 0.75726, 0, 0],
  7297. "57358": [0.41951, 0.91951, 0, 0],
  7298. "57359": [0.30274, 0.79383, 0, 0],
  7299. "57360": [0.30274, 0.79383, 0, 0],
  7300. "57361": [0.41951, 0.91951, 0, 0],
  7301. "57366": [0.25142, 0.75726, 0, 0],
  7302. "57367": [0.25142, 0.75726, 0, 0],
  7303. "57368": [0.25142, 0.75726, 0, 0],
  7304. "57369": [0.25142, 0.75726, 0, 0],
  7305. "57370": [0.13597, 0.63597, 0, 0],
  7306. "57371": [0.13597, 0.63597, 0, 0]
  7307. },
  7308. "Caligraphic-Regular": {
  7309. "48": [0, 0.43056, 0, 0],
  7310. "49": [0, 0.43056, 0, 0],
  7311. "50": [0, 0.43056, 0, 0],
  7312. "51": [0.19444, 0.43056, 0, 0],
  7313. "52": [0.19444, 0.43056, 0, 0],
  7314. "53": [0.19444, 0.43056, 0, 0],
  7315. "54": [0, 0.64444, 0, 0],
  7316. "55": [0.19444, 0.43056, 0, 0],
  7317. "56": [0, 0.64444, 0, 0],
  7318. "57": [0.19444, 0.43056, 0, 0],
  7319. "65": [0, 0.68333, 0, 0.19445],
  7320. "66": [0, 0.68333, 0.03041, 0.13889],
  7321. "67": [0, 0.68333, 0.05834, 0.13889],
  7322. "68": [0, 0.68333, 0.02778, 0.08334],
  7323. "69": [0, 0.68333, 0.08944, 0.11111],
  7324. "70": [0, 0.68333, 0.09931, 0.11111],
  7325. "71": [0.09722, 0.68333, 0.0593, 0.11111],
  7326. "72": [0, 0.68333, 0.00965, 0.11111],
  7327. "73": [0, 0.68333, 0.07382, 0],
  7328. "74": [0.09722, 0.68333, 0.18472, 0.16667],
  7329. "75": [0, 0.68333, 0.01445, 0.05556],
  7330. "76": [0, 0.68333, 0, 0.13889],
  7331. "77": [0, 0.68333, 0, 0.13889],
  7332. "78": [0, 0.68333, 0.14736, 0.08334],
  7333. "79": [0, 0.68333, 0.02778, 0.11111],
  7334. "80": [0, 0.68333, 0.08222, 0.08334],
  7335. "81": [0.09722, 0.68333, 0, 0.11111],
  7336. "82": [0, 0.68333, 0, 0.08334],
  7337. "83": [0, 0.68333, 0.075, 0.13889],
  7338. "84": [0, 0.68333, 0.25417, 0],
  7339. "85": [0, 0.68333, 0.09931, 0.08334],
  7340. "86": [0, 0.68333, 0.08222, 0],
  7341. "87": [0, 0.68333, 0.08222, 0.08334],
  7342. "88": [0, 0.68333, 0.14643, 0.13889],
  7343. "89": [0.09722, 0.68333, 0.08222, 0.08334],
  7344. "90": [0, 0.68333, 0.07944, 0.13889]
  7345. },
  7346. "Fraktur-Regular": {
  7347. "33": [0, 0.69141, 0, 0],
  7348. "34": [0, 0.69141, 0, 0],
  7349. "38": [0, 0.69141, 0, 0],
  7350. "39": [0, 0.69141, 0, 0],
  7351. "40": [0.24982, 0.74947, 0, 0],
  7352. "41": [0.24982, 0.74947, 0, 0],
  7353. "42": [0, 0.62119, 0, 0],
  7354. "43": [0.08319, 0.58283, 0, 0],
  7355. "44": [0, 0.10803, 0, 0],
  7356. "45": [0.08319, 0.58283, 0, 0],
  7357. "46": [0, 0.10803, 0, 0],
  7358. "47": [0.24982, 0.74947, 0, 0],
  7359. "48": [0, 0.47534, 0, 0],
  7360. "49": [0, 0.47534, 0, 0],
  7361. "50": [0, 0.47534, 0, 0],
  7362. "51": [0.18906, 0.47534, 0, 0],
  7363. "52": [0.18906, 0.47534, 0, 0],
  7364. "53": [0.18906, 0.47534, 0, 0],
  7365. "54": [0, 0.69141, 0, 0],
  7366. "55": [0.18906, 0.47534, 0, 0],
  7367. "56": [0, 0.69141, 0, 0],
  7368. "57": [0.18906, 0.47534, 0, 0],
  7369. "58": [0, 0.47534, 0, 0],
  7370. "59": [0.12604, 0.47534, 0, 0],
  7371. "61": [-0.13099, 0.36866, 0, 0],
  7372. "63": [0, 0.69141, 0, 0],
  7373. "65": [0, 0.69141, 0, 0],
  7374. "66": [0, 0.69141, 0, 0],
  7375. "67": [0, 0.69141, 0, 0],
  7376. "68": [0, 0.69141, 0, 0],
  7377. "69": [0, 0.69141, 0, 0],
  7378. "70": [0.12604, 0.69141, 0, 0],
  7379. "71": [0, 0.69141, 0, 0],
  7380. "72": [0.06302, 0.69141, 0, 0],
  7381. "73": [0, 0.69141, 0, 0],
  7382. "74": [0.12604, 0.69141, 0, 0],
  7383. "75": [0, 0.69141, 0, 0],
  7384. "76": [0, 0.69141, 0, 0],
  7385. "77": [0, 0.69141, 0, 0],
  7386. "78": [0, 0.69141, 0, 0],
  7387. "79": [0, 0.69141, 0, 0],
  7388. "80": [0.18906, 0.69141, 0, 0],
  7389. "81": [0.03781, 0.69141, 0, 0],
  7390. "82": [0, 0.69141, 0, 0],
  7391. "83": [0, 0.69141, 0, 0],
  7392. "84": [0, 0.69141, 0, 0],
  7393. "85": [0, 0.69141, 0, 0],
  7394. "86": [0, 0.69141, 0, 0],
  7395. "87": [0, 0.69141, 0, 0],
  7396. "88": [0, 0.69141, 0, 0],
  7397. "89": [0.18906, 0.69141, 0, 0],
  7398. "90": [0.12604, 0.69141, 0, 0],
  7399. "91": [0.24982, 0.74947, 0, 0],
  7400. "93": [0.24982, 0.74947, 0, 0],
  7401. "94": [0, 0.69141, 0, 0],
  7402. "97": [0, 0.47534, 0, 0],
  7403. "98": [0, 0.69141, 0, 0],
  7404. "99": [0, 0.47534, 0, 0],
  7405. "100": [0, 0.62119, 0, 0],
  7406. "101": [0, 0.47534, 0, 0],
  7407. "102": [0.18906, 0.69141, 0, 0],
  7408. "103": [0.18906, 0.47534, 0, 0],
  7409. "104": [0.18906, 0.69141, 0, 0],
  7410. "105": [0, 0.69141, 0, 0],
  7411. "106": [0, 0.69141, 0, 0],
  7412. "107": [0, 0.69141, 0, 0],
  7413. "108": [0, 0.69141, 0, 0],
  7414. "109": [0, 0.47534, 0, 0],
  7415. "110": [0, 0.47534, 0, 0],
  7416. "111": [0, 0.47534, 0, 0],
  7417. "112": [0.18906, 0.52396, 0, 0],
  7418. "113": [0.18906, 0.47534, 0, 0],
  7419. "114": [0, 0.47534, 0, 0],
  7420. "115": [0, 0.47534, 0, 0],
  7421. "116": [0, 0.62119, 0, 0],
  7422. "117": [0, 0.47534, 0, 0],
  7423. "118": [0, 0.52396, 0, 0],
  7424. "119": [0, 0.52396, 0, 0],
  7425. "120": [0.18906, 0.47534, 0, 0],
  7426. "121": [0.18906, 0.47534, 0, 0],
  7427. "122": [0.18906, 0.47534, 0, 0],
  7428. "8216": [0, 0.69141, 0, 0],
  7429. "8217": [0, 0.69141, 0, 0],
  7430. "58112": [0, 0.62119, 0, 0],
  7431. "58113": [0, 0.62119, 0, 0],
  7432. "58114": [0.18906, 0.69141, 0, 0],
  7433. "58115": [0.18906, 0.69141, 0, 0],
  7434. "58116": [0.18906, 0.47534, 0, 0],
  7435. "58117": [0, 0.69141, 0, 0],
  7436. "58118": [0, 0.62119, 0, 0],
  7437. "58119": [0, 0.47534, 0, 0]
  7438. },
  7439. "Main-Bold": {
  7440. "33": [0, 0.69444, 0, 0],
  7441. "34": [0, 0.69444, 0, 0],
  7442. "35": [0.19444, 0.69444, 0, 0],
  7443. "36": [0.05556, 0.75, 0, 0],
  7444. "37": [0.05556, 0.75, 0, 0],
  7445. "38": [0, 0.69444, 0, 0],
  7446. "39": [0, 0.69444, 0, 0],
  7447. "40": [0.25, 0.75, 0, 0],
  7448. "41": [0.25, 0.75, 0, 0],
  7449. "42": [0, 0.75, 0, 0],
  7450. "43": [0.13333, 0.63333, 0, 0],
  7451. "44": [0.19444, 0.15556, 0, 0],
  7452. "45": [0, 0.44444, 0, 0],
  7453. "46": [0, 0.15556, 0, 0],
  7454. "47": [0.25, 0.75, 0, 0],
  7455. "48": [0, 0.64444, 0, 0],
  7456. "49": [0, 0.64444, 0, 0],
  7457. "50": [0, 0.64444, 0, 0],
  7458. "51": [0, 0.64444, 0, 0],
  7459. "52": [0, 0.64444, 0, 0],
  7460. "53": [0, 0.64444, 0, 0],
  7461. "54": [0, 0.64444, 0, 0],
  7462. "55": [0, 0.64444, 0, 0],
  7463. "56": [0, 0.64444, 0, 0],
  7464. "57": [0, 0.64444, 0, 0],
  7465. "58": [0, 0.44444, 0, 0],
  7466. "59": [0.19444, 0.44444, 0, 0],
  7467. "60": [0.08556, 0.58556, 0, 0],
  7468. "61": [-0.10889, 0.39111, 0, 0],
  7469. "62": [0.08556, 0.58556, 0, 0],
  7470. "63": [0, 0.69444, 0, 0],
  7471. "64": [0, 0.69444, 0, 0],
  7472. "65": [0, 0.68611, 0, 0],
  7473. "66": [0, 0.68611, 0, 0],
  7474. "67": [0, 0.68611, 0, 0],
  7475. "68": [0, 0.68611, 0, 0],
  7476. "69": [0, 0.68611, 0, 0],
  7477. "70": [0, 0.68611, 0, 0],
  7478. "71": [0, 0.68611, 0, 0],
  7479. "72": [0, 0.68611, 0, 0],
  7480. "73": [0, 0.68611, 0, 0],
  7481. "74": [0, 0.68611, 0, 0],
  7482. "75": [0, 0.68611, 0, 0],
  7483. "76": [0, 0.68611, 0, 0],
  7484. "77": [0, 0.68611, 0, 0],
  7485. "78": [0, 0.68611, 0, 0],
  7486. "79": [0, 0.68611, 0, 0],
  7487. "80": [0, 0.68611, 0, 0],
  7488. "81": [0.19444, 0.68611, 0, 0],
  7489. "82": [0, 0.68611, 0, 0],
  7490. "83": [0, 0.68611, 0, 0],
  7491. "84": [0, 0.68611, 0, 0],
  7492. "85": [0, 0.68611, 0, 0],
  7493. "86": [0, 0.68611, 0.01597, 0],
  7494. "87": [0, 0.68611, 0.01597, 0],
  7495. "88": [0, 0.68611, 0, 0],
  7496. "89": [0, 0.68611, 0.02875, 0],
  7497. "90": [0, 0.68611, 0, 0],
  7498. "91": [0.25, 0.75, 0, 0],
  7499. "92": [0.25, 0.75, 0, 0],
  7500. "93": [0.25, 0.75, 0, 0],
  7501. "94": [0, 0.69444, 0, 0],
  7502. "95": [0.31, 0.13444, 0.03194, 0],
  7503. "96": [0, 0.69444, 0, 0],
  7504. "97": [0, 0.44444, 0, 0],
  7505. "98": [0, 0.69444, 0, 0],
  7506. "99": [0, 0.44444, 0, 0],
  7507. "100": [0, 0.69444, 0, 0],
  7508. "101": [0, 0.44444, 0, 0],
  7509. "102": [0, 0.69444, 0.10903, 0],
  7510. "103": [0.19444, 0.44444, 0.01597, 0],
  7511. "104": [0, 0.69444, 0, 0],
  7512. "105": [0, 0.69444, 0, 0],
  7513. "106": [0.19444, 0.69444, 0, 0],
  7514. "107": [0, 0.69444, 0, 0],
  7515. "108": [0, 0.69444, 0, 0],
  7516. "109": [0, 0.44444, 0, 0],
  7517. "110": [0, 0.44444, 0, 0],
  7518. "111": [0, 0.44444, 0, 0],
  7519. "112": [0.19444, 0.44444, 0, 0],
  7520. "113": [0.19444, 0.44444, 0, 0],
  7521. "114": [0, 0.44444, 0, 0],
  7522. "115": [0, 0.44444, 0, 0],
  7523. "116": [0, 0.63492, 0, 0],
  7524. "117": [0, 0.44444, 0, 0],
  7525. "118": [0, 0.44444, 0.01597, 0],
  7526. "119": [0, 0.44444, 0.01597, 0],
  7527. "120": [0, 0.44444, 0, 0],
  7528. "121": [0.19444, 0.44444, 0.01597, 0],
  7529. "122": [0, 0.44444, 0, 0],
  7530. "123": [0.25, 0.75, 0, 0],
  7531. "124": [0.25, 0.75, 0, 0],
  7532. "125": [0.25, 0.75, 0, 0],
  7533. "126": [0.35, 0.34444, 0, 0],
  7534. "168": [0, 0.69444, 0, 0],
  7535. "172": [0, 0.44444, 0, 0],
  7536. "175": [0, 0.59611, 0, 0],
  7537. "176": [0, 0.69444, 0, 0],
  7538. "177": [0.13333, 0.63333, 0, 0],
  7539. "180": [0, 0.69444, 0, 0],
  7540. "215": [0.13333, 0.63333, 0, 0],
  7541. "247": [0.13333, 0.63333, 0, 0],
  7542. "305": [0, 0.44444, 0, 0],
  7543. "567": [0.19444, 0.44444, 0, 0],
  7544. "710": [0, 0.69444, 0, 0],
  7545. "711": [0, 0.63194, 0, 0],
  7546. "713": [0, 0.59611, 0, 0],
  7547. "714": [0, 0.69444, 0, 0],
  7548. "715": [0, 0.69444, 0, 0],
  7549. "728": [0, 0.69444, 0, 0],
  7550. "729": [0, 0.69444, 0, 0],
  7551. "730": [0, 0.69444, 0, 0],
  7552. "732": [0, 0.69444, 0, 0],
  7553. "768": [0, 0.69444, 0, 0],
  7554. "769": [0, 0.69444, 0, 0],
  7555. "770": [0, 0.69444, 0, 0],
  7556. "771": [0, 0.69444, 0, 0],
  7557. "772": [0, 0.59611, 0, 0],
  7558. "774": [0, 0.69444, 0, 0],
  7559. "775": [0, 0.69444, 0, 0],
  7560. "776": [0, 0.69444, 0, 0],
  7561. "778": [0, 0.69444, 0, 0],
  7562. "779": [0, 0.69444, 0, 0],
  7563. "780": [0, 0.63194, 0, 0],
  7564. "824": [0.19444, 0.69444, 0, 0],
  7565. "915": [0, 0.68611, 0, 0],
  7566. "916": [0, 0.68611, 0, 0],
  7567. "920": [0, 0.68611, 0, 0],
  7568. "923": [0, 0.68611, 0, 0],
  7569. "926": [0, 0.68611, 0, 0],
  7570. "928": [0, 0.68611, 0, 0],
  7571. "931": [0, 0.68611, 0, 0],
  7572. "933": [0, 0.68611, 0, 0],
  7573. "934": [0, 0.68611, 0, 0],
  7574. "936": [0, 0.68611, 0, 0],
  7575. "937": [0, 0.68611, 0, 0],
  7576. "8211": [0, 0.44444, 0.03194, 0],
  7577. "8212": [0, 0.44444, 0.03194, 0],
  7578. "8216": [0, 0.69444, 0, 0],
  7579. "8217": [0, 0.69444, 0, 0],
  7580. "8220": [0, 0.69444, 0, 0],
  7581. "8221": [0, 0.69444, 0, 0],
  7582. "8224": [0.19444, 0.69444, 0, 0],
  7583. "8225": [0.19444, 0.69444, 0, 0],
  7584. "8242": [0, 0.55556, 0, 0],
  7585. "8407": [0, 0.72444, 0.15486, 0],
  7586. "8463": [0, 0.69444, 0, 0],
  7587. "8465": [0, 0.69444, 0, 0],
  7588. "8467": [0, 0.69444, 0, 0],
  7589. "8472": [0.19444, 0.44444, 0, 0],
  7590. "8476": [0, 0.69444, 0, 0],
  7591. "8501": [0, 0.69444, 0, 0],
  7592. "8592": [-0.10889, 0.39111, 0, 0],
  7593. "8593": [0.19444, 0.69444, 0, 0],
  7594. "8594": [-0.10889, 0.39111, 0, 0],
  7595. "8595": [0.19444, 0.69444, 0, 0],
  7596. "8596": [-0.10889, 0.39111, 0, 0],
  7597. "8597": [0.25, 0.75, 0, 0],
  7598. "8598": [0.19444, 0.69444, 0, 0],
  7599. "8599": [0.19444, 0.69444, 0, 0],
  7600. "8600": [0.19444, 0.69444, 0, 0],
  7601. "8601": [0.19444, 0.69444, 0, 0],
  7602. "8636": [-0.10889, 0.39111, 0, 0],
  7603. "8637": [-0.10889, 0.39111, 0, 0],
  7604. "8640": [-0.10889, 0.39111, 0, 0],
  7605. "8641": [-0.10889, 0.39111, 0, 0],
  7606. "8656": [-0.10889, 0.39111, 0, 0],
  7607. "8657": [0.19444, 0.69444, 0, 0],
  7608. "8658": [-0.10889, 0.39111, 0, 0],
  7609. "8659": [0.19444, 0.69444, 0, 0],
  7610. "8660": [-0.10889, 0.39111, 0, 0],
  7611. "8661": [0.25, 0.75, 0, 0],
  7612. "8704": [0, 0.69444, 0, 0],
  7613. "8706": [0, 0.69444, 0.06389, 0],
  7614. "8707": [0, 0.69444, 0, 0],
  7615. "8709": [0.05556, 0.75, 0, 0],
  7616. "8711": [0, 0.68611, 0, 0],
  7617. "8712": [0.08556, 0.58556, 0, 0],
  7618. "8715": [0.08556, 0.58556, 0, 0],
  7619. "8722": [0.13333, 0.63333, 0, 0],
  7620. "8723": [0.13333, 0.63333, 0, 0],
  7621. "8725": [0.25, 0.75, 0, 0],
  7622. "8726": [0.25, 0.75, 0, 0],
  7623. "8727": [-0.02778, 0.47222, 0, 0],
  7624. "8728": [-0.02639, 0.47361, 0, 0],
  7625. "8729": [-0.02639, 0.47361, 0, 0],
  7626. "8730": [0.18, 0.82, 0, 0],
  7627. "8733": [0, 0.44444, 0, 0],
  7628. "8734": [0, 0.44444, 0, 0],
  7629. "8736": [0, 0.69224, 0, 0],
  7630. "8739": [0.25, 0.75, 0, 0],
  7631. "8741": [0.25, 0.75, 0, 0],
  7632. "8743": [0, 0.55556, 0, 0],
  7633. "8744": [0, 0.55556, 0, 0],
  7634. "8745": [0, 0.55556, 0, 0],
  7635. "8746": [0, 0.55556, 0, 0],
  7636. "8747": [0.19444, 0.69444, 0.12778, 0],
  7637. "8764": [-0.10889, 0.39111, 0, 0],
  7638. "8768": [0.19444, 0.69444, 0, 0],
  7639. "8771": [0.00222, 0.50222, 0, 0],
  7640. "8776": [0.02444, 0.52444, 0, 0],
  7641. "8781": [0.00222, 0.50222, 0, 0],
  7642. "8801": [0.00222, 0.50222, 0, 0],
  7643. "8804": [0.19667, 0.69667, 0, 0],
  7644. "8805": [0.19667, 0.69667, 0, 0],
  7645. "8810": [0.08556, 0.58556, 0, 0],
  7646. "8811": [0.08556, 0.58556, 0, 0],
  7647. "8826": [0.08556, 0.58556, 0, 0],
  7648. "8827": [0.08556, 0.58556, 0, 0],
  7649. "8834": [0.08556, 0.58556, 0, 0],
  7650. "8835": [0.08556, 0.58556, 0, 0],
  7651. "8838": [0.19667, 0.69667, 0, 0],
  7652. "8839": [0.19667, 0.69667, 0, 0],
  7653. "8846": [0, 0.55556, 0, 0],
  7654. "8849": [0.19667, 0.69667, 0, 0],
  7655. "8850": [0.19667, 0.69667, 0, 0],
  7656. "8851": [0, 0.55556, 0, 0],
  7657. "8852": [0, 0.55556, 0, 0],
  7658. "8853": [0.13333, 0.63333, 0, 0],
  7659. "8854": [0.13333, 0.63333, 0, 0],
  7660. "8855": [0.13333, 0.63333, 0, 0],
  7661. "8856": [0.13333, 0.63333, 0, 0],
  7662. "8857": [0.13333, 0.63333, 0, 0],
  7663. "8866": [0, 0.69444, 0, 0],
  7664. "8867": [0, 0.69444, 0, 0],
  7665. "8868": [0, 0.69444, 0, 0],
  7666. "8869": [0, 0.69444, 0, 0],
  7667. "8900": [-0.02639, 0.47361, 0, 0],
  7668. "8901": [-0.02639, 0.47361, 0, 0],
  7669. "8902": [-0.02778, 0.47222, 0, 0],
  7670. "8968": [0.25, 0.75, 0, 0],
  7671. "8969": [0.25, 0.75, 0, 0],
  7672. "8970": [0.25, 0.75, 0, 0],
  7673. "8971": [0.25, 0.75, 0, 0],
  7674. "8994": [-0.13889, 0.36111, 0, 0],
  7675. "8995": [-0.13889, 0.36111, 0, 0],
  7676. "9651": [0.19444, 0.69444, 0, 0],
  7677. "9657": [-0.02778, 0.47222, 0, 0],
  7678. "9661": [0.19444, 0.69444, 0, 0],
  7679. "9667": [-0.02778, 0.47222, 0, 0],
  7680. "9711": [0.19444, 0.69444, 0, 0],
  7681. "9824": [0.12963, 0.69444, 0, 0],
  7682. "9825": [0.12963, 0.69444, 0, 0],
  7683. "9826": [0.12963, 0.69444, 0, 0],
  7684. "9827": [0.12963, 0.69444, 0, 0],
  7685. "9837": [0, 0.75, 0, 0],
  7686. "9838": [0.19444, 0.69444, 0, 0],
  7687. "9839": [0.19444, 0.69444, 0, 0],
  7688. "10216": [0.25, 0.75, 0, 0],
  7689. "10217": [0.25, 0.75, 0, 0],
  7690. "10815": [0, 0.68611, 0, 0],
  7691. "10927": [0.19667, 0.69667, 0, 0],
  7692. "10928": [0.19667, 0.69667, 0, 0]
  7693. },
  7694. "Main-Italic": {
  7695. "33": [0, 0.69444, 0.12417, 0],
  7696. "34": [0, 0.69444, 0.06961, 0],
  7697. "35": [0.19444, 0.69444, 0.06616, 0],
  7698. "37": [0.05556, 0.75, 0.13639, 0],
  7699. "38": [0, 0.69444, 0.09694, 0],
  7700. "39": [0, 0.69444, 0.12417, 0],
  7701. "40": [0.25, 0.75, 0.16194, 0],
  7702. "41": [0.25, 0.75, 0.03694, 0],
  7703. "42": [0, 0.75, 0.14917, 0],
  7704. "43": [0.05667, 0.56167, 0.03694, 0],
  7705. "44": [0.19444, 0.10556, 0, 0],
  7706. "45": [0, 0.43056, 0.02826, 0],
  7707. "46": [0, 0.10556, 0, 0],
  7708. "47": [0.25, 0.75, 0.16194, 0],
  7709. "48": [0, 0.64444, 0.13556, 0],
  7710. "49": [0, 0.64444, 0.13556, 0],
  7711. "50": [0, 0.64444, 0.13556, 0],
  7712. "51": [0, 0.64444, 0.13556, 0],
  7713. "52": [0.19444, 0.64444, 0.13556, 0],
  7714. "53": [0, 0.64444, 0.13556, 0],
  7715. "54": [0, 0.64444, 0.13556, 0],
  7716. "55": [0.19444, 0.64444, 0.13556, 0],
  7717. "56": [0, 0.64444, 0.13556, 0],
  7718. "57": [0, 0.64444, 0.13556, 0],
  7719. "58": [0, 0.43056, 0.0582, 0],
  7720. "59": [0.19444, 0.43056, 0.0582, 0],
  7721. "61": [-0.13313, 0.36687, 0.06616, 0],
  7722. "63": [0, 0.69444, 0.1225, 0],
  7723. "64": [0, 0.69444, 0.09597, 0],
  7724. "65": [0, 0.68333, 0, 0],
  7725. "66": [0, 0.68333, 0.10257, 0],
  7726. "67": [0, 0.68333, 0.14528, 0],
  7727. "68": [0, 0.68333, 0.09403, 0],
  7728. "69": [0, 0.68333, 0.12028, 0],
  7729. "70": [0, 0.68333, 0.13305, 0],
  7730. "71": [0, 0.68333, 0.08722, 0],
  7731. "72": [0, 0.68333, 0.16389, 0],
  7732. "73": [0, 0.68333, 0.15806, 0],
  7733. "74": [0, 0.68333, 0.14028, 0],
  7734. "75": [0, 0.68333, 0.14528, 0],
  7735. "76": [0, 0.68333, 0, 0],
  7736. "77": [0, 0.68333, 0.16389, 0],
  7737. "78": [0, 0.68333, 0.16389, 0],
  7738. "79": [0, 0.68333, 0.09403, 0],
  7739. "80": [0, 0.68333, 0.10257, 0],
  7740. "81": [0.19444, 0.68333, 0.09403, 0],
  7741. "82": [0, 0.68333, 0.03868, 0],
  7742. "83": [0, 0.68333, 0.11972, 0],
  7743. "84": [0, 0.68333, 0.13305, 0],
  7744. "85": [0, 0.68333, 0.16389, 0],
  7745. "86": [0, 0.68333, 0.18361, 0],
  7746. "87": [0, 0.68333, 0.18361, 0],
  7747. "88": [0, 0.68333, 0.15806, 0],
  7748. "89": [0, 0.68333, 0.19383, 0],
  7749. "90": [0, 0.68333, 0.14528, 0],
  7750. "91": [0.25, 0.75, 0.1875, 0],
  7751. "93": [0.25, 0.75, 0.10528, 0],
  7752. "94": [0, 0.69444, 0.06646, 0],
  7753. "95": [0.31, 0.12056, 0.09208, 0],
  7754. "97": [0, 0.43056, 0.07671, 0],
  7755. "98": [0, 0.69444, 0.06312, 0],
  7756. "99": [0, 0.43056, 0.05653, 0],
  7757. "100": [0, 0.69444, 0.10333, 0],
  7758. "101": [0, 0.43056, 0.07514, 0],
  7759. "102": [0.19444, 0.69444, 0.21194, 0],
  7760. "103": [0.19444, 0.43056, 0.08847, 0],
  7761. "104": [0, 0.69444, 0.07671, 0],
  7762. "105": [0, 0.65536, 0.1019, 0],
  7763. "106": [0.19444, 0.65536, 0.14467, 0],
  7764. "107": [0, 0.69444, 0.10764, 0],
  7765. "108": [0, 0.69444, 0.10333, 0],
  7766. "109": [0, 0.43056, 0.07671, 0],
  7767. "110": [0, 0.43056, 0.07671, 0],
  7768. "111": [0, 0.43056, 0.06312, 0],
  7769. "112": [0.19444, 0.43056, 0.06312, 0],
  7770. "113": [0.19444, 0.43056, 0.08847, 0],
  7771. "114": [0, 0.43056, 0.10764, 0],
  7772. "115": [0, 0.43056, 0.08208, 0],
  7773. "116": [0, 0.61508, 0.09486, 0],
  7774. "117": [0, 0.43056, 0.07671, 0],
  7775. "118": [0, 0.43056, 0.10764, 0],
  7776. "119": [0, 0.43056, 0.10764, 0],
  7777. "120": [0, 0.43056, 0.12042, 0],
  7778. "121": [0.19444, 0.43056, 0.08847, 0],
  7779. "122": [0, 0.43056, 0.12292, 0],
  7780. "126": [0.35, 0.31786, 0.11585, 0],
  7781. "163": [0, 0.69444, 0, 0],
  7782. "305": [0, 0.43056, 0, 0.02778],
  7783. "567": [0.19444, 0.43056, 0, 0.08334],
  7784. "768": [0, 0.69444, 0, 0],
  7785. "769": [0, 0.69444, 0.09694, 0],
  7786. "770": [0, 0.69444, 0.06646, 0],
  7787. "771": [0, 0.66786, 0.11585, 0],
  7788. "772": [0, 0.56167, 0.10333, 0],
  7789. "774": [0, 0.69444, 0.10806, 0],
  7790. "775": [0, 0.66786, 0.11752, 0],
  7791. "776": [0, 0.66786, 0.10474, 0],
  7792. "778": [0, 0.69444, 0, 0],
  7793. "779": [0, 0.69444, 0.1225, 0],
  7794. "780": [0, 0.62847, 0.08295, 0],
  7795. "915": [0, 0.68333, 0.13305, 0],
  7796. "916": [0, 0.68333, 0, 0],
  7797. "920": [0, 0.68333, 0.09403, 0],
  7798. "923": [0, 0.68333, 0, 0],
  7799. "926": [0, 0.68333, 0.15294, 0],
  7800. "928": [0, 0.68333, 0.16389, 0],
  7801. "931": [0, 0.68333, 0.12028, 0],
  7802. "933": [0, 0.68333, 0.11111, 0],
  7803. "934": [0, 0.68333, 0.05986, 0],
  7804. "936": [0, 0.68333, 0.11111, 0],
  7805. "937": [0, 0.68333, 0.10257, 0],
  7806. "8211": [0, 0.43056, 0.09208, 0],
  7807. "8212": [0, 0.43056, 0.09208, 0],
  7808. "8216": [0, 0.69444, 0.12417, 0],
  7809. "8217": [0, 0.69444, 0.12417, 0],
  7810. "8220": [0, 0.69444, 0.1685, 0],
  7811. "8221": [0, 0.69444, 0.06961, 0],
  7812. "8463": [0, 0.68889, 0, 0]
  7813. },
  7814. "Main-Regular": {
  7815. "32": [0, 0, 0, 0],
  7816. "33": [0, 0.69444, 0, 0],
  7817. "34": [0, 0.69444, 0, 0],
  7818. "35": [0.19444, 0.69444, 0, 0],
  7819. "36": [0.05556, 0.75, 0, 0],
  7820. "37": [0.05556, 0.75, 0, 0],
  7821. "38": [0, 0.69444, 0, 0],
  7822. "39": [0, 0.69444, 0, 0],
  7823. "40": [0.25, 0.75, 0, 0],
  7824. "41": [0.25, 0.75, 0, 0],
  7825. "42": [0, 0.75, 0, 0],
  7826. "43": [0.08333, 0.58333, 0, 0],
  7827. "44": [0.19444, 0.10556, 0, 0],
  7828. "45": [0, 0.43056, 0, 0],
  7829. "46": [0, 0.10556, 0, 0],
  7830. "47": [0.25, 0.75, 0, 0],
  7831. "48": [0, 0.64444, 0, 0],
  7832. "49": [0, 0.64444, 0, 0],
  7833. "50": [0, 0.64444, 0, 0],
  7834. "51": [0, 0.64444, 0, 0],
  7835. "52": [0, 0.64444, 0, 0],
  7836. "53": [0, 0.64444, 0, 0],
  7837. "54": [0, 0.64444, 0, 0],
  7838. "55": [0, 0.64444, 0, 0],
  7839. "56": [0, 0.64444, 0, 0],
  7840. "57": [0, 0.64444, 0, 0],
  7841. "58": [0, 0.43056, 0, 0],
  7842. "59": [0.19444, 0.43056, 0, 0],
  7843. "60": [0.0391, 0.5391, 0, 0],
  7844. "61": [-0.13313, 0.36687, 0, 0],
  7845. "62": [0.0391, 0.5391, 0, 0],
  7846. "63": [0, 0.69444, 0, 0],
  7847. "64": [0, 0.69444, 0, 0],
  7848. "65": [0, 0.68333, 0, 0],
  7849. "66": [0, 0.68333, 0, 0],
  7850. "67": [0, 0.68333, 0, 0],
  7851. "68": [0, 0.68333, 0, 0],
  7852. "69": [0, 0.68333, 0, 0],
  7853. "70": [0, 0.68333, 0, 0],
  7854. "71": [0, 0.68333, 0, 0],
  7855. "72": [0, 0.68333, 0, 0],
  7856. "73": [0, 0.68333, 0, 0],
  7857. "74": [0, 0.68333, 0, 0],
  7858. "75": [0, 0.68333, 0, 0],
  7859. "76": [0, 0.68333, 0, 0],
  7860. "77": [0, 0.68333, 0, 0],
  7861. "78": [0, 0.68333, 0, 0],
  7862. "79": [0, 0.68333, 0, 0],
  7863. "80": [0, 0.68333, 0, 0],
  7864. "81": [0.19444, 0.68333, 0, 0],
  7865. "82": [0, 0.68333, 0, 0],
  7866. "83": [0, 0.68333, 0, 0],
  7867. "84": [0, 0.68333, 0, 0],
  7868. "85": [0, 0.68333, 0, 0],
  7869. "86": [0, 0.68333, 0.01389, 0],
  7870. "87": [0, 0.68333, 0.01389, 0],
  7871. "88": [0, 0.68333, 0, 0],
  7872. "89": [0, 0.68333, 0.025, 0],
  7873. "90": [0, 0.68333, 0, 0],
  7874. "91": [0.25, 0.75, 0, 0],
  7875. "92": [0.25, 0.75, 0, 0],
  7876. "93": [0.25, 0.75, 0, 0],
  7877. "94": [0, 0.69444, 0, 0],
  7878. "95": [0.31, 0.12056, 0.02778, 0],
  7879. "96": [0, 0.69444, 0, 0],
  7880. "97": [0, 0.43056, 0, 0],
  7881. "98": [0, 0.69444, 0, 0],
  7882. "99": [0, 0.43056, 0, 0],
  7883. "100": [0, 0.69444, 0, 0],
  7884. "101": [0, 0.43056, 0, 0],
  7885. "102": [0, 0.69444, 0.07778, 0],
  7886. "103": [0.19444, 0.43056, 0.01389, 0],
  7887. "104": [0, 0.69444, 0, 0],
  7888. "105": [0, 0.66786, 0, 0],
  7889. "106": [0.19444, 0.66786, 0, 0],
  7890. "107": [0, 0.69444, 0, 0],
  7891. "108": [0, 0.69444, 0, 0],
  7892. "109": [0, 0.43056, 0, 0],
  7893. "110": [0, 0.43056, 0, 0],
  7894. "111": [0, 0.43056, 0, 0],
  7895. "112": [0.19444, 0.43056, 0, 0],
  7896. "113": [0.19444, 0.43056, 0, 0],
  7897. "114": [0, 0.43056, 0, 0],
  7898. "115": [0, 0.43056, 0, 0],
  7899. "116": [0, 0.61508, 0, 0],
  7900. "117": [0, 0.43056, 0, 0],
  7901. "118": [0, 0.43056, 0.01389, 0],
  7902. "119": [0, 0.43056, 0.01389, 0],
  7903. "120": [0, 0.43056, 0, 0],
  7904. "121": [0.19444, 0.43056, 0.01389, 0],
  7905. "122": [0, 0.43056, 0, 0],
  7906. "123": [0.25, 0.75, 0, 0],
  7907. "124": [0.25, 0.75, 0, 0],
  7908. "125": [0.25, 0.75, 0, 0],
  7909. "126": [0.35, 0.31786, 0, 0],
  7910. "160": [0, 0, 0, 0],
  7911. "168": [0, 0.66786, 0, 0],
  7912. "172": [0, 0.43056, 0, 0],
  7913. "175": [0, 0.56778, 0, 0],
  7914. "176": [0, 0.69444, 0, 0],
  7915. "177": [0.08333, 0.58333, 0, 0],
  7916. "180": [0, 0.69444, 0, 0],
  7917. "215": [0.08333, 0.58333, 0, 0],
  7918. "247": [0.08333, 0.58333, 0, 0],
  7919. "305": [0, 0.43056, 0, 0],
  7920. "567": [0.19444, 0.43056, 0, 0],
  7921. "710": [0, 0.69444, 0, 0],
  7922. "711": [0, 0.62847, 0, 0],
  7923. "713": [0, 0.56778, 0, 0],
  7924. "714": [0, 0.69444, 0, 0],
  7925. "715": [0, 0.69444, 0, 0],
  7926. "728": [0, 0.69444, 0, 0],
  7927. "729": [0, 0.66786, 0, 0],
  7928. "730": [0, 0.69444, 0, 0],
  7929. "732": [0, 0.66786, 0, 0],
  7930. "768": [0, 0.69444, 0, 0],
  7931. "769": [0, 0.69444, 0, 0],
  7932. "770": [0, 0.69444, 0, 0],
  7933. "771": [0, 0.66786, 0, 0],
  7934. "772": [0, 0.56778, 0, 0],
  7935. "774": [0, 0.69444, 0, 0],
  7936. "775": [0, 0.66786, 0, 0],
  7937. "776": [0, 0.66786, 0, 0],
  7938. "778": [0, 0.69444, 0, 0],
  7939. "779": [0, 0.69444, 0, 0],
  7940. "780": [0, 0.62847, 0, 0],
  7941. "824": [0.19444, 0.69444, 0, 0],
  7942. "915": [0, 0.68333, 0, 0],
  7943. "916": [0, 0.68333, 0, 0],
  7944. "920": [0, 0.68333, 0, 0],
  7945. "923": [0, 0.68333, 0, 0],
  7946. "926": [0, 0.68333, 0, 0],
  7947. "928": [0, 0.68333, 0, 0],
  7948. "931": [0, 0.68333, 0, 0],
  7949. "933": [0, 0.68333, 0, 0],
  7950. "934": [0, 0.68333, 0, 0],
  7951. "936": [0, 0.68333, 0, 0],
  7952. "937": [0, 0.68333, 0, 0],
  7953. "8211": [0, 0.43056, 0.02778, 0],
  7954. "8212": [0, 0.43056, 0.02778, 0],
  7955. "8216": [0, 0.69444, 0, 0],
  7956. "8217": [0, 0.69444, 0, 0],
  7957. "8220": [0, 0.69444, 0, 0],
  7958. "8221": [0, 0.69444, 0, 0],
  7959. "8224": [0.19444, 0.69444, 0, 0],
  7960. "8225": [0.19444, 0.69444, 0, 0],
  7961. "8230": [0, 0.12, 0, 0],
  7962. "8242": [0, 0.55556, 0, 0],
  7963. "8407": [0, 0.71444, 0.15382, 0],
  7964. "8463": [0, 0.68889, 0, 0],
  7965. "8465": [0, 0.69444, 0, 0],
  7966. "8467": [0, 0.69444, 0, 0.11111],
  7967. "8472": [0.19444, 0.43056, 0, 0.11111],
  7968. "8476": [0, 0.69444, 0, 0],
  7969. "8501": [0, 0.69444, 0, 0],
  7970. "8592": [-0.13313, 0.36687, 0, 0],
  7971. "8593": [0.19444, 0.69444, 0, 0],
  7972. "8594": [-0.13313, 0.36687, 0, 0],
  7973. "8595": [0.19444, 0.69444, 0, 0],
  7974. "8596": [-0.13313, 0.36687, 0, 0],
  7975. "8597": [0.25, 0.75, 0, 0],
  7976. "8598": [0.19444, 0.69444, 0, 0],
  7977. "8599": [0.19444, 0.69444, 0, 0],
  7978. "8600": [0.19444, 0.69444, 0, 0],
  7979. "8601": [0.19444, 0.69444, 0, 0],
  7980. "8614": [0.011, 0.511, 0, 0],
  7981. "8617": [0.011, 0.511, 0, 0],
  7982. "8618": [0.011, 0.511, 0, 0],
  7983. "8636": [-0.13313, 0.36687, 0, 0],
  7984. "8637": [-0.13313, 0.36687, 0, 0],
  7985. "8640": [-0.13313, 0.36687, 0, 0],
  7986. "8641": [-0.13313, 0.36687, 0, 0],
  7987. "8652": [0.011, 0.671, 0, 0],
  7988. "8656": [-0.13313, 0.36687, 0, 0],
  7989. "8657": [0.19444, 0.69444, 0, 0],
  7990. "8658": [-0.13313, 0.36687, 0, 0],
  7991. "8659": [0.19444, 0.69444, 0, 0],
  7992. "8660": [-0.13313, 0.36687, 0, 0],
  7993. "8661": [0.25, 0.75, 0, 0],
  7994. "8704": [0, 0.69444, 0, 0],
  7995. "8706": [0, 0.69444, 0.05556, 0.08334],
  7996. "8707": [0, 0.69444, 0, 0],
  7997. "8709": [0.05556, 0.75, 0, 0],
  7998. "8711": [0, 0.68333, 0, 0],
  7999. "8712": [0.0391, 0.5391, 0, 0],
  8000. "8715": [0.0391, 0.5391, 0, 0],
  8001. "8722": [0.08333, 0.58333, 0, 0],
  8002. "8723": [0.08333, 0.58333, 0, 0],
  8003. "8725": [0.25, 0.75, 0, 0],
  8004. "8726": [0.25, 0.75, 0, 0],
  8005. "8727": [-0.03472, 0.46528, 0, 0],
  8006. "8728": [-0.05555, 0.44445, 0, 0],
  8007. "8729": [-0.05555, 0.44445, 0, 0],
  8008. "8730": [0.2, 0.8, 0, 0],
  8009. "8733": [0, 0.43056, 0, 0],
  8010. "8734": [0, 0.43056, 0, 0],
  8011. "8736": [0, 0.69224, 0, 0],
  8012. "8739": [0.25, 0.75, 0, 0],
  8013. "8741": [0.25, 0.75, 0, 0],
  8014. "8743": [0, 0.55556, 0, 0],
  8015. "8744": [0, 0.55556, 0, 0],
  8016. "8745": [0, 0.55556, 0, 0],
  8017. "8746": [0, 0.55556, 0, 0],
  8018. "8747": [0.19444, 0.69444, 0.11111, 0],
  8019. "8764": [-0.13313, 0.36687, 0, 0],
  8020. "8768": [0.19444, 0.69444, 0, 0],
  8021. "8771": [-0.03625, 0.46375, 0, 0],
  8022. "8773": [-0.022, 0.589, 0, 0],
  8023. "8776": [-0.01688, 0.48312, 0, 0],
  8024. "8781": [-0.03625, 0.46375, 0, 0],
  8025. "8784": [-0.133, 0.67, 0, 0],
  8026. "8800": [0.215, 0.716, 0, 0],
  8027. "8801": [-0.03625, 0.46375, 0, 0],
  8028. "8804": [0.13597, 0.63597, 0, 0],
  8029. "8805": [0.13597, 0.63597, 0, 0],
  8030. "8810": [0.0391, 0.5391, 0, 0],
  8031. "8811": [0.0391, 0.5391, 0, 0],
  8032. "8826": [0.0391, 0.5391, 0, 0],
  8033. "8827": [0.0391, 0.5391, 0, 0],
  8034. "8834": [0.0391, 0.5391, 0, 0],
  8035. "8835": [0.0391, 0.5391, 0, 0],
  8036. "8838": [0.13597, 0.63597, 0, 0],
  8037. "8839": [0.13597, 0.63597, 0, 0],
  8038. "8846": [0, 0.55556, 0, 0],
  8039. "8849": [0.13597, 0.63597, 0, 0],
  8040. "8850": [0.13597, 0.63597, 0, 0],
  8041. "8851": [0, 0.55556, 0, 0],
  8042. "8852": [0, 0.55556, 0, 0],
  8043. "8853": [0.08333, 0.58333, 0, 0],
  8044. "8854": [0.08333, 0.58333, 0, 0],
  8045. "8855": [0.08333, 0.58333, 0, 0],
  8046. "8856": [0.08333, 0.58333, 0, 0],
  8047. "8857": [0.08333, 0.58333, 0, 0],
  8048. "8866": [0, 0.69444, 0, 0],
  8049. "8867": [0, 0.69444, 0, 0],
  8050. "8868": [0, 0.69444, 0, 0],
  8051. "8869": [0, 0.69444, 0, 0],
  8052. "8872": [0.249, 0.75, 0, 0],
  8053. "8900": [-0.05555, 0.44445, 0, 0],
  8054. "8901": [-0.05555, 0.44445, 0, 0],
  8055. "8902": [-0.03472, 0.46528, 0, 0],
  8056. "8904": [0.005, 0.505, 0, 0],
  8057. "8942": [0.03, 0.9, 0, 0],
  8058. "8943": [-0.19, 0.31, 0, 0],
  8059. "8945": [-0.1, 0.82, 0, 0],
  8060. "8968": [0.25, 0.75, 0, 0],
  8061. "8969": [0.25, 0.75, 0, 0],
  8062. "8970": [0.25, 0.75, 0, 0],
  8063. "8971": [0.25, 0.75, 0, 0],
  8064. "8994": [-0.14236, 0.35764, 0, 0],
  8065. "8995": [-0.14236, 0.35764, 0, 0],
  8066. "9136": [0.244, 0.744, 0, 0],
  8067. "9137": [0.244, 0.744, 0, 0],
  8068. "9651": [0.19444, 0.69444, 0, 0],
  8069. "9657": [-0.03472, 0.46528, 0, 0],
  8070. "9661": [0.19444, 0.69444, 0, 0],
  8071. "9667": [-0.03472, 0.46528, 0, 0],
  8072. "9711": [0.19444, 0.69444, 0, 0],
  8073. "9824": [0.12963, 0.69444, 0, 0],
  8074. "9825": [0.12963, 0.69444, 0, 0],
  8075. "9826": [0.12963, 0.69444, 0, 0],
  8076. "9827": [0.12963, 0.69444, 0, 0],
  8077. "9837": [0, 0.75, 0, 0],
  8078. "9838": [0.19444, 0.69444, 0, 0],
  8079. "9839": [0.19444, 0.69444, 0, 0],
  8080. "10216": [0.25, 0.75, 0, 0],
  8081. "10217": [0.25, 0.75, 0, 0],
  8082. "10222": [0.244, 0.744, 0, 0],
  8083. "10223": [0.244, 0.744, 0, 0],
  8084. "10229": [0.011, 0.511, 0, 0],
  8085. "10230": [0.011, 0.511, 0, 0],
  8086. "10231": [0.011, 0.511, 0, 0],
  8087. "10232": [0.024, 0.525, 0, 0],
  8088. "10233": [0.024, 0.525, 0, 0],
  8089. "10234": [0.024, 0.525, 0, 0],
  8090. "10236": [0.011, 0.511, 0, 0],
  8091. "10815": [0, 0.68333, 0, 0],
  8092. "10927": [0.13597, 0.63597, 0, 0],
  8093. "10928": [0.13597, 0.63597, 0, 0]
  8094. },
  8095. "Math-BoldItalic": {
  8096. "47": [0.19444, 0.69444, 0, 0],
  8097. "65": [0, 0.68611, 0, 0],
  8098. "66": [0, 0.68611, 0.04835, 0],
  8099. "67": [0, 0.68611, 0.06979, 0],
  8100. "68": [0, 0.68611, 0.03194, 0],
  8101. "69": [0, 0.68611, 0.05451, 0],
  8102. "70": [0, 0.68611, 0.15972, 0],
  8103. "71": [0, 0.68611, 0, 0],
  8104. "72": [0, 0.68611, 0.08229, 0],
  8105. "73": [0, 0.68611, 0.07778, 0],
  8106. "74": [0, 0.68611, 0.10069, 0],
  8107. "75": [0, 0.68611, 0.06979, 0],
  8108. "76": [0, 0.68611, 0, 0],
  8109. "77": [0, 0.68611, 0.11424, 0],
  8110. "78": [0, 0.68611, 0.11424, 0],
  8111. "79": [0, 0.68611, 0.03194, 0],
  8112. "80": [0, 0.68611, 0.15972, 0],
  8113. "81": [0.19444, 0.68611, 0, 0],
  8114. "82": [0, 0.68611, 0.00421, 0],
  8115. "83": [0, 0.68611, 0.05382, 0],
  8116. "84": [0, 0.68611, 0.15972, 0],
  8117. "85": [0, 0.68611, 0.11424, 0],
  8118. "86": [0, 0.68611, 0.25555, 0],
  8119. "87": [0, 0.68611, 0.15972, 0],
  8120. "88": [0, 0.68611, 0.07778, 0],
  8121. "89": [0, 0.68611, 0.25555, 0],
  8122. "90": [0, 0.68611, 0.06979, 0],
  8123. "97": [0, 0.44444, 0, 0],
  8124. "98": [0, 0.69444, 0, 0],
  8125. "99": [0, 0.44444, 0, 0],
  8126. "100": [0, 0.69444, 0, 0],
  8127. "101": [0, 0.44444, 0, 0],
  8128. "102": [0.19444, 0.69444, 0.11042, 0],
  8129. "103": [0.19444, 0.44444, 0.03704, 0],
  8130. "104": [0, 0.69444, 0, 0],
  8131. "105": [0, 0.69326, 0, 0],
  8132. "106": [0.19444, 0.69326, 0.0622, 0],
  8133. "107": [0, 0.69444, 0.01852, 0],
  8134. "108": [0, 0.69444, 0.0088, 0],
  8135. "109": [0, 0.44444, 0, 0],
  8136. "110": [0, 0.44444, 0, 0],
  8137. "111": [0, 0.44444, 0, 0],
  8138. "112": [0.19444, 0.44444, 0, 0],
  8139. "113": [0.19444, 0.44444, 0.03704, 0],
  8140. "114": [0, 0.44444, 0.03194, 0],
  8141. "115": [0, 0.44444, 0, 0],
  8142. "116": [0, 0.63492, 0, 0],
  8143. "117": [0, 0.44444, 0, 0],
  8144. "118": [0, 0.44444, 0.03704, 0],
  8145. "119": [0, 0.44444, 0.02778, 0],
  8146. "120": [0, 0.44444, 0, 0],
  8147. "121": [0.19444, 0.44444, 0.03704, 0],
  8148. "122": [0, 0.44444, 0.04213, 0],
  8149. "915": [0, 0.68611, 0.15972, 0],
  8150. "916": [0, 0.68611, 0, 0],
  8151. "920": [0, 0.68611, 0.03194, 0],
  8152. "923": [0, 0.68611, 0, 0],
  8153. "926": [0, 0.68611, 0.07458, 0],
  8154. "928": [0, 0.68611, 0.08229, 0],
  8155. "931": [0, 0.68611, 0.05451, 0],
  8156. "933": [0, 0.68611, 0.15972, 0],
  8157. "934": [0, 0.68611, 0, 0],
  8158. "936": [0, 0.68611, 0.11653, 0],
  8159. "937": [0, 0.68611, 0.04835, 0],
  8160. "945": [0, 0.44444, 0, 0],
  8161. "946": [0.19444, 0.69444, 0.03403, 0],
  8162. "947": [0.19444, 0.44444, 0.06389, 0],
  8163. "948": [0, 0.69444, 0.03819, 0],
  8164. "949": [0, 0.44444, 0, 0],
  8165. "950": [0.19444, 0.69444, 0.06215, 0],
  8166. "951": [0.19444, 0.44444, 0.03704, 0],
  8167. "952": [0, 0.69444, 0.03194, 0],
  8168. "953": [0, 0.44444, 0, 0],
  8169. "954": [0, 0.44444, 0, 0],
  8170. "955": [0, 0.69444, 0, 0],
  8171. "956": [0.19444, 0.44444, 0, 0],
  8172. "957": [0, 0.44444, 0.06898, 0],
  8173. "958": [0.19444, 0.69444, 0.03021, 0],
  8174. "959": [0, 0.44444, 0, 0],
  8175. "960": [0, 0.44444, 0.03704, 0],
  8176. "961": [0.19444, 0.44444, 0, 0],
  8177. "962": [0.09722, 0.44444, 0.07917, 0],
  8178. "963": [0, 0.44444, 0.03704, 0],
  8179. "964": [0, 0.44444, 0.13472, 0],
  8180. "965": [0, 0.44444, 0.03704, 0],
  8181. "966": [0.19444, 0.44444, 0, 0],
  8182. "967": [0.19444, 0.44444, 0, 0],
  8183. "968": [0.19444, 0.69444, 0.03704, 0],
  8184. "969": [0, 0.44444, 0.03704, 0],
  8185. "977": [0, 0.69444, 0, 0],
  8186. "981": [0.19444, 0.69444, 0, 0],
  8187. "982": [0, 0.44444, 0.03194, 0],
  8188. "1009": [0.19444, 0.44444, 0, 0],
  8189. "1013": [0, 0.44444, 0, 0]
  8190. },
  8191. "Math-Italic": {
  8192. "47": [0.19444, 0.69444, 0, 0],
  8193. "65": [0, 0.68333, 0, 0.13889],
  8194. "66": [0, 0.68333, 0.05017, 0.08334],
  8195. "67": [0, 0.68333, 0.07153, 0.08334],
  8196. "68": [0, 0.68333, 0.02778, 0.05556],
  8197. "69": [0, 0.68333, 0.05764, 0.08334],
  8198. "70": [0, 0.68333, 0.13889, 0.08334],
  8199. "71": [0, 0.68333, 0, 0.08334],
  8200. "72": [0, 0.68333, 0.08125, 0.05556],
  8201. "73": [0, 0.68333, 0.07847, 0.11111],
  8202. "74": [0, 0.68333, 0.09618, 0.16667],
  8203. "75": [0, 0.68333, 0.07153, 0.05556],
  8204. "76": [0, 0.68333, 0, 0.02778],
  8205. "77": [0, 0.68333, 0.10903, 0.08334],
  8206. "78": [0, 0.68333, 0.10903, 0.08334],
  8207. "79": [0, 0.68333, 0.02778, 0.08334],
  8208. "80": [0, 0.68333, 0.13889, 0.08334],
  8209. "81": [0.19444, 0.68333, 0, 0.08334],
  8210. "82": [0, 0.68333, 0.00773, 0.08334],
  8211. "83": [0, 0.68333, 0.05764, 0.08334],
  8212. "84": [0, 0.68333, 0.13889, 0.08334],
  8213. "85": [0, 0.68333, 0.10903, 0.02778],
  8214. "86": [0, 0.68333, 0.22222, 0],
  8215. "87": [0, 0.68333, 0.13889, 0],
  8216. "88": [0, 0.68333, 0.07847, 0.08334],
  8217. "89": [0, 0.68333, 0.22222, 0],
  8218. "90": [0, 0.68333, 0.07153, 0.08334],
  8219. "97": [0, 0.43056, 0, 0],
  8220. "98": [0, 0.69444, 0, 0],
  8221. "99": [0, 0.43056, 0, 0.05556],
  8222. "100": [0, 0.69444, 0, 0.16667],
  8223. "101": [0, 0.43056, 0, 0.05556],
  8224. "102": [0.19444, 0.69444, 0.10764, 0.16667],
  8225. "103": [0.19444, 0.43056, 0.03588, 0.02778],
  8226. "104": [0, 0.69444, 0, 0],
  8227. "105": [0, 0.65952, 0, 0],
  8228. "106": [0.19444, 0.65952, 0.05724, 0],
  8229. "107": [0, 0.69444, 0.03148, 0],
  8230. "108": [0, 0.69444, 0.01968, 0.08334],
  8231. "109": [0, 0.43056, 0, 0],
  8232. "110": [0, 0.43056, 0, 0],
  8233. "111": [0, 0.43056, 0, 0.05556],
  8234. "112": [0.19444, 0.43056, 0, 0.08334],
  8235. "113": [0.19444, 0.43056, 0.03588, 0.08334],
  8236. "114": [0, 0.43056, 0.02778, 0.05556],
  8237. "115": [0, 0.43056, 0, 0.05556],
  8238. "116": [0, 0.61508, 0, 0.08334],
  8239. "117": [0, 0.43056, 0, 0.02778],
  8240. "118": [0, 0.43056, 0.03588, 0.02778],
  8241. "119": [0, 0.43056, 0.02691, 0.08334],
  8242. "120": [0, 0.43056, 0, 0.02778],
  8243. "121": [0.19444, 0.43056, 0.03588, 0.05556],
  8244. "122": [0, 0.43056, 0.04398, 0.05556],
  8245. "915": [0, 0.68333, 0.13889, 0.08334],
  8246. "916": [0, 0.68333, 0, 0.16667],
  8247. "920": [0, 0.68333, 0.02778, 0.08334],
  8248. "923": [0, 0.68333, 0, 0.16667],
  8249. "926": [0, 0.68333, 0.07569, 0.08334],
  8250. "928": [0, 0.68333, 0.08125, 0.05556],
  8251. "931": [0, 0.68333, 0.05764, 0.08334],
  8252. "933": [0, 0.68333, 0.13889, 0.05556],
  8253. "934": [0, 0.68333, 0, 0.08334],
  8254. "936": [0, 0.68333, 0.11, 0.05556],
  8255. "937": [0, 0.68333, 0.05017, 0.08334],
  8256. "945": [0, 0.43056, 0.0037, 0.02778],
  8257. "946": [0.19444, 0.69444, 0.05278, 0.08334],
  8258. "947": [0.19444, 0.43056, 0.05556, 0],
  8259. "948": [0, 0.69444, 0.03785, 0.05556],
  8260. "949": [0, 0.43056, 0, 0.08334],
  8261. "950": [0.19444, 0.69444, 0.07378, 0.08334],
  8262. "951": [0.19444, 0.43056, 0.03588, 0.05556],
  8263. "952": [0, 0.69444, 0.02778, 0.08334],
  8264. "953": [0, 0.43056, 0, 0.05556],
  8265. "954": [0, 0.43056, 0, 0],
  8266. "955": [0, 0.69444, 0, 0],
  8267. "956": [0.19444, 0.43056, 0, 0.02778],
  8268. "957": [0, 0.43056, 0.06366, 0.02778],
  8269. "958": [0.19444, 0.69444, 0.04601, 0.11111],
  8270. "959": [0, 0.43056, 0, 0.05556],
  8271. "960": [0, 0.43056, 0.03588, 0],
  8272. "961": [0.19444, 0.43056, 0, 0.08334],
  8273. "962": [0.09722, 0.43056, 0.07986, 0.08334],
  8274. "963": [0, 0.43056, 0.03588, 0],
  8275. "964": [0, 0.43056, 0.1132, 0.02778],
  8276. "965": [0, 0.43056, 0.03588, 0.02778],
  8277. "966": [0.19444, 0.43056, 0, 0.08334],
  8278. "967": [0.19444, 0.43056, 0, 0.05556],
  8279. "968": [0.19444, 0.69444, 0.03588, 0.11111],
  8280. "969": [0, 0.43056, 0.03588, 0],
  8281. "977": [0, 0.69444, 0, 0.08334],
  8282. "981": [0.19444, 0.69444, 0, 0.08334],
  8283. "982": [0, 0.43056, 0.02778, 0],
  8284. "1009": [0.19444, 0.43056, 0, 0.08334],
  8285. "1013": [0, 0.43056, 0, 0.05556]
  8286. },
  8287. "Math-Regular": {
  8288. "65": [0, 0.68333, 0, 0.13889],
  8289. "66": [0, 0.68333, 0.05017, 0.08334],
  8290. "67": [0, 0.68333, 0.07153, 0.08334],
  8291. "68": [0, 0.68333, 0.02778, 0.05556],
  8292. "69": [0, 0.68333, 0.05764, 0.08334],
  8293. "70": [0, 0.68333, 0.13889, 0.08334],
  8294. "71": [0, 0.68333, 0, 0.08334],
  8295. "72": [0, 0.68333, 0.08125, 0.05556],
  8296. "73": [0, 0.68333, 0.07847, 0.11111],
  8297. "74": [0, 0.68333, 0.09618, 0.16667],
  8298. "75": [0, 0.68333, 0.07153, 0.05556],
  8299. "76": [0, 0.68333, 0, 0.02778],
  8300. "77": [0, 0.68333, 0.10903, 0.08334],
  8301. "78": [0, 0.68333, 0.10903, 0.08334],
  8302. "79": [0, 0.68333, 0.02778, 0.08334],
  8303. "80": [0, 0.68333, 0.13889, 0.08334],
  8304. "81": [0.19444, 0.68333, 0, 0.08334],
  8305. "82": [0, 0.68333, 0.00773, 0.08334],
  8306. "83": [0, 0.68333, 0.05764, 0.08334],
  8307. "84": [0, 0.68333, 0.13889, 0.08334],
  8308. "85": [0, 0.68333, 0.10903, 0.02778],
  8309. "86": [0, 0.68333, 0.22222, 0],
  8310. "87": [0, 0.68333, 0.13889, 0],
  8311. "88": [0, 0.68333, 0.07847, 0.08334],
  8312. "89": [0, 0.68333, 0.22222, 0],
  8313. "90": [0, 0.68333, 0.07153, 0.08334],
  8314. "97": [0, 0.43056, 0, 0],
  8315. "98": [0, 0.69444, 0, 0],
  8316. "99": [0, 0.43056, 0, 0.05556],
  8317. "100": [0, 0.69444, 0, 0.16667],
  8318. "101": [0, 0.43056, 0, 0.05556],
  8319. "102": [0.19444, 0.69444, 0.10764, 0.16667],
  8320. "103": [0.19444, 0.43056, 0.03588, 0.02778],
  8321. "104": [0, 0.69444, 0, 0],
  8322. "105": [0, 0.65952, 0, 0],
  8323. "106": [0.19444, 0.65952, 0.05724, 0],
  8324. "107": [0, 0.69444, 0.03148, 0],
  8325. "108": [0, 0.69444, 0.01968, 0.08334],
  8326. "109": [0, 0.43056, 0, 0],
  8327. "110": [0, 0.43056, 0, 0],
  8328. "111": [0, 0.43056, 0, 0.05556],
  8329. "112": [0.19444, 0.43056, 0, 0.08334],
  8330. "113": [0.19444, 0.43056, 0.03588, 0.08334],
  8331. "114": [0, 0.43056, 0.02778, 0.05556],
  8332. "115": [0, 0.43056, 0, 0.05556],
  8333. "116": [0, 0.61508, 0, 0.08334],
  8334. "117": [0, 0.43056, 0, 0.02778],
  8335. "118": [0, 0.43056, 0.03588, 0.02778],
  8336. "119": [0, 0.43056, 0.02691, 0.08334],
  8337. "120": [0, 0.43056, 0, 0.02778],
  8338. "121": [0.19444, 0.43056, 0.03588, 0.05556],
  8339. "122": [0, 0.43056, 0.04398, 0.05556],
  8340. "915": [0, 0.68333, 0.13889, 0.08334],
  8341. "916": [0, 0.68333, 0, 0.16667],
  8342. "920": [0, 0.68333, 0.02778, 0.08334],
  8343. "923": [0, 0.68333, 0, 0.16667],
  8344. "926": [0, 0.68333, 0.07569, 0.08334],
  8345. "928": [0, 0.68333, 0.08125, 0.05556],
  8346. "931": [0, 0.68333, 0.05764, 0.08334],
  8347. "933": [0, 0.68333, 0.13889, 0.05556],
  8348. "934": [0, 0.68333, 0, 0.08334],
  8349. "936": [0, 0.68333, 0.11, 0.05556],
  8350. "937": [0, 0.68333, 0.05017, 0.08334],
  8351. "945": [0, 0.43056, 0.0037, 0.02778],
  8352. "946": [0.19444, 0.69444, 0.05278, 0.08334],
  8353. "947": [0.19444, 0.43056, 0.05556, 0],
  8354. "948": [0, 0.69444, 0.03785, 0.05556],
  8355. "949": [0, 0.43056, 0, 0.08334],
  8356. "950": [0.19444, 0.69444, 0.07378, 0.08334],
  8357. "951": [0.19444, 0.43056, 0.03588, 0.05556],
  8358. "952": [0, 0.69444, 0.02778, 0.08334],
  8359. "953": [0, 0.43056, 0, 0.05556],
  8360. "954": [0, 0.43056, 0, 0],
  8361. "955": [0, 0.69444, 0, 0],
  8362. "956": [0.19444, 0.43056, 0, 0.02778],
  8363. "957": [0, 0.43056, 0.06366, 0.02778],
  8364. "958": [0.19444, 0.69444, 0.04601, 0.11111],
  8365. "959": [0, 0.43056, 0, 0.05556],
  8366. "960": [0, 0.43056, 0.03588, 0],
  8367. "961": [0.19444, 0.43056, 0, 0.08334],
  8368. "962": [0.09722, 0.43056, 0.07986, 0.08334],
  8369. "963": [0, 0.43056, 0.03588, 0],
  8370. "964": [0, 0.43056, 0.1132, 0.02778],
  8371. "965": [0, 0.43056, 0.03588, 0.02778],
  8372. "966": [0.19444, 0.43056, 0, 0.08334],
  8373. "967": [0.19444, 0.43056, 0, 0.05556],
  8374. "968": [0.19444, 0.69444, 0.03588, 0.11111],
  8375. "969": [0, 0.43056, 0.03588, 0],
  8376. "977": [0, 0.69444, 0, 0.08334],
  8377. "981": [0.19444, 0.69444, 0, 0.08334],
  8378. "982": [0, 0.43056, 0.02778, 0],
  8379. "1009": [0.19444, 0.43056, 0, 0.08334],
  8380. "1013": [0, 0.43056, 0, 0.05556]
  8381. },
  8382. "SansSerif-Regular": {
  8383. "33": [0, 0.69444, 0, 0],
  8384. "34": [0, 0.69444, 0, 0],
  8385. "35": [0.19444, 0.69444, 0, 0],
  8386. "36": [0.05556, 0.75, 0, 0],
  8387. "37": [0.05556, 0.75, 0, 0],
  8388. "38": [0, 0.69444, 0, 0],
  8389. "39": [0, 0.69444, 0, 0],
  8390. "40": [0.25, 0.75, 0, 0],
  8391. "41": [0.25, 0.75, 0, 0],
  8392. "42": [0, 0.75, 0, 0],
  8393. "43": [0.08333, 0.58333, 0, 0],
  8394. "44": [0.125, 0.08333, 0, 0],
  8395. "45": [0, 0.44444, 0, 0],
  8396. "46": [0, 0.08333, 0, 0],
  8397. "47": [0.25, 0.75, 0, 0],
  8398. "48": [0, 0.65556, 0, 0],
  8399. "49": [0, 0.65556, 0, 0],
  8400. "50": [0, 0.65556, 0, 0],
  8401. "51": [0, 0.65556, 0, 0],
  8402. "52": [0, 0.65556, 0, 0],
  8403. "53": [0, 0.65556, 0, 0],
  8404. "54": [0, 0.65556, 0, 0],
  8405. "55": [0, 0.65556, 0, 0],
  8406. "56": [0, 0.65556, 0, 0],
  8407. "57": [0, 0.65556, 0, 0],
  8408. "58": [0, 0.44444, 0, 0],
  8409. "59": [0.125, 0.44444, 0, 0],
  8410. "61": [-0.13, 0.37, 0, 0],
  8411. "63": [0, 0.69444, 0, 0],
  8412. "64": [0, 0.69444, 0, 0],
  8413. "65": [0, 0.69444, 0, 0],
  8414. "66": [0, 0.69444, 0, 0],
  8415. "67": [0, 0.69444, 0, 0],
  8416. "68": [0, 0.69444, 0, 0],
  8417. "69": [0, 0.69444, 0, 0],
  8418. "70": [0, 0.69444, 0, 0],
  8419. "71": [0, 0.69444, 0, 0],
  8420. "72": [0, 0.69444, 0, 0],
  8421. "73": [0, 0.69444, 0, 0],
  8422. "74": [0, 0.69444, 0, 0],
  8423. "75": [0, 0.69444, 0, 0],
  8424. "76": [0, 0.69444, 0, 0],
  8425. "77": [0, 0.69444, 0, 0],
  8426. "78": [0, 0.69444, 0, 0],
  8427. "79": [0, 0.69444, 0, 0],
  8428. "80": [0, 0.69444, 0, 0],
  8429. "81": [0.125, 0.69444, 0, 0],
  8430. "82": [0, 0.69444, 0, 0],
  8431. "83": [0, 0.69444, 0, 0],
  8432. "84": [0, 0.69444, 0, 0],
  8433. "85": [0, 0.69444, 0, 0],
  8434. "86": [0, 0.69444, 0.01389, 0],
  8435. "87": [0, 0.69444, 0.01389, 0],
  8436. "88": [0, 0.69444, 0, 0],
  8437. "89": [0, 0.69444, 0.025, 0],
  8438. "90": [0, 0.69444, 0, 0],
  8439. "91": [0.25, 0.75, 0, 0],
  8440. "93": [0.25, 0.75, 0, 0],
  8441. "94": [0, 0.69444, 0, 0],
  8442. "95": [0.35, 0.09444, 0.02778, 0],
  8443. "97": [0, 0.44444, 0, 0],
  8444. "98": [0, 0.69444, 0, 0],
  8445. "99": [0, 0.44444, 0, 0],
  8446. "100": [0, 0.69444, 0, 0],
  8447. "101": [0, 0.44444, 0, 0],
  8448. "102": [0, 0.69444, 0.06944, 0],
  8449. "103": [0.19444, 0.44444, 0.01389, 0],
  8450. "104": [0, 0.69444, 0, 0],
  8451. "105": [0, 0.67937, 0, 0],
  8452. "106": [0.19444, 0.67937, 0, 0],
  8453. "107": [0, 0.69444, 0, 0],
  8454. "108": [0, 0.69444, 0, 0],
  8455. "109": [0, 0.44444, 0, 0],
  8456. "110": [0, 0.44444, 0, 0],
  8457. "111": [0, 0.44444, 0, 0],
  8458. "112": [0.19444, 0.44444, 0, 0],
  8459. "113": [0.19444, 0.44444, 0, 0],
  8460. "114": [0, 0.44444, 0.01389, 0],
  8461. "115": [0, 0.44444, 0, 0],
  8462. "116": [0, 0.57143, 0, 0],
  8463. "117": [0, 0.44444, 0, 0],
  8464. "118": [0, 0.44444, 0.01389, 0],
  8465. "119": [0, 0.44444, 0.01389, 0],
  8466. "120": [0, 0.44444, 0, 0],
  8467. "121": [0.19444, 0.44444, 0.01389, 0],
  8468. "122": [0, 0.44444, 0, 0],
  8469. "126": [0.35, 0.32659, 0, 0],
  8470. "305": [0, 0.44444, 0, 0],
  8471. "567": [0.19444, 0.44444, 0, 0],
  8472. "768": [0, 0.69444, 0, 0],
  8473. "769": [0, 0.69444, 0, 0],
  8474. "770": [0, 0.69444, 0, 0],
  8475. "771": [0, 0.67659, 0, 0],
  8476. "772": [0, 0.60889, 0, 0],
  8477. "774": [0, 0.69444, 0, 0],
  8478. "775": [0, 0.67937, 0, 0],
  8479. "776": [0, 0.67937, 0, 0],
  8480. "778": [0, 0.69444, 0, 0],
  8481. "779": [0, 0.69444, 0, 0],
  8482. "780": [0, 0.63194, 0, 0],
  8483. "915": [0, 0.69444, 0, 0],
  8484. "916": [0, 0.69444, 0, 0],
  8485. "920": [0, 0.69444, 0, 0],
  8486. "923": [0, 0.69444, 0, 0],
  8487. "926": [0, 0.69444, 0, 0],
  8488. "928": [0, 0.69444, 0, 0],
  8489. "931": [0, 0.69444, 0, 0],
  8490. "933": [0, 0.69444, 0, 0],
  8491. "934": [0, 0.69444, 0, 0],
  8492. "936": [0, 0.69444, 0, 0],
  8493. "937": [0, 0.69444, 0, 0],
  8494. "8211": [0, 0.44444, 0.02778, 0],
  8495. "8212": [0, 0.44444, 0.02778, 0],
  8496. "8216": [0, 0.69444, 0, 0],
  8497. "8217": [0, 0.69444, 0, 0],
  8498. "8220": [0, 0.69444, 0, 0],
  8499. "8221": [0, 0.69444, 0, 0]
  8500. },
  8501. "Script-Regular": {
  8502. "65": [0, 0.7, 0.22925, 0],
  8503. "66": [0, 0.7, 0.04087, 0],
  8504. "67": [0, 0.7, 0.1689, 0],
  8505. "68": [0, 0.7, 0.09371, 0],
  8506. "69": [0, 0.7, 0.18583, 0],
  8507. "70": [0, 0.7, 0.13634, 0],
  8508. "71": [0, 0.7, 0.17322, 0],
  8509. "72": [0, 0.7, 0.29694, 0],
  8510. "73": [0, 0.7, 0.19189, 0],
  8511. "74": [0.27778, 0.7, 0.19189, 0],
  8512. "75": [0, 0.7, 0.31259, 0],
  8513. "76": [0, 0.7, 0.19189, 0],
  8514. "77": [0, 0.7, 0.15981, 0],
  8515. "78": [0, 0.7, 0.3525, 0],
  8516. "79": [0, 0.7, 0.08078, 0],
  8517. "80": [0, 0.7, 0.08078, 0],
  8518. "81": [0, 0.7, 0.03305, 0],
  8519. "82": [0, 0.7, 0.06259, 0],
  8520. "83": [0, 0.7, 0.19189, 0],
  8521. "84": [0, 0.7, 0.29087, 0],
  8522. "85": [0, 0.7, 0.25815, 0],
  8523. "86": [0, 0.7, 0.27523, 0],
  8524. "87": [0, 0.7, 0.27523, 0],
  8525. "88": [0, 0.7, 0.26006, 0],
  8526. "89": [0, 0.7, 0.2939, 0],
  8527. "90": [0, 0.7, 0.24037, 0]
  8528. },
  8529. "Size1-Regular": {
  8530. "40": [0.35001, 0.85, 0, 0],
  8531. "41": [0.35001, 0.85, 0, 0],
  8532. "47": [0.35001, 0.85, 0, 0],
  8533. "91": [0.35001, 0.85, 0, 0],
  8534. "92": [0.35001, 0.85, 0, 0],
  8535. "93": [0.35001, 0.85, 0, 0],
  8536. "123": [0.35001, 0.85, 0, 0],
  8537. "125": [0.35001, 0.85, 0, 0],
  8538. "710": [0, 0.72222, 0, 0],
  8539. "732": [0, 0.72222, 0, 0],
  8540. "770": [0, 0.72222, 0, 0],
  8541. "771": [0, 0.72222, 0, 0],
  8542. "8214": [-0.00099, 0.601, 0, 0],
  8543. "8593": [1e-05, 0.6, 0, 0],
  8544. "8595": [1e-05, 0.6, 0, 0],
  8545. "8657": [1e-05, 0.6, 0, 0],
  8546. "8659": [1e-05, 0.6, 0, 0],
  8547. "8719": [0.25001, 0.75, 0, 0],
  8548. "8720": [0.25001, 0.75, 0, 0],
  8549. "8721": [0.25001, 0.75, 0, 0],
  8550. "8730": [0.35001, 0.85, 0, 0],
  8551. "8739": [-0.00599, 0.606, 0, 0],
  8552. "8741": [-0.00599, 0.606, 0, 0],
  8553. "8747": [0.30612, 0.805, 0.19445, 0],
  8554. "8748": [0.306, 0.805, 0.19445, 0],
  8555. "8749": [0.306, 0.805, 0.19445, 0],
  8556. "8750": [0.30612, 0.805, 0.19445, 0],
  8557. "8896": [0.25001, 0.75, 0, 0],
  8558. "8897": [0.25001, 0.75, 0, 0],
  8559. "8898": [0.25001, 0.75, 0, 0],
  8560. "8899": [0.25001, 0.75, 0, 0],
  8561. "8968": [0.35001, 0.85, 0, 0],
  8562. "8969": [0.35001, 0.85, 0, 0],
  8563. "8970": [0.35001, 0.85, 0, 0],
  8564. "8971": [0.35001, 0.85, 0, 0],
  8565. "9168": [-0.00099, 0.601, 0, 0],
  8566. "10216": [0.35001, 0.85, 0, 0],
  8567. "10217": [0.35001, 0.85, 0, 0],
  8568. "10752": [0.25001, 0.75, 0, 0],
  8569. "10753": [0.25001, 0.75, 0, 0],
  8570. "10754": [0.25001, 0.75, 0, 0],
  8571. "10756": [0.25001, 0.75, 0, 0],
  8572. "10758": [0.25001, 0.75, 0, 0]
  8573. },
  8574. "Size2-Regular": {
  8575. "40": [0.65002, 1.15, 0, 0],
  8576. "41": [0.65002, 1.15, 0, 0],
  8577. "47": [0.65002, 1.15, 0, 0],
  8578. "91": [0.65002, 1.15, 0, 0],
  8579. "92": [0.65002, 1.15, 0, 0],
  8580. "93": [0.65002, 1.15, 0, 0],
  8581. "123": [0.65002, 1.15, 0, 0],
  8582. "125": [0.65002, 1.15, 0, 0],
  8583. "710": [0, 0.75, 0, 0],
  8584. "732": [0, 0.75, 0, 0],
  8585. "770": [0, 0.75, 0, 0],
  8586. "771": [0, 0.75, 0, 0],
  8587. "8719": [0.55001, 1.05, 0, 0],
  8588. "8720": [0.55001, 1.05, 0, 0],
  8589. "8721": [0.55001, 1.05, 0, 0],
  8590. "8730": [0.65002, 1.15, 0, 0],
  8591. "8747": [0.86225, 1.36, 0.44445, 0],
  8592. "8748": [0.862, 1.36, 0.44445, 0],
  8593. "8749": [0.862, 1.36, 0.44445, 0],
  8594. "8750": [0.86225, 1.36, 0.44445, 0],
  8595. "8896": [0.55001, 1.05, 0, 0],
  8596. "8897": [0.55001, 1.05, 0, 0],
  8597. "8898": [0.55001, 1.05, 0, 0],
  8598. "8899": [0.55001, 1.05, 0, 0],
  8599. "8968": [0.65002, 1.15, 0, 0],
  8600. "8969": [0.65002, 1.15, 0, 0],
  8601. "8970": [0.65002, 1.15, 0, 0],
  8602. "8971": [0.65002, 1.15, 0, 0],
  8603. "10216": [0.65002, 1.15, 0, 0],
  8604. "10217": [0.65002, 1.15, 0, 0],
  8605. "10752": [0.55001, 1.05, 0, 0],
  8606. "10753": [0.55001, 1.05, 0, 0],
  8607. "10754": [0.55001, 1.05, 0, 0],
  8608. "10756": [0.55001, 1.05, 0, 0],
  8609. "10758": [0.55001, 1.05, 0, 0]
  8610. },
  8611. "Size3-Regular": {
  8612. "40": [0.95003, 1.45, 0, 0],
  8613. "41": [0.95003, 1.45, 0, 0],
  8614. "47": [0.95003, 1.45, 0, 0],
  8615. "91": [0.95003, 1.45, 0, 0],
  8616. "92": [0.95003, 1.45, 0, 0],
  8617. "93": [0.95003, 1.45, 0, 0],
  8618. "123": [0.95003, 1.45, 0, 0],
  8619. "125": [0.95003, 1.45, 0, 0],
  8620. "710": [0, 0.75, 0, 0],
  8621. "732": [0, 0.75, 0, 0],
  8622. "770": [0, 0.75, 0, 0],
  8623. "771": [0, 0.75, 0, 0],
  8624. "8730": [0.95003, 1.45, 0, 0],
  8625. "8968": [0.95003, 1.45, 0, 0],
  8626. "8969": [0.95003, 1.45, 0, 0],
  8627. "8970": [0.95003, 1.45, 0, 0],
  8628. "8971": [0.95003, 1.45, 0, 0],
  8629. "10216": [0.95003, 1.45, 0, 0],
  8630. "10217": [0.95003, 1.45, 0, 0]
  8631. },
  8632. "Size4-Regular": {
  8633. "40": [1.25003, 1.75, 0, 0],
  8634. "41": [1.25003, 1.75, 0, 0],
  8635. "47": [1.25003, 1.75, 0, 0],
  8636. "91": [1.25003, 1.75, 0, 0],
  8637. "92": [1.25003, 1.75, 0, 0],
  8638. "93": [1.25003, 1.75, 0, 0],
  8639. "123": [1.25003, 1.75, 0, 0],
  8640. "125": [1.25003, 1.75, 0, 0],
  8641. "710": [0, 0.825, 0, 0],
  8642. "732": [0, 0.825, 0, 0],
  8643. "770": [0, 0.825, 0, 0],
  8644. "771": [0, 0.825, 0, 0],
  8645. "8730": [1.25003, 1.75, 0, 0],
  8646. "8968": [1.25003, 1.75, 0, 0],
  8647. "8969": [1.25003, 1.75, 0, 0],
  8648. "8970": [1.25003, 1.75, 0, 0],
  8649. "8971": [1.25003, 1.75, 0, 0],
  8650. "9115": [0.64502, 1.155, 0, 0],
  8651. "9116": [1e-05, 0.6, 0, 0],
  8652. "9117": [0.64502, 1.155, 0, 0],
  8653. "9118": [0.64502, 1.155, 0, 0],
  8654. "9119": [1e-05, 0.6, 0, 0],
  8655. "9120": [0.64502, 1.155, 0, 0],
  8656. "9121": [0.64502, 1.155, 0, 0],
  8657. "9122": [-0.00099, 0.601, 0, 0],
  8658. "9123": [0.64502, 1.155, 0, 0],
  8659. "9124": [0.64502, 1.155, 0, 0],
  8660. "9125": [-0.00099, 0.601, 0, 0],
  8661. "9126": [0.64502, 1.155, 0, 0],
  8662. "9127": [1e-05, 0.9, 0, 0],
  8663. "9128": [0.65002, 1.15, 0, 0],
  8664. "9129": [0.90001, 0, 0, 0],
  8665. "9130": [0, 0.3, 0, 0],
  8666. "9131": [1e-05, 0.9, 0, 0],
  8667. "9132": [0.65002, 1.15, 0, 0],
  8668. "9133": [0.90001, 0, 0, 0],
  8669. "9143": [0.88502, 0.915, 0, 0],
  8670. "10216": [1.25003, 1.75, 0, 0],
  8671. "10217": [1.25003, 1.75, 0, 0],
  8672. "57344": [-0.00499, 0.605, 0, 0],
  8673. "57345": [-0.00499, 0.605, 0, 0],
  8674. "57680": [0, 0.12, 0, 0],
  8675. "57681": [0, 0.12, 0, 0],
  8676. "57682": [0, 0.12, 0, 0],
  8677. "57683": [0, 0.12, 0, 0]
  8678. },
  8679. "Typewriter-Regular": {
  8680. "33": [0, 0.61111, 0, 0],
  8681. "34": [0, 0.61111, 0, 0],
  8682. "35": [0, 0.61111, 0, 0],
  8683. "36": [0.08333, 0.69444, 0, 0],
  8684. "37": [0.08333, 0.69444, 0, 0],
  8685. "38": [0, 0.61111, 0, 0],
  8686. "39": [0, 0.61111, 0, 0],
  8687. "40": [0.08333, 0.69444, 0, 0],
  8688. "41": [0.08333, 0.69444, 0, 0],
  8689. "42": [0, 0.52083, 0, 0],
  8690. "43": [-0.08056, 0.53055, 0, 0],
  8691. "44": [0.13889, 0.125, 0, 0],
  8692. "45": [-0.08056, 0.53055, 0, 0],
  8693. "46": [0, 0.125, 0, 0],
  8694. "47": [0.08333, 0.69444, 0, 0],
  8695. "48": [0, 0.61111, 0, 0],
  8696. "49": [0, 0.61111, 0, 0],
  8697. "50": [0, 0.61111, 0, 0],
  8698. "51": [0, 0.61111, 0, 0],
  8699. "52": [0, 0.61111, 0, 0],
  8700. "53": [0, 0.61111, 0, 0],
  8701. "54": [0, 0.61111, 0, 0],
  8702. "55": [0, 0.61111, 0, 0],
  8703. "56": [0, 0.61111, 0, 0],
  8704. "57": [0, 0.61111, 0, 0],
  8705. "58": [0, 0.43056, 0, 0],
  8706. "59": [0.13889, 0.43056, 0, 0],
  8707. "60": [-0.05556, 0.55556, 0, 0],
  8708. "61": [-0.19549, 0.41562, 0, 0],
  8709. "62": [-0.05556, 0.55556, 0, 0],
  8710. "63": [0, 0.61111, 0, 0],
  8711. "64": [0, 0.61111, 0, 0],
  8712. "65": [0, 0.61111, 0, 0],
  8713. "66": [0, 0.61111, 0, 0],
  8714. "67": [0, 0.61111, 0, 0],
  8715. "68": [0, 0.61111, 0, 0],
  8716. "69": [0, 0.61111, 0, 0],
  8717. "70": [0, 0.61111, 0, 0],
  8718. "71": [0, 0.61111, 0, 0],
  8719. "72": [0, 0.61111, 0, 0],
  8720. "73": [0, 0.61111, 0, 0],
  8721. "74": [0, 0.61111, 0, 0],
  8722. "75": [0, 0.61111, 0, 0],
  8723. "76": [0, 0.61111, 0, 0],
  8724. "77": [0, 0.61111, 0, 0],
  8725. "78": [0, 0.61111, 0, 0],
  8726. "79": [0, 0.61111, 0, 0],
  8727. "80": [0, 0.61111, 0, 0],
  8728. "81": [0.13889, 0.61111, 0, 0],
  8729. "82": [0, 0.61111, 0, 0],
  8730. "83": [0, 0.61111, 0, 0],
  8731. "84": [0, 0.61111, 0, 0],
  8732. "85": [0, 0.61111, 0, 0],
  8733. "86": [0, 0.61111, 0, 0],
  8734. "87": [0, 0.61111, 0, 0],
  8735. "88": [0, 0.61111, 0, 0],
  8736. "89": [0, 0.61111, 0, 0],
  8737. "90": [0, 0.61111, 0, 0],
  8738. "91": [0.08333, 0.69444, 0, 0],
  8739. "92": [0.08333, 0.69444, 0, 0],
  8740. "93": [0.08333, 0.69444, 0, 0],
  8741. "94": [0, 0.61111, 0, 0],
  8742. "95": [0.09514, 0, 0, 0],
  8743. "96": [0, 0.61111, 0, 0],
  8744. "97": [0, 0.43056, 0, 0],
  8745. "98": [0, 0.61111, 0, 0],
  8746. "99": [0, 0.43056, 0, 0],
  8747. "100": [0, 0.61111, 0, 0],
  8748. "101": [0, 0.43056, 0, 0],
  8749. "102": [0, 0.61111, 0, 0],
  8750. "103": [0.22222, 0.43056, 0, 0],
  8751. "104": [0, 0.61111, 0, 0],
  8752. "105": [0, 0.61111, 0, 0],
  8753. "106": [0.22222, 0.61111, 0, 0],
  8754. "107": [0, 0.61111, 0, 0],
  8755. "108": [0, 0.61111, 0, 0],
  8756. "109": [0, 0.43056, 0, 0],
  8757. "110": [0, 0.43056, 0, 0],
  8758. "111": [0, 0.43056, 0, 0],
  8759. "112": [0.22222, 0.43056, 0, 0],
  8760. "113": [0.22222, 0.43056, 0, 0],
  8761. "114": [0, 0.43056, 0, 0],
  8762. "115": [0, 0.43056, 0, 0],
  8763. "116": [0, 0.55358, 0, 0],
  8764. "117": [0, 0.43056, 0, 0],
  8765. "118": [0, 0.43056, 0, 0],
  8766. "119": [0, 0.43056, 0, 0],
  8767. "120": [0, 0.43056, 0, 0],
  8768. "121": [0.22222, 0.43056, 0, 0],
  8769. "122": [0, 0.43056, 0, 0],
  8770. "123": [0.08333, 0.69444, 0, 0],
  8771. "124": [0.08333, 0.69444, 0, 0],
  8772. "125": [0.08333, 0.69444, 0, 0],
  8773. "126": [0, 0.61111, 0, 0],
  8774. "127": [0, 0.61111, 0, 0],
  8775. "305": [0, 0.43056, 0, 0],
  8776. "567": [0.22222, 0.43056, 0, 0],
  8777. "768": [0, 0.61111, 0, 0],
  8778. "769": [0, 0.61111, 0, 0],
  8779. "770": [0, 0.61111, 0, 0],
  8780. "771": [0, 0.61111, 0, 0],
  8781. "772": [0, 0.56555, 0, 0],
  8782. "774": [0, 0.61111, 0, 0],
  8783. "776": [0, 0.61111, 0, 0],
  8784. "778": [0, 0.61111, 0, 0],
  8785. "780": [0, 0.56597, 0, 0],
  8786. "915": [0, 0.61111, 0, 0],
  8787. "916": [0, 0.61111, 0, 0],
  8788. "920": [0, 0.61111, 0, 0],
  8789. "923": [0, 0.61111, 0, 0],
  8790. "926": [0, 0.61111, 0, 0],
  8791. "928": [0, 0.61111, 0, 0],
  8792. "931": [0, 0.61111, 0, 0],
  8793. "933": [0, 0.61111, 0, 0],
  8794. "934": [0, 0.61111, 0, 0],
  8795. "936": [0, 0.61111, 0, 0],
  8796. "937": [0, 0.61111, 0, 0],
  8797. "2018": [0, 0.61111, 0, 0],
  8798. "2019": [0, 0.61111, 0, 0],
  8799. "8216": [0, 0.61111, 0, 0],
  8800. "8217": [0, 0.61111, 0, 0],
  8801. "8242": [0, 0.61111, 0, 0],
  8802. "9251": [0.11111, 0.21944, 0, 0]
  8803. }
  8804. };
  8805. exports.default = fontMetricsData;
  8806. },{}],103:[function(require,module,exports){
  8807. "use strict";
  8808. Object.defineProperty(exports, "__esModule", {
  8809. value: true
  8810. });
  8811. var _utils = require("./utils");
  8812. var _utils2 = _interopRequireDefault(_utils);
  8813. var _ParseError = require("./ParseError");
  8814. var _ParseError2 = _interopRequireDefault(_ParseError);
  8815. var _ParseNode = require("./ParseNode");
  8816. var _ParseNode2 = _interopRequireDefault(_ParseNode);
  8817. var _defineFunction2 = require("./defineFunction");
  8818. var _defineFunction3 = _interopRequireDefault(_defineFunction2);
  8819. require("./functions/phantom");
  8820. require("./functions/operators");
  8821. require("./functions/delimsizing");
  8822. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8823. // WARNING: New functions should be added to src/functions and imported here.
  8824. /** Include this to ensure that all functions are defined. */
  8825. var functions = _defineFunction2._functions;
  8826. exports.default = functions;
  8827. // Define a convenience function that mimcs the old semantics of defineFunction
  8828. // to support existing code so that we can migrate it a little bit at a time.
  8829. var defineFunction = function defineFunction(names, props, handler) // null only if handled in parser
  8830. {
  8831. (0, _defineFunction3.default)({ names: names, props: props, handler: handler });
  8832. };
  8833. // A normal square root
  8834. defineFunction(["\\sqrt"], {
  8835. numArgs: 1,
  8836. numOptionalArgs: 1
  8837. }, function (context, args, optArgs) {
  8838. var index = optArgs[0];
  8839. var body = args[0];
  8840. return {
  8841. type: "sqrt",
  8842. body: body,
  8843. index: index
  8844. };
  8845. });
  8846. // Non-mathy text, possibly in a font
  8847. var textFunctionFonts = {
  8848. "\\text": undefined, "\\textrm": "mathrm", "\\textsf": "mathsf",
  8849. "\\texttt": "mathtt", "\\textnormal": "mathrm", "\\textbf": "mathbf",
  8850. "\\textit": "textit"
  8851. };
  8852. defineFunction(["\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", "\\textbf", "\\textit"], {
  8853. numArgs: 1,
  8854. argTypes: ["text"],
  8855. greediness: 2,
  8856. allowedInText: true
  8857. }, function (context, args) {
  8858. var body = args[0];
  8859. return {
  8860. type: "text",
  8861. body: (0, _defineFunction2.ordargument)(body),
  8862. font: textFunctionFonts[context.funcName]
  8863. };
  8864. });
  8865. // A two-argument custom color
  8866. defineFunction(["\\textcolor"], {
  8867. numArgs: 2,
  8868. allowedInText: true,
  8869. greediness: 3,
  8870. argTypes: ["color", "original"]
  8871. }, function (context, args) {
  8872. var color = args[0];
  8873. var body = args[1];
  8874. return {
  8875. type: "color",
  8876. color: color.value,
  8877. value: (0, _defineFunction2.ordargument)(body)
  8878. };
  8879. });
  8880. // \color is handled in Parser.js's parseImplicitGroup
  8881. defineFunction(["\\color"], {
  8882. numArgs: 1,
  8883. allowedInText: true,
  8884. greediness: 3,
  8885. argTypes: ["color"]
  8886. }, null);
  8887. // colorbox
  8888. defineFunction(["\\colorbox"], {
  8889. numArgs: 2,
  8890. allowedInText: true,
  8891. greediness: 3,
  8892. argTypes: ["color", "text"]
  8893. }, function (context, args) {
  8894. var color = args[0];
  8895. var body = args[1];
  8896. return {
  8897. type: "enclose",
  8898. label: context.funcName,
  8899. backgroundColor: color,
  8900. body: body
  8901. };
  8902. });
  8903. // fcolorbox
  8904. defineFunction(["\\fcolorbox"], {
  8905. numArgs: 3,
  8906. allowedInText: true,
  8907. greediness: 3,
  8908. argTypes: ["color", "color", "text"]
  8909. }, function (context, args) {
  8910. var borderColor = args[0];
  8911. var backgroundColor = args[1];
  8912. var body = args[2];
  8913. return {
  8914. type: "enclose",
  8915. label: context.funcName,
  8916. backgroundColor: backgroundColor,
  8917. borderColor: borderColor,
  8918. body: body
  8919. };
  8920. });
  8921. // An overline
  8922. defineFunction(["\\overline"], {
  8923. numArgs: 1
  8924. }, function (context, args) {
  8925. var body = args[0];
  8926. return {
  8927. type: "overline",
  8928. body: body
  8929. };
  8930. });
  8931. // An underline
  8932. defineFunction(["\\underline"], {
  8933. numArgs: 1
  8934. }, function (context, args) {
  8935. var body = args[0];
  8936. return {
  8937. type: "underline",
  8938. body: body
  8939. };
  8940. });
  8941. // A box of the width and height
  8942. defineFunction(["\\rule"], {
  8943. numArgs: 2,
  8944. numOptionalArgs: 1,
  8945. argTypes: ["size", "size", "size"]
  8946. }, function (context, args, optArgs) {
  8947. var shift = optArgs[0];
  8948. var width = args[0];
  8949. var height = args[1];
  8950. return {
  8951. type: "rule",
  8952. shift: shift && shift.value,
  8953. width: width.value,
  8954. height: height.value
  8955. };
  8956. });
  8957. // TODO: In TeX, \mkern only accepts mu-units, and \kern does not accept
  8958. // mu-units. In current KaTeX we relax this; both commands accept any unit.
  8959. defineFunction(["\\kern", "\\mkern"], {
  8960. numArgs: 1,
  8961. argTypes: ["size"]
  8962. }, function (context, args) {
  8963. return {
  8964. type: "kern",
  8965. dimension: args[0].value
  8966. };
  8967. });
  8968. // A KaTeX logo
  8969. defineFunction(["\\KaTeX"], {
  8970. numArgs: 0,
  8971. allowedInText: true
  8972. }, function (context) {
  8973. return {
  8974. type: "katex"
  8975. };
  8976. });
  8977. // Math class commands except \mathop
  8978. defineFunction(["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], {
  8979. numArgs: 1
  8980. }, function (context, args) {
  8981. var body = args[0];
  8982. return {
  8983. type: "mclass",
  8984. mclass: "m" + context.funcName.substr(5),
  8985. value: (0, _defineFunction2.ordargument)(body)
  8986. };
  8987. });
  8988. // Build a relation by placing one symbol on top of another
  8989. defineFunction(["\\stackrel"], {
  8990. numArgs: 2
  8991. }, function (context, args) {
  8992. var top = args[0];
  8993. var bottom = args[1];
  8994. var bottomop = new _ParseNode2.default("op", {
  8995. type: "op",
  8996. limits: true,
  8997. alwaysHandl###pSub: true,
  8998. symbol: false,
  8999. value: (0, _defineFunction2.ordargument)(bottom)
  9000. }, bottom.mode);
  9001. var supsub = new _ParseNode2.default("supsub", {
  9002. base: bottomop,
  9003. sup: top,
  9004. sub: null
  9005. }, top.mode);
  9006. return {
  9007. type: "mclass",
  9008. mclass: "mrel",
  9009. value: [supsub]
  9010. };
  9011. });
  9012. // \mod-type functions
  9013. defineFunction(["\\bmod"], {
  9014. numArgs: 0
  9015. }, function (context, args) {
  9016. return {
  9017. type: "mod",
  9018. modType: "bmod",
  9019. value: null
  9020. };
  9021. });
  9022. defineFunction(["\\pod", "\\pmod", "\\mod"], {
  9023. numArgs: 1
  9024. }, function (context, args) {
  9025. var body = args[0];
  9026. return {
  9027. type: "mod",
  9028. modType: context.funcName.substr(1),
  9029. value: (0, _defineFunction2.ordargument)(body)
  9030. };
  9031. });
  9032. var fontAliases = {
  9033. "\\Bbb": "\\mathbb",
  9034. "\\bold": "\\mathbf",
  9035. "\\frak": "\\mathfrak"
  9036. };
  9037. // Single-argument color functions
  9038. 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"], {
  9039. numArgs: 1,
  9040. allowedInText: true,
  9041. greediness: 3
  9042. }, function (context, args) {
  9043. var body = args[0];
  9044. return {
  9045. type: "color",
  9046. color: "katex-" + context.funcName.slice(1),
  9047. value: (0, _defineFunction2.ordargument)(body)
  9048. };
  9049. });
  9050. // There are 2 flags for operators; whether they produce limits in
  9051. // displaystyle, and whether they are symbols and should grow in
  9052. // displaystyle. These four groups cover the four possible choices.
  9053. // No limits, not symbols
  9054. 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"], {
  9055. numArgs: 0
  9056. }, function (context) {
  9057. return {
  9058. type: "op",
  9059. limits: false,
  9060. symbol: false,
  9061. body: context.funcName
  9062. };
  9063. });
  9064. // Limits, not symbols
  9065. defineFunction(["\\det", "\\###", "\\inf", "\\lim", "\\liminf", "\\limsup", "\\max", "\\min", "\\Pr", "\\sup"], {
  9066. numArgs: 0
  9067. }, function (context) {
  9068. return {
  9069. type: "op",
  9070. limits: true,
  9071. symbol: false,
  9072. body: context.funcName
  9073. };
  9074. });
  9075. // No limits, symbols
  9076. defineFunction(["\\int", "\\iint", "\\iiint", "\\oint"], {
  9077. numArgs: 0
  9078. }, function (context) {
  9079. return {
  9080. type: "op",
  9081. limits: false,
  9082. symbol: true,
  9083. body: context.funcName
  9084. };
  9085. });
  9086. // Limits, symbols
  9087. defineFunction(["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint"], {
  9088. numArgs: 0
  9089. }, function (context) {
  9090. return {
  9091. type: "op",
  9092. limits: true,
  9093. symbol: true,
  9094. body: context.funcName
  9095. };
  9096. });
  9097. // \mathop class command
  9098. defineFunction(["\\mathop"], {
  9099. numArgs: 1
  9100. }, function (context, args) {
  9101. var body = args[0];
  9102. return {
  9103. type: "op",
  9104. limits: false,
  9105. symbol: false,
  9106. value: (0, _defineFunction2.ordargument)(body)
  9107. };
  9108. });
  9109. // Fractions
  9110. defineFunction(["\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac"], {
  9111. numArgs: 2,
  9112. greediness: 2
  9113. }, function (context, args) {
  9114. var numer = args[0];
  9115. var denom = args[1];
  9116. var hasBarLine = void 0;
  9117. var leftDelim = null;
  9118. var rightDelim = null;
  9119. var size = "auto";
  9120. switch (context.funcName) {
  9121. case "\\dfrac":
  9122. case "\\frac":
  9123. case "\\tfrac":
  9124. hasBarLine = true;
  9125. break;
  9126. case "\\\\atopfrac":
  9127. hasBarLine = false;
  9128. break;
  9129. case "\\dbinom":
  9130. case "\\binom":
  9131. case "\\tbinom":
  9132. hasBarLine = false;
  9133. leftDelim = "(";
  9134. rightDelim = ")";
  9135. break;
  9136. default:
  9137. throw new Error("Unrecognized genfrac command");
  9138. }
  9139. switch (context.funcName) {
  9140. case "\\dfrac":
  9141. case "\\dbinom":
  9142. size = "display";
  9143. break;
  9144. case "\\tfrac":
  9145. case "\\tbinom":
  9146. size = "text";
  9147. break;
  9148. }
  9149. return {
  9150. type: "genfrac",
  9151. numer: numer,
  9152. denom: denom,
  9153. hasBarLine: hasBarLine,
  9154. leftDelim: leftDelim,
  9155. rightDelim: rightDelim,
  9156. size: size
  9157. };
  9158. });
  9159. // Horizontal overlap functions
  9160. defineFunction(["\\mathllap", "\\mathrlap", "\\mathclap"], {
  9161. numArgs: 1,
  9162. allowedInText: true
  9163. }, function (context, args) {
  9164. var body = args[0];
  9165. return {
  9166. type: "lap",
  9167. alignment: context.funcName.slice(5),
  9168. body: body
  9169. };
  9170. });
  9171. // smash, with optional [tb], as in AMS
  9172. defineFunction(["\\smash"], {
  9173. numArgs: 1,
  9174. numOptionalArgs: 1,
  9175. allowedInText: true
  9176. }, function (context, args, optArgs) {
  9177. var smashHeight = false;
  9178. var smashDepth = false;
  9179. var tbArg = optArgs[0];
  9180. if (tbArg) {
  9181. // Optional [tb] argument is engaged.
  9182. // ref: amsmath: \renewcommand{\smash}[1][tb]{%
  9183. // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}%
  9184. var letter = "";
  9185. for (var i = 0; i < tbArg.value.length; ++i) {
  9186. letter = tbArg.value[i].value;
  9187. if (letter === "t") {
  9188. smashHeight = true;
  9189. } else if (letter === "b") {
  9190. smashDepth = true;
  9191. } else {
  9192. smashHeight = false;
  9193. smashDepth = false;
  9194. break;
  9195. }
  9196. }
  9197. } else {
  9198. smashHeight = true;
  9199. smashDepth = true;
  9200. }
  9201. var body = args[0];
  9202. return {
  9203. type: "smash",
  9204. body: body,
  9205. smashHeight: smashHeight,
  9206. smashDepth: smashDepth
  9207. };
  9208. });
  9209. // Sizing functions (handled in Parser.js explicitly, hence no handler)
  9210. defineFunction(["\\tiny", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"], { numArgs: 0 }, null);
  9211. // Style changing functions (handled in Parser.js explicitly, hence no
  9212. // handler)
  9213. defineFunction(["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], { numArgs: 0 }, null);
  9214. // Old font changing functions
  9215. defineFunction(["\\rm", "\\sf", "\\tt", "\\bf", "\\it"], { numArgs: 0 }, null);
  9216. defineFunction([
  9217. // styles
  9218. "\\mathrm", "\\mathit", "\\mathbf",
  9219. // families
  9220. "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt",
  9221. // aliases
  9222. "\\Bbb", "\\bold", "\\frak"], {
  9223. numArgs: 1,
  9224. greediness: 2
  9225. }, function (context, args) {
  9226. var body = args[0];
  9227. var func = context.funcName;
  9228. if (func in fontAliases) {
  9229. func = fontAliases[func];
  9230. }
  9231. return {
  9232. type: "font",
  9233. font: func.slice(1),
  9234. body: body
  9235. };
  9236. });
  9237. // Accents
  9238. defineFunction(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], {
  9239. numArgs: 1
  9240. }, function (context, args) {
  9241. var base = args[0];
  9242. var isStretchy = !_utils2.default.contains(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot"], context.funcName);
  9243. var isShifty = !isStretchy || _utils2.default.contains(["\\widehat", "\\widetilde"], context.funcName);
  9244. return {
  9245. type: "accent",
  9246. label: context.funcName,
  9247. isStretchy: isStretchy,
  9248. isShifty: isShifty,
  9249. base: base
  9250. };
  9251. });
  9252. // Text-mode accents
  9253. defineFunction(["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\r", "\\H", "\\v"], {
  9254. numArgs: 1,
  9255. allowedInText: true,
  9256. allowedInMath: false
  9257. }, function (context, args) {
  9258. var base = args[0];
  9259. return {
  9260. type: "accent",
  9261. label: context.funcName,
  9262. isStretchy: false,
  9263. isShifty: true,
  9264. base: base
  9265. };
  9266. });
  9267. // Horizontal stretchy braces
  9268. defineFunction(["\\overbrace", "\\underbrace"], {
  9269. numArgs: 1
  9270. }, function (context, args) {
  9271. var base = args[0];
  9272. return {
  9273. type: "horizBrace",
  9274. label: context.funcName,
  9275. isOver: /^\\over/.test(context.funcName),
  9276. base: base
  9277. };
  9278. });
  9279. // Stretchy accents under the body
  9280. defineFunction(["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\undertilde"], {
  9281. numArgs: 1
  9282. }, function (context, args) {
  9283. var base = args[0];
  9284. return {
  9285. type: "accentUnder",
  9286. label: context.funcName,
  9287. base: base
  9288. };
  9289. });
  9290. // Stretchy arrows with an optional argument
  9291. defineFunction(["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xLongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xLongequal", "\\xtofrom"], {
  9292. numArgs: 1,
  9293. numOptionalArgs: 1
  9294. }, function (context, args, optArgs) {
  9295. var below = optArgs[0];
  9296. var body = args[0];
  9297. return {
  9298. type: "xArrow", // x for extensible
  9299. label: context.funcName,
  9300. body: body,
  9301. below: below
  9302. };
  9303. });
  9304. // enclose
  9305. defineFunction(["\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\fbox"], {
  9306. numArgs: 1
  9307. }, function (context, args) {
  9308. var body = args[0];
  9309. return {
  9310. type: "enclose",
  9311. label: context.funcName,
  9312. body: body
  9313. };
  9314. });
  9315. // Infix generalized fractions
  9316. defineFunction(["\\over", "\\choose", "\\atop"], {
  9317. numArgs: 0,
  9318. infix: true
  9319. }, function (context) {
  9320. var replaceWith = void 0;
  9321. switch (context.funcName) {
  9322. case "\\over":
  9323. replaceWith = "\\frac";
  9324. break;
  9325. case "\\choose":
  9326. replaceWith = "\\binom";
  9327. break;
  9328. case "\\atop":
  9329. replaceWith = "\\\\atopfrac";
  9330. break;
  9331. default:
  9332. throw new Error("Unrecognized infix genfrac command");
  9333. }
  9334. return {
  9335. type: "infix",
  9336. replaceWith: replaceWith,
  9337. token: context.token
  9338. };
  9339. });
  9340. // Row breaks for aligned data
  9341. defineFunction(["\\\\", "\\cr"], {
  9342. numArgs: 0,
  9343. numOptionalArgs: 1,
  9344. argTypes: ["size"]
  9345. }, function (context, args, optArgs) {
  9346. var size = optArgs[0];
  9347. return {
  9348. type: "cr",
  9349. size: size
  9350. };
  9351. });
  9352. // Environment delimiters
  9353. defineFunction(["\\begin", "\\end"], {
  9354. numArgs: 1,
  9355. argTypes: ["text"]
  9356. }, function (context, args) {
  9357. var nameGroup = args[0];
  9358. if (nameGroup.type !== "ordgroup") {
  9359. throw new _ParseError2.default("Invalid environment name", nameGroup);
  9360. }
  9361. var name = "";
  9362. for (var i = 0; i < nameGroup.value.length; ++i) {
  9363. name += nameGroup.value[i].value;
  9364. }
  9365. return {
  9366. type: "environment",
  9367. name: name,
  9368. nameGroup: nameGroup
  9369. };
  9370. });
  9371. // Box manipulation
  9372. defineFunction(["\\raisebox"], {
  9373. numArgs: 2,
  9374. argTypes: ["size", "text"],
  9375. allowedInText: true
  9376. }, function (context, args) {
  9377. var amount = args[0];
  9378. var body = args[1];
  9379. return {
  9380. type: "raisebox",
  9381. dy: amount,
  9382. body: body,
  9383. value: (0, _defineFunction2.ordargument)(body)
  9384. };
  9385. });
  9386. // \verb and \verb* are dealt with directly in Parser.js.
  9387. // If we end up here, it's because of a failure to match the two delimiters
  9388. // in the regex in Lexer.js. LaTeX raises the following error when \verb is
  9389. // terminated by end of line (or file).
  9390. defineFunction(["\\verb"], {
  9391. numArgs: 0,
  9392. allowedInText: true
  9393. }, function (context) {
  9394. throw new _ParseError2.default("\\verb ended by end of line instead of matching delimiter");
  9395. });
  9396. },{"./ParseError":84,"./ParseNode":85,"./defineFunction":96,"./functions/delimsizing":104,"./functions/operators":105,"./functions/phantom":106,"./utils":115}],104:[function(require,module,exports){
  9397. "use strict";
  9398. var _buildCommon = require("../buildCommon");
  9399. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  9400. var _defineFunction = require("../defineFunction");
  9401. var _defineFunction2 = _interopRequireDefault(_defineFunction);
  9402. var _delimiter = require("../delimiter");
  9403. var _delimiter2 = _interopRequireDefault(_delimiter);
  9404. var _mathMLTree = require("../mathMLTree");
  9405. var _mathMLTree2 = _interopRequireDefault(_mathMLTree);
  9406. var _ParseError = require("../ParseError");
  9407. var _ParseError2 = _interopRequireDefault(_ParseError);
  9408. var _utils = require("../utils");
  9409. var _utils2 = _interopRequireDefault(_utils);
  9410. var _buildHTML = require("../buildHTML");
  9411. var html = _interopRequireWildcard(_buildHTML);
  9412. var _buildMathML = require("../buildMathML");
  9413. var mml = _interopRequireWildcard(_buildMathML);
  9414. 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; } }
  9415. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9416. // Extra data needed for the delimiter handler down below
  9417. var delimiterSizes = {
  9418. "\\bigl": { mclass: "mopen", size: 1 },
  9419. "\\Bigl": { mclass: "mopen", size: 2 },
  9420. "\\biggl": { mclass: "mopen", size: 3 },
  9421. "\\Biggl": { mclass: "mopen", size: 4 },
  9422. "\\bigr": { mclass: "mclose", size: 1 },
  9423. "\\Bigr": { mclass: "mclose", size: 2 },
  9424. "\\biggr": { mclass: "mclose", size: 3 },
  9425. "\\Biggr": { mclass: "mclose", size: 4 },
  9426. "\\bigm": { mclass: "mrel", size: 1 },
  9427. "\\Bigm": { mclass: "mrel", size: 2 },
  9428. "\\biggm": { mclass: "mrel", size: 3 },
  9429. "\\Biggm": { mclass: "mrel", size: 4 },
  9430. "\\big": { mclass: "mord", size: 1 },
  9431. "\\Big": { mclass: "mord", size: 2 },
  9432. "\\bigg": { mclass: "mord", size: 3 },
  9433. "\\Bigg": { mclass: "mord", size: 4 }
  9434. };
  9435. 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", "."];
  9436. // Delimiter functions
  9437. function checkDelimiter(delim, context) {
  9438. if (_utils2.default.contains(delimiters, delim.value)) {
  9439. return delim;
  9440. } else {
  9441. throw new _ParseError2.default("Invalid delimiter: '" + delim.value + "' after '" + context.funcName + "'", delim);
  9442. }
  9443. }
  9444. (0, _defineFunction2.default)({
  9445. type: "delimsizing",
  9446. names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"],
  9447. props: {
  9448. numArgs: 1
  9449. },
  9450. handler: function handler(context, args) {
  9451. var delim = checkDelimiter(args[0], context);
  9452. return {
  9453. type: "delimsizing",
  9454. size: delimiterSizes[context.funcName].size,
  9455. mclass: delimiterSizes[context.funcName].mclass,
  9456. value: delim.value
  9457. };
  9458. },
  9459. htmlBuilder: function htmlBuilder(group, options) {
  9460. var delim = group.value.value;
  9461. if (delim === ".") {
  9462. // Empty delimiters still count as elements, even though they don't
  9463. // show anything.
  9464. return _buildCommon2.default.makeSpan([group.value.mclass]);
  9465. }
  9466. // Use delimiter.sizedDelim to generate the delimiter.
  9467. return _delimiter2.default.sizedDelim(delim, group.value.size, options, group.mode, [group.value.mclass]);
  9468. },
  9469. mathmlBuilder: function mathmlBuilder(group) {
  9470. var children = [];
  9471. if (group.value.value !== ".") {
  9472. children.push(mml.makeText(group.value.value, group.mode));
  9473. }
  9474. var node = new _mathMLTree2.default.MathNode("mo", children);
  9475. if (group.value.mclass === "mopen" || group.value.mclass === "mclose") {
  9476. // Only some of the delimsizing functions act as fences, and they
  9477. // return "mopen" or "mclose" mclass.
  9478. node.setAttribute("fence", "true");
  9479. } else {
  9480. // Explicitly disable fencing if it's not a fence, to override the
  9481. // defaults.
  9482. node.setAttribute("fence", "false");
  9483. }
  9484. return node;
  9485. }
  9486. });
  9487. (0, _defineFunction2.default)({
  9488. type: "leftright",
  9489. names: ["\\left", "\\right"],
  9490. props: {
  9491. numArgs: 1
  9492. },
  9493. handler: function handler(context, args) {
  9494. var delim = checkDelimiter(args[0], context);
  9495. // \left and \right are caught somewhere in Parser.js, which is
  9496. // why this data doesn't match what is in buildHTML.
  9497. return {
  9498. type: "leftright",
  9499. value: delim.value
  9500. };
  9501. },
  9502. htmlBuilder: function htmlBuilder(group, options) {
  9503. // Build the inner expression
  9504. var inner = html.buildExpression(group.value.body, options, true);
  9505. var innerHeight = 0;
  9506. var innerDepth = 0;
  9507. var hadMiddle = false;
  9508. // Calculate its height and depth
  9509. for (var i = 0; i < inner.length; i++) {
  9510. if (inner[i].isMiddle) {
  9511. hadMiddle = true;
  9512. } else {
  9513. innerHeight = Math.max(inner[i].height, innerHeight);
  9514. innerDepth = Math.max(inner[i].depth, innerDepth);
  9515. }
  9516. }
  9517. // The size of delimiters is the same, regardless of what style we are
  9518. // in. Thus, to correctly calculate the size of delimiter we need around
  9519. // a group, we scale down the inner size based on the size.
  9520. innerHeight *= options.sizeMultiplier;
  9521. innerDepth *= options.sizeMultiplier;
  9522. var leftDelim = void 0;
  9523. if (group.value.left === ".") {
  9524. // Empty delimiters in \left and \right make null delimiter spaces.
  9525. leftDelim = html.makeNullDelimiter(options, ["mopen"]);
  9526. } else {
  9527. // Otherwise, use leftRightDelim to generate the correct sized
  9528. // delimiter.
  9529. leftDelim = _delimiter2.default.leftRightDelim(group.value.left, innerHeight, innerDepth, options, group.mode, ["mopen"]);
  9530. }
  9531. // Add it to the beginning of the expression
  9532. inner.unshift(leftDelim);
  9533. // Handle middle delimiters
  9534. if (hadMiddle) {
  9535. for (var _i = 1; _i < inner.length; _i++) {
  9536. var middleDelim = inner[_i];
  9537. if (middleDelim.isMiddle) {
  9538. // Apply the options that were active when \middle was called
  9539. inner[_i] = _delimiter2.default.leftRightDelim(middleDelim.isMiddle.value, innerHeight, innerDepth, middleDelim.isMiddle.options, group.mode, []);
  9540. // Add back spaces shifted into the delimiter
  9541. var spaces = html.spliceSpaces(middleDelim.children, 0);
  9542. if (spaces) {
  9543. _buildCommon2.default.prependChildren(inner[_i], spaces);
  9544. }
  9545. }
  9546. }
  9547. }
  9548. var rightDelim = void 0;
  9549. // Same for the right delimiter
  9550. if (group.value.right === ".") {
  9551. rightDelim = html.makeNullDelimiter(options, ["mclose"]);
  9552. } else {
  9553. rightDelim = _delimiter2.default.leftRightDelim(group.value.right, innerHeight, innerDepth, options, group.mode, ["mclose"]);
  9554. }
  9555. // Add it to the end of the expression.
  9556. inner.push(rightDelim);
  9557. return _buildCommon2.default.makeSpan(["minner"], inner, options);
  9558. },
  9559. mathmlBuilder: function mathmlBuilder(group, options) {
  9560. var inner = mml.buildExpression(group.value.body, options);
  9561. if (group.value.left !== ".") {
  9562. var leftNode = new _mathMLTree2.default.MathNode("mo", [mml.makeText(group.value.left, group.mode)]);
  9563. leftNode.setAttribute("fence", "true");
  9564. inner.unshift(leftNode);
  9565. }
  9566. if (group.value.right !== ".") {
  9567. var rightNode = new _mathMLTree2.default.MathNode("mo", [mml.makeText(group.value.right, group.mode)]);
  9568. rightNode.setAttribute("fence", "true");
  9569. inner.push(rightNode);
  9570. }
  9571. var outerNode = new _mathMLTree2.default.MathNode("mrow", inner);
  9572. return outerNode;
  9573. }
  9574. });
  9575. (0, _defineFunction2.default)({
  9576. type: "middle",
  9577. names: ["\\middle"],
  9578. props: {
  9579. numArgs: 1
  9580. },
  9581. handler: function handler(context, args) {
  9582. var delim = checkDelimiter(args[0], context);
  9583. if (!context.parser.leftrightDepth) {
  9584. throw new _ParseError2.default("\\middle without preceding \\left", delim);
  9585. }
  9586. return {
  9587. type: "middle",
  9588. value: delim.value
  9589. };
  9590. },
  9591. htmlBuilder: function htmlBuilder(group, options) {
  9592. var middleDelim = void 0;
  9593. if (group.value.value === ".") {
  9594. middleDelim = html.makeNullDelimiter(options, []);
  9595. } else {
  9596. middleDelim = _delimiter2.default.sizedDelim(group.value.value, 1, options, group.mode, []);
  9597. middleDelim.isMiddle = { value: group.value.value, options: options };
  9598. }
  9599. return middleDelim;
  9600. },
  9601. mathmlBuilder: function mathmlBuilder(group, options) {
  9602. var middleNode = new _mathMLTree2.default.MathNode("mo", [mml.makeText(group.value.middle, group.mode)]);
  9603. middleNode.setAttribute("fence", "true");
  9604. return middleNode;
  9605. }
  9606. });
  9607. },{"../ParseError":84,"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../delimiter":97,"../mathMLTree":108,"../utils":115}],105:[function(require,module,exports){
  9608. "use strict";
  9609. var _defineFunction = require("../defineFunction");
  9610. var _defineFunction2 = _interopRequireDefault(_defineFunction);
  9611. var _buildCommon = require("../buildCommon");
  9612. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  9613. var _mathMLTree = require("../mathMLTree");
  9614. var _mathMLTree2 = _interopRequireDefault(_mathMLTree);
  9615. var _domTree = require("../domTree");
  9616. var _domTree2 = _interopRequireDefault(_domTree);
  9617. var _buildHTML = require("../buildHTML");
  9618. var html = _interopRequireWildcard(_buildHTML);
  9619. var _buildMathML = require("../buildMathML");
  9620. var mml = _interopRequireWildcard(_buildMathML);
  9621. 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; } }
  9622. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9623. // \operatorname
  9624. // amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@
  9625. (0, _defineFunction2.default)({
  9626. type: "operatorname",
  9627. names: ["\\operatorname"],
  9628. props: {
  9629. numArgs: 1
  9630. },
  9631. handler: function handler(context, args) {
  9632. var body = args[0];
  9633. return {
  9634. type: "operatorname",
  9635. value: (0, _defineFunction.ordargument)(body)
  9636. };
  9637. },
  9638. htmlBuilder: function htmlBuilder(group, options) {
  9639. var output = [];
  9640. if (group.value.value.length > 0) {
  9641. var letter = "";
  9642. var mode = "";
  9643. // Consolidate Greek letter function names into symbol characters.
  9644. var temp = html.buildExpression(group.value.value, options, true);
  9645. // All we want from temp are the letters. With them, we'll
  9646. // create a text operator similar to \tan or \cos.
  9647. for (var i = 0; i < temp.length; i++) {
  9648. letter = temp[i].value;
  9649. // In the amsopn package, \newmcodes@ changes four
  9650. // characters, *-/:’, from math operators back into text.
  9651. // Given what is in temp, we have to address two of them.
  9652. letter = letter.replace(/\u2212/, "-"); // minus => hyphen
  9653. letter = letter.replace(/\u2217/, "*");
  9654. // Use math mode for Greek letters
  9655. mode = /[\u0391-\u03D7]/.test(letter) ? "math" : "text";
  9656. output.push(_buildCommon2.default.mathsym(letter, mode));
  9657. }
  9658. }
  9659. return _buildCommon2.default.makeSpan(["mop"], output, options);
  9660. },
  9661. mathmlBuilder: function mathmlBuilder(group, options) {
  9662. // The steps taken here are similar to the html version.
  9663. var output = [];
  9664. if (group.value.value.length > 0) {
  9665. var temp = mml.buildExpression(group.value.value, options);
  9666. var word = "";
  9667. for (var i = 0; i < temp.length; i++) {
  9668. word += temp[i].children[0].text;
  9669. }
  9670. word = word.replace(/\u2212/g, "-");
  9671. word = word.replace(/\u2217/g, "*");
  9672. output = [new _mathMLTree2.default.TextNode(word)];
  9673. }
  9674. var identifier = new _mathMLTree2.default.MathNode("mi", output);
  9675. identifier.setAttribute("mathvariant", "normal");
  9676. var operator = new _mathMLTree2.default.MathNode("mo", [mml.makeText("&ApplyFunction;", "text")]);
  9677. return new _domTree2.default.documentFragment([identifier, operator]);
  9678. }
  9679. });
  9680. },{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../domTree":98,"../mathMLTree":108}],106:[function(require,module,exports){
  9681. "use strict";
  9682. var _defineFunction = require("../defineFunction");
  9683. var _defineFunction2 = _interopRequireDefault(_defineFunction);
  9684. var _buildCommon = require("../buildCommon");
  9685. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  9686. var _mathMLTree = require("../mathMLTree");
  9687. var _mathMLTree2 = _interopRequireDefault(_mathMLTree);
  9688. var _buildHTML = require("../buildHTML");
  9689. var html = _interopRequireWildcard(_buildHTML);
  9690. var _buildMathML = require("../buildMathML");
  9691. var mml = _interopRequireWildcard(_buildMathML);
  9692. 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; } }
  9693. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9694. (0, _defineFunction2.default)({
  9695. type: "phantom",
  9696. names: ["\\phantom"],
  9697. props: {
  9698. numArgs: 1
  9699. },
  9700. handler: function handler(context, args) {
  9701. var body = args[0];
  9702. return {
  9703. type: "phantom",
  9704. value: (0, _defineFunction.ordargument)(body)
  9705. };
  9706. },
  9707. htmlBuilder: function htmlBuilder(group, options) {
  9708. var elements = html.buildExpression(group.value.value, options.withPhantom(), false);
  9709. // \phantom isn't supposed to affect the elements it contains.
  9710. // See "color" for more details.
  9711. return new _buildCommon2.default.makeFragment(elements);
  9712. },
  9713. mathmlBuilder: function mathmlBuilder(group, options) {
  9714. var inner = mml.buildExpression(group.value.value, options);
  9715. return new _mathMLTree2.default.MathNode("mphantom", inner);
  9716. }
  9717. });
  9718. (0, _defineFunction2.default)({
  9719. type: "hphantom",
  9720. names: ["\\hphantom"],
  9721. props: {
  9722. numArgs: 1
  9723. },
  9724. handler: function handler(context, args) {
  9725. var body = args[0];
  9726. return {
  9727. type: "hphantom",
  9728. value: (0, _defineFunction.ordargument)(body),
  9729. body: body
  9730. };
  9731. },
  9732. htmlBuilder: function htmlBuilder(group, options) {
  9733. var node = _buildCommon2.default.makeSpan([], [html.buildGroup(group.value.body, options.withPhantom())]);
  9734. node.height = 0;
  9735. node.depth = 0;
  9736. if (node.children) {
  9737. for (var i = 0; i < node.children.length; i++) {
  9738. node.children[i].height = 0;
  9739. node.children[i].depth = 0;
  9740. }
  9741. }
  9742. // See smash for comment re: use of makeVList
  9743. node = _buildCommon2.default.makeVList([{ type: "elem", elem: node }], "firstBaseline", null, options);
  9744. return node;
  9745. },
  9746. mathmlBuilder: function mathmlBuilder(group, options) {
  9747. var inner = mml.buildExpression(group.value.value, options);
  9748. var node = new _mathMLTree2.default.MathNode("mphantom", inner);
  9749. node.setAttribute("height", "0px");
  9750. return node;
  9751. }
  9752. });
  9753. (0, _defineFunction2.default)({
  9754. type: "vphantom",
  9755. names: ["\\vphantom"],
  9756. props: {
  9757. numArgs: 1
  9758. },
  9759. handler: function handler(context, args) {
  9760. var body = args[0];
  9761. return {
  9762. type: "vphantom",
  9763. value: (0, _defineFunction.ordargument)(body),
  9764. body: body
  9765. };
  9766. },
  9767. htmlBuilder: function htmlBuilder(group, options) {
  9768. var inner = _buildCommon2.default.makeSpan(["inner"], [html.buildGroup(group.value.body, options.withPhantom())]);
  9769. var fix = _buildCommon2.default.makeSpan(["fix"], []);
  9770. return _buildCommon2.default.makeSpan(["mord", "rlap"], [inner, fix], options);
  9771. },
  9772. mathmlBuilder: function mathmlBuilder(group, options) {
  9773. var inner = mml.buildExpression(group.value.value, options);
  9774. var node = new _mathMLTree2.default.MathNode("mphantom", inner);
  9775. node.setAttribute("width", "0px");
  9776. return node;
  9777. }
  9778. });
  9779. },{"../buildCommon":91,"../buildHTML":92,"../buildMathML":93,"../defineFunction":96,"../mathMLTree":108}],107:[function(require,module,exports){
  9780. "use strict";
  9781. Object.defineProperty(exports, "__esModule", {
  9782. value: true
  9783. });
  9784. var _symbols = require("./symbols");
  9785. var _symbols2 = _interopRequireDefault(_symbols);
  9786. var _utils = require("./utils");
  9787. var _utils2 = _interopRequireDefault(_utils);
  9788. var _Token = require("./Token");
  9789. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9790. /**
  9791. * Provides context to macros defined by functions. Implemented by
  9792. * MacroExpander.
  9793. */
  9794. /** Macro tokens (in reverse order). */
  9795. var builtinMacros = {};
  9796. /**
  9797. * Predefined macros for KaTeX.
  9798. * This can be used to define some commands in terms of others.
  9799. */
  9800. exports.default = builtinMacros;
  9801. // This function might one day accept an additional argument and do more things.
  9802. function defineMacro(name, body) {
  9803. builtinMacros[name] = body;
  9804. }
  9805. //////////////////////////////////////////////////////////////////////
  9806. // basics
  9807. defineMacro("\\bgroup", "{");
  9808. defineMacro("\\egroup", "}");
  9809. defineMacro("\\begingroup", "{");
  9810. defineMacro("\\endgroup", "}");
  9811. // We don't distinguish between math and nonmath kerns.
  9812. // (In TeX, the mu unit works only with \mkern.)
  9813. defineMacro("\\mkern", "\\kern");
  9814. // \llap and \rlap render their contents in text mode
  9815. defineMacro("\\llap", "\\mathllap{\\textrm{#1}}");
  9816. defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}");
  9817. defineMacro("\\clap", "\\mathclap{\\textrm{#1}}");
  9818. //////////////////////////////////////////////////////////////////////
  9819. // amsmath.sty
  9820. // http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf
  9821. // \def\overset#1#2{\binrel@{#2}\binrel@@{\mathop{\kern\z@#2}\limits^{#1}}}
  9822. defineMacro("\\overset", "\\mathop{#2}\\limits^{#1}");
  9823. defineMacro("\\underset", "\\mathop{#2}\\limits_{#1}");
  9824. // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
  9825. defineMacro("\\boxed", "\\fbox{\\displaystyle{#1}}");
  9826. // \def\iff{\DOTSB\;\Longleftrightarrow\;}
  9827. // \def\implies{\DOTSB\;\Longrightarrow\;}
  9828. // \def\impliedby{\DOTSB\;\Longleftarrow\;}
  9829. defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;");
  9830. defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;");
  9831. defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;");
  9832. // AMSMath's automatic \dots, based on \mdots@@ macro.
  9833. var dotsByToken = {
  9834. ',': '\\dotsc',
  9835. '\\not': '\\dotsb',
  9836. // \keybin@ checks for the following:
  9837. '+': '\\dotsb',
  9838. '=': '\\dotsb',
  9839. '<': '\\dotsb',
  9840. '>': '\\dotsb',
  9841. '-': '\\dotsb',
  9842. '*': '\\dotsb',
  9843. ':': '\\dotsb',
  9844. // Symbols whose definition starts with \DOTSB:
  9845. '\\DOTSB': '\\dotsb',
  9846. '\\coprod': '\\dotsb',
  9847. '\\bigvee': '\\dotsb',
  9848. '\\bigwedge': '\\dotsb',
  9849. '\\biguplus': '\\dotsb',
  9850. '\\bigcap': '\\dotsb',
  9851. '\\bigcup': '\\dotsb',
  9852. '\\prod': '\\dotsb',
  9853. '\\sum': '\\dotsb',
  9854. '\\bigotimes': '\\dotsb',
  9855. '\\bigoplus': '\\dotsb',
  9856. '\\bigodot': '\\dotsb',
  9857. '\\bigsqcup': '\\dotsb',
  9858. '\\implies': '\\dotsb',
  9859. '\\impliedby': '\\dotsb',
  9860. '\\And': '\\dotsb',
  9861. '\\longrightarrow': '\\dotsb',
  9862. '\\Longrightarrow': '\\dotsb',
  9863. '\\longleftarrow': '\\dotsb',
  9864. '\\Longleftarrow': '\\dotsb',
  9865. '\\longleftrightarrow': '\\dotsb',
  9866. '\\Longleftrightarrow': '\\dotsb',
  9867. '\\mapsto': '\\dotsb',
  9868. '\\longmapsto': '\\dotsb',
  9869. '\\hookrightarrow': '\\dotsb',
  9870. '\\iff': '\\dotsb',
  9871. '\\doteq': '\\dotsb',
  9872. // Symbols whose definition starts with \mathbin:
  9873. '\\mathbin': '\\dotsb',
  9874. '\\bmod': '\\dotsb',
  9875. // Symbols whose definition starts with \mathrel:
  9876. '\\mathrel': '\\dotsb',
  9877. '\\relbar': '\\dotsb',
  9878. '\\Relbar': '\\dotsb',
  9879. '\\xrightarrow': '\\dotsb',
  9880. '\\xleftarrow': '\\dotsb',
  9881. // Symbols whose definition starts with \DOTSI:
  9882. '\\DOTSI': '\\dotsi',
  9883. '\\int': '\\dotsi',
  9884. '\\oint': '\\dotsi',
  9885. '\\iint': '\\dotsi',
  9886. '\\iiint': '\\dotsi',
  9887. '\\iiiint': '\\dotsi',
  9888. '\\idotsint': '\\dotsi',
  9889. // Symbols whose definition starts with \DOTSX:
  9890. '\\DOTSX': '\\dotsx'
  9891. };
  9892. defineMacro("\\dots", function (context) {
  9893. // TODO: If used in text mode, should expand to \textellipsis.
  9894. // However, in KaTeX, \textellipsis and \ldots behave the same
  9895. // (in text mode), and it's unlikely we'd see any of the math commands
  9896. // that affect the behavior of \dots when in text mode. So fine for now
  9897. // (until we support \ifmmode ... \else ... \fi).
  9898. var thedots = '\\dotso';
  9899. var next = context.expandAfterFuture().text;
  9900. if (next in dotsByToken) {
  9901. thedots = dotsByToken[next];
  9902. } else if (next.substr(0, 4) === '\\not') {
  9903. thedots = '\\dotsb';
  9904. } else if (next in _symbols2.default.math) {
  9905. if (_utils2.default.contains(['bin', 'rel'], _symbols2.default.math[next].group)) {
  9906. thedots = '\\dotsb';
  9907. }
  9908. }
  9909. return thedots;
  9910. });
  9911. var spaceAfterDots = {
  9912. // \rightdelim@ checks for the following:
  9913. ')': true,
  9914. ']': true,
  9915. '\\rbrack': true,
  9916. '\\}': true,
  9917. '\\rbrace': true,
  9918. '\\rangle': true,
  9919. '\\rceil': true,
  9920. '\\rfloor': true,
  9921. '\\rgroup': true,
  9922. '\\rmoustache': true,
  9923. '\\right': true,
  9924. '\\bigr': true,
  9925. '\\biggr': true,
  9926. '\\Bigr': true,
  9927. '\\Biggr': true,
  9928. // \extra@ also tests for the following:
  9929. '$': true,
  9930. // \extrap@ checks for the following:
  9931. ';': true,
  9932. '.': true,
  9933. ',': true
  9934. };
  9935. defineMacro("\\dotso", function (context) {
  9936. var next = context.future().text;
  9937. if (next in spaceAfterDots) {
  9938. return "\\ldots\\,";
  9939. } else {
  9940. return "\\ldots";
  9941. }
  9942. });
  9943. defineMacro("\\dotsc", function (context) {
  9944. var next = context.future().text;
  9945. // \dotsc uses \extra@ but not \extrap@, instead specially checking for
  9946. // ';' and '.', but doesn't check for ','.
  9947. if (next in spaceAfterDots && next !== ',') {
  9948. return "\\ldots\\,";
  9949. } else {
  9950. return "\\ldots";
  9951. }
  9952. });
  9953. defineMacro("\\cdots", function (context) {
  9954. var next = context.future().text;
  9955. if (next in spaceAfterDots) {
  9956. return "\\@cdots\\,";
  9957. } else {
  9958. return "\\@cdots";
  9959. }
  9960. });
  9961. defineMacro("\\dotsb", "\\cdots");
  9962. defineMacro("\\dotsm", "\\cdots");
  9963. defineMacro("\\dotsi", "\\!\\cdots");
  9964. // amsmath doesn't actually define \dotsx, but \dots followed by a macro
  9965. // starting with \DOTSX implies \dotso, and then \extra@ detects this case
  9966. // and forces the added `\,`.
  9967. defineMacro("\\dotsx", "\\ldots\\,");
  9968. // \let\DOTSI\relax
  9969. // \let\DOTSB\relax
  9970. // \let\DOTSX\relax
  9971. defineMacro("\\DOTSI", "\\relax");
  9972. defineMacro("\\DOTSB", "\\relax");
  9973. defineMacro("\\DOTSX", "\\relax");
  9974. // http://texdoc.net/texmf-dist/doc/latex/amsmath/amsmath.pdf
  9975. defineMacro("\\thinspace", "\\,"); // \let\thinspace\,
  9976. defineMacro("\\medspace", "\\:"); // \let\medspace\:
  9977. defineMacro("\\thickspace", "\\;"); // \let\thickspace\;
  9978. //////////////////////////////////////////////////////////////////////
  9979. // LaTeX source2e
  9980. // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
  9981. // \def\@hspace#1{\hskip #1\relax}
  9982. // KaTeX doesn't do line breaks, so \hspace is the same as \kern
  9983. defineMacro("\\hspace", "\\kern{#1}");
  9984. //////////////////////////////////////////////////////////////////////
  9985. // mathtools.sty
  9986. //\providecommand\ordinarycolon{:}
  9987. defineMacro("\\ordinarycolon", ":");
  9988. //\def\vcentcolon{\mathrel{\mathop\ordinarycolon}}
  9989. //TODO(edemaine): Not yet centered. Fix via \raisebox or #726
  9990. defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}");
  9991. // \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon}
  9992. defineMacro("\\dblcolon", "\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon");
  9993. // \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=}
  9994. defineMacro("\\coloneqq", "\\vcentcolon\\mathrel{\\mkern-1.2mu}=");
  9995. // \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=}
  9996. defineMacro("\\Coloneqq", "\\dblcolon\\mathrel{\\mkern-1.2mu}=");
  9997. // \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  9998. defineMacro("\\coloneq", "\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}");
  9999. // \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}}
  10000. defineMacro("\\Coloneq", "\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}");
  10001. // \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon}
  10002. defineMacro("\\eqqcolon", "=\\mathrel{\\mkern-1.2mu}\\vcentcolon");
  10003. // \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon}
  10004. defineMacro("\\Eqqcolon", "=\\mathrel{\\mkern-1.2mu}\\dblcolon");
  10005. // \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon}
  10006. defineMacro("\\eqcolon", "\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon");
  10007. // \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon}
  10008. defineMacro("\\Eqcolon", "\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon");
  10009. // \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx}
  10010. defineMacro("\\colonapprox", "\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx");
  10011. // \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx}
  10012. defineMacro("\\Colonapprox", "\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx");
  10013. // \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim}
  10014. defineMacro("\\colonsim", "\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim");
  10015. // \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim}
  10016. defineMacro("\\Colonsim", "\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim");
  10017. //////////////////////////////////////////////////////////////////////
  10018. // colonequals.sty
  10019. // Alternate names for mathtools's macros:
  10020. defineMacro("\\ratio", "\\vcentcolon");
  10021. defineMacro("\\coloncolon", "\\dblcolon");
  10022. defineMacro("\\colonequals", "\\coloneqq");
  10023. defineMacro("\\coloncolonequals", "\\Coloneqq");
  10024. defineMacro("\\equalscolon", "\\eqqcolon");
  10025. defineMacro("\\equalscoloncolon", "\\Eqqcolon");
  10026. defineMacro("\\colonminus", "\\coloneq");
  10027. defineMacro("\\coloncolonminus", "\\Coloneq");
  10028. defineMacro("\\minuscolon", "\\eqcolon");
  10029. defineMacro("\\minuscoloncolon", "\\Eqcolon");
  10030. // \colonapprox name is same in mathtools and colonequals.
  10031. defineMacro("\\coloncolonapprox", "\\Colonapprox");
  10032. // \colonsim name is same in mathtools and colonequals.
  10033. defineMacro("\\coloncolonsim", "\\Colonsim");
  10034. // Additional macros, implemented by analogy with mathtools definitions:
  10035. defineMacro("\\simcolon", "\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon");
  10036. defineMacro("\\simcoloncolon", "\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon");
  10037. defineMacro("\\approxcolon", "\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon");
  10038. defineMacro("\\approxcoloncolon", "\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon");
  10039. },{"./Token":90,"./symbols":112,"./utils":115}],108:[function(require,module,exports){
  10040. "use strict";
  10041. Object.defineProperty(exports, "__esModule", {
  10042. value: true
  10043. });
  10044. var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
  10045. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  10046. var _createClass2 = require("babel-runtime/helpers/createClass");
  10047. var _createClass3 = _interopRequireDefault(_createClass2);
  10048. var _utils = require("./utils");
  10049. var _utils2 = _interopRequireDefault(_utils);
  10050. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10051. /**
  10052. * This node represents a general purpose MathML node of any type. The
  10053. * constructor requires the type of node to create (for example, `"mo"` or
  10054. * `"mspace"`, corresponding to `<mo>` and `<mspace>` tags).
  10055. */
  10056. var MathNode = function () {
  10057. function MathNode(type, children) {
  10058. (0, _classCallCheck3.default)(this, MathNode);
  10059. this.type = type;
  10060. this.attributes = {};
  10061. this.children = children || [];
  10062. }
  10063. /**
  10064. * Sets an attribute on a MathML node. MathML depends on attributes to convey a
  10065. * semantic content, so this is used heavily.
  10066. */
  10067. (0, _createClass3.default)(MathNode, [{
  10068. key: "setAttribute",
  10069. value: function setAttribute(name, value) {
  10070. this.attributes[name] = value;
  10071. }
  10072. /**
  10073. * Converts the math node into a MathML-namespaced DOM element.
  10074. */
  10075. }, {
  10076. key: "toNode",
  10077. value: function toNode() {
  10078. var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type);
  10079. for (var attr in this.attributes) {
  10080. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  10081. node.setAttribute(attr, this.attributes[attr]);
  10082. }
  10083. }
  10084. for (var i = 0; i < this.children.length; i++) {
  10085. node.appendChild(this.children[i].toNode());
  10086. }
  10087. return node;
  10088. }
  10089. /**
  10090. * Converts the math node into an HTML markup string.
  10091. */
  10092. }, {
  10093. key: "toMarkup",
  10094. value: function toMarkup() {
  10095. var markup = "<" + this.type;
  10096. // Add the attributes
  10097. for (var attr in this.attributes) {
  10098. if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
  10099. markup += " " + attr + "=\"";
  10100. markup += _utils2.default.escape(this.attributes[attr]);
  10101. markup += "\"";
  10102. }
  10103. }
  10104. markup += ">";
  10105. for (var i = 0; i < this.children.length; i++) {
  10106. markup += this.children[i].toMarkup();
  10107. }
  10108. markup += "</" + this.type + ">";
  10109. return markup;
  10110. }
  10111. }]);
  10112. return MathNode;
  10113. }();
  10114. /**
  10115. * This node represents a piece of text.
  10116. */
  10117. /**
  10118. * These objects store data about MathML nodes. This is the MathML equivalent
  10119. * of the types in domTree.js. Since MathML handles its own rendering, and
  10120. * since we're mainly using MathML to improve accessibility, we don't manage
  10121. * any of the styling state that the plain DOM nodes do.
  10122. *
  10123. * The `toNode` and `toMarkup` functions work simlarly to how they do in
  10124. * domTree.js, creating namespaced DOM nodes and HTML text markup respectively.
  10125. */
  10126. var TextNode = function () {
  10127. function TextNode(text) {
  10128. (0, _classCallCheck3.default)(this, TextNode);
  10129. this.text = text;
  10130. }
  10131. /**
  10132. * Converts the text node into a DOM text node.
  10133. */
  10134. (0, _createClass3.default)(TextNode, [{
  10135. key: "toNode",
  10136. value: function toNode() {
  10137. return document.createTextNode(this.text);
  10138. }
  10139. /**
  10140. * Converts the text node into HTML markup (which is just the text itself).
  10141. */
  10142. }, {
  10143. key: "toMarkup",
  10144. value: function toMarkup() {
  10145. return _utils2.default.escape(this.text);
  10146. }
  10147. }]);
  10148. return TextNode;
  10149. }();
  10150. exports.default = {
  10151. MathNode: MathNode,
  10152. TextNode: TextNode
  10153. };
  10154. },{"./utils":115,"babel-runtime/helpers/classCallCheck":8,"babel-runtime/helpers/createClass":9}],109:[function(require,module,exports){
  10155. 'use strict';
  10156. Object.defineProperty(exports, "__esModule", {
  10157. value: true
  10158. });
  10159. var _Parser = require('./Parser');
  10160. var _Parser2 = _interopRequireDefault(_Parser);
  10161. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10162. /**
  10163. * Parses an expression using a Parser, then returns the parsed r###lt.
  10164. */
  10165. var parseTree = function parseTree(toParse, settings) {
  10166. if (!(typeof toParse === 'string' || toParse instanceof String)) {
  10167. throw new TypeError('KaTeX can only parse string typed expression');
  10168. }
  10169. var parser = new _Parser2.default(toParse, settings);
  10170. return parser.parse();
  10171. }; /**
  10172. * Provides a single function for parsing an expression using a Parser
  10173. * TODO(emily): Remove this
  10174. */
  10175. exports.default = parseTree;
  10176. },{"./Parser":86}],110:[function(require,module,exports){
  10177. "use strict";
  10178. Object.defineProperty(exports, "__esModule", {
  10179. value: true
  10180. });
  10181. var _slicedToArray2 = require("babel-runtime/helpers/slicedToArray");
  10182. var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
  10183. var _domTree = require("./domTree");
  10184. var _domTree2 = _interopRequireDefault(_domTree);
  10185. var _buildCommon = require("./buildCommon");
  10186. var _buildCommon2 = _interopRequireDefault(_buildCommon);
  10187. var _mathMLTree = require("./mathMLTree");
  10188. var _mathMLTree2 = _interopRequireDefault(_mathMLTree);
  10189. var _utils = require("./utils");
  10190. var _utils2 = _interopRequireDefault(_utils);
  10191. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10192. /**
  10193. * This file provides support to buildMathML.js and buildHTML.js
  10194. * for stretchy wide elements rendered from SVG files
  10195. * and other CSS trickery.
  10196. */
  10197. var stretchyCodePoint = {
  10198. widehat: "^",
  10199. widetilde: "~",
  10200. undertilde: "~",
  10201. overleftarrow: "\u2190",
  10202. underleftarrow: "\u2190",
  10203. xleftarrow: "\u2190",
  10204. overrightarrow: "\u2192",
  10205. underrightarrow: "\u2192",
  10206. xrightarrow: "\u2192",
  10207. underbrace: "\u23B5",
  10208. overbrace: "\u23DE",
  10209. overleftrightarrow: "\u2194",
  10210. underleftrightarrow: "\u2194",
  10211. xleftrightarrow: "\u2194",
  10212. Overrightarrow: "\u21D2",
  10213. xRightarrow: "\u21D2",
  10214. overleftharpoon: "\u21BC",
  10215. xleftharpoonup: "\u21BC",
  10216. overrightharpoon: "\u21C0",
  10217. xrightharpoonup: "\u21C0",
  10218. xLeftarrow: "\u21D0",
  10219. xLeftrightarrow: "\u21D4",
  10220. xhookleftarrow: "\u21A9",
  10221. xhookrightarrow: "\u21AA",
  10222. xmapsto: "\u21A6",
  10223. xrightharpoondown: "\u21C1",
  10224. xleftharpoondown: "\u21BD",
  10225. xrightleftharpoons: "\u21CC",
  10226. xleftrightharpoons: "\u21CB",
  10227. xtwoheadleftarrow: "\u219E",
  10228. xtwoheadrightarrow: "\u21A0",
  10229. xLongequal: "=",
  10230. xtofrom: "\u21C4"
  10231. };
  10232. var mathMLnode = function mathMLnode(label) {
  10233. var node = new _mathMLTree2.default.MathNode("mo", [new _mathMLTree2.default.TextNode(stretchyCodePoint[label.substr(1)])]);
  10234. node.setAttribute("stretchy", "true");
  10235. return node;
  10236. };
  10237. // Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts.
  10238. // Copyright (c) 2009-2010, Design Science, Inc. (<www.mathjax.org>)
  10239. // Copyright (c) 2014-2017 Khan Academy (<www.khanacademy.org>)
  10240. // Licensed under the SIL Open Font License, Version 1.1.
  10241. // See \nhttp://scripts.sil.org/OFL
  10242. // Very Long SVGs
  10243. // Many of the KaTeX stretchy wide elements use a long SVG image and an
  10244. // overflow: hidden tactic to achieve a stretchy image while avoiding
  10245. // distortion of arrowheads or brace corners.
  10246. // The SVG typically contains a very long (400 em) arrow.
  10247. // The SVG is in a container span that has overflow: hidden, so the span
  10248. // acts like a window that exposes only part of the SVG.
  10249. // The SVG always has a longer, thinner aspect ratio than the container span.
  10250. // After the SVG fills 100% of the height of the container span,
  10251. // there is a long arrow shaft left over. That left-over shaft is not shown.
  10252. // Instead, it is sliced off because the span's CSS has overflow: hidden.
  10253. // Thus, the reader sees an arrow that matches the subject matter width
  10254. // without distortion.
  10255. // Some functions, such as \cancel, need to vary their aspect ratio. These
  10256. // functions do not get the overflow SVG treatment.
  10257. // Second Brush Stroke
  10258. // Low resolution monitors struggle to display images in fine detail.
  10259. // So browsers apply anti-aliasing. A long straight arrow shaft therefore
  10260. // will sometimes appear as if it has a blurred edge.
  10261. // To mitigate this, these SVG files contain a second "brush-stroke" on the
  10262. // arrow shafts. That is, a second long thin rectangular SVG path has been
  10263. // written directly on top of each arrow shaft. This reinforcement causes
  10264. // some of the screen pixels to display as black instead of the anti-aliased
  10265. // gray pixel that a single path would generate. So we get arrow shafts
  10266. // whose edges appear to be sharper.
  10267. // In the katexImagesData object just below, the dimensions all
  10268. // correspond to path geometry inside the relevant SVG.
  10269. // For example, \overrightarrow uses the same arrowhead as glyph U+2192
  10270. // from the KaTeX Main font. The scaling factor is 1000.
  10271. // That is, inside the font, that arrowhead is 522 units tall, which
  10272. // corresponds to 0.522 em inside the document.
  10273. var katexImagesData = {
  10274. // path(s), minWidth, height, align
  10275. overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"],
  10276. overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"],
  10277. underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"],
  10278. underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"],
  10279. xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"],
  10280. xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"],
  10281. Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"],
  10282. xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"],
  10283. xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"],
  10284. overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"],
  10285. xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"],
  10286. xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"],
  10287. overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"],
  10288. xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"],
  10289. xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"],
  10290. xLongequal: [["longequal"], 0.888, 334, "xMinYMin"],
  10291. xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"],
  10292. xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"],
  10293. overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522],
  10294. overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548],
  10295. underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548],
  10296. underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522],
  10297. xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522],
  10298. xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560],
  10299. xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716],
  10300. xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716],
  10301. xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522],
  10302. xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522],
  10303. overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522],
  10304. underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522],
  10305. overgroup: [["leftgroup", "rightgroup"], 0.888, 342],
  10306. undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342],
  10307. xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522],
  10308. xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528]
  10309. };
  10310. var groupLength = function groupLength(arg) {
  10311. if (arg.type === "ordgroup") {
  10312. return arg.value.length;
  10313. } else {
  10314. return 1;
  10315. }
  10316. };
  10317. var svgSpan = function svgSpan(group, options) {
  10318. // Create a span with inline SVG for the element.
  10319. var label = group.value.label.substr(1);
  10320. var attributes = [];
  10321. var height = void 0;
  10322. var viewBoxWidth = 400000; // default
  10323. var viewBoxHeight = 0;
  10324. var minWidth = 0;
  10325. var path = void 0;
  10326. var paths = void 0;
  10327. var pathName = void 0;
  10328. var svgNode = void 0;
  10329. var span = void 0;
  10330. if (_utils2.default.contains(["widehat", "widetilde", "undertilde"], label)) {
  10331. // There are four SVG images available for each function.
  10332. // Choose a taller image when there are more characters.
  10333. var numChars = groupLength(group.value.base);
  10334. var _viewBoxHeight = void 0;
  10335. if (numChars > 5) {
  10336. _viewBoxHeight = label === "widehat" ? 420 : 312;
  10337. viewBoxWidth = label === "widehat" ? 2364 : 2340;
  10338. // Next get the span height, in 1000 ems
  10339. height = label === "widehat" ? 0.42 : 0.34;
  10340. pathName = (label === "widehat" ? "widehat" : "tilde") + "4";
  10341. } else {
  10342. var imgIndex = [1, 1, 2, 2, 3, 3][numChars];
  10343. if (label === "widehat") {
  10344. viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex];
  10345. _viewBoxHeight = [0, 239, 300, 360, 420][imgIndex];
  10346. height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex];
  10347. pathName = "widehat" + imgIndex;
  10348. } else {
  10349. viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex];
  10350. _viewBoxHeight = [0, 260, 286, 306, 312][imgIndex];
  10351. height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex];
  10352. pathName = "tilde" + imgIndex;
  10353. }
  10354. }
  10355. path = new _domTree2.default.pathNode(pathName);
  10356. attributes.push(["width", "100%"]);
  10357. attributes.push(["height", height + "em"]);
  10358. attributes.push(["viewBox", "0 0 " + viewBoxWidth + " " + _viewBoxHeight]);
  10359. attributes.push(["preserveAspectRatio", "none"]);
  10360. svgNode = new _domTree2.default.svgNode([path], attributes);
  10361. span = _buildCommon2.default.makeSpan([], [svgNode], options);
  10362. } else {
  10363. var widthClass = void 0;
  10364. var align = void 0;
  10365. var spans = [];
  10366. var _katexImagesData$labe = (0, _slicedToArray3.default)(katexImagesData[label], 4);
  10367. paths = _katexImagesData$labe[0];
  10368. minWidth = _katexImagesData$labe[1];
  10369. viewBoxHeight = _katexImagesData$labe[2];
  10370. align = _katexImagesData$labe[3];
  10371. var numSvgChildren = paths.length;
  10372. height = viewBoxHeight / 1000;
  10373. for (var i = 0; i < numSvgChildren; i++) {
  10374. path = new _domTree2.default.pathNode(paths[i]);
  10375. attributes = [["width", "400em"], ["height", height + "em"]];
  10376. attributes.push(["viewBox", "0 0 " + viewBoxWidth + " " + viewBoxHeight]);
  10377. if (numSvgChildren === 2) {
  10378. widthClass = ["halfarrow-left", "halfarrow-right"][i];
  10379. align = ["xMinYMin", "xMaxYMin"][i];
  10380. } else if (numSvgChildren === 3) {
  10381. widthClass = ["brace-left", "brace-center", "brace-right"][i];
  10382. align = ["xMinYMin", "xMidYMin", "xMaxYMin"][i];
  10383. }
  10384. attributes.push(["preserveAspectRatio", align + " slice"]);
  10385. svgNode = new _domTree2.default.svgNode([path], attributes);
  10386. if (numSvgChildren === 1) {
  10387. span = _buildCommon2.default.makeSpan(["hide-tail"], [svgNode], options);
  10388. } else {
  10389. span = _buildCommon2.default.makeSpan([widthClass], [svgNode], options);
  10390. span.style.height = height + "em";
  10391. spans.push(span);
  10392. }
  10393. }
  10394. if (numSvgChildren > 1) {
  10395. span = _buildCommon2.default.makeSpan(["stretchy"], spans, options);
  10396. }
  10397. }
  10398. // Note that we are returning span.depth = 0.
  10399. // Any adjustments relative to the baseline must be done in buildHTML.
  10400. span.height = height;
  10401. span.style.height = height + "em";
  10402. if (minWidth > 0) {
  10403. span.style.minWidth = minWidth + "em";
  10404. }
  10405. return span;
  10406. };
  10407. var encloseSpan = function encloseSpan(inner, label, pad, options) {
  10408. // Return an image span for \cancel, \bcancel, \xcancel, or \fbox
  10409. var img = void 0;
  10410. var totalHeight = inner.height + inner.depth + 2 * pad;
  10411. if (/(fbox)|(color)/.test(label)) {
  10412. img = _buildCommon2.default.makeSpan(["stretchy", label], [], options);
  10413. if (label === "fbox" && options.color) {
  10414. img.style.borderColor = options.getColor();
  10415. }
  10416. } else {
  10417. // \cancel, \bcancel, or \xcancel
  10418. // Since \cancel's SVG is inline and it omits the viewBox attribute,
  10419. // its stroke-width will not vary with span area.
  10420. var attributes = [["x1", "0"]];
  10421. var lines = [];
  10422. if (label !== "cancel") {
  10423. attributes.push(["y1", "0"]);
  10424. attributes.push(["x2", "100%"]);
  10425. attributes.push(["y2", "100%"]);
  10426. attributes.push(["stroke-width", "0.046em"]);
  10427. lines.push(new _domTree2.default.lineNode(attributes));
  10428. }
  10429. if (label === "xcancel") {
  10430. attributes = [["x1", "0"]]; // start a second line.
  10431. }
  10432. if (label !== "bcancel") {
  10433. attributes.push(["y1", "100%"]);
  10434. attributes.push(["x2", "100%"]);
  10435. attributes.push(["y2", "0"]);
  10436. attributes.push(["stroke-width", "0.046em"]);
  10437. lines.push(new _domTree2.default.lineNode(attributes));
  10438. }
  10439. attributes = [["width", "100%"], ["height", totalHeight + "em"]];
  10440. var svgNode = new _domTree2.default.svgNode(lines, attributes);
  10441. img = _buildCommon2.default.makeSpan([], [svgNode], options);
  10442. }
  10443. img.height = totalHeight;
  10444. img.style.height = totalHeight + "em";
  10445. return img;
  10446. };
  10447. exports.default = {
  10448. encloseSpan: encloseSpan,
  10449. mathMLnode: mathMLnode,
  10450. svgSpan: svgSpan
  10451. };
  10452. },{"./buildCommon":91,"./domTree":98,"./mathMLTree":108,"./utils":115,"babel-runtime/helpers/slicedToArray":10}],111:[function(require,module,exports){
  10453. "use strict";
  10454. Object.defineProperty(exports, "__esModule", {
  10455. value: true
  10456. });
  10457. var path = {
  10458. // sqrtMain path geometry is from glyph U221A in the font KaTeX Main
  10459. 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",
  10460. // size1 is from glyph U221A in the font KaTeX_Size1-Regular
  10461. 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",
  10462. // size2 is from glyph U221A in the font KaTeX_Size2-Regular
  10463. 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",
  10464. // size3 is from glyph U221A in the font KaTeX_Size3-Regular
  10465. 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",
  10466. // size4 is from glyph U221A in the font KaTeX_Size4-Regular
  10467. 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",
  10468. // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main
  10469. 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",
  10470. // doublerightarrow is from glyph U+21D2 in font KaTeX Main
  10471. 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",
  10472. // leftarrow is from glyph U+2190 in font KaTeX Main
  10473. 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",
  10474. // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular
  10475. 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",
  10476. 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",
  10477. // overgroup is from the MnSymbol package (public domain)
  10478. 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",
  10479. 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",
  10480. // Harpoons are from glyph U+21BD in font KaTeX Main
  10481. 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",
  10482. 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",
  10483. 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",
  10484. 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",
  10485. // hook is from glyph U+21A9 in font KaTeX Main
  10486. 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",
  10487. leftlinesegment: "M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z",
  10488. leftmapsto: "M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z",
  10489. // tofrom is from glyph U+21C4 in font KaTeX AMS Regular
  10490. 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",
  10491. longequal: "M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z",
  10492. 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",
  10493. 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",
  10494. 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",
  10495. 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",
  10496. 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",
  10497. 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",
  10498. 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",
  10499. 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",
  10500. 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",
  10501. 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",
  10502. 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",
  10503. 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",
  10504. rightlinesegment: "M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z",
  10505. 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",
  10506. // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular
  10507. 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",
  10508. 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",
  10509. // tilde1 is a modified version of a glyph from the MnSymbol package
  10510. 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",
  10511. // ditto tilde2, tilde3, & tilde4
  10512. 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",
  10513. 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",
  10514. 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",
  10515. // widehat1 is a modified version of a glyph from the MnSymbol package
  10516. 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",
  10517. // ditto widehat2, widehat3, & widehat4
  10518. 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",
  10519. 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",
  10520. 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"
  10521. };
  10522. exports.default = { path: path };
  10523. },{}],112:[function(require,module,exports){
  10524. "use strict";
  10525. Object.defineProperty(exports, "__esModule", {
  10526. value: true
  10527. });
  10528. /**
  10529. * This file holds a list of all no-argument functions and single-character
  10530. * symbols (like 'a' or ';').
  10531. *
  10532. * For each of the symbols, there are three properties they can have:
  10533. * - font (required): the font to be used for this symbol. Either "main" (the
  10534. normal font), or "ams" (the ams fonts).
  10535. * - group (required): the ParseNode group type the symbol should have (i.e.
  10536. "textord", "mathord", etc).
  10537. See https://github.com/Khan/KaTeX/wiki/Examining-TeX#group-types
  10538. * - replace: the character that this symbol or function should be
  10539. * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi
  10540. * character in the main font).
  10541. *
  10542. * The outermost map in the table indicates what mode the symbols should be
  10543. * accepted in (e.g. "math" or "text").
  10544. */
  10545. var symbols = {
  10546. "math": {},
  10547. "text": {}
  10548. };
  10549. exports.default = symbols;
  10550. /** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
  10551. function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) {
  10552. symbols[mode][name] = { font: font, group: group, replace: replace };
  10553. if (acceptUnicodeChar && replace) {
  10554. symbols[mode][replace] = symbols[mode][name];
  10555. }
  10556. }
  10557. // Some abbreviations for commonly used strings.
  10558. // This helps minify the code, and also spotting typos using jshint.
  10559. // modes:
  10560. var math = "math";
  10561. var text = "text";
  10562. // fonts:
  10563. var main = "main";
  10564. var ams = "ams";
  10565. // groups:
  10566. var accent = "accent";
  10567. var bin = "bin";
  10568. var close = "close";
  10569. var inner = "inner";
  10570. var mathord = "mathord";
  10571. var op = "op";
  10572. var open = "open";
  10573. var punct = "punct";
  10574. var rel = "rel";
  10575. var spacing = "spacing";
  10576. var textord = "textord";
  10577. // Now comes the symbol table
  10578. // Relation Symbols
  10579. defineSymbol(math, main, rel, "\u2261", "\\equiv");
  10580. defineSymbol(math, main, rel, "\u227A", "\\prec");
  10581. defineSymbol(math, main, rel, "\u227B", "\\succ");
  10582. defineSymbol(math, main, rel, "\u223C", "\\sim");
  10583. defineSymbol(math, main, rel, "\u22A5", "\\perp");
  10584. defineSymbol(math, main, rel, "\u2AAF", "\\preceq");
  10585. defineSymbol(math, main, rel, "\u2AB0", "\\succeq");
  10586. defineSymbol(math, main, rel, "\u2243", "\\simeq");
  10587. defineSymbol(math, main, rel, "\u2223", "\\mid");
  10588. defineSymbol(math, main, rel, "\u226A", "\\ll");
  10589. defineSymbol(math, main, rel, "\u226B", "\\gg");
  10590. defineSymbol(math, main, rel, "\u224D", "\\asymp");
  10591. defineSymbol(math, main, rel, "\u2225", "\\parallel");
  10592. defineSymbol(math, main, rel, "\u22C8", "\\bowtie");
  10593. defineSymbol(math, main, rel, "\u2323", "\\smile");
  10594. defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq");
  10595. defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq");
  10596. defineSymbol(math, main, rel, "\u2250", "\\doteq");
  10597. defineSymbol(math, main, rel, "\u2322", "\\frown");
  10598. defineSymbol(math, main, rel, "\u220B", "\\ni");
  10599. defineSymbol(math, main, rel, "\u221D", "\\propto");
  10600. defineSymbol(math, main, rel, "\u22A2", "\\vdash");
  10601. defineSymbol(math, main, rel, "\u22A3", "\\dashv");
  10602. defineSymbol(math, main, rel, "\u220B", "\\owns");
  10603. // Punctuation
  10604. defineSymbol(math, main, punct, ".", "\\ldotp");
  10605. defineSymbol(math, main, punct, "\u22C5", "\\cdotp");
  10606. // Misc Symbols
  10607. defineSymbol(math, main, textord, "#", "\\#");
  10608. defineSymbol(text, main, textord, "#", "\\#");
  10609. defineSymbol(math, main, textord, "&", "\\&");
  10610. defineSymbol(text, main, textord, "&", "\\&");
  10611. defineSymbol(math, main, textord, "\u2135", "\\aleph");
  10612. defineSymbol(math, main, textord, "\u2200", "\\forall");
  10613. defineSymbol(math, main, textord, "\u210F", "\\hbar");
  10614. defineSymbol(math, main, textord, "\u2203", "\\exists");
  10615. defineSymbol(math, main, textord, "\u2207", "\\nabla");
  10616. defineSymbol(math, main, textord, "\u266D", "\\flat");
  10617. defineSymbol(math, main, textord, "\u2113", "\\ell");
  10618. defineSymbol(math, main, textord, "\u266E", "\\natural");
  10619. defineSymbol(math, main, textord, "\u2663", "\\clubsuit");
  10620. defineSymbol(math, main, textord, "\u2118", "\\wp");
  10621. defineSymbol(math, main, textord, "\u266F", "\\sharp");
  10622. defineSymbol(math, main, textord, "\u2662", "\\diamondsuit");
  10623. defineSymbol(math, main, textord, "\u211C", "\\Re");
  10624. defineSymbol(math, main, textord, "\u2661", "\\heartsuit");
  10625. defineSymbol(math, main, textord, "\u2111", "\\Im");
  10626. defineSymbol(math, main, textord, "\u2660", "\\spad###it");
  10627. // Math and Text
  10628. defineSymbol(math, main, textord, "\u2020", "\\dag");
  10629. defineSymbol(text, main, textord, "\u2020", "\\dag");
  10630. defineSymbol(text, main, textord, "\u2020", "\\textdagger");
  10631. defineSymbol(math, main, textord, "\u2021", "\\ddag");
  10632. defineSymbol(text, main, textord, "\u2021", "\\ddag");
  10633. defineSymbol(text, main, textord, "\u2020", "\\textdaggerdbl");
  10634. // Large Delimiters
  10635. defineSymbol(math, main, close, "\u23B1", "\\rmoustache");
  10636. defineSymbol(math, main, open, "\u23B0", "\\lmoustache");
  10637. defineSymbol(math, main, close, "\u27EF", "\\rgroup");
  10638. defineSymbol(math, main, open, "\u27EE", "\\lgroup");
  10639. // Binary Operators
  10640. defineSymbol(math, main, bin, "\u2213", "\\mp");
  10641. defineSymbol(math, main, bin, "\u2296", "\\ominus");
  10642. defineSymbol(math, main, bin, "\u228E", "\\uplus");
  10643. defineSymbol(math, main, bin, "\u2293", "\\sqcap");
  10644. defineSymbol(math, main, bin, "\u2217", "\\ast");
  10645. defineSymbol(math, main, bin, "\u2294", "\\sqcup");
  10646. defineSymbol(math, main, bin, "\u25EF", "\\bigcirc");
  10647. defineSymbol(math, main, bin, "\u2219", "\\bullet");
  10648. defineSymbol(math, main, bin, "\u2021", "\\ddagger");
  10649. defineSymbol(math, main, bin, "\u2240", "\\wr");
  10650. defineSymbol(math, main, bin, "\u2A3F", "\\amalg");
  10651. defineSymbol(math, main, bin, "&", "\\And"); // from amsmath
  10652. // Arrow Symbols
  10653. defineSymbol(math, main, rel, "\u27F5", "\\longleftarrow");
  10654. defineSymbol(math, main, rel, "\u21D0", "\\Leftarrow");
  10655. defineSymbol(math, main, rel, "\u27F8", "\\Longleftarrow");
  10656. defineSymbol(math, main, rel, "\u27F6", "\\longrightarrow");
  10657. defineSymbol(math, main, rel, "\u21D2", "\\Rightarrow");
  10658. defineSymbol(math, main, rel, "\u27F9", "\\Longrightarrow");
  10659. defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow");
  10660. defineSymbol(math, main, rel, "\u27F7", "\\longleftrightarrow");
  10661. defineSymbol(math, main, rel, "\u21D4", "\\Leftrightarrow");
  10662. defineSymbol(math, main, rel, "\u27FA", "\\Longleftrightarrow");
  10663. defineSymbol(math, main, rel, "\u21A6", "\\mapsto");
  10664. defineSymbol(math, main, rel, "\u27FC", "\\longmapsto");
  10665. defineSymbol(math, main, rel, "\u2197", "\\nearrow");
  10666. defineSymbol(math, main, rel, "\u21A9", "\\hookleftarrow");
  10667. defineSymbol(math, main, rel, "\u21AA", "\\hookrightarrow");
  10668. defineSymbol(math, main, rel, "\u2198", "\\searrow");
  10669. defineSymbol(math, main, rel, "\u21BC", "\\leftharpoonup");
  10670. defineSymbol(math, main, rel, "\u21C0", "\\rightharpoonup");
  10671. defineSymbol(math, main, rel, "\u2199", "\\swarrow");
  10672. defineSymbol(math, main, rel, "\u21BD", "\\leftharpoondown");
  10673. defineSymbol(math, main, rel, "\u21C1", "\\rightharpoondown");
  10674. defineSymbol(math, main, rel, "\u2196", "\\nwarrow");
  10675. defineSymbol(math, main, rel, "\u21CC", "\\rightleftharpoons");
  10676. // AMS Negated Binary Relations
  10677. defineSymbol(math, ams, rel, "\u226E", "\\nless");
  10678. defineSymbol(math, ams, rel, "\uE010", "\\nleqslant");
  10679. defineSymbol(math, ams, rel, "\uE011", "\\nleqq");
  10680. defineSymbol(math, ams, rel, "\u2A87", "\\lneq");
  10681. defineSymbol(math, ams, rel, "\u2268", "\\lneqq");
  10682. defineSymbol(math, ams, rel, "\uE00C", "\\lvertneqq");
  10683. defineSymbol(math, ams, rel, "\u22E6", "\\lnsim");
  10684. defineSymbol(math, ams, rel, "\u2A89", "\\lnapprox");
  10685. defineSymbol(math, ams, rel, "\u2280", "\\nprec");
  10686. defineSymbol(math, ams, rel, "\u22E0", "\\npreceq");
  10687. defineSymbol(math, ams, rel, "\u22E8", "\\precnsim");
  10688. defineSymbol(math, ams, rel, "\u2AB9", "\\precnapprox");
  10689. defineSymbol(math, ams, rel, "\u2241", "\\nsim");
  10690. defineSymbol(math, ams, rel, "\uE006", "\\nshortmid");
  10691. defineSymbol(math, ams, rel, "\u2224", "\\nmid");
  10692. defineSymbol(math, ams, rel, "\u22AC", "\\nvdash");
  10693. defineSymbol(math, ams, rel, "\u22AD", "\\nvDash");
  10694. defineSymbol(math, ams, rel, "\u22EA", "\\ntriangleleft");
  10695. defineSymbol(math, ams, rel, "\u22EC", "\\ntrianglelefteq");
  10696. defineSymbol(math, ams, rel, "\u228A", "\\subsetneq");
  10697. defineSymbol(math, ams, rel, "\uE01A", "\\varsubsetneq");
  10698. defineSymbol(math, ams, rel, "\u2ACB", "\\subsetneqq");
  10699. defineSymbol(math, ams, rel, "\uE017", "\\varsubsetneqq");
  10700. defineSymbol(math, ams, rel, "\u226F", "\\ngtr");
  10701. defineSymbol(math, ams, rel, "\uE00F", "\\ngeqslant");
  10702. defineSymbol(math, ams, rel, "\uE00E", "\\ngeqq");
  10703. defineSymbol(math, ams, rel, "\u2A88", "\\gneq");
  10704. defineSymbol(math, ams, rel, "\u2269", "\\gneqq");
  10705. defineSymbol(math, ams, rel, "\uE00D", "\\gvertneqq");
  10706. defineSymbol(math, ams, rel, "\u22E7", "\\gnsim");
  10707. defineSymbol(math, ams, rel, "\u2A8A", "\\gnapprox");
  10708. defineSymbol(math, ams, rel, "\u2281", "\\nsucc");
  10709. defineSymbol(math, ams, rel, "\u22E1", "\\nsucceq");
  10710. defineSymbol(math, ams, rel, "\u22E9", "\\succnsim");
  10711. defineSymbol(math, ams, rel, "\u2ABA", "\\succnapprox");
  10712. defineSymbol(math, ams, rel, "\u2246", "\\ncong");
  10713. defineSymbol(math, ams, rel, "\uE007", "\\nshortparallel");
  10714. defineSymbol(math, ams, rel, "\u2226", "\\nparallel");
  10715. defineSymbol(math, ams, rel, "\u22AF", "\\nVDash");
  10716. defineSymbol(math, ams, rel, "\u22EB", "\\ntriangleright");
  10717. defineSymbol(math, ams, rel, "\u22ED", "\\ntrianglerighteq");
  10718. defineSymbol(math, ams, rel, "\uE018", "\\nsupseteqq");
  10719. defineSymbol(math, ams, rel, "\u228B", "\\supsetneq");
  10720. defineSymbol(math, ams, rel, "\uE01B", "\\varsupsetneq");
  10721. defineSymbol(math, ams, rel, "\u2ACC", "\\supsetneqq");
  10722. defineSymbol(math, ams, rel, "\uE019", "\\varsupsetneqq");
  10723. defineSymbol(math, ams, rel, "\u22AE", "\\nVdash");
  10724. defineSymbol(math, ams, rel, "\u2AB5", "\\precneqq");
  10725. defineSymbol(math, ams, rel, "\u2AB6", "\\succneqq");
  10726. defineSymbol(math, ams, rel, "\uE016", "\\nsubseteqq");
  10727. defineSymbol(math, ams, bin, "\u22B4", "\\unlhd");
  10728. defineSymbol(math, ams, bin, "\u22B5", "\\unrhd");
  10729. // AMS Negated Arrows
  10730. defineSymbol(math, ams, rel, "\u219A", "\\nleftarrow");
  10731. defineSymbol(math, ams, rel, "\u219B", "\\nrightarrow");
  10732. defineSymbol(math, ams, rel, "\u21CD", "\\nLeftarrow");
  10733. defineSymbol(math, ams, rel, "\u21CF", "\\nRightarrow");
  10734. defineSymbol(math, ams, rel, "\u21AE", "\\nleftrightarrow");
  10735. defineSymbol(math, ams, rel, "\u21CE", "\\nLeftrightarrow");
  10736. // AMS Misc
  10737. defineSymbol(math, ams, rel, "\u25B3", "\\vartriangle");
  10738. defineSymbol(math, ams, textord, "\u210F", "\\hslash");
  10739. defineSymbol(math, ams, textord, "\u25BD", "\\triangledown");
  10740. defineSymbol(math, ams, textord, "\u25CA", "\\lozenge");
  10741. defineSymbol(math, ams, textord, "\u24C8", "\\circledS");
  10742. defineSymbol(math, ams, textord, "\xAE", "\\circledR");
  10743. defineSymbol(text, ams, textord, "\xAE", "\\circledR");
  10744. defineSymbol(math, ams, textord, "\u2221", "\\measuredangle");
  10745. defineSymbol(math, ams, textord, "\u2204", "\\nexists");
  10746. defineSymbol(math, ams, textord, "\u2127", "\\mho");
  10747. defineSymbol(math, ams, textord, "\u2132", "\\Finv");
  10748. defineSymbol(math, ams, textord, "\u2141", "\\Game");
  10749. defineSymbol(math, ams, textord, "k", "\\Bbbk");
  10750. defineSymbol(math, ams, textord, "\u2035", "\\backprime");
  10751. defineSymbol(math, ams, textord, "\u25B2", "\\blacktriangle");
  10752. defineSymbol(math, ams, textord, "\u25BC", "\\blacktriangledown");
  10753. defineSymbol(math, ams, textord, "\u25A0", "\\blacksquare");
  10754. defineSymbol(math, ams, textord, "\u29EB", "\\blacklozenge");
  10755. defineSymbol(math, ams, textord, "\u2605", "\\bigstar");
  10756. defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle");
  10757. defineSymbol(math, ams, textord, "\u2201", "\\complement");
  10758. defineSymbol(math, ams, textord, "\xF0", "\\eth");
  10759. defineSymbol(math, ams, textord, "\u2571", "\\diagup");
  10760. defineSymbol(math, ams, textord, "\u2572", "\\diagdown");
  10761. defineSymbol(math, ams, textord, "\u25A1", "\\square");
  10762. defineSymbol(math, ams, textord, "\u25A1", "\\Box");
  10763. defineSymbol(math, ams, textord, "\u25CA", "\\Diamond");
  10764. defineSymbol(math, ams, textord, "\xA5", "\\yen");
  10765. defineSymbol(math, ams, textord, "\u2713", "\\checkmark");
  10766. defineSymbol(text, ams, textord, "\u2713", "\\checkmark");
  10767. // AMS Hebrew
  10768. defineSymbol(math, ams, textord, "\u2136", "\\beth");
  10769. defineSymbol(math, ams, textord, "\u2138", "\\daleth");
  10770. defineSymbol(math, ams, textord, "\u2137", "\\gimel");
  10771. // AMS Greek
  10772. defineSymbol(math, ams, textord, "\u03DD", "\\digamma");
  10773. defineSymbol(math, ams, textord, "\u03F0", "\\varkappa");
  10774. // AMS Delimiters
  10775. defineSymbol(math, ams, open, "\u250C", "\\ulcorner");
  10776. defineSymbol(math, ams, close, "\u2510", "\\urcorner");
  10777. defineSymbol(math, ams, open, "\u2514", "\\llcorner");
  10778. defineSymbol(math, ams, close, "\u2518", "\\lrcorner");
  10779. // AMS Binary Relations
  10780. defineSymbol(math, ams, rel, "\u2266", "\\leqq");
  10781. defineSymbol(math, ams, rel, "\u2A7D", "\\leqslant");
  10782. defineSymbol(math, ams, rel, "\u2A95", "\\eqslantless");
  10783. defineSymbol(math, ams, rel, "\u2272", "\\lesssim");
  10784. defineSymbol(math, ams, rel, "\u2A85", "\\lessapprox");
  10785. defineSymbol(math, ams, rel, "\u224A", "\\approxeq");
  10786. defineSymbol(math, ams, bin, "\u22D6", "\\lessdot");
  10787. defineSymbol(math, ams, rel, "\u22D8", "\\lll");
  10788. defineSymbol(math, ams, rel, "\u2276", "\\lessgtr");
  10789. defineSymbol(math, ams, rel, "\u22DA", "\\lesseqgtr");
  10790. defineSymbol(math, ams, rel, "\u2A8B", "\\lesseqqgtr");
  10791. defineSymbol(math, ams, rel, "\u2251", "\\doteqdot");
  10792. defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq");
  10793. defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq");
  10794. defineSymbol(math, ams, rel, "\u223D", "\\backsim");
  10795. defineSymbol(math, ams, rel, "\u22CD", "\\backsimeq");
  10796. defineSymbol(math, ams, rel, "\u2AC5", "\\subseteqq");
  10797. defineSymbol(math, ams, rel, "\u22D0", "\\Subset");
  10798. defineSymbol(math, ams, rel, "\u228F", "\\sqsubset");
  10799. defineSymbol(math, ams, rel, "\u227C", "\\preccurlyeq");
  10800. defineSymbol(math, ams, rel, "\u22DE", "\\curlyeqprec");
  10801. defineSymbol(math, ams, rel, "\u227E", "\\precsim");
  10802. defineSymbol(math, ams, rel, "\u2AB7", "\\precapprox");
  10803. defineSymbol(math, ams, rel, "\u22B2", "\\vartriangleleft");
  10804. defineSymbol(math, ams, rel, "\u22B4", "\\trianglelefteq");
  10805. defineSymbol(math, ams, rel, "\u22A8", "\\vDash");
  10806. defineSymbol(math, ams, rel, "\u22AA", "\\Vvdash");
  10807. defineSymbol(math, ams, rel, "\u2323", "\\smallsmile");
  10808. defineSymbol(math, ams, rel, "\u2322", "\\smallfrown");
  10809. defineSymbol(math, ams, rel, "\u224F", "\\bumpeq");
  10810. defineSymbol(math, ams, rel, "\u224E", "\\Bumpeq");
  10811. defineSymbol(math, ams, rel, "\u2267", "\\geqq");
  10812. defineSymbol(math, ams, rel, "\u2A7E", "\\geqslant");
  10813. defineSymbol(math, ams, rel, "\u2A96", "\\eqslantgtr");
  10814. defineSymbol(math, ams, rel, "\u2273", "\\gtrsim");
  10815. defineSymbol(math, ams, rel, "\u2A86", "\\gtrapprox");
  10816. defineSymbol(math, ams, bin, "\u22D7", "\\gtrdot");
  10817. defineSymbol(math, ams, rel, "\u22D9", "\\ggg");
  10818. defineSymbol(math, ams, rel, "\u2277", "\\gtrless");
  10819. defineSymbol(math, ams, rel, "\u22DB", "\\gtreqless");
  10820. defineSymbol(math, ams, rel, "\u2A8C", "\\gtreqqless");
  10821. defineSymbol(math, ams, rel, "\u2256", "\\eqcirc");
  10822. defineSymbol(math, ams, rel, "\u2257", "\\circeq");
  10823. defineSymbol(math, ams, rel, "\u225C", "\\triangleq");
  10824. defineSymbol(math, ams, rel, "\u223C", "\\thicksim");
  10825. defineSymbol(math, ams, rel, "\u2248", "\\thickapprox");
  10826. defineSymbol(math, ams, rel, "\u2AC6", "\\supseteqq");
  10827. defineSymbol(math, ams, rel, "\u22D1", "\\Supset");
  10828. defineSymbol(math, ams, rel, "\u2290", "\\sqsupset");
  10829. defineSymbol(math, ams, rel, "\u227D", "\\succcurlyeq");
  10830. defineSymbol(math, ams, rel, "\u22DF", "\\curlyeqsucc");
  10831. defineSymbol(math, ams, rel, "\u227F", "\\succsim");
  10832. defineSymbol(math, ams, rel, "\u2AB8", "\\succapprox");
  10833. defineSymbol(math, ams, rel, "\u22B3", "\\vartriangleright");
  10834. defineSymbol(math, ams, rel, "\u22B5", "\\trianglerighteq");
  10835. defineSymbol(math, ams, rel, "\u22A9", "\\Vdash");
  10836. defineSymbol(math, ams, rel, "\u2223", "\\shortmid");
  10837. defineSymbol(math, ams, rel, "\u2225", "\\shortparallel");
  10838. defineSymbol(math, ams, rel, "\u226C", "\\between");
  10839. defineSymbol(math, ams, rel, "\u22D4", "\\pitchfork");
  10840. defineSymbol(math, ams, rel, "\u221D", "\\varpropto");
  10841. defineSymbol(math, ams, rel, "\u25C0", "\\blacktriangleleft");
  10842. defineSymbol(math, ams, rel, "\u2234", "\\therefore");
  10843. defineSymbol(math, ams, rel, "\u220D", "\\backepsilon");
  10844. defineSymbol(math, ams, rel, "\u25B6", "\\blacktriangleright");
  10845. defineSymbol(math, ams, rel, "\u2235", "\\because");
  10846. defineSymbol(math, ams, rel, "\u22D8", "\\llless");
  10847. defineSymbol(math, ams, rel, "\u22D9", "\\gggtr");
  10848. defineSymbol(math, ams, bin, "\u22B2", "\\lhd");
  10849. defineSymbol(math, ams, bin, "\u22B3", "\\rhd");
  10850. defineSymbol(math, ams, rel, "\u2242", "\\eqsim");
  10851. defineSymbol(math, main, rel, "\u22C8", "\\Join");
  10852. defineSymbol(math, ams, rel, "\u2251", "\\Doteq");
  10853. // AMS Binary Operators
  10854. defineSymbol(math, ams, bin, "\u2214", "\\dotplus");
  10855. defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus");
  10856. defineSymbol(math, ams, bin, "\u22D2", "\\Cap");
  10857. defineSymbol(math, ams, bin, "\u22D3", "\\Cup");
  10858. defineSymbol(math, ams, bin, "\u2A5E", "\\doublebarwedge");
  10859. defineSymbol(math, ams, bin, "\u229F", "\\boxminus");
  10860. defineSymbol(math, ams, bin, "\u229E", "\\boxplus");
  10861. defineSymbol(math, ams, bin, "\u22C7", "\\divideontimes");
  10862. defineSymbol(math, ams, bin, "\u22C9", "\\ltimes");
  10863. defineSymbol(math, ams, bin, "\u22CA", "\\rtimes");
  10864. defineSymbol(math, ams, bin, "\u22CB", "\\leftthreetimes");
  10865. defineSymbol(math, ams, bin, "\u22CC", "\\rightthreetimes");
  10866. defineSymbol(math, ams, bin, "\u22CF", "\\curlywedge");
  10867. defineSymbol(math, ams, bin, "\u22CE", "\\curlyvee");
  10868. defineSymbol(math, ams, bin, "\u229D", "\\circleddash");
  10869. defineSymbol(math, ams, bin, "\u229B", "\\circledast");
  10870. defineSymbol(math, ams, bin, "\u22C5", "\\centerdot");
  10871. defineSymbol(math, ams, bin, "\u22BA", "\\intercal");
  10872. defineSymbol(math, ams, bin, "\u22D2", "\\doublecap");
  10873. defineSymbol(math, ams, bin, "\u22D3", "\\doublecup");
  10874. defineSymbol(math, ams, bin, "\u22A0", "\\boxtimes");
  10875. // AMS Arrows
  10876. defineSymbol(math, ams, rel, "\u21E2", "\\dashrightarrow");
  10877. defineSymbol(math, ams, rel, "\u21E0", "\\dashleftarrow");
  10878. defineSymbol(math, ams, rel, "\u21C7", "\\leftleftarrows");
  10879. defineSymbol(math, ams, rel, "\u21C6", "\\leftrightarrows");
  10880. defineSymbol(math, ams, rel, "\u21DA", "\\Lleftarrow");
  10881. defineSymbol(math, ams, rel, "\u219E", "\\twoheadleftarrow");
  10882. defineSymbol(math, ams, rel, "\u21A2", "\\leftarrowtail");
  10883. defineSymbol(math, ams, rel, "\u21AB", "\\looparrowleft");
  10884. defineSymbol(math, ams, rel, "\u21CB", "\\leftrightharpoons");
  10885. defineSymbol(math, ams, rel, "\u21B6", "\\curvearrowleft");
  10886. defineSymbol(math, ams, rel, "\u21BA", "\\circlearrowleft");
  10887. defineSymbol(math, ams, rel, "\u21B0", "\\Lsh");
  10888. defineSymbol(math, ams, rel, "\u21C8", "\\upuparrows");
  10889. defineSymbol(math, ams, rel, "\u21BF", "\\upharpoonleft");
  10890. defineSymbol(math, ams, rel, "\u21C3", "\\downharpoonleft");
  10891. defineSymbol(math, ams, rel, "\u22B8", "\\multimap");
  10892. defineSymbol(math, ams, rel, "\u21AD", "\\leftrightsquigarrow");
  10893. defineSymbol(math, ams, rel, "\u21C9", "\\rightrightarrows");
  10894. defineSymbol(math, ams, rel, "\u21C4", "\\rightleftarrows");
  10895. defineSymbol(math, ams, rel, "\u21A0", "\\twoheadrightarrow");
  10896. defineSymbol(math, ams, rel, "\u21A3", "\\rightarrowtail");
  10897. defineSymbol(math, ams, rel, "\u21AC", "\\looparrowright");
  10898. defineSymbol(math, ams, rel, "\u21B7", "\\curvearrowright");
  10899. defineSymbol(math, ams, rel, "\u21BB", "\\circlearrowright");
  10900. defineSymbol(math, ams, rel, "\u21B1", "\\Rsh");
  10901. defineSymbol(math, ams, rel, "\u21CA", "\\downdownarrows");
  10902. defineSymbol(math, ams, rel, "\u21BE", "\\upharpoonright");
  10903. defineSymbol(math, ams, rel, "\u21C2", "\\downharpoonright");
  10904. defineSymbol(math, ams, rel, "\u21DD", "\\rightsquigarrow");
  10905. defineSymbol(math, ams, rel, "\u21DD", "\\leadsto");
  10906. defineSymbol(math, ams, rel, "\u21DB", "\\Rrightarrow");
  10907. defineSymbol(math, ams, rel, "\u21BE", "\\restriction");
  10908. defineSymbol(math, main, textord, "\u2018", "`");
  10909. defineSymbol(math, main, textord, "$", "\\$");
  10910. defineSymbol(text, main, textord, "$", "\\$");
  10911. defineSymbol(text, main, textord, "$", "\\textdollar");
  10912. defineSymbol(math, main, textord, "%", "\\%");
  10913. defineSymbol(text, main, textord, "%", "\\%");
  10914. defineSymbol(math, main, textord, "_", "\\_");
  10915. defineSymbol(text, main, textord, "_", "\\_");
  10916. defineSymbol(text, main, textord, "_", "\\textunderscore");
  10917. defineSymbol(math, main, textord, "\u2220", "\\angle");
  10918. defineSymbol(math, main, textord, "\u221E", "\\infty");
  10919. defineSymbol(math, main, textord, "\u2032", "\\prime");
  10920. defineSymbol(math, main, textord, "\u25B3", "\\triangle");
  10921. defineSymbol(math, main, textord, "\u0393", "\\Gamma", true);
  10922. defineSymbol(math, main, textord, "\u0394", "\\Delta", true);
  10923. defineSymbol(math, main, textord, "\u0398", "\\Theta", true);
  10924. defineSymbol(math, main, textord, "\u039B", "\\Lambda", true);
  10925. defineSymbol(math, main, textord, "\u039E", "\\Xi", true);
  10926. defineSymbol(math, main, textord, "\u03A0", "\\Pi", true);
  10927. defineSymbol(math, main, textord, "\u03A3", "\\Sigma", true);
  10928. defineSymbol(math, main, textord, "\u03A5", "\\Upsilon", true);
  10929. defineSymbol(math, main, textord, "\u03A6", "\\Phi", true);
  10930. defineSymbol(math, main, textord, "\u03A8", "\\Psi", true);
  10931. defineSymbol(math, main, textord, "\u03A9", "\\Omega", true);
  10932. defineSymbol(math, main, textord, "\xAC", "\\neg");
  10933. defineSymbol(math, main, textord, "\xAC", "\\lnot");
  10934. defineSymbol(math, main, textord, "\u22A4", "\\top");
  10935. defineSymbol(math, main, textord, "\u22A5", "\\bot");
  10936. defineSymbol(math, main, textord, "\u2205", "\\emptyset");
  10937. defineSymbol(math, ams, textord, "\u2205", "\\varnothing");
  10938. defineSymbol(math, main, mathord, "\u03B1", "\\alpha", true);
  10939. defineSymbol(math, main, mathord, "\u03B2", "\\beta", true);
  10940. defineSymbol(math, main, mathord, "\u03B3", "\\gamma", true);
  10941. defineSymbol(math, main, mathord, "\u03B4", "\\delta", true);
  10942. defineSymbol(math, main, mathord, "\u03F5", "\\epsilon", true);
  10943. defineSymbol(math, main, mathord, "\u03B6", "\\zeta", true);
  10944. defineSymbol(math, main, mathord, "\u03B7", "\\eta", true);
  10945. defineSymbol(math, main, mathord, "\u03B8", "\\theta", true);
  10946. defineSymbol(math, main, mathord, "\u03B9", "\\iota", true);
  10947. defineSymbol(math, main, mathord, "\u03BA", "\\kappa", true);
  10948. defineSymbol(math, main, mathord, "\u03BB", "\\lambda", true);
  10949. defineSymbol(math, main, mathord, "\u03BC", "\\mu", true);
  10950. defineSymbol(math, main, mathord, "\u03BD", "\\nu", true);
  10951. defineSymbol(math, main, mathord, "\u03BE", "\\xi", true);
  10952. defineSymbol(math, main, mathord, "\u03BF", "\\omicron", true);
  10953. defineSymbol(math, main, mathord, "\u03C0", "\\pi", true);
  10954. defineSymbol(math, main, mathord, "\u03C1", "\\rho", true);
  10955. defineSymbol(math, main, mathord, "\u03C3", "\\sigma", true);
  10956. defineSymbol(math, main, mathord, "\u03C4", "\\tau", true);
  10957. defineSymbol(math, main, mathord, "\u03C5", "\\upsilon", true);
  10958. defineSymbol(math, main, mathord, "\u03D5", "\\phi", true);
  10959. defineSymbol(math, main, mathord, "\u03C7", "\\chi", true);
  10960. defineSymbol(math, main, mathord, "\u03C8", "\\psi", true);
  10961. defineSymbol(math, main, mathord, "\u03C9", "\\omega", true);
  10962. defineSymbol(math, main, mathord, "\u03B5", "\\varepsilon", true);
  10963. defineSymbol(math, main, mathord, "\u03D1", "\\vartheta", true);
  10964. defineSymbol(math, main, mathord, "\u03D6", "\\varpi", true);
  10965. defineSymbol(math, main, mathord, "\u03F1", "\\varrho", true);
  10966. defineSymbol(math, main, mathord, "\u03C2", "\\varsigma", true);
  10967. defineSymbol(math, main, mathord, "\u03C6", "\\varphi", true);
  10968. defineSymbol(math, main, bin, "\u2217", "*");
  10969. defineSymbol(math, main, bin, "+", "+");
  10970. defineSymbol(math, main, bin, "\u2212", "-");
  10971. defineSymbol(math, main, bin, "\u22C5", "\\cdot");
  10972. defineSymbol(math, main, bin, "\u2218", "\\circ");
  10973. defineSymbol(math, main, bin, "\xF7", "\\div");
  10974. defineSymbol(math, main, bin, "\xB1", "\\pm");
  10975. defineSymbol(math, main, bin, "\xD7", "\\times");
  10976. defineSymbol(math, main, bin, "\u2229", "\\cap");
  10977. defineSymbol(math, main, bin, "\u222A", "\\cup");
  10978. defineSymbol(math, main, bin, "\u2216", "\\setminus");
  10979. defineSymbol(math, main, bin, "\u2227", "\\land");
  10980. defineSymbol(math, main, bin, "\u2228", "\\lor");
  10981. defineSymbol(math, main, bin, "\u2227", "\\wedge");
  10982. defineSymbol(math, main, bin, "\u2228", "\\vee");
  10983. defineSymbol(math, main, textord, "\u221A", "\\surd");
  10984. defineSymbol(math, main, open, "(", "(");
  10985. defineSymbol(math, main, open, "[", "[");
  10986. defineSymbol(math, main, open, "\u27E8", "\\langle");
  10987. defineSymbol(math, main, open, "\u2223", "\\lvert");
  10988. defineSymbol(math, main, open, "\u2225", "\\lVert");
  10989. defineSymbol(math, main, close, ")", ")");
  10990. defineSymbol(math, main, close, "]", "]");
  10991. defineSymbol(math, main, close, "?", "?");
  10992. defineSymbol(math, main, close, "!", "!");
  10993. defineSymbol(math, main, close, "\u27E9", "\\rangle");
  10994. defineSymbol(math, main, close, "\u2223", "\\rvert");
  10995. defineSymbol(math, main, close, "\u2225", "\\rVert");
  10996. defineSymbol(math, main, rel, "=", "=");
  10997. defineSymbol(math, main, rel, "<", "<");
  10998. defineSymbol(math, main, rel, ">", ">");
  10999. defineSymbol(math, main, rel, ":", ":");
  11000. defineSymbol(math, main, rel, "\u2248", "\\approx");
  11001. defineSymbol(math, main, rel, "\u2245", "\\cong");
  11002. defineSymbol(math, main, rel, "\u2265", "\\ge");
  11003. defineSymbol(math, main, rel, "\u2265", "\\geq");
  11004. defineSymbol(math, main, rel, "\u2190", "\\gets");
  11005. defineSymbol(math, main, rel, ">", "\\gt");
  11006. defineSymbol(math, main, rel, "\u2208", "\\in");
  11007. defineSymbol(math, main, rel, "\u2209", "\\notin");
  11008. defineSymbol(math, main, rel, "\u0338", "\\not");
  11009. defineSymbol(math, main, rel, "\u2282", "\\subset");
  11010. defineSymbol(math, main, rel, "\u2283", "\\supset");
  11011. defineSymbol(math, main, rel, "\u2286", "\\subseteq");
  11012. defineSymbol(math, main, rel, "\u2287", "\\supseteq");
  11013. defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq");
  11014. defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq");
  11015. defineSymbol(math, main, rel, "\u22A8", "\\models");
  11016. defineSymbol(math, main, rel, "\u2190", "\\leftarrow");
  11017. defineSymbol(math, main, rel, "\u2264", "\\le");
  11018. defineSymbol(math, main, rel, "\u2264", "\\leq");
  11019. defineSymbol(math, main, rel, "<", "\\lt");
  11020. defineSymbol(math, main, rel, "\u2260", "\\ne");
  11021. defineSymbol(math, main, rel, "\u2260", "\\neq");
  11022. defineSymbol(math, main, rel, "\u2192", "\\rightarrow");
  11023. defineSymbol(math, main, rel, "\u2192", "\\to");
  11024. defineSymbol(math, ams, rel, "\u2271", "\\ngeq");
  11025. defineSymbol(math, ams, rel, "\u2270", "\\nleq");
  11026. defineSymbol(math, main, spacing, null, "\\!");
  11027. defineSymbol(math, main, spacing, "\xA0", "\\ ");
  11028. defineSymbol(math, main, spacing, "\xA0", "~");
  11029. defineSymbol(math, main, spacing, null, "\\,");
  11030. defineSymbol(math, main, spacing, null, "\\:");
  11031. defineSymbol(math, main, spacing, null, "\\;");
  11032. defineSymbol(math, main, spacing, null, "\\enspace");
  11033. defineSymbol(math, main, spacing, null, "\\qquad");
  11034. defineSymbol(math, main, spacing, null, "\\quad");
  11035. defineSymbol(math, main, spacing, "\xA0", "\\space");
  11036. defineSymbol(math, main, punct, ",", ",");
  11037. defineSymbol(math, main, punct, ";", ";");
  11038. defineSymbol(math, main, punct, ":", "\\colon");
  11039. defineSymbol(math, ams, bin, "\u22BC", "\\barwedge");
  11040. defineSymbol(math, ams, bin, "\u22BB", "\\veebar");
  11041. defineSymbol(math, main, bin, "\u2299", "\\odot");
  11042. defineSymbol(math, main, bin, "\u2295", "\\oplus");
  11043. defineSymbol(math, main, bin, "\u2297", "\\otimes");
  11044. defineSymbol(math, main, textord, "\u2202", "\\partial");
  11045. defineSymbol(math, main, bin, "\u2298", "\\oslash");
  11046. defineSymbol(math, ams, bin, "\u229A", "\\circledcirc");
  11047. defineSymbol(math, ams, bin, "\u22A1", "\\boxdot");
  11048. defineSymbol(math, main, bin, "\u25B3", "\\bigtriangleup");
  11049. defineSymbol(math, main, bin, "\u25BD", "\\bigtriangledown");
  11050. defineSymbol(math, main, bin, "\u2020", "\\dagger");
  11051. defineSymbol(math, main, bin, "\u22C4", "\\diamond");
  11052. defineSymbol(math, main, bin, "\u22C6", "\\star");
  11053. defineSymbol(math, main, bin, "\u25C3", "\\triangleleft");
  11054. defineSymbol(math, main, bin, "\u25B9", "\\triangleright");
  11055. defineSymbol(math, main, open, "{", "\\{");
  11056. defineSymbol(text, main, textord, "{", "\\{");
  11057. defineSymbol(text, main, textord, "{", "\\textbraceleft");
  11058. defineSymbol(math, main, close, "}", "\\}");
  11059. defineSymbol(text, main, textord, "}", "\\}");
  11060. defineSymbol(text, main, textord, "}", "\\textbraceright");
  11061. defineSymbol(math, main, open, "{", "\\lbrace");
  11062. defineSymbol(math, main, close, "}", "\\rbrace");
  11063. defineSymbol(math, main, open, "[", "\\lbrack");
  11064. defineSymbol(math, main, close, "]", "\\rbrack");
  11065. defineSymbol(text, main, textord, "<", "\\textless"); // in T1 fontenc
  11066. defineSymbol(text, main, textord, ">", "\\textgreater"); // in T1 fontenc
  11067. defineSymbol(math, main, open, "\u230A", "\\lfloor");
  11068. defineSymbol(math, main, close, "\u230B", "\\rfloor");
  11069. defineSymbol(math, main, open, "\u2308", "\\lceil");
  11070. defineSymbol(math, main, close, "\u2309", "\\rceil");
  11071. defineSymbol(math, main, textord, "\\", "\\backslash");
  11072. defineSymbol(math, main, textord, "\u2223", "|");
  11073. defineSymbol(math, main, textord, "\u2223", "\\vert");
  11074. defineSymbol(text, main, textord, "|", "\\textbar"); // in T1 fontenc
  11075. defineSymbol(math, main, textord, "\u2225", "\\|");
  11076. defineSymbol(math, main, textord, "\u2225", "\\Vert");
  11077. defineSymbol(text, main, textord, "\u2225", "\\textbardbl");
  11078. defineSymbol(math, main, rel, "\u2191", "\\uparrow");
  11079. defineSymbol(math, main, rel, "\u21D1", "\\Uparrow");
  11080. defineSymbol(math, main, rel, "\u2193", "\\downarrow");
  11081. defineSymbol(math, main, rel, "\u21D3", "\\Downarrow");
  11082. defineSymbol(math, main, rel, "\u2195", "\\updownarrow");
  11083. defineSymbol(math, main, rel, "\u21D5", "\\Updownarrow");
  11084. defineSymbol(math, main, op, "\u2210", "\\coprod");
  11085. defineSymbol(math, main, op, "\u22C1", "\\bigvee");
  11086. defineSymbol(math, main, op, "\u22C0", "\\bigwedge");
  11087. defineSymbol(math, main, op, "\u2A04", "\\biguplus");
  11088. defineSymbol(math, main, op, "\u22C2", "\\bigcap");
  11089. defineSymbol(math, main, op, "\u22C3", "\\bigcup");
  11090. defineSymbol(math, main, op, "\u222B", "\\int");
  11091. defineSymbol(math, main, op, "\u222B", "\\intop");
  11092. defineSymbol(math, main, op, "\u222C", "\\iint");
  11093. defineSymbol(math, main, op, "\u222D", "\\iiint");
  11094. defineSymbol(math, main, op, "\u220F", "\\prod");
  11095. defineSymbol(math, main, op, "\u2211", "\\sum");
  11096. defineSymbol(math, main, op, "\u2A02", "\\bigotimes");
  11097. defineSymbol(math, main, op, "\u2A01", "\\bigoplus");
  11098. defineSymbol(math, main, op, "\u2A00", "\\bigodot");
  11099. defineSymbol(math, main, op, "\u222E", "\\oint");
  11100. defineSymbol(math, main, op, "\u2A06", "\\bigsqcup");
  11101. defineSymbol(math, main, op, "\u222B", "\\smallint");
  11102. defineSymbol(text, main, inner, "\u2026", "\\textellipsis");
  11103. defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
  11104. defineSymbol(text, main, inner, "\u2026", "\\ldots", true);
  11105. defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
  11106. defineSymbol(math, main, inner, "\u22EF", "\\@cdots", true);
  11107. defineSymbol(math, main, inner, "\u22F1", "\\ddots", true);
  11108. defineSymbol(math, main, textord, "\u22EE", "\\vdots", true);
  11109. defineSymbol(math, main, accent, "\xB4", "\\acute");
  11110. defineSymbol(math, main, accent, "`", "\\grave");
  11111. defineSymbol(math, main, accent, "\xA8", "\\ddot");
  11112. defineSymbol(math, main, accent, "~", "\\tilde");
  11113. defineSymbol(math, main, accent, "\xAF", "\\bar");
  11114. defineSymbol(math, main, accent, "\u02D8", "\\breve");
  11115. defineSymbol(math, main, accent, "\u02C7", "\\check");
  11116. defineSymbol(math, main, accent, "^", "\\hat");
  11117. defineSymbol(math, main, accent, "\u20D7", "\\vec");
  11118. defineSymbol(math, main, accent, "\u02D9", "\\dot");
  11119. defineSymbol(math, main, mathord, "\u0131", "\\imath");
  11120. defineSymbol(math, main, mathord, "\u0237", "\\jmath");
  11121. defineSymbol(text, main, accent, "\u02CA", "\\'"); // acute
  11122. defineSymbol(text, main, accent, "\u02CB", "\\`"); // grave
  11123. defineSymbol(text, main, accent, "\u02C6", "\\^"); // circumflex
  11124. defineSymbol(text, main, accent, "\u02DC", "\\~"); // tilde
  11125. defineSymbol(text, main, accent, "\u02C9", "\\="); // macron
  11126. defineSymbol(text, main, accent, "\u02D8", "\\u"); // breve
  11127. defineSymbol(text, main, accent, "\u02D9", "\\."); // dot above
  11128. defineSymbol(text, main, accent, "\u02DA", "\\r"); // ring above
  11129. defineSymbol(text, main, accent, "\u02C7", "\\v"); // caron
  11130. defineSymbol(text, main, accent, "\xA8", '\\"'); // diaresis
  11131. defineSymbol(text, main, accent, "\u030B", "\\H"); // double acute
  11132. defineSymbol(text, main, textord, "\u2013", "--");
  11133. defineSymbol(text, main, textord, "\u2013", "\\textendash");
  11134. defineSymbol(text, main, textord, "\u2014", "---");
  11135. defineSymbol(text, main, textord, "\u2014", "\\textemdash");
  11136. defineSymbol(text, main, textord, "\u2018", "`");
  11137. defineSymbol(text, main, textord, "\u2018", "\\textquoteleft");
  11138. defineSymbol(text, main, textord, "\u2019", "'");
  11139. defineSymbol(text, main, textord, "\u2019", "\\textquoteright");
  11140. defineSymbol(text, main, textord, "\u201C", "``");
  11141. defineSymbol(text, main, textord, "\u201C", "\\textquotedblleft");
  11142. defineSymbol(text, main, textord, "\u201D", "''");
  11143. defineSymbol(text, main, textord, "\u201D", "\\textquotedblright");
  11144. defineSymbol(math, main, textord, "\xB0", "\\degree");
  11145. defineSymbol(text, main, textord, "\xB0", "\\degree");
  11146. // TODO: In LaTeX, \pounds can generate a different character in text and math
  11147. // mode, but among our fonts, only Main-Italic defines this character "163".
  11148. defineSymbol(math, main, mathord, "\xA3", "\\pounds");
  11149. defineSymbol(math, main, mathord, "\xA3", "\\mathsterling");
  11150. defineSymbol(text, main, mathord, "\xA3", "\\pounds");
  11151. defineSymbol(text, main, mathord, "\xA3", "\\textsterling");
  11152. defineSymbol(math, ams, textord, "\u2720", "\\maltese");
  11153. defineSymbol(text, ams, textord, "\u2720", "\\maltese");
  11154. defineSymbol(text, main, spacing, "\xA0", "\\ ");
  11155. defineSymbol(text, main, spacing, "\xA0", " ");
  11156. defineSymbol(text, main, spacing, "\xA0", "~");
  11157. // There are lots of symbols which are the same, so we add them in afterwards.
  11158. // All of these are textords in math mode
  11159. var mathTextSymbols = "0123456789/@.\"";
  11160. for (var i = 0; i < mathTextSymbols.length; i++) {
  11161. var ch = mathTextSymbols.charAt(i);
  11162. defineSymbol(math, main, textord, ch, ch);
  11163. }
  11164. // All of these are textords in text mode
  11165. var textSymbols = "0123456789!@*()-=+[]<>|\";:?/.,";
  11166. for (var _i = 0; _i < textSymbols.length; _i++) {
  11167. var _ch = textSymbols.charAt(_i);
  11168. defineSymbol(text, main, textord, _ch, _ch);
  11169. }
  11170. // All of these are textords in text mode, and mathords in math mode
  11171. var letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  11172. for (var _i2 = 0; _i2 < letters.length; _i2++) {
  11173. var _ch2 = letters.charAt(_i2);
  11174. defineSymbol(math, main, mathord, _ch2, _ch2);
  11175. defineSymbol(text, main, textord, _ch2, _ch2);
  11176. }
  11177. // Latin-1 letters
  11178. for (var _i3 = 0x00C0; _i3 <= 0x00D6; _i3++) {
  11179. var _ch3 = String.fromCharCode(_i3);
  11180. defineSymbol(math, main, mathord, _ch3, _ch3);
  11181. defineSymbol(text, main, textord, _ch3, _ch3);
  11182. }
  11183. for (var _i4 = 0x00D8; _i4 <= 0x00F6; _i4++) {
  11184. var _ch4 = String.fromCharCode(_i4);
  11185. defineSymbol(math, main, mathord, _ch4, _ch4);
  11186. defineSymbol(text, main, textord, _ch4, _ch4);
  11187. }
  11188. for (var _i5 = 0x00F8; _i5 <= 0x00FF; _i5++) {
  11189. var _ch5 = String.fromCharCode(_i5);
  11190. defineSymbol(math, main, mathord, _ch5, _ch5);
  11191. defineSymbol(text, main, textord, _ch5, _ch5);
  11192. }
  11193. // Cyrillic
  11194. for (var _i6 = 0x0410; _i6 <= 0x044F; _i6++) {
  11195. var _ch6 = String.fromCharCode(_i6);
  11196. defineSymbol(text, main, textord, _ch6, _ch6);
  11197. }
  11198. // Unicode versions of existing characters
  11199. defineSymbol(text, main, textord, "\u2013", "–");
  11200. defineSymbol(text, main, textord, "\u2014", "—");
  11201. defineSymbol(text, main, textord, "\u2018", "‘");
  11202. defineSymbol(text, main, textord, "\u2019", "’");
  11203. defineSymbol(text, main, textord, "\u201C", "“");
  11204. defineSymbol(text, main, textord, "\u201D", "”");
  11205. },{}],113:[function(require,module,exports){
  11206. "use strict";
  11207. Object.defineProperty(exports, "__esModule", {
  11208. value: true
  11209. });
  11210. var hangulRegex = exports.hangulRegex = /[\uAC00-\uD7AF]/;
  11211. // This regex combines
  11212. // - CJK symbols and punctuation: [\u3000-\u303F]
  11213. // - Hiragana: [\u3040-\u309F]
  11214. // - Katakana: [\u30A0-\u30FF]
  11215. // - CJK ideograms: [\u4E00-\u9FAF]
  11216. // - Hangul syllables: [\uAC00-\uD7AF]
  11217. // - Fullwidth punctuation: [\uFF00-\uFF60]
  11218. // Notably missing are halfwidth Katakana and Romanji glyphs.
  11219. var cjkRegex = exports.cjkRegex = /[\u3000-\u30FF\u4E00-\u9FAF\uAC00-\uD7AF\uFF00-\uFF60]/;
  11220. },{}],114:[function(require,module,exports){
  11221. "use strict";
  11222. Object.defineProperty(exports, "__esModule", {
  11223. value: true
  11224. });
  11225. exports.calculateSize = exports.validUnit = undefined;
  11226. var _ParseError = require("./ParseError");
  11227. var _ParseError2 = _interopRequireDefault(_ParseError);
  11228. var _Options = require("./Options");
  11229. var _Options2 = _interopRequireDefault(_Options);
  11230. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11231. // This table gives the number of TeX pts in one of each *absolute* TeX unit.
  11232. // Thus, multiplying a length by this number converts the length from units
  11233. // into pts. Dividing the r###lt by ptPerEm gives the number of ems
  11234. // *assuming* a font size of ptPerEm (normal size, normal style).
  11235. /**
  11236. * This file does conversion between units. In particular, it provides
  11237. * calculateSize to convert other units into ems.
  11238. */
  11239. var ptPerUnit = {
  11240. // https://en.wikibooks.org/wiki/LaTeX/Lengths and
  11241. // https://tex.stackexchange.com/a/8263
  11242. "pt": 1, // TeX point
  11243. "mm": 7227 / 2540, // millimeter
  11244. "cm": 7227 / 254, // centimeter
  11245. "in": 72.27, // inch
  11246. "bp": 803 / 800, // big (PostScript) points
  11247. "pc": 12, // pica
  11248. "dd": 1238 / 1157, // didot
  11249. "cc": 14856 / 1157, // cicero (12 didot)
  11250. "nd": 685 / 642, // new didot
  11251. "nc": 1370 / 107, // new cicero (12 new didot)
  11252. "sp": 1 / 65536, // scaled point (TeX's internal smallest unit)
  11253. // https://tex.stackexchange.com/a/41371
  11254. "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
  11255. };
  11256. // Dictionary of relative units, for fast validity testing.
  11257. var relativeUnit = {
  11258. "ex": true,
  11259. "em": true,
  11260. "mu": true
  11261. };
  11262. /**
  11263. * Determine whether the specified unit (either a string defining the unit
  11264. * or a "size" parse node containing a unit field) is valid.
  11265. */
  11266. var validUnit = exports.validUnit = function validUnit(unit) {
  11267. if (typeof unit !== "string") {
  11268. unit = unit.unit;
  11269. }
  11270. return unit in ptPerUnit || unit in relativeUnit || unit === "ex";
  11271. };
  11272. /*
  11273. * Convert a "size" parse node (with numeric "number" and string "unit" fields,
  11274. * as parsed by functions.js argType "size") into a CSS em value for the
  11275. * current style/scale. `options` gives the current options.
  11276. */
  11277. var calculateSize = exports.calculateSize = function calculateSize(sizeValue, options) {
  11278. var scale = void 0;
  11279. if (sizeValue.unit in ptPerUnit) {
  11280. // Absolute units
  11281. scale = ptPerUnit[sizeValue.unit] // Convert unit to pt
  11282. / options.fontMetrics().ptPerEm // Convert pt to CSS em
  11283. / options.sizeMultiplier; // Unscale to make absolute units
  11284. } else if (sizeValue.unit === "mu") {
  11285. // `mu` units scale with scriptstyle/scriptscriptstyle.
  11286. scale = options.fontMetrics().cssEmPerMu;
  11287. } else {
  11288. // Other relative units always refer to the *textstyle* font
  11289. // in the current size.
  11290. var unitOptions = void 0;
  11291. if (options.style.isTight()) {
  11292. // isTight() means current style is script/scriptscript.
  11293. unitOptions = options.havingStyle(options.style.text());
  11294. } else {
  11295. unitOptions = options;
  11296. }
  11297. // TODO: In TeX these units are relative to the quad of the current
  11298. // *text* font, e.g. cmr10. KaTeX instead uses values from the
  11299. // comparably-sized *Computer Modern symbol* font. At 10pt, these
  11300. // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
  11301. // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
  11302. // TeX \showlists shows a kern of 1.13889 * fontsize;
  11303. // KaTeX shows a kern of 1.171 * fontsize.
  11304. if (sizeValue.unit === "ex") {
  11305. scale = unitOptions.fontMetrics().xHeight;
  11306. } else if (sizeValue.unit === "em") {
  11307. scale = unitOptions.fontMetrics().quad;
  11308. } else {
  11309. throw new _ParseError2.default("Invalid unit: '" + sizeValue.unit + "'");
  11310. }
  11311. if (unitOptions !== options) {
  11312. scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
  11313. }
  11314. }
  11315. return Math.min(sizeValue.number * scale, options.maxSize);
  11316. };
  11317. },{"./Options":83,"./ParseError":84}],115:[function(require,module,exports){
  11318. "use strict";
  11319. Object.defineProperty(exports, "__esModule", {
  11320. value: true
  11321. });
  11322. /**
  11323. * This file contains a list of utility functions which are useful in other
  11324. * files.
  11325. */
  11326. /**
  11327. * Provide an `indexOf` function which works in IE8, but defers to native if
  11328. * possible.
  11329. */
  11330. var nativeIndexOf = Array.prototype.indexOf;
  11331. var indexOf = function indexOf(list, elem) {
  11332. if (list == null) {
  11333. return -1;
  11334. }
  11335. if (nativeIndexOf && list.indexOf === nativeIndexOf) {
  11336. return list.indexOf(elem);
  11337. }
  11338. var l = list.length;
  11339. for (var i = 0; i < l; i++) {
  11340. if (list[i] === elem) {
  11341. return i;
  11342. }
  11343. }
  11344. return -1;
  11345. };
  11346. /**
  11347. * Return whether an element is contained in a list
  11348. */
  11349. var contains = function contains(list, elem) {
  11350. return indexOf(list, elem) !== -1;
  11351. };
  11352. /**
  11353. * Provide a default value if a setting is undefined
  11354. * NOTE: Couldn't use `T` as the output type due to facebook/flow#5022.
  11355. */
  11356. var deflt = function deflt(setting, defaultIfUndefined) {
  11357. return setting === undefined ? defaultIfUndefined : setting;
  11358. };
  11359. // hyphenate and escape adapted from Facebook's React under Apache 2 license
  11360. var uppercase = /([A-Z])/g;
  11361. var hyphenate = function hyphenate(str) {
  11362. return str.replace(uppercase, "-$1").toLowerCase();
  11363. };
  11364. var ESCAPE_LOOKUP = {
  11365. "&": "&amp;",
  11366. ">": "&gt;",
  11367. "<": "&lt;",
  11368. "\"": "&quot;",
  11369. "'": "&#x27;"
  11370. };
  11371. var ESCAPE_REGEX = /[&><"']/g;
  11372. /**
  11373. * Escapes text to prevent scripting attacks.
  11374. */
  11375. function escape(text) {
  11376. return String(text).replace(ESCAPE_REGEX, function (match) {
  11377. return ESCAPE_LOOKUP[match];
  11378. });
  11379. }
  11380. /**
  11381. * A function to set the text content of a DOM element in all supported
  11382. * browsers. Note that we don't define this if there is no document.
  11383. */
  11384. var setTextContent = void 0;
  11385. if (typeof document !== "undefined") {
  11386. var testNode = document.createElement("span");
  11387. if ("textContent" in testNode) {
  11388. setTextContent = function setTextContent(node, text) {
  11389. node.textContent = text;
  11390. };
  11391. } else {
  11392. setTextContent = function setTextContent(node, text) {
  11393. node.innerText = text;
  11394. };
  11395. }
  11396. }
  11397. /**
  11398. * A function to clear a node.
  11399. */
  11400. function clearNode(node) {
  11401. setTextContent(node, "");
  11402. }
  11403. exports.default = {
  11404. contains: contains,
  11405. deflt: deflt,
  11406. escape: escape,
  11407. hyphenate: hyphenate,
  11408. indexOf: indexOf,
  11409. setTextContent: setTextContent,
  11410. clearNode: clearNode
  11411. };
  11412. },{}]},{},[1])(1)
  11413. });