PageSourceSearch

https://planetrl.github.io/lib/template.v1.js

js planetrl.github.io collected 2026-10-03 09:46:06 UTC 590,983 bytes, 18,269 lines download raw bytes

1// modified distill.pub template v1 for world models.
2(function (global, factory) {
3	typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4	typeof define === 'function' && define.amd ? define(['exports'], factory) :
5	(factory((global.dl = global.dl || {})));
6}(this, (function (exports) { 'use strict';
7
8var html = function(dom) {
9  if (!dom.querySelector("html").getAttribute("lang")) {
10    dom.querySelector("html").setAttribute("lang", "en");
11  }
12
13  var head = dom.querySelector("head");
14
15  if (!dom.querySelector("meta[charset]")) {
16    var meta = dom.createElement("meta");
17    meta.setAttribute("charset", "utf-8");
18    head.appendChild(meta);
19  }
20  if (!dom.querySelector("meta[name=viewport]")) {
21    var meta$1 = dom.createElement("meta");
22    meta$1.setAttribute("name", "viewport");
23    meta$1.setAttribute("content", "width=device-width, initial-scale=1");
24    head.appendChild(meta$1);
25  }
26};
27
28var base = "html {\n  font: 400 16px/1.55em -apple-system, BlinkMacSystemFont, \"Roboto\", Helvetica, sans-serif;\n  /*background-color: hsl(223, 9%, 25%);*/\n  -ms-text-size-adjust: 100%;\n  -webkit-text-size-adjust: 100%;\n  text-size-adjust: 100%;\n}\nbody {\n  margin: 0;\n  /*background-color: hsl(223, 9%, 25%);*/\n}\n\na {\n  color: #004276;\n}\n\nfigure {\n  margin: 0;\n}\n\nh1 {\n  font-family: Cochin, Georgia, serif;\n}\n\n/*\nhtml, body, div, span, applet, object, iframe,\nh1, h2, h3, h4, h5, h6, p, blockquote, pre,\na, abbr, acronym, address, big, cite, code,\ndel, dfn, em, img, ins, kbd, q, s, samp,\nsmall, strike, strong, sub, sup, tt, var,\nb, u, i, center,\ndl, dt, dd, ol, ul, li,\nfieldset, form, label, legend,\ntable, caption, tbody, tfoot, thead, tr, th, td,\narticle, aside, canvas, details, embed,\nfigure, figcaption, footer, header, hgroup,\nmenu, nav, output, ruby, section, summary,\ntime, mark, audio, video {\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tfont-size: 100%;\n\tfont: inherit;\n\tvertical-align: baseline;\n}\narticle, aside, details, figcaption, figure,\nfooter, header, hgroup, menu, nav, section {\n\tdisplay: block;\n}\nbody {\n\tline-height: 1;\n}\nol, ul {\n\tlist-style: none;\n}\nblockquote, q {\n\tquotes: none;\n}\nblockquote:before, blockquote:after,\nq:before, q:after {\n\tcontent: '';\n\tcontent: none;\n}\ntable {\n\tborder-collapse: collapse;\n\tborder-spacing: 0;\n}*/\n";
29
30var layout = "/*\n  Column: 60px\n  Gutter: 24px\n\n  Body: 648px\n    - 8 columns\n    - 7 gutters\n  Middle: 816px\n  Page: 984px\n    - 12 columns\n    - 11 gutters\n*/\n\n.l-body,\n.l-body-outset,\n.l-page,\n.l-page-outset,\n.l-middle,\n.l-middle-outset,\ndt-article > div,\ndt-article > p,\ndt-article > h1,\ndt-article > h2,\ndt-article > h3,\ndt-article > h4,\ndt-article > figure,\ndt-article > table,\ndt-article > ol,\ndt-article > ul,\ndt-article > dt-byline,\ndt-article > dt-math,\ndt-article > dt-code,\ndt-article section > div,\ndt-article section > p,\ndt-article section > h1,\ndt-article section > h2,\ndt-article section > h3,\ndt-article section > h4,\ndt-article section > figure,\ndt-article section > table,\ndt-article section > ol,\ndt-article section > ul,\ndt-article section > dt-byline,\ndt-article section > dt-code {\n  width: auto;\n  margin-left: 24px;\n  margin-right: 24px;\n  box-sizing: border-box;\n}\n\n@media(min-width: 768px) {\n  .l-body,\n  .l-body-outset,\n  .l-page,\n  .l-page-outset,\n  .l-mid
30dle,\n  .l-middle-outset,\n  dt-article > div,\n  dt-article > p,\n  dt-article > h1,\n  dt-article > h2,\n  dt-article > h3,\n  dt-article > h4,\n  dt-article > figure,\n  dt-article > table,\n  dt-article > ol,\n  dt-article > ul,\n  dt-article > dt-byline,\n  dt-article > dt-math,\n  dt-article > dt-code,\n  dt-article section > div,\n  dt-article section > p,\n  dt-article section > h1,\n  dt-article section > h2,\n  dt-article section > h3,\n  dt-article section > h4,\n  dt-article section > figure,\n  dt-article section > table,\n  dt-article section > ol,\n  dt-article section > ul,\n  dt-article section > dt-byline,\n  dt-article section > dt-code {\n    margin-left: 72px;\n    margin-right: 72px;\n  }\n}\n\n@media(min-width: 1080px) {\n  .l-body,\n  dt-article > div,\n  dt-article > p,\n  dt-article > h2,\n  dt-article > h3,\n  dt-article > h4,\n  dt-article > figure,\n  dt-article > table,\n  dt-article > ol,\n  dt-article > ul,\n  dt-article > dt-byline,\n  dt-article > dt-math,\n  dt-article > dt-code,\n  dt-article section > div,\n  dt-article section > p,\n  dt-article section > h2,\n  dt-article section > h3,\n  dt-article section > h4,\n  dt-article section > figure,\n  dt-article section > table,\n  dt-article section > ol,\n  dt-article section > ul,\n  dt-article section > dt-byline,\n  dt-article section > dt-code {\n    margin-left: calc(50% - 984px / 2);\n    width: 648px;\n  }\n  .l-body-outset,\n  dt-article .l-body-outset {\n    margin-left: calc(50% - 984px / 2 - 96px/2);\n    width: calc(648px + 96px);\n  }\n  .l-middle,\n  dt-article .l-middle {\n    width: 816px;\n    margin-left: calc(50% - 984px / 2);\n    margin-right: auto;\n  }\n  .l-middle-outset,\n  dt-article .l-middle-outset {\n    width: calc(816px + 96px);\n    margin-left: calc(50% - 984px / 2 - 48px);\n    margin-right: auto;\n  }\n  dt-article > h1,\n  dt-article section > h1,\n  .l-page,\n  dt-article .l-page,\n  dt-article.centered .l-page {\n    width: 984px;\n    margin-left: auto;\n    margin-right: auto;\n  }\n  .l-page-outset,\n  dt-article .l-page-outset,\n  dt-article.centered .l-page-outset {\n    width: 1080px;\n    margin-left: auto;\n    margin-right: auto;\n  }\n  .l-screen,\n  dt-article .l-screen,\n  dt-article.centered .l-screen {\n    margin-left: auto;\n    margin-right: auto;\n    width: auto;\n  }\n  .l-screen-inset,\n  dt-article .l-screen-inset,\n  dt-article.centered .l-screen-inset {\n    margin-left: 24px;\n    margin-right: 24px;\n    width: auto;\n  }\n  .l-gutter,\n  dt-article .l-gutter {\n    clear: both;\n    float: right;\n    margin-top: 0;\n    margin-left: 24px;\n    margin-right: calc((100vw - 984px) / 2 + 168px);\n    width: calc((984px - 648px) / 2 - 24px);\n  }\n\n  /* Side */\n  .side.l-body,\n  dt-article .side.l-body {\n    clear: both;\n    float: right;\n    margin-top: 0;\n    margin-left: 48px;\n    margin-right: calc((100vw - 984px + 648px) / 2);\n    width: calc(648px / 2 - 24px - 84px);\n  }\n  .side.l-body-outset,\n  dt-article .side.l-body-outset {\n    clear: both;\n    float: right;\n    margin-top: 0;\n    margin-left: 48px;\n    margin-right: calc((100vw - 984px + 648px - 48px) / 2);\n    width: calc(648px / 2 - 48px + 24px);\n  }\n  .side.l-middle,\n  dt-article .side.l-middle {\n    clear: both;\n    float: right;\n    width: calc(456px - 84px);\n    margin-left: 48px;\n    margin-right: calc((100vw - 984px) / 2 + 168px);\n  }\n  .side.l-middle-outset,\n  dt-article .side.l-middle-outset {\n    clear: both;\n    float: right;\n    width: 456px;\n    margin-left: 48px;\n    margin-right: calc((100vw - 984px) / 2 + 168px);\n  }\n  .side.l-page,\n  dt-article .side.l-page {\n    clear: both;\n    float: right;\n    margin-left: 48px;\n    width: calc(624px - 84px);\n    margin-right: calc((100vw - 984px) / 2);\n  }\n  .side.l-page-outset,\n  dt-article .side.l-page-outset {\n    clear: both;\n    float: right;\n    width: 624px;\n    margin-right: calc((100vw - 984px) / 2);\n  }\n}\n\n/* Centered */\n\n@media(min-width: 1080px) {\n  .centered .l-body,\n  .centered.l-body,\n  dt-article.centered > div,\n  dt-article.centered > p,\n  dt-article.centered > h2,\n  dt-article.centered > h3,\n  dt-article.centered > h4,\n  dt-article.centered > figure,\n  dt-article.centered > table,\n  dt-article.centered > ol,\n  dt-article.centered > ul,\n  dt-article.centered > dt-byline,\n  dt-article.centered > dt-code,\n  dt-article.centered section > div,\n  dt-article.centered section > p,\n  dt-article.centered section > h2,\n  dt-article.centered section > h3,\n  dt-article.centered section > h4,\n  dt-article.centered section > figure,\n  dt-article.centered section > table,\n  dt-article.cebtered section > ol,\n  dt-article.centered section > ul,\n  dt-article.centered section > dt-byline,\n  dt-article.centered section > dt-code,\n  dt-article section.centered > div,\n  dt-article section.centered > p,\n  dt-article section.centered > h2,\n  dt-article section.centered > h3,\n  dt-article section.centered > h4,\n  dt-article section.centered > figure,\n  dt-article section.centered > table,\n  dt-article section.centered > ol,\n  dt-article section.centered > ul,\n  dt-article section.centered > dt-byline,\n  dt-article section.centered > dt-code {\n    margin-left: auto;\n    margin-right: auto;\n    width: 648px;\n  }\n  .centered .l-body-outset,\n  .centered.l-body-outset,\n  dt-article.centered .l-body-outset {\n    margin-left: auto;\n    margin-right: auto;\n    width: calc(648px + 96px);\n  }\n  dt-article.centered > h1,\n  dt-article.centered section > h1,\n  dt-article section.centered > h1,\n  .centered .l-middle,\n  .centered.l-middle,\n  dt-article.centered .l-middle {\n    width: 816px;\n    margin-left: auto;\n    margin-right: auto;\n  }
30\n\n  .centered .l-middle-outset,\n  .centered.l-middle-outset,\n  dt-article.centered .l-middle-outset {\n    width: calc(816px + 96px);\n    margin-left: auto;\n    margin-right: auto;\n  }\n\n  /* page and screen are already centered */\n\n  /* Side */\n\n  .centered .side.l-body,\n  .centered dt-article .side.l-body {\n    clear: both;\n    float: right;\n    margin-top: 0;\n    margin-left: 48px;\n    margin-right: calc((100vw - 648px) / 2);\n    width: calc(4 * 60px + 3 * 24px);\n  }\n  .centered .side.l-body-outset,\n  .centered dt-article .side.l-body-outset {\n    clear: both;\n    float: right;\n    margin-top: 0;\n    margin-left: 48px;\n    margin-right: calc((100vw - 648px) / 2);\n    width: calc(4 * 60px + 3 * 24px);\n  }\n  .centered .side.l-middle,\n  .centered dt-article .side.l-middle {\n    clear: both;\n    float: right;\n    width: 396px;\n    margin-left: 48px;\n    margin-right: calc((100vw - 984px) / 2 + 168px / 2);\n  }\n  .centered .side.l-middle-outset,\n  .centered dt-article .side.l-middle-outset {\n    clear: both;\n    float: right;\n    width: 456px;\n    margin-left: 48px;\n    margin-right: calc((100vw - 984px) / 2 + 168px);\n  }\n  .centered .side.l-page,\n  .centered dt-article .side.l-page {\n    clear: both;\n    float: right;\n    width: 480px;\n    margin-right: calc((100vw - 984px) / 2);\n  }\n  .centered .side.l-page-outset,\n  .centered dt-article .side.l-page-outset {\n    clear: both;\n    float: right;\n    width: 480px;\n    margin-right: calc((100vw - 984px) / 2);\n  }\n  .centered .l-gutter,\n  .centered.l-gutter,\n  dt-article.centered .l-gutter {\n    clear: both;\n    float: right;\n    margin-top: 0;\n    margin-left: 24px;\n    margin-right: calc((100vw - 984px) / 2);\n    width: calc((984px - 648px) / 2 - 24px);\n  }\n\n}\n\n/* Rows and Columns */\n\n.row {\n  display: flex;\n}\n.column {\n  flex: 1;\n  box-sizing: border-box;\n  margin-right: 24px;\n  margin-left: 24px;\n}\n.row > .column:first-of-type {\n  margin-left: 0;\n}\n.row > .column:last-of-type {\n  margin-right: 0;\n}\n";
31
32var article = "dt-article {\n  display: block;\n  color: rgba(0, 0, 0, 0.8);\n  font: 17px/1.55em -apple-system, BlinkMacSystemFont, \"Roboto\", sans-serif;\n  padding-bottom: 72px;\n  background: white;\n}\n\n@media(min-width: 1024px) {\n  dt-article {\n    font-size: 20px;\n  }\n}\n\n/* H1 */\n\ndt-article h1 {\n  margin-top: 18px;\n  font-weight: 400;\n  font-size: 40px;\n  line-height: 1em;\n  font-family: HoeflerText-Regular, Cochin, Georgia, serif;\n}\n@media(min-width: 768px) {\n  dt-article h1 {\n    font-size: 46px;\n    margin-top: 48px;\n    margin-bottom: 12px;\n  }\n}\n\n@media(min-width: 1080px) {\n  .centered h1 {\n    text-align: center;\n  }\n\n  dt-article h1 {\n    font-size: 50px;\n    letter-spacing: -0.02em;\n  }\n\n  dt-article > h1:first-of-type,\n  dt-article section > h1:first-of-type {\n    margin-top: 80px;\n  }\n}\n\n\n@media(min-width: 1200px) {\n  dt-article h1 {\n    font-size: 56px;\n  }\n\n  dt-article > h1:first-of-type {\n    margin-top: 100px;\n  }\n}\n\n/* H2 */\n\ndt-article h2 {\n  font-family: HoeflerText-Regular, Cochin, Georgia, serif;\n  font-weight: 400;\n  font-size: 26px;\n  line-height: 1.25em;\n  margin-top: 36px;\n  margin-bottom: 24px;\n}\n\n@media(min-width: 1024px) {\n  dt-article h2 {\n    margin-top: 48px;\n    font-size: 30px;\n  }\n}\n\ndt-article h1 + h2 {\n  font-weight: 300;\n  font-size: 20px;\n  line-height: 1.4em;\n  margin-top: 8px;\n  font-style: normal;\n}\n\n\n@media(min-width: 1080px) {\n  .centered h1 + h2 {\n    text-align: center;\n  }\n  dt-article h1 + h2 {\n    margin-top: 12px;\n    font-size: 24px;\n  }\n}\n\n/* H3 */\n\ndt-article h3 {\n  font-family: HoeflerText-Regular, Georgia, serif;\n  font-weight: 400;\n  font-size: 20px;\n  line-height: 1.4em;\n  margin-top: 36px;\n  margin-bottom: 18px;\n  font-style: italic;\n}\n\ndt-article h1 + h3 {\n  margin-top: 48px;\n}\n\n@media(min-width: 1024px) {\n  dt-article h3 {\n    font-size: 26px;\n  }\n}\n\n/* H4 */\n\ndt-article h4 {\n  font-weight: 600;\n  text-transform: uppercase;\n  font-size: 14px;\n  line-height: 1.4em;\n}\n\ndt-article a {\n  color: inherit;\n}\n\ndt-article p,\ndt-article ul,\ndt-article ol {\n  margin-bottom: 24px;\n  font-family: Georgia, serif;\n}\n\ndt-article p b,\ndt-article ul b,\ndt-article ol b {\n  -webkit-font-smoothing: antialiased;\n}\n\ndt-article a {\n  border-bottom: 1px solid rgba(0, 0, 0, 0.4);\n  text-decoration: none;\n}\n\ndt-article a:hover {\n  border-bottom: 1px solid rgba(0, 0, 0, 0.8);\n}\n\ndt-article .link {\n  text-decoration: underline;\n  cursor: pointer;\n}\n\ndt-article ul,\ndt-article ol {\n  padding-left: 24px;\n}\n\ndt-article li {\n  margin-bottom: 24px;\n  margin-left: 0;\n  padding-left: 0;\n}\n\ndt-article pre {\n  font-size: 14px;\n  margin-bottom: 20px;\n}\n\n\ndt-article hr {\n  border: none;\n  border-bottom: 1px solid rgba(0, 0, 0, 0.2);\n  margin-top: 60px;\n  margin-bottom: 60px;\n}\n\ndt-article section {\n  margin-top: 60px;\n  margin-bottom: 60px;\n}\n\n/* Tables */\n\ndt-article table {\n  border-collapse: collapse;\n}\n\ndt-article table th {\n  border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n}\n\ndt-article table td {\n  border-bottom: 1px solid rgba(0, 0, 0, 0.05);\n}\n\ndt-article table th,\ndt-article table td {\n  font-size: 15px;\n  padding: 2px 0;\n}\n\n/* Figure */\n\ndt-article figure {\n  position: relative;\n  margin-top: 30px;\n  margin-bottom: 30px;\n}\n\n@media(min-width: 1024px) {\n  dt-article figure {\n    margin-top: 48px;\n    margin-bottom: 48px;\n  }\n}\n\ndt-article figure img {\n  width: 100%;\n}\n\ndt-article figure svg text,\ndt-article figure svg tspan {\n}\n\ndt-article figure figcaption {\n  color: rgba(0, 0, 0, 0.6);\n  font-size: 12px;\n  line-height: 1.5em;\n}\n@media(min-width: 1024px) {\n  dt-article figure figcaption {\n    font-size: 13px;\n  }\n}\n\ndt-article figure.external img {\n  background: white;\n  border: 1px solid rgba(0, 0, 0, 0.1);\n  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1);\n  padding: 18px;\n  box-sizing: border-box;\n}\n\ndt-article figure figcaption a {\n  color: rgba(0, 0, 0, 0.6);\n}\n\ndt-article span.equation-mimic {\n  font-family: georgia;\n  font-size: 115%;\n  font-style: italic;\n}\n\ndt-article figure figcaption b {\n  font-weight: 600;\n  color: rgba(0, 0, 0, 1.0);\n}\n\ndt-article > dt-code,\ndt-article section > dt-code  {\n  display: block;\n}\n\ndt-article .citation {\n  color: #668;\n  cursor: pointer;\n}\n\ndt-include {\n  width: auto;\n  display: block;\n}\n";
33
34var code = "/**\n * prism.js default theme for JavaScript, CSS and HTML\n * Based on dabblet (http://dabblet.com)\n * @author Lea Verou\n */\n\ncode {\n  white-space: nowrap;\n  background: rgba(0, 0, 0, 0.04);\n  border-radius: 2px;\n  padding: 4px 7px;\n  font-size: 15px;\n  color: rgba(0, 0, 0, 0.6);\n}\n\npre code {\n  display: block;\n  background: white;\n  border-left: 3px solid rgba(0, 0, 0, 0.05);\n  padding: 0 0 0 24px;\n}\n\n\ncode[class*=\"language-\"],\npre[class*=\"language-\"] {\n  text-shadow: 0 1px white;
34\n  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;\n  text-align: left;\n  white-space: pre;\n  word-spacing: normal;\n  word-break: normal;\n  word-wrap: normal;\n  line-height: 1.5;\n\n  -moz-tab-size: 4;\n  -o-tab-size: 4;\n  tab-size: 4;\n\n  -webkit-hyphens: none;\n  -moz-hyphens: none;\n  -ms-hyphens: none;\n  hyphens: none;\n}\n\npre[class*=\"language-\"]::-moz-selection, pre[class*=\"language-\"] ::-moz-selection,\ncode[class*=\"language-\"]::-moz-selection, code[class*=\"language-\"] ::-moz-selection {\n  text-shadow: none;\n  background: #b3d4fc;\n}\n\npre[class*=\"language-\"]::selection, pre[class*=\"language-\"] ::selection,\ncode[class*=\"language-\"]::selection, code[class*=\"language-\"] ::selection {\n  text-shadow: none;\n  background: #b3d4fc;\n}\n\n@media print {\n  code[class*=\"language-\"],\n  pre[class*=\"language-\"] {\n  text-shadow: none;\n  }\n}\n\n/* Code blocks */\npre[class*=\"language-\"] {\n  overflow: auto;\n}\n\n:not(pre) > code[class*=\"language-\"],\
34npre[class*=\"language-\"] {\n}\n\n/* Inline code */\n:not(pre) > code[class*=\"language-\"] {\n  white-space: normal;\n}\n\n.token.comment,\n.token.prolog,\n.token.doctype,\n.token.cdata {\n  color: slategray;\n}\n\n.token.punctuation {\n  color: #999;\n}\n\n.namespace {\n  opacity: .7;\n}\n\n.token.property,\n.token.tag,\n.token.boolean,\n.token.number,\n.token.constant,\n.token.symbol,\n.token.deleted {\n  color: #905;\n}\n\n.token.selector,\n.token.attr-name,\n.token.string,\n.token.char,\n.token.builtin,\n.token.inserted {\n  color: #690;\n}\n\n.token.operator,\n.token.entity,\n.token.url,\n.language-css .token.string,\n.style .token.string {\n  color: #a67f59;\n  background: hsla(0, 0%, 100%, .5);\n}\n\n.token.atrule,\n.token.attr-value,\n.token.keyword {\n  color: #07a;\n}\n\n.token.function {\n  color: #DD4A68;\n}\n\n.token.regex,\n.token.important,\n.token.variable {\n  color: #e90;\n}\n\n.token.important,\n.token.bold {\n  font-weight: bold;\n}\n.token.italic {\n  font-style: italic;\n}\n\n.token.entity {\n  cursor: help;\n}\n";
35
36var print = "\n@media print {\n  @page {\n    size: 8in 11in;\n  }\n  html {\n  }\n  p, code {\n    page-break-inside: avoid;\n  }\n  h2, h3 {\n    page-break-after: avoid;\n  }\n  dt-header {\n    visibility: hidden;\n  }\n  dt-footer {\n    display: none!important;\n  }\n}\n";
37
38var styles = function(dom) {
39  var s = dom.createElement("style");
40  s.textContent = base + layout + article + code + print;
41  dom.querySelector("head").appendChild(s);
42};
43
44function isNothing(subject) {
45  return (typeof subject === 'undefined') || (subject === null);
46}
47
48
49function isObject(subject) {
50  return (typeof subject === 'object') && (subject !== null);
51}
52
53
54function toArray(sequence) {
55  if (Array.isArray(sequence)) { return sequence; }
56  else if (isNothing(sequence)) { return []; }
57
58  return [ sequence ];
59}
60
61
62function extend(target, source) {
63  var index, length, key, sourceKeys;
64
65  if (source) {
66    sourceKeys = Object.keys(source);
67
68    for (index = 0, length = sourceKeys.length; index < length; index += 1) {
69      key = sourceKeys[index];
70      target[key] = source[key];
71    }
72  }
73
74  return target;
75}
76
77
78function repeat(string, count) {
79  var result = '', cycle;
80
81  for (cycle = 0; cycle < count; cycle += 1) {
82    result += string;
83  }
84
85  return result;
86}
87
88
89function isNegativeZero(number) {
90  return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
91}
92
93
94var isNothing_1 = isNothing;
95var isObject_1 = isObject;
96var toArray_1 = toArray;
97var repeat_1 = repeat;
98var isNegativeZero_1 = isNegativeZero;
99var extend_1 = extend;
100
101var common$1 = {
102	isNothing: isNothing_1,
103	isObject: isObject_1,
104	toArray: toArray_1,
105	repeat: repeat_1,
106	isNegativeZero: isNegativeZero_1,
107	extend: extend_1
108};
109
110// YAML error class. http://stackoverflow.com/questions/8458984
111//
112function YAMLException$2(reason, mark) {
113  // Super constructor
114  Error.call(this);
115
116  // Include stack trace in error object
117  if (Error.captureStackTrace) {
118    // Chrome and NodeJS
119    Error.captureStackTrace(this, this.constructor);
120  } else {
121    // FF, IE 10+ and Safari 6+. Fallback for others
122    this.stack = (new Error()).stack || '';
123  }
124
125  this.name = 'YAMLException';
126  this.reason = reason;
127  this.mark = mark;
128  this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
129}
130
131
132// Inherit from Error
133YAMLException$2.prototype = Object.create(Error.prototype);
134YAMLException$2.prototype.constructor = YAMLException$2;
135
136
137YAMLException$2.prototype.toString = function toString(compact) {
138  var result = this.name + ': ';
139
140  result += this.reason || '(unknown reason)';
141
142  if (!compact && this.mark) {
143    result += ' ' + this.mark.toString();
144  }
145
146  return result;
147};
148
149
150var exception = YAMLException$2;
151
152var common$3 = common$1;
153
154
155function Mark$1(name, buffer, position, line, column) {
156  this.name     = name;
157  this.buffer   = buffer;
158  this.position = position;
159  this.line     = line;
160  this.column   = column;
161}
162
163
164Mark$1.prototype.getSnippet = function getSnippet(indent, maxLength) {
165  var this$1 = this;
166
167  var head, start, tail, end, snippet;
168
169  if (!this.buffer) { return null; }
170
171  indent = indent || 4;
172  maxLength = maxLength || 75;
173
174  head = '';
175  start = this.position;
176
177  while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
178    start -= 1;
179    if (this$1.position - start > (maxLength / 2 - 1)) {
180      head = ' ... ';
181      start += 5;
182      break;
183    }
184  }
185
186  tail = '';
187  end = this.position;
188
189  while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
190    end += 1;
191    if (end - this$1.position > (maxLength / 2 - 1)) {
192      tail = ' ... ';
193      end -= 5;
194      break;
195    }
196  }
197
198  snippet = this.buffer.slice(start, end);
199
200  return common$3.repeat(' ', indent) + head + snippet + tail + '\n' +
201         common$3.repeat(' ', indent + this.position - start + head.length) + '^';
202};
203
204
205Mark$1.prototype.toString = function toString(compact) {
206  var snippet, where = '';
207
208  if (this.name) {
209    where += 'in "' + this.name + '" ';
210  }
211
212  where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
213
214  if (!compact) {
215    snippet = this.getSnippet();
216
217    if (snippet) {
218      where += ':\n' + snippet;
219    }
220  }
221
222  return where;
223};
224
225
226var mark = Mark$1;
227
228var YAMLException$4 = exception;
229
230var TYPE_CONSTRUCTOR_OPTIONS = [
231  'kind',
232  'resolve',
233  'construct',
234  'instanceOf',
235  'predicate',
236  'represent',
237  'defaultStyle',
238  'styleAliases'
239];
240
241var YAML_NODE_KINDS = [
242  'scalar',
243  'sequence',
244  'mapping'
245];
246
247function compileStyleAliases(map) {
248  var result = {};
249
250  if (map !== null) {
251    Object.keys(map).forEach(function (style) {
252      map[style].forEach(function (alias) {
253        result[String(alias)] = style;
254      });
255    });
256  }
257
258  return result;
259}
260
261function Type$2(tag, options) {
262  options = options || {};
263
264  Object.keys(options).forEach(function (name) {
265    if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
266      throw new YAMLException$4('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
267    }
268  });
269
270  // TODO: Add tag format check.
271  this.tag          = tag;
272  this.kind         = options['kind']         || null;
273  this.resolve      = options['resolve']      || function () { return true; };
274  this.construct    = options['construct']    || function (data) { return data; };
275  this.instanceOf   = options['instanceOf']   || null;
276  this.predicate    = options['predicate']    || null;
277  this.represent    = options['represent']    || null;
278  this.defaultStyle = options['defaultStyle'] || null;
279  this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
280
281  if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
282    throw new YAMLException$4('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
283  }
284}
285
286var type = Type$2;
287
288/*eslint-disable max-len*/
289
290var common$4        = common$1;
291var YAMLException$3 = exception;
292var Type$1          = type;
293
294
295function compileList(schema, name, result) {
296  var exclude = [];
297
298  schema.include.forEach(function (includedSchema) {
299    result = compileList(includedSchema, name, result);
300  });
301
302  schema[name].forEach(function (currentType) {
303    result.forEach(function (previousType, previousIndex) {
304      if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
305        exclude.push(previousIndex);
306      }
307    });
308
309    result.push(currentType);
310  });
311
312  return result.filter(function (type$$1, index) {
313    return exclude.indexOf(index) === -1;
314  });
315}
316
317
318function compileMap(/* lists... */) {
319  var arguments$1 = arguments;
320
321  var result = {
322        scalar: {},
323        sequence: {},
324        mapping: {},
325        fallback: {}
326      }, index, length;
327
328  function collectType(type$$1) {
329    result[type$$1.kind][type$$1.tag] = result['fallback'][type$$1.tag] = type$$1;
330  }
331
332  for (index = 0, length = arguments.length; index < length; index += 1) {
333    arguments$1[index].forEach(collectType);
334  }
335  return result;
336}
337
338
339function Schema$2(definition) {
340  this.include  = definition.include  || [];
341  this.implicit = definition.implicit || [];
342  this.explicit = definition.explicit || [];
343
344  this.implicit.forEach(function (type$$1) {
345    if (type$$1.loadKind && type$$1.loadKind !== 'scalar') {
346      throw new YAMLException$3('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
347    }
348  });
349
350  this.compiledImplicit = compileList(this, 'implicit', []);
351  this.compiledExplicit = compileList(this, 'explicit', []);
352  this.compiledTypeMap  = compileMap(this.compiledImplicit, this.compiledExplicit);
353}
354
355
356Schema$2.DEFAULT = null;
357
358
359Schema$2.create = function createSchema() {
360  var schemas, types;
361
362  switch (arguments.length) {
363    case 1:
364      schemas = Schema$2.DEFAULT;
365      types = arguments[0];
366      break;
367
368    case 2:
369      schemas = arguments[0];
370      types = arguments[1];
371      break;
372
373    default:
374      throw new YAMLException$3('Wrong number of arguments for Schema.create function');
375  }
376
377  schemas = common$4.toArray(schemas);
378  types = common$4.toArray(types);
379
380  if (!schemas.every(function (schema) { return schema instanceof Schema$2; })) {
381    throw new YAMLException$3('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
382  }
383
384  if (!types.every(function (type$$1) { return type$$1 instanceof Type$1; })) {
385    throw new YAMLException$3('Specified list of YAML types (or a single Type object) contains a non-Type object.');
386  }
387
388  return new Schema$2({
389    include: schemas,
390    explicit: types
391  });
392};
393
394
395var schema = Schema$2;
396
397var Type$3 = type;
398
399var str = new Type$3('tag:yaml.org,2002:str', {
400  kind: 'scalar',
401  construct: function (data) { return data !== null ? data : ''; }
402});
403
404var Type$4 = type;
405
406var seq = new Type$4('tag:yaml.org,2002:seq', {
407  kind: 'sequence',
408  construct: function (data) { return data !== null ? data : []; }
409});
410
411var Type$5 = type;
412
413var map = new Type$5('tag:yaml.org,2002:map', {
414  kind: 'mapping',
415  construct: function (data) { return data !== null ? data : {}; }
416});
417
418var Schema$5 = schema;
419
420
421var failsafe = new Schema$5({
422  explicit: [
423    str,
424    seq,
425    map
426  ]
427});
428
429var Type$6 = type;
430
431function resolveYamlNull(data) {
432  if (data === null) { return true; }
433
434  var max = data.length;
435
436  return (max === 1 && data === '~') ||
437         (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
438}
439
440function constructYamlNull() {
441  return null;
442}
443
444function isNull(object) {
445  return object === null;
446}
447
448var _null = new Type$6('tag:yaml.org,2002:null', {
449  kind: 'scalar',
450  resolve: resolveYamlNull,
451  construct: constructYamlNull,
452  predicate: isNull,
453  represent: {
454    canonical: function () { return '~';    },
455    lowercase: function () { return 'null'; },
456    uppercase: function () { return 'NULL'; },
457    camelcase: function () { return 'Null'; }
458  },
459  defaultStyle: 'lowercase'
460});
461
462var Type$7 = type;
463
464function resolveYamlBoolean(data) {
465  if (data === null) { return false; }
466
467  var max = data.length;
468
469  return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
470         (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
471}
472
473function constructYamlBoolean(data) {
474  return data === 'true' ||
475         data === 'True' ||
476         data === 'TRUE';
477}
478
479function isBoolean(object) {
480  return Object.prototype.toString.call(object) === '[object Boolean]';
481}
482
483var bool = new Type$7('tag:yaml.org,2002:bool', {
484  kind: 'scalar',
485  resolve: resolveYamlBoolean,
486  construct: constructYamlBoolean,
487  predicate: isBoolean,
488  represent: {
489    lowercase: function (object) { return object ? 'true' : 'false'; },
490    uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
491    camelcase: function (object) { return object ? 'True' : 'False'; }
492  },
493  defaultStyle: 'lowercase'
494});
495
496var common$5 = common$1;
497var Type$8   = type;
498
499function isHexCode(c) {
500  return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
501         ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
502         ((0x61/* a */ <= c) && (c <= 0x66/* f */));
503}
504
505function isOctCode(c) {
506  return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
507}
508
509function isDecCode(c) {
510  return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
511}
512
513function resolveYamlInteger(data) {
514  if (data === null) { return false; }
515
516  var max = data.length,
517      index = 0,
518      hasDigits = false,
519      ch;
520
521  if (!max) { return false; }
522
523  ch = data[index];
524
525  // sign
526  if (ch === '-' || ch === '+') {
527    ch = data[++index];
528  }
529
530  if (ch === '0') {
531    // 0
532    if (index + 1 === max) { return true; }
533    ch = data[++index];
534
535    // base 2, base 8, base 16
536
537    if (ch === 'b') {
538      // base 2
539      index++;
540
541      for (; index < max; index++) {
542        ch = data[index];
543        if (ch === '_') { continue; }
544        if (ch !== '0' && ch !== '1') { return false; }
545        hasDigits = true;
546      }
547      return hasDigits;
548    }
549
550
551    if (ch === 'x') {
552      // base 16
553      index++;
554
555      for (; index < max; index++) {
556        ch = data[index];
557        if (ch === '_') { continue; }
558        if (!isHexCode(data.charCodeAt(index))) { return false; }
559        hasDigits = true;
560      }
561      return hasDigits;
562    }
563
564    // base 8
565    for (; index < max; index++) {
566      ch = data[index];
567      if (ch === '_') { continue; }
568      if (!isOctCode(data.charCodeAt(index))) { return false; }
569      hasDigits = true;
570    }
571    return hasDigits;
572  }
573
574  // base 10 (except 0) or base 60
575
576  for (; index < max; index++) {
577    ch = data[index];
578    if (ch === '_') { continue; }
579    if (ch === ':') { break; }
580    if (!isDecCode(data.charCodeAt(index))) {
581      return false;
582    }
583    hasDigits = true;
584  }
585
586  if (!hasDigits) { return false; }
587
588  // if !base60 - done;
589  if (ch !== ':') { return true; }
590
591  // base60 almost not used, no needs to optimize
592  return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
593}
594
595function constructYamlInteger(data) {
596  var value = data, sign = 1, ch, base, digits = [];
597
598  if (value.indexOf('_') !== -1) {
599    value = value.replace(/_/g, '');
600  }
601
602  ch = value[0];
603
604  if (ch === '-' || ch === '+') {
605    if (ch === '-') { sign = -1; }
606    value = value.slice(1);
607    ch = value[0];
608  }
609
610  if (value === '0') { return 0; }
611
612  if (ch === '0') {
613    if (value[1] === 'b') { return sign * parseInt(value.slice(2), 2); }
614    if (value[1] === 'x') { return sign * parseInt(value, 16); }
615    return sign * parseInt(value, 8);
616  }
617
618  if (value.indexOf(':') !== -1) {
619    value.split(':').forEach(function (v) {
620      digits.unshift(parseInt(v, 10));
621    });
622
623    value = 0;
624    base = 1;
625
626    digits.forEach(function (d) {
627      value += (d * base);
628      base *= 60;
629    });
630
631    return sign * value;
632
633  }
634
635  return sign * parseInt(value, 10);
636}
637
638function isInteger(object) {
639  return (Object.prototype.toString.call(object)) === '[object Number]' &&
640         (object % 1 === 0 && !common$5.isNegativeZero(object));
641}
642
643var int_1 = new Type$8('tag:yaml.org,2002:int', {
644  kind: 'scalar',
645  resolve: resolveYamlInteger,
646  construct: constructYamlInteger,
647  predicate: isInteger,
648  represent: {
649    binary:      function (object) { return '0b' + object.toString(2); },
650    octal:       function (object) { return '0'  + object.toString(8); },
651    decimal:     function (object) { return        object.toString(10); },
652    hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); }
653  },
654  defaultStyle: 'decimal',
655  styleAliases: {
656    binary:      [ 2,  'bin' ],
657    octal:       [ 8,  'oct' ],
658    decimal:     [ 10, 'dec' ],
659    hexadecimal: [ 16, 'hex' ]
660  }
661});
662
663var common$6 = common$1;
664var Type$9   = type;
665
666var YAML_FLOAT_PATTERN = new RegExp(
667  '^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' +
668  '|\\.[0-9_]+(?:[eE][-+][0-9]+)?' +
669  '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
670  '|[-+]?\\.(?:inf|Inf|INF)' +
671  '|\\.(?:nan|NaN|NAN))$');
672
673function resolveYamlFloat(data) {
674  if (data === null) { return false; }
675
676  if (!YAML_FLOAT_PATTERN.test(data)) { return false; }
677
678  return true;
679}
680
681function constructYamlFloat(data) {
682  var value, sign, base, digits;
683
684  value  = data.replace(/_/g, '').toLowerCase();
685  sign   = value[0] === '-' ? -1 : 1;
686  digits = [];
687
688  if ('+-'.indexOf(value[0]) >= 0) {
689    value = value.slice(1);
690  }
691
692  if (value === '.inf') {
693    return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
694
695  } else if (value === '.nan') {
696    return NaN;
697
698  } else if (value.indexOf(':') >= 0) {
699    value.split(':').forEach(function (v) {
700      digits.unshift(parseFloat(v, 10));
701    });
702
703    value = 0.0;
704    base = 1;
705
706    digits.forEach(function (d) {
707      value += d * base;
708      base *= 60;
709    });
710
711    return sign * value;
712
713  }
714  return sign * parseFloat(value, 10);
715}
716
717
718var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
719
720function representYamlFloat(object, style) {
721  var res;
722
723  if (isNaN(object)) {
724    switch (style) {
725      case 'lowercase': return '.nan';
726      case 'uppercase': return '.NAN';
727      case 'camelcase': return '.NaN';
728    }
729  } else if (Number.POSITIVE_INFINITY === object) {
730    switch (style) {
731      case 'lowercase': return '.inf';
732      case 'uppercase': return '.INF';
733      case 'camelcase': return '.Inf';
734    }
735  } else if (Number.NEGATIVE_INFINITY === object) {
736    switch (style) {
737      case 'lowercase': return '-.inf';
738      case 'uppercase': return '-.INF';
739      case 'camelcase': return '-.Inf';
740    }
741  } else if (common$6.isNegativeZero(object)) {
742    return '-0.0';
743  }
744
745  res = object.toString(10);
746
747  // JS stringifier can build scientific format without dots: 5e-100,
748  // while YAML requres dot: 5.e-100. Fix it with simple hack
749
750  return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
751}
752
753function isFloat(object) {
754  return (Object.prototype.toString.call(object) === '[object Number]') &&
755         (object % 1 !== 0 || common$6.isNegativeZero(object));
756}
757
758var float_1 = new Type$9('tag:yaml.org,2002:float', {
759  kind: 'scalar',
760  resolve: resolveYamlFloat,
761  construct: constructYamlFloat,
762  predicate: isFloat,
763  represent: representYamlFloat,
764  defaultStyle: 'lowercase'
765});
766
767var Schema$4 = schema;
768
769
770var json = new Schema$4({
771  include: [
772    failsafe
773  ],
774  implicit: [
775    _null,
776    bool,
777    int_1,
778    float_1
779  ]
780});
781
782var Schema$3 = schema;
783
784
785var core = new Schema$3({
786  include: [
787    json
788  ]
789});
790
791var Type$10 = type;
792
793var YAML_DATE_REGEXP = new RegExp(
794  '^([0-9][0-9][0-9][0-9])'          + // [1] year
795  '-([0-9][0-9])'                    + // [2] month
796  '-([0-9][0-9])$');                   // [3] day
797
798var YAML_TIMESTAMP_REGEXP = new RegExp(
799  '^([0-9][0-9][0-9][0-9])'          + // [1] year
800  '-([0-9][0-9]?)'                   + // [2] month
801  '-([0-9][0-9]?)'                   + // [3] day
802  '(?:[Tt]|[ \\t]+)'                 + // ...
803  '([0-9][0-9]?)'                    + // [4] hour
804  ':([0-9][0-9])'                    + // [5] minute
805  ':([0-9][0-9])'                    + // [6] second
806  '(?:\\.([0-9]*))?'                 + // [7] fraction
807  '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
808  '(?::([0-9][0-9]))?))?$');           // [11] tz_minute
809
810function resolveYamlTimestamp(data) {
811  if (data === null) { return false; }
812  if (YAML_DATE_REGEXP.exec(data) !== null) { return true; }
813  if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) { return true; }
814  return false;
815}
816
817function constructYamlTimestamp(data) {
818  var match, year, month, day, hour, minute, second, fraction = 0,
819      delta = null, tz_hour, tz_minute, date;
820
821  match = YAML_DATE_REGEXP.exec(data);
822  if (match === null) { match = YAML_TIMESTAMP_REGEXP.exec(data); }
823
824  if (match === null) { throw new Error('Date resolve error'); }
825
826  // match: [1] year [2] month [3] day
827
828  year = +(match[1]);
829  month = +(match[2]) - 1; // JS month starts with 0
830  day = +(match[3]);
831
832  if (!match[4]) { // no hour
833    return new Date(Date.UTC(year, month, day));
834  }
835
836  // match: [4] hour [5] minute [6] second [7] fraction
837
838  hour = +(match[4]);
839  minute = +(match[5]);
840  second = +(match[6]);
841
842  if (match[7]) {
843    fraction = match[7].slice(0, 3);
844    while (fraction.length < 3) { // milli-seconds
845      fraction += '0';
846    }
847    fraction = +fraction;
848  }
849
850  // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
851
852  if (match[9]) {
853    tz_hour = +(match[10]);
854    tz_minute = +(match[11] || 0);
855    delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
856    if (match[9] === '-') { delta = -delta; }
857  }
858
859  date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
860
861  if (delta) { date.setTime(date.getTime() - delta); }
862
863  return date;
864}
865
866function representYamlTimestamp(object /*, style*/) {
867  return object.toISOString();
868}
869
870var timestamp = new Type$10('tag:yaml.org,2002:timestamp', {
871  kind: 'scalar',
872  resolve: resolveYamlTimestamp,
873  construct: constructYamlTimestamp,
874  instanceOf: Date,
875  represent: representYamlTimestamp
876});
877
878var Type$11 = type;
879
880function resolveYamlMerge(data) {
881  return data === '<<' || data === null;
882}
883
884var merge = new Type$11('tag:yaml.org,2002:merge', {
885  kind: 'scalar',
886  resolve: resolveYamlMerge
887});
888
889var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
890
891function commonjsRequire () {
892	throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
893}
894
895
896
897function createCommonjsModule(fn, module) {
898	return module = { exports: {} }, fn(module, module.exports), module.exports;
899}
900
901/*eslint-disable no-bitwise*/
902
903var NodeBuffer;
904
905try {
906  // A trick for browserified version, to not include `Buffer` shim
907  var _require = commonjsRequire;
908  NodeBuffer = _require('buffer').Buffer;
909} catch (__) {}
910
911var Type$12       = type;
912
913
914// [ 64, 65, 66 ] -> [ padding, CR, LF ]
915var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
916
917
918function resolveYamlBinary(data) {
919  if (data === null) { return false; }
920
921  var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
922
923  // Convert one by one.
924  for (idx = 0; idx < max; idx++) {
925    code = map.indexOf(data.charAt(idx));
926
927    // Skip CR/LF
928    if (code > 64) { continue; }
929
930    // Fail on illegal characters
931    if (code < 0) { return false; }
932
933    bitlen += 6;
934  }
935
936  // If there are any bits left, source was corrupted
937  return (bitlen % 8) === 0;
938}
939
940function constructYamlBinary(data) {
941  var idx, tailbits,
942      input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
943      max = input.length,
944      map = BASE64_MAP,
945      bits = 0,
946      result = [];
947
948  // Collect by 6*4 bits (3 bytes)
949
950  for (idx = 0; idx < max; idx++) {
951    if ((idx % 4 === 0) && idx) {
952      result.push((bits >> 16) & 0xFF);
953      result.push((bits >> 8) & 0xFF);
954      result.push(bits & 0xFF);
955    }
956
957    bits = (bits << 6) | map.indexOf(input.charAt(idx));
958  }
959
960  // Dump tail
961
962  tailbits = (max % 4) * 6;
963
964  if (tailbits === 0) {
965    result.push((bits >> 16) & 0xFF);
966    result.push((bits >> 8) & 0xFF);
967    result.push(bits & 0xFF);
968  } else if (tailbits === 18) {
969    result.push((bits >> 10) & 0xFF);
970    result.push((bits >> 2) & 0xFF);
971  } else if (tailbits === 12) {
972    result.push((bits >> 4) & 0xFF);
973  }
974
975  // Wrap into Buffer for NodeJS and leave Array for browser
976  if (NodeBuffer) { return new NodeBuffer(result); }
977
978  return result;
979}
980
981function representYamlBinary(object /*, style*/) {
982  var result = '', bits = 0, idx, tail,
983      max = object.length,
984      map = BASE64_MAP;
985
986  // Convert every three bytes to 4 ASCII characters.
987
988  for (idx = 0; idx < max; idx++) {
989    if ((idx % 3 === 0) && idx) {
990      result += map[(bits >> 18) & 0x3F];
991      result += map[(bits >> 12) & 0x3F];
992      result += map[(bits >> 6) & 0x3F];
993      result += map[bits & 0x3F];
994    }
995
996    bits = (bits << 8) + object[idx];
997  }
998
999  // Dump tail
1000
1001  tail = max % 3;
1002
1003  if (tail === 0) {
1004    result += map[(bits >> 18) & 0x3F];
1005    result += map[(bits >> 12) & 0x3F];
1006    result += map[(bits >> 6) & 0x3F];
1007    result += map[bits & 0x3F];
1008  } else if (tail === 2) {
1009    result += map[(bits >> 10) & 0x3F];
1010    result += map[(bits >> 4) & 0x3F];
1011    result += map[(bits << 2) & 0x3F];
1012    result += map[64];
1013  } else if (tail === 1) {
1014    result += map[(bits >> 2) & 0x3F];
1015    result += map[(bits << 4) & 0x3F];
1016    result += map[64];
1017    result += map[64];
1018  }
1019
1020  return result;
1021}
1022
1023function isBinary(object) {
1024  return NodeBuffer && NodeBuffer.isBuffer(object);
1025}
1026
1027var binary = new Type$12('tag:yaml.org,2002:binary', {
1028  kind: 'scalar',
1029  resolve: resolveYamlBinary,
1030  construct: constructYamlBinary,
1031  predicate: isBinary,
1032  represent: representYamlBinary
1033});
1034
1035var Type$13 = type;
1036
1037var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1038var _toString       = Object.prototype.toString;
1039
1040function resolveYamlOmap(data) {
1041  if (data === null) { return true; }
1042
1043  var objectKeys = [], index, length, pair, pairKey, pairHasKey,
1044      object = data;
1045
1046  for (index = 0, length = object.length; index < length; index += 1) {
1047    pair = object[index];
1048    pairHasKey = false;
1049
1050    if (_toString.call(pair) !== '[object Object]') { return false; }
1051
1052    for (pairKey in pair) {
1053      if (_hasOwnProperty$1.call(pair, pairKey)) {
1054        if (!pairHasKey) { pairHasKey = true; }
1055        else { return false; }
1056      }
1057    }
1058
1059    if (!pairHasKey) { return false; }
1060
1061    if (objectKeys.indexOf(pairKey) === -1) { objectKeys.push(pairKey); }
1062    else { return false; }
1063  }
1064
1065  return true;
1066}
1067
1068function constructYamlOmap(data) {
1069  return data !== null ? data : [];
1070}
1071
1072var omap = new Type$13('tag:yaml.org,2002:omap', {
1073  kind: 'sequence',
1074  resolve: resolveYamlOmap,
1075  construct: constructYamlOmap
1076});
1077
1078var Type$14 = type;
1079
1080var _toString$1 = Object.prototype.toString;
1081
1082function resolveYamlPairs(data) {
1083  if (data === null) { return true; }
1084
1085  var index, length, pair, keys, result,
1086      object = data;
1087
1088  result = new Array(object.length);
1089
1090  for (index = 0, length = object.length; index < length; index += 1) {
1091    pair = object[index];
1092
1093    if (_toString$1.call(pair) !== '[object Object]') { return false; }
1094
1095    keys = Object.keys(pair);
1096
1097    if (keys.length !== 1) { return false; }
1098
1099    result[index] = [ keys[0], pair[keys[0]] ];
1100  }
1101
1102  return true;
1103}
1104
1105function constructYamlPairs(data) {
1106  if (data === null) { return []; }
1107
1108  var index, length, pair, keys, result,
1109      object = data;
1110
1111  result = new Array(object.length);
1112
1113  for (index = 0, length = object.length; index < length; index += 1) {
1114    pair = object[index];
1115
1116    keys = Object.keys(pair);
1117
1118    result[index] = [ keys[0], pair[keys[0]] ];
1119  }
1120
1121  return result;
1122}
1123
1124var pairs = new Type$14('tag:yaml.org,2002:pairs', {
1125  kind: 'sequence',
1126  resolve: resolveYamlPairs,
1127  construct: constructYamlPairs
1128});
1129
1130var Type$15 = type;
1131
1132var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1133
1134function resolveYamlSet(data) {
1135  if (data === null) { return true; }
1136
1137  var key, object = data;
1138
1139  for (key in object) {
1140    if (_hasOwnProperty$2.call(object, key)) {
1141      if (object[key] !== null) { return false; }
1142    }
1143  }
1144
1145  return true;
1146}
1147
1148function constructYamlSet(data) {
1149  return data !== null ? data : {};
1150}
1151
1152var set = new Type$15('tag:yaml.org,2002:set', {
1153  kind: 'mapping',
1154  resolve: resolveYamlSet,
1155  construct: constructYamlSet
1156});
1157
1158var Schema$1 = schema;
1159
1160
1161var default_safe = new Schema$1({
1162  include: [
1163    core
1164  ],
1165  implicit: [
1166    timestamp,
1167    merge
1168  ],
1169  explicit: [
1170    binary,
1171    omap,
1172    pairs,
1173    set
1174  ]
1175});
1176
1177var Type$16 = type;
1178
1179function resolveJavascriptUndefined() {
1180  return true;
1181}
1182
1183function constructJavascriptUndefined() {
1184  /*eslint-disable no-undefined*/
1185  return undefined;
1186}
1187
1188function representJavascriptUndefined() {
1189  return '';
1190}
1191
1192function isUndefined(object) {
1193  return typeof object === 'undefined';
1194}
1195
1196var _undefined = new Type$16('tag:yaml.org,2002:js/undefined', {
1197  kind: 'scalar',
1198  resolve: resolveJavascriptUndefined,
1199  construct: constructJavascriptUndefined,
1200  predicate: isUndefined,
1201  represent: representJavascriptUndefined
1202});
1203
1204var Type$17 = type;
1205
1206function resolveJavascriptRegExp(data) {
1207  if (data === null) { return false; }
1208  if (data.length === 0) { return false; }
1209
1210  var regexp = data,
1211      tail   = /\/([gim]*)$/.exec(data),
1212      modifiers = '';
1213
1214  // if regexp starts with '/' it can have modifiers and must be properly closed
1215  // `/foo/gim` - modifiers tail can be maximum 3 chars
1216  if (regexp[0] === '/') {
1217    if (tail) { modifiers = tail[1]; }
1218
1219    if (modifiers.length > 3) { return false; }
1220    // if expression starts with /, is should be properly terminated
1221    if (regexp[regexp.length - modifiers.length - 1] !== '/') { return false; }
1222  }
1223
1224  return true;
1225}
1226
1227function constructJavascriptRegExp(data) {
1228  var regexp = data,
1229      tail   = /\/([gim]*)$/.exec(data),
1230      modifiers = '';
1231
1232  // `/foo/gim` - tail can be maximum 4 chars
1233  if (regexp[0] === '/') {
1234    if (tail) { modifiers = tail[1]; }
1235    regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
1236  }
1237
1238  return new RegExp(regexp, modifiers);
1239}
1240
1241function representJavascriptRegExp(object /*, style*/) {
1242  var result = '/' + object.source + '/';
1243
1244  if (object.global) { result += 'g'; }
1245  if (object.multiline) { result += 'm'; }
1246  if (object.ignoreCase) { result += 'i'; }
1247
1248  return result;
1249}
1250
1251function isRegExp(object) {
1252  return Object.prototype.toString.call(object) === '[object RegExp]';
1253}
1254
1255var regexp = new Type$17('tag:yaml.org,2002:js/regexp', {
1256  kind: 'scalar',
1257  resolve: resolveJavascriptRegExp,
1258  construct: constructJavascriptRegExp,
1259  predicate: isRegExp,
1260  represent: representJavascriptRegExp
1261});
1262
1263var esprima;
1264
1265// Browserified version does not have esprima
1266//
1267// 1. For node.js just require module as deps
1268// 2. For browser try to require mudule via external AMD system.
1269//    If not found - try to fallback to window.esprima. If not
1270//    found too - then fail to parse.
1271//
1272try {
1273  // workaround to exclude package from browserify list.
1274  var _require$1 = commonjsRequire;
1275  esprima = _require$1('esprima');
1276} catch (_) {
1277  /*global window */
1278  if (typeof window !== 'undefined') { esprima = window.esprima; }
1279}
1280
1281var Type$18 = type;
1282
1283function resolveJavascriptFunction(data) {
1284  if (data === null) { return false; }
1285
1286  try {
1287    var source = '(' + data + ')',
1288        ast    = esprima.parse(source, { range: true });
1289
1290    if (ast.type                    !== 'Program'             ||
1291        ast.body.length             !== 1                     ||
1292        ast.body[0].type            !== 'ExpressionStatement' ||
1293        ast.body[0].expression.type !== 'FunctionExpression') {
1294      return false;
1295    }
1296
1297    return true;
1298  } catch (err) {
1299    return false;
1300  }
1301}
1302
1303function constructJavascriptFunction(data) {
1304  /*jslint evil:true*/
1305
1306  var source = '(' + data + ')',
1307      ast    = esprima.parse(source, { range: true }),
1308      params = [],
1309      body;
1310
1311  if (ast.type                    !== 'Program'             ||
1312      ast.body.length             !== 1                     ||
1313      ast.body[0].type            !== 'ExpressionStatement' ||
1314      ast.body[0].expression.type !== 'FunctionExpression') {
1315    throw new Error('Failed to resolve function');
1316  }
1317
1318  ast.body[0].expression.params.forEach(function (param) {
1319    params.push(param.name);
1320  });
1321
1322  body = ast.body[0].expression.body.range;
1323
1324  // Esprima's ranges include the first '{' and the last '}' characters on
1325  // function expressions. So cut them out.
1326  /*eslint-disable no-new-func*/
1327  return new Function(params, source.slice(body[0] + 1, body[1] - 1));
1328}
1329
1330function representJavascriptFunction(object /*, style*/) {
1331  return object.toString();
1332}
1333
1334function isFunction(object) {
1335  return Object.prototype.toString.call(object) === '[object Function]';
1336}
1337
1338var _function = new Type$18('tag:yaml.org,2002:js/function', {
1339  kind: 'scalar',
1340  resolve: resolveJavascriptFunction,
1341  construct: constructJavascriptFunction,
1342  predicate: isFunction,
1343  represent: representJavascriptFunction
1344});
1345
1346var Schema$6 = schema;
1347
1348
1349var default_full = Schema$6.DEFAULT = new Schema$6({
1350  include: [
1351    default_safe
1352  ],
1353  explicit: [
1354    _undefined,
1355    regexp,
1356    _function
1357  ]
1358});
1359
1360/*eslint-disable max-len,no-use-before-define*/
1361
1362var common              = common$1;
1363var YAMLException$1       = exception;
1364var Mark                = mark;
1365var DEFAULT_SAFE_SCHEMA$1 = default_safe;
1366var DEFAULT_FULL_SCHEMA$1 = default_full;
1367
1368
1369var _hasOwnProperty = Object.prototype.hasOwnProperty;
1370
1371
1372var CONTEXT_FLOW_IN   = 1;
1373var CONTEXT_FLOW_OUT  = 2;
1374var CONTEXT_BLOCK_IN  = 3;
1375var CONTEXT_BLOCK_OUT = 4;
1376
1377
1378var CHOMPING_CLIP  = 1;
1379var CHOMPING_STRIP = 2;
1380var CHOMPING_KEEP  = 3;
1381
1382
1383var PATTERN_NON_PRINTABLE         = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1384var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
1385var PATTERN_FLOW_INDICATORS       = /[,\[\]\{\}]/;
1386var PATTERN_TAG_HANDLE            = /^(?:!|!!|![a-z\-]+!)$/i;
1387var PATTERN_TAG_URI               = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
1388
1389
1390function is_EOL(c) {
1391  return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
1392}
1393
1394function is_WHITE_SPACE(c) {
1395  return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
1396}
1397
1398function is_WS_OR_EOL(c) {
1399  return (c === 0x09/* Tab */) ||
1400         (c === 0x20/* Space */) ||
1401         (c === 0x0A/* LF */) ||
1402         (c === 0x0D/* CR */);
1403}
1404
1405function is_FLOW_INDICATOR(c) {
1406  return c === 0x2C/* , */ ||
1407         c === 0x5B/* [ */ ||
1408         c === 0x5D/* ] */ ||
1409         c === 0x7B/* { */ ||
1410         c === 0x7D/* } */;
1411}
1412
1413function fromHexCode(c) {
1414  var lc;
1415
1416  if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1417    return c - 0x30;
1418  }
1419
1420  /*eslint-disable no-bitwise*/
1421  lc = c | 0x20;
1422
1423  if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
1424    return lc - 0x61 + 10;
1425  }
1426
1427  return -1;
1428}
1429
1430function escapedHexLen(c) {
1431  if (c === 0x78/* x */) { return 2; }
1432  if (c === 0x75/* u */) { return 4; }
1433  if (c === 0x55/* U */) { return 8; }
1434  return 0;
1435}
1436
1437function fromDecimalCode(c) {
1438  if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
1439    return c - 0x30;
1440  }
1441
1442  return -1;
1443}
1444
1445function simpleEscapeSequence(c) {
1446  return (c === 0x30/* 0 */) ? '\x00' :
1447        (c === 0x61/* a */) ? '\x07' :
1448        (c === 0x62/* b */) ? '\x08' :
1449        (c === 0x74/* t */) ? '\x09' :
1450        (c === 0x09/* Tab */) ? '\x09' :
1451        (c === 0x6E/* n */) ? '\x0A' :
1452        (c === 0x76/* v */) ? '\x0B' :
1453        (c === 0x66/* f */) ? '\x0C' :
1454        (c === 0x72/* r */) ? '\x0D' :
1455        (c === 0x65/* e */) ? '\x1B' :
1456        (c === 0x20/* Space */) ? ' ' :
1457        (c === 0x22/* " */) ? '\x22' :
1458        (c === 0x2F/* / */) ? '/' :
1459        (c === 0x5C/* \ */) ? '\x5C' :
1460        (c === 0x4E/* N */) ? '\x85' :
1461        (c === 0x5F/* _ */) ? '\xA0' :
1462        (c === 0x4C/* L */) ? '\u2028' :
1463        (c === 0x50/* P */) ? '\u2029' : '';
1464}
1465
1466function charFromCodepoint(c) {
1467  if (c <= 0xFFFF) {
1468    return String.fromCharCode(c);
1469  }
1470  // Encode UTF-16 surrogate pair
1471  // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
1472  return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
1473                             ((c - 0x010000) & 0x03FF) + 0xDC00);
1474}
1475
1476var simpleEscapeCheck = new Array(256); // integer, for fast access
1477var simpleEscapeMap = new Array(256);
1478for (var i = 0; i < 256; i++) {
1479  simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1480  simpleEscapeMap[i] = simpleEscapeSequence(i);
1481}
1482
1483
1484function State(input, options) {
1485  this.input = input;
1486
1487  this.filename  = options['filename']  || null;
1488  this.schema    = options['schema']    || DEFAULT_FULL_SCHEMA$1;
1489  this.onWarning = options['onWarning'] || null;
1490  this.legacy    = options['legacy']    || false;
1491  this.json      = options['json']      || false;
1492  this.listener  = options['listener']  || null;
1493
1494  this.implicitTypes = this.schema.compiledImplicit;
1495  this.typeMap       = this.schema.compiledTypeMap;
1496
1497  this.length     = input.length;
1498  this.position   = 0;
1499  this.line       = 0;
1500  this.lineStart  = 0;
1501  this.lineIndent = 0;
1502
1503  this.documents = [];
1504
1505  /*
1506  this.version;
1507  this.checkLineBreaks;
1508  this.tagMap;
1509  this.anchorMap;
1510  this.tag;
1511  this.anchor;
1512  this.kind;
1513  this.result;*/
1514
1515}
1516
1517
1518function generateError(state, message) {
1519  return new YAMLException$1(
1520    message,
1521    new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
1522}
1523
1524function throwError(state, message) {
1525  throw generateError(state, message);
1526}
1527
1528function throwWarning(state, message) {
1529  if (state.onWarning) {
1530    state.onWarning.call(null, generateError(state, message));
1531  }
1532}
1533
1534
1535var directiveHandlers = {
1536
1537  YAML: function handleYamlDirective(state, name, args) {
1538
1539    var match, major, minor;
1540
1541    if (state.version !== null) {
1542      throwError(state, 'duplication of %YAML directive');
1543    }
1544
1545    if (args.length !== 1) {
1546      throwError(state, 'YAML directive accepts exactly one argument');
1547    }
1548
1549    match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1550
1551    if (match === null) {
1552      throwError(state, 'ill-formed argument of the YAML directive');
1553    }
1554
1555    major = parseInt(match[1], 10);
1556    minor = parseInt(match[2], 10);
1557
1558    if (major !== 1) {
1559      throwError(state, 'unacceptable YAML version of the document');
1560    }
1561
1562    state.version = args[0];
1563    state.checkLineBreaks = (minor < 2);
1564
1565    if (minor !== 1 && minor !== 2) {
1566      throwWarning(state, 'unsupported YAML version of the document');
1567    }
1568  },
1569
1570  TAG: function handleTagDirective(state, name, args) {
1571
1572    var handle, prefix;
1573
1574    if (args.length !== 2) {
1575      throwError(state, 'TAG directive accepts exactly two arguments');
1576    }
1577
1578    handle = args[0];
1579    prefix = args[1];
1580
1581    if (!PATTERN_TAG_HANDLE.test(handle)) {
1582      throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
1583    }
1584
1585    if (_hasOwnProperty.call(state.tagMap, handle)) {
1586      throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1587    }
1588
1589    if (!PATTERN_TAG_URI.test(prefix)) {
1590      throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
1591    }
1592
1593    state.tagMap[handle] = prefix;
1594  }
1595};
1596
1597
1598function captureSegment(state, start, end, checkJson) {
1599  var _position, _length, _character, _result;
1600
1601  if (start < end) {
1602    _result = state.input.slice(start, end);
1603
1604    if (checkJson) {
1605      for (_position = 0, _length = _result.length;
1606           _position < _length;
1607           _position += 1) {
1608        _character = _result.charCodeAt(_position);
1609        if (!(_character === 0x09 ||
1610              (0x20 <= _character && _character <= 0x10FFFF))) {
1611          throwError(state, 'expected valid JSON character');
1612        }
1613      }
1614    } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1615      throwError(state, 'the stream contains non-printable characters');
1616    }
1617
1618    state.result += _result;
1619  }
1620}
1621
1622function mergeMappings(state, destination, source, overridableKeys) {
1623  var sourceKeys, key, index, quantity;
1624
1625  if (!common.isObject(source)) {
1626    throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
1627  }
1628
1629  sourceKeys = Object.keys(source);
1630
1631  for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1632    key = sourceKeys[index];
1633
1634    if (!_hasOwnProperty.call(destination, key)) {
1635      destination[key] = source[key];
1636      overridableKeys[key] = true;
1637    }
1638  }
1639}
1640
1641function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode) {
1642  var index, quantity;
1643
1644  keyNode = String(keyNode);
1645
1646  if (_result === null) {
1647    _result = {};
1648  }
1649
1650  if (keyTag === 'tag:yaml.org,2002:merge') {
1651    if (Array.isArray(valueNode)) {
1652      for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1653        mergeMappings(state, _result, valueNode[index], overridableKeys);
1654      }
1655    } else {
1656      mergeMappings(state, _result, valueNode, overridableKeys);
1657    }
1658  } else {
1659    if (!state.json &&
1660        !_hasOwnProperty.call(overridableKeys, keyNode) &&
1661        _hasOwnProperty.call(_result, keyNode)) {
1662      throwError(state, 'duplicated mapping key');
1663    }
1664    _result[keyNode] = valueNode;
1665    delete overridableKeys[keyNode];
1666  }
1667
1668  return _result;
1669}
1670
1671function readLineBreak(state) {
1672  var ch;
1673
1674  ch = state.input.charCodeAt(state.position);
1675
1676  if (ch === 0x0A/* LF */) {
1677    state.position++;
1678  } else if (ch === 0x0D/* CR */) {
1679    state.position++;
1680    if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
1681      state.position++;
1682    }
1683  } else {
1684    throwError(state, 'a line break is expected');
1685  }
1686
1687  state.line += 1;
1688  state.lineStart = state.position;
1689}
1690
1691function skipSeparationSpace(state, allowComments, checkIndent) {
1692  var lineBreaks = 0,
1693      ch = state.input.charCodeAt(state.position);
1694
1695  while (ch !== 0) {
1696    while (is_WHITE_SPACE(ch)) {
1697      ch = state.input.charCodeAt(++state.position);
1698    }
1699
1700    if (allowComments && ch === 0x23/* # */) {
1701      do {
1702        ch = state.input.charCodeAt(++state.position);
1703      } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
1704    }
1705
1706    if (is_EOL(ch)) {
1707      readLineBreak(state);
1708
1709      ch = state.input.charCodeAt(state.position);
1710      lineBreaks++;
1711      state.lineIndent = 0;
1712
1713      while (ch === 0x20/* Space */) {
1714        state.lineIndent++;
1715        ch = state.input.charCodeAt(++state.position);
1716      }
1717    } else {
1718      break;
1719    }
1720  }
1721
1722  if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1723    throwWarning(state, 'deficient indentation');
1724  }
1725
1726  return lineBreaks;
1727}
1728
1729function testDocumentSeparator(state) {
1730  var _position = state.position,
1731      ch;
1732
1733  ch = state.input.charCodeAt(_position);
1734
1735  // Condition state.position === state.lineStart is tested
1736  // in parent on each call, for efficiency. No needs to test here again.
1737  if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
1738      ch === state.input.charCodeAt(_position + 1) &&
1739      ch === state.input.charCodeAt(_position + 2)) {
1740
1741    _position += 3;
1742
1743    ch = state.input.charCodeAt(_position);
1744
1745    if (ch === 0 || is_WS_OR_EOL(ch)) {
1746      return true;
1747    }
1748  }
1749
1750  return false;
vendor: 8,932 bytes, lines 1751-2093
1751}
1752
1753function writeFoldedLines(state, count) {
1754  if (count === 1) {
1755    state.result += ' ';
1756  } else if (count > 1) {
1757    state.result += common.repeat('\n', count - 1);
1758  }
1759}
1760
1761
1762function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1763  var preceding,
1764      following,
1765      captureStart,
1766      captureEnd,
1767      hasPendingContent,
1768      _line,
1769      _lineStart,
1770      _lineIndent,
1771      _kind = state.kind,
1772      _result = state.result,
1773      ch;
1774
1775  ch = state.input.charCodeAt(state.position);
1776
1777  if (is_WS_OR_EOL(ch)      ||
1778      is_FLOW_INDICATOR(ch) ||
1779      ch === 0x23/* # */    ||
1780      ch === 0x26/* & */    ||
1781      ch === 0x2A/* * */    ||
1782      ch === 0x21/* ! */    ||
1783      ch === 0x7C/* | */    ||
1784      ch === 0x3E/* > */    ||
1785      ch === 0x27/* ' */    ||
1786      ch === 0x22/* " */    ||
1787      ch === 0x25/* % */    ||
1788      ch === 0x40/* @ */    ||
1789      ch === 0x60/* ` */) {
1790    return false;
1791  }
1792
1793  if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
1794    following = state.input.charCodeAt(state.position + 1);
1795
1796    if (is_WS_OR_EOL(following) ||
1797        withinFlowCollection && is_FLOW_INDICATOR(following)) {
1798      return false;
1799    }
1800  }
1801
1802  state.kind = 'scalar';
1803  state.result = '';
1804  captureStart = captureEnd = state.position;
1805  hasPendingContent = false;
1806
1807  while (ch !== 0) {
1808    if (ch === 0x3A/* : */) {
1809      following = state.input.charCodeAt(state.position + 1);
1810
1811      if (is_WS_OR_EOL(following) ||
1812          withinFlowCollection && is_FLOW_INDICATOR(following)) {
1813        break;
1814      }
1815
1816    } else if (ch === 0x23/* # */) {
1817      preceding = state.input.charCodeAt(state.position - 1);
1818
1819      if (is_WS_OR_EOL(preceding)) {
1820        break;
1821      }
1822
1823    } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
1824               withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1825      break;
1826
1827    } else if (is_EOL(ch)) {
1828      _line = state.line;
1829      _lineStart = state.lineStart;
1830      _lineIndent = state.lineIndent;
1831      skipSeparationSpace(state, false, -1);
1832
1833      if (state.lineIndent >= nodeIndent) {
1834        hasPendingContent = true;
1835        ch = state.input.charCodeAt(state.position);
1836        continue;
1837      } else {
1838        state.position = captureEnd;
1839        state.line = _line;
1840        state.lineStart = _lineStart;
1841        state.lineIndent = _lineIndent;
1842        break;
1843      }
1844    }
1845
1846    if (hasPendingContent) {
1847      captureSegment(state, captureStart, captureEnd, false);
1848      writeFoldedLines(state, state.line - _line);
1849      captureStart = captureEnd = state.position;
1850      hasPendingContent = false;
1851    }
1852
1853    if (!is_WHITE_SPACE(ch)) {
1854      captureEnd = state.position + 1;
1855    }
1856
1857    ch = state.input.charCodeAt(++state.position);
1858  }
1859
1860  captureSegment(state, captureStart, captureEnd, false);
1861
1862  if (state.result) {
1863    return true;
1864  }
1865
1866  state.kind = _kind;
1867  state.result = _result;
1868  return false;
1869}
1870
1871function readSingleQuotedScalar(state, nodeIndent) {
1872  var ch,
1873      captureStart, captureEnd;
1874
1875  ch = state.input.charCodeAt(state.position);
1876
1877  if (ch !== 0x27/* ' */) {
1878    return false;
1879  }
1880
1881  state.kind = 'scalar';
1882  state.result = '';
1883  state.position++;
1884  captureStart = captureEnd = state.position;
1885
1886  while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1887    if (ch === 0x27/* ' */) {
1888      captureSegment(state, captureStart, state.position, true);
1889      ch = state.input.charCodeAt(++state.position);
1890
1891      if (ch === 0x27/* ' */) {
1892        captureStart = state.position;
1893        state.position++;
1894        captureEnd = state.position;
1895      } else {
1896        return true;
1897      }
1898
1899    } else if (is_EOL(ch)) {
1900      captureSegment(state, captureStart, captureEnd, true);
1901      writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1902      captureStart = captureEnd = state.position;
1903
1904    } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1905      throwError(state, 'unexpected end of the document within a single quoted scalar');
1906
1907    } else {
1908      state.position++;
1909      captureEnd = state.position;
1910    }
1911  }
1912
1913  throwError(state, 'unexpected end of the stream within a single quoted scalar');
1914}
1915
1916function readDoubleQuotedScalar(state, nodeIndent) {
1917  var captureStart,
1918      captureEnd,
1919      hexLength,
1920      hexResult,
1921      tmp,
1922      ch;
1923
1924  ch = state.input.charCodeAt(state.position);
1925
1926  if (ch !== 0x22/* " */) {
1927    return false;
1928  }
1929
1930  state.kind = 'scalar';
1931  state.result = '';
1932  state.position++;
1933  captureStart = captureEnd = state.position;
1934
1935  while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1936    if (ch === 0x22/* " */) {
1937      captureSegment(state, captureStart, state.position, true);
1938      state.position++;
1939      return true;
1940
1941    } else if (ch === 0x5C/* \ */) {
1942      captureSegment(state, captureStart, state.position, true);
1943      ch = state.input.charCodeAt(++state.position);
1944
1945      if (is_EOL(ch)) {
1946        skipSeparationSpace(state, false, nodeIndent);
1947
1948        // TODO: rework to inline fn with no type cast?
1949      } else if (ch < 256 && simpleEscapeCheck[ch]) {
1950        state.result += simpleEscapeMap[ch];
1951        state.position++;
1952
1953      } else if ((tmp = escapedHexLen(ch)) > 0) {
1954        hexLength = tmp;
1955        hexResult = 0;
1956
1957        for (; hexLength > 0; hexLength--) {
1958          ch = state.input.charCodeAt(++state.position);
1959
1960          if ((tmp = fromHexCode(ch)) >= 0) {
1961            hexResult = (hexResult << 4) + tmp;
1962
1963          } else {
1964            throwError(state, 'expected hexadecimal character');
1965          }
1966        }
1967
1968        state.result += charFromCodepoint(hexResult);
1969
1970        state.position++;
1971
1972      } else {
1973        throwError(state, 'unknown escape sequence');
1974      }
1975
1976      captureStart = captureEnd = state.position;
1977
1978    } else if (is_EOL(ch)) {
1979      captureSegment(state, captureStart, captureEnd, true);
1980      writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1981      captureStart = captureEnd = state.position;
1982
1983    } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1984      throwError(state, 'unexpected end of the document within a double quoted scalar');
1985
1986    } else {
1987      state.position++;
1988      captureEnd = state.position;
1989    }
1990  }
1991
1992  throwError(state, 'unexpected end of the stream within a double quoted scalar');
1993}
1994
1995function readFlowCollection(state, nodeIndent) {
1996  var readNext = true,
1997      _line,
1998      _tag     = state.tag,
1999      _result,
2000      _anchor  = state.anchor,
2001      following,
2002      terminator,
2003      isPair,
2004      isExplicitPair,
2005      isMapping,
2006      overridableKeys = {},
2007      keyNode,
2008      keyTag,
2009      valueNode,
2010      ch;
2011
2012  ch = state.input.charCodeAt(state.position);
2013
2014  if (ch === 0x5B/* [ */) {
2015    terminator = 0x5D;/* ] */
2016    isMapping = false;
2017    _result = [];
2018  } else if (ch === 0x7B/* { */) {
2019    terminator = 0x7D;/* } */
2020    isMapping = true;
2021    _result = {};
2022  } else {
2023    return false;
2024  }
2025
2026  if (state.anchor !== null) {
2027    state.anchorMap[state.anchor] = _result;
2028  }
2029
2030  ch = state.input.charCodeAt(++state.position);
2031
2032  while (ch !== 0) {
2033    skipSeparationSpace(state, true, nodeIndent);
2034
2035    ch = state.input.charCodeAt(state.position);
2036
2037    if (ch === terminator) {
2038      state.position++;
2039      state.tag = _tag;
2040      state.anchor = _anchor;
2041      state.kind = isMapping ? 'mapping' : 'sequence';
2042      state.result = _result;
2043      return true;
2044    } else if (!readNext) {
2045      throwError(state, 'missed comma between flow collection entries');
2046    }
2047
2048    keyTag = keyNode = valueNode = null;
2049    isPair = isExplicitPair = false;
2050
2051    if (ch === 0x3F/* ? */) {
2052      following = state.input.charCodeAt(state.position + 1);
2053
2054      if (is_WS_OR_EOL(following)) {
2055        isPair = isExplicitPair = true;
2056        state.position++;
2057        skipSeparationSpace(state, true, nodeIndent);
2058      }
2059    }
2060
2061    _line = state.line;
2062    composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
2063    keyTag = state.tag;
2064    keyNode = state.result;
2065    skipSeparationSpace(state, true, nodeIndent);
2066
2067    ch = state.input.charCodeAt(state.position);
2068
2069    if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
2070      isPair = true;
2071      ch = state.input.charCodeAt(++state.position);
2072      skipSeparationSpace(state, true, nodeIndent);
2073      composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
2074      valueNode = state.result;
2075    }
2076
2077    if (isMapping) {
2078      storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
2079    } else if (isPair) {
2080      _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
2081    } else {
2082      _result.push(keyNode);
2083    }
2084
2085    skipSeparationSpace(state, true, nodeIndent);
2086
2087    ch = state.input.charCodeAt(state.position);
2088
2089    if (ch === 0x2C/* , */) {
2090      readNext = true;
2091      ch = state.input.charCodeAt(++state.position);
2092    } else {
2093      readNext = false;
2094    }
2095  }
2096
2097  throwError(state, 'unexpected end of the stream within a flow collection');
2098}
2099
2100function readBlockScalar(state, nodeIndent) {
2101  var captureStart,
2102      folding,
2103      chomping       = CHOMPING_CLIP,
2104      didReadContent = false,
2105      detectedIndent = false,
2106      textIndent     = nodeIndent,
2107      emptyLines     = 0,
2108      atMoreIndented = false,
2109      tmp,
2110      ch;
2111
2112  ch = state.input.charCodeAt(state.position);
2113
2114  if (ch === 0x7C/* | */) {
2115    folding = false;
2116  } else if (ch === 0x3E/* > */) {
2117    folding = true;
2118  } else {
2119    return false;
2120  }
2121
2122  state.kind = 'scalar';
2123  state.result = '';
2124
2125  while (ch !== 0) {
2126    ch = state.input.charCodeAt(++state.position);
2127
2128    if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
2129      if (CHOMPING_CLIP === chomping) {
2130        chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
2131      } else {
2132        throwError(state, 'repeat of a chomping mode identifier');
2133      }
2134
2135    } else if ((tmp = fromDecimalCode(ch)) >= 0) {
2136      if (tmp === 0) {
2137        throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
2138      } else if (!detectedIndent) {
2139        textIndent = nodeIndent + tmp - 1;
2140        detectedIndent = true;
2141      } else {
2142        throwError(state, 'repeat of an indentation width identifier');
2143      }
2144
2145    } else {
2146      break;
2147    }
2148  }
2149
2150  if (is_WHITE_SPACE(ch)) {
2151    do { ch = state.input.charCodeAt(++state.position); }
2152    while (is_WHITE_SPACE(ch));
2153
2154    if (ch === 0x23/* # */) {
2155      do { ch = state.input.charCodeAt(++state.position); }
2156      while (!is_EOL(ch) && (ch !== 0));
2157    }
2158  }
2159
2160  while (ch !== 0) {
2161    readLineBreak(state);
2162    state.lineIndent = 0;
2163
2164    ch = state.input.charCodeAt(state.position);
2165
2166    while ((!detectedIndent || state.lineIndent < textIndent) &&
2167           (ch === 0x20/* Space */)) {
2168      state.lineIndent++;
2169      ch = state.input.charCodeAt(++state.position);
2170    }
2171
2172    if (!detectedIndent && state.lineIndent > textIndent) {
2173      textIndent = state.lineIndent;
2174    }
2175
2176    if (is_EOL(ch)) {
2177      emptyLines++;
2178      continue;
2179    }
2180
2181    // End of the scalar.
2182    if (state.lineIndent < textIndent) {
2183
2184      // Perform the chomping.
2185      if (chomping === CHOMPING_KEEP) {
2186        state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
2187      } else if (chomping === CHOMPING_CLIP) {
2188        if (didReadContent) { // i.e. only if the scalar is not empty.
2189          state.result += '\n';
2190        }
2191      }
2192
2193      // Break this `while` cycle and go to the funciton's epilogue.
2194      break;
2195    }
2196
2197    // Folded style: use fancy rules to handle line breaks.
2198    if (folding) {
2199
2200      // Lines starting with white space characters (more-indented lines) are not folded.
2201      if (is_WHITE_SPACE(ch)) {
2202        atMoreIndented = true;
2203        // except for the first content line (cf. Example 8.1)
2204        state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
2205
2206      // End of more-indented block.
2207      } else if (atMoreIndented) {
2208        atMoreIndented = false;
2209        state.result += common.repeat('\n', emptyLines + 1);
2210
2211      // Just one line break - perceive as the same line.
2212      } else if (emptyLines === 0) {
2213        if (didReadContent) { // i.e. only if we have already read some scalar content.
2214          state.result += ' ';
2215        }
2216
2217      // Several line breaks - perceive as different lines.
2218      } else {
2219        state.result += common.repeat('\n', emptyLines);
2220      }
2221
2222    // Literal style: just add exact number of line breaks between content lines.
2223    } else {
2224      // Keep all line breaks except the header line break.
2225      state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
2226    }
2227
2228    didReadContent = true;
2229    detectedIndent = true;
2230    emptyLines = 0;
2231    captureStart = state.position;
2232
2233    while (!is_EOL(ch) && (ch !== 0)) {
2234      ch = state.input.charCodeAt(++state.position);
2235    }
2236
2237    captureSegment(state, captureStart, state.position, false);
2238  }
2239
2240  return true;
2241}
2242
2243function readBlockSequence(state, nodeIndent) {
2244  var _line,
2245      _tag      = state.tag,
2246      _anchor   = state.anchor,
2247      _result   = [],
2248      following,
2249      detected  = false,
2250      ch;
2251
2252  if (state.anchor !== null) {
2253    state.anchorMap[state.anchor] = _result;
2254  }
2255
2256  ch = state.input.charCodeAt(state.position);
2257
2258  while (ch !== 0) {
2259
2260    if (ch !== 0x2D/* - */) {
2261      break;
2262    }
2263
2264    following = state.input.charCodeAt(state.position + 1);
2265
2266    if (!is_WS_OR_EOL(following)) {
2267      break;
2268    }
2269
2270    detected = true;
2271    state.position++;
2272
2273    if (skipSeparationSpace(state, true, -1)) {
2274      if (state.lineIndent <= nodeIndent) {
2275        _result.push(null);
2276        ch = state.input.charCodeAt(state.position);
2277        continue;
2278      }
2279    }
2280
2281    _line = state.line;
2282    composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
2283    _result.push(state.result);
2284    skipSeparationSpace(state, true, -1);
2285
2286    ch = state.input.charCodeAt(state.position);
2287
2288    if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
2289      throwError(state, 'bad indentation of a sequence entry');
2290    } else if (state.lineIndent < nodeIndent) {
2291      break;
2292    }
2293  }
2294
2295  if (detected) {
2296    state.tag = _tag;
2297    state.anchor = _anchor;
2298    state.kind = 'sequence';
2299    state.result = _result;
2300    return true;
2301  }
2302  return false;
2303}
2304
2305function readBlockMapping(state, nodeIndent, flowIndent) {
2306  var following,
2307      allowCompact,
2308      _line,
2309      _tag          = state.tag,
2310      _anchor       = state.anchor,
2311      _result       = {},
2312      overridableKeys = {},
2313      keyTag        = null,
2314      keyNode       = null,
2315      valueNode     = null,
2316      atExplicitKey = false,
2317      detected      = false,
2318      ch;
2319
2320  if (state.anchor !== null) {
2321    state.anchorMap[state.anchor] = _result;
2322  }
2323
2324  ch = state.input.charCodeAt(state.position);
2325
2326  while (ch !== 0) {
2327    following = state.input.charCodeAt(state.position + 1);
2328    _line = state.line; // Save the current line.
2329
2330    //
2331    // Explicit notation case. There are two separate blocks:
2332    // first for the key (denoted by "?") and second for the value (denoted by ":")
2333    //
2334    if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
2335
2336      if (ch === 0x3F/* ? */) {
2337        if (atExplicitKey) {
2338          storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
2339          keyTag = keyNode = valueNode = null;
2340        }
2341
2342        detected = true;
2343        atExplicitKey = true;
2344        allowCompact = true;
2345
2346      } else if (atExplicitKey) {
2347        // i.e. 0x3A/* : */ === character after the explicit key.
2348        atExplicitKey = false;
2349        allowCompact = true;
2350
2351      } else {
2352        throwError(state, 'incomplete explicit mapping pair; a key node is missed');
2353      }
2354
2355      state.position += 1;
2356      ch = following;
2357
2358    //
2359    // Implicit notation case. Flow-style node as the key first, then ":", and the value.
2360    //
2361    } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
2362
2363      if (state.line === _line) {
2364        ch = state.input.charCodeAt(state.position);
2365
2366        while (is_WHITE_SPACE(ch)) {
2367          ch = state.input.charCodeAt(++state.position);
2368        }
2369
2370        if (ch === 0x3A/* : */) {
2371          ch = state.input.charCodeAt(++state.position);
2372
2373          if (!is_WS_OR_EOL(ch)) {
2374            throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
2375          }
2376
2377          if (atExplicitKey) {
2378            storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
2379            keyTag = keyNode = valueNode = null;
2380          }
2381
2382          detected = true;
2383          atExplicitKey = false;
2384          allowCompact = false;
2385          keyTag = state.tag;
2386          keyNode = state.result;
2387
2388        } else if (detected) {
2389          throwError(state, 'can not read an implicit mapping pair; a colon is missed');
2390
2391        } else {
2392          state.tag = _tag;
2393          state.anchor = _anchor;
2394          return true; // Keep the result of `composeNode`.
2395        }
2396
2397      } else if (detected) {
2398        throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
2399
2400      } else {
2401        state.tag = _tag;
2402        state.anchor = _anchor;
2403        return true; // Keep the result of `composeNode`.
2404      }
2405
2406    } else {
2407      break; // Reading is done. Go to the epilogue.
2408    }
2409
2410    //
2411    // Common reading code for both explicit and implicit notations.
2412    //
2413    if (state.line === _line || state.lineIndent > nodeIndent) {
2414      if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
2415        if (atExplicitKey) {
2416          keyNode = state.result;
2417        } else {
2418          valueNode = state.result;
2419        }
2420      }
2421
2422      if (!atExplicitKey) {
2423        storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
2424        keyTag = keyNode = valueNode = null;
2425      }
2426
2427      skipSeparationSpace(state, true, -1);
2428      ch = state.input.charCodeAt(state.position);
2429    }
2430
2431    if (state.lineIndent > nodeIndent && (ch !== 0)) {
2432      throwError(state, 'bad indentation of a mapping entry');
2433    } else if (state.lineIndent < nodeIndent) {
2434      break;
2435    }
2436  }
2437
2438  //
2439  // Epilogue.
2440  //
2441
2442  // Special case: last mapping's node contains only the key in explicit notation.
2443  if (atExplicitKey) {
2444    storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
2445  }
2446
2447  // Expose the resulting mapping.
2448  if (detected) {
2449    state.tag = _tag;
2450    state.anchor = _anchor;
2451    state.kind = 'mapping';
2452    state.result = _result;
2453  }
2454
2455  return detected;
2456}
2457
2458function readTagProperty(state) {
2459  var _position,
2460      isVerbatim = false,
2461      isNamed    = false,
2462      tagHandle,
2463      tagName,
2464      ch;
2465
2466  ch = state.input.charCodeAt(state.position);
2467
2468  if (ch !== 0x21/* ! */) { return false; }
2469
2470  if (state.tag !== null) {
2471    throwError(state, 'duplication of a tag property');
2472  }
2473
2474  ch = state.input.charCodeAt(++state.position);
2475
2476  if (ch === 0x3C/* < */) {
2477    isVerbatim = true;
2478    ch = state.input.charCodeAt(++state.position);
2479
2480  } else if (ch === 0x21/* ! */) {
2481    isNamed = true;
2482    tagHandle = '!!';
2483    ch = state.input.charCodeAt(++state.position);
2484
2485  } else {
2486    tagHandle = '!';
2487  }
2488
2489  _position = state.position;
2490
2491  if (isVerbatim) {
2492    do { ch = state.input.charCodeAt(++state.position); }
2493    while (ch !== 0 && ch !== 0x3E/* > */);
2494
2495    if (state.position < state.length) {
2496      tagName = state.input.slice(_position, state.position);
2497      ch = state.input.charCodeAt(++state.position);
2498    } else {
2499      throwError(state, 'unexpected end of the stream within a verbatim tag');
2500    }
2501  } else {
2502    while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2503
2504      if (ch === 0x21/* ! */) {
2505        if (!isNamed) {
2506          tagHandle = state.input.slice(_position - 1, state.position + 1);
2507
2508          if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
2509            throwError(state, 'named tag handle cannot contain such characters');
2510          }
2511
2512          isNamed = true;
2513          _position = state.position + 1;
2514        } else {
2515          throwError(state, 'tag suffix cannot contain exclamation marks');
2516        }
2517      }
2518
2519      ch = state.input.charCodeAt(++state.position);
2520    }
2521
2522    tagName = state.input.slice(_position, state.position);
2523
2524    if (PATTERN_FLOW_INDICATORS.test(tagName)) {
2525      throwError(state, 'tag suffix cannot contain flow indicator characters');
2526    }
2527  }
2528
2529  if (tagName && !PATTERN_TAG_URI.test(tagName)) {
2530    throwError(state, 'tag name cannot contain such characters: ' + tagName);
2531  }
2532
2533  if (isVerbatim) {
2534    state.tag = tagName;
2535
2536  } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
2537    state.tag = state.tagMap[tagHandle] + tagName;
2538
2539  } else if (tagHandle === '!') {
2540    state.tag = '!' + tagName;
2541
2542  } else if (tagHandle === '!!') {
2543    state.tag = 'tag:yaml.org,2002:' + tagName;
2544
2545  } else {
2546    throwError(state, 'undeclared tag handle "' + tagHandle + '"');
2547  }
2548
2549  return true;
2550}
2551
2552function readAnchorProperty(state) {
2553  var _position,
2554      ch;
2555
2556  ch = state.input.charCodeAt(state.position);
2557
2558  if (ch !== 0x26/* & */) { return false; }
2559
2560  if (state.anchor !== null) {
2561    throwError(state, 'duplication of an anchor property');
2562  }
2563
2564  ch = state.input.charCodeAt(++state.position);
2565  _position = state.position;
2566
2567  while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2568    ch = state.input.charCodeAt(++state.position);
2569  }
2570
2571  if (state.position === _position) {
2572    throwError(state, 'name of an anchor node must contain at least one character');
2573  }
2574
2575  state.anchor = state.input.slice(_position, state.position);
2576  return true;
2577}
2578
2579function readAlias(state) {
2580  var _position, alias,
2581      ch;
2582
2583  ch = state.input.charCodeAt(state.position);
2584
2585  if (ch !== 0x2A/* * */) { return false; }
2586
2587  ch = state.input.charCodeAt(++state.position);
2588  _position = state.position;
2589
2590  while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2591    ch = state.input.charCodeAt(++state.position);
2592  }
2593
2594  if (state.position === _position) {
2595    throwError(state, 'name of an alias node must contain at least one character');
2596  }
2597
2598  alias = state.input.slice(_position, state.position);
2599
2600  if (!state.anchorMap.hasOwnProperty(alias)) {
2601    throwError(state, 'unidentified alias "' + alias + '"');
2602  }
2603
2604  state.result = state.anchorMap[alias];
2605  skipSeparationSpace(state, true, -1);
2606  return true;
2607}
2608
2609function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2610  var allowBlockStyles,
2611      allowBlockScalars,
2612      allowBlockCollections,
2613      indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
2614      atNewLine  = false,
2615      hasContent = false,
2616      typeIndex,
2617      typeQuantity,
2618      type,
2619      flowIndent,
2620      blockIndent;
2621
2622  if (state.listener !== null) {
2623    state.listener('open', state);
2624  }
2625
2626  state.tag    = null;
2627  state.anchor = null;
2628  state.kind   = null;
2629  state.result = null;
2630
2631  allowBlockStyles = allowBlockScalars = allowBlockCollections =
2632    CONTEXT_BLOCK_OUT === nodeContext ||
2633    CONTEXT_BLOCK_IN  === nodeContext;
2634
2635  if (allowToSeek) {
2636    if (skipSeparationSpace(state, true, -1)) {
2637      atNewLine = true;
2638
2639      if (state.lineIndent > parentIndent) {
2640        indentStatus = 1;
2641      } else if (state.lineIndent === parentIndent) {
2642        indentStatus = 0;
2643      } else if (state.lineIndent < parentIndent) {
2644        indentStatus = -1;
2645      }
2646    }
2647  }
2648
2649  if (indentStatus === 1) {
2650    while (readTagProperty(state) || readAnchorProperty(state)) {
2651      if (skipSeparationSpace(state, true, -1)) {
2652        atNewLine = true;
2653        allowBlockCollections = allowBlockStyles;
2654
2655        if (state.lineIndent > parentIndent) {
2656          indentStatus = 1;
2657        } else if (state.lineIndent === parentIndent) {
2658          indentStatus = 0;
2659        } else if (state.lineIndent < parentIndent) {
2660          indentStatus = -1;
2661        }
2662      } else {
2663        allowBlockCollections = false;
2664      }
2665    }
2666  }
2667
2668  if (allowBlockCollections) {
2669    allowBlockCollections = atNewLine || allowCompact;
2670  }
2671
2672  if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
2673    if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2674      flowIndent = parentIndent;
2675    } else {
2676      flowIndent = parentIndent + 1;
2677    }
2678
2679    blockIndent = state.position - state.lineStart;
2680
2681    if (indentStatus === 1) {
2682      if (allowBlockCollections &&
2683          (readBlockSequence(state, blockIndent) ||
2684           readBlockMapping(state, blockIndent, flowIndent)) ||
2685          readFlowCollection(state, flowIndent)) {
2686        hasContent = true;
2687      } else {
2688        if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
2689            readSingleQuotedScalar(state, flowIndent) ||
2690            readDoubleQuotedScalar(state, flowIndent)) {
2691          hasContent = true;
2692
2693        } else if (readAlias(state)) {
2694          hasContent = true;
2695
2696          if (state.tag !== null || state.anchor !== null) {
2697            throwError(state, 'alias node should not have any properties');
2698          }
2699
2700        } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2701          hasContent = true;
2702
2703          if (state.tag === null) {
2704            state.tag = '?';
2705          }
2706        }
2707
2708        if (state.anchor !== null) {
2709          state.anchorMap[state.anchor] = state.result;
2710        }
2711      }
2712    } else if (indentStatus === 0) {
2713      // Special case: block sequences are allowed to have same indentation level as the parent.
2714      // http://www.yaml.org/spec/1.2/spec.html#id2799784
2715      hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2716    }
2717  }
2718
2719  if (state.tag !== null && state.tag !== '!') {
2720    if (state.tag === '?') {
2721      for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
2722           typeIndex < typeQuantity;
2723           typeIndex += 1) {
2724        type = state.implicitTypes[typeIndex];
2725
2726        // Implicit resolving is not allowed for non-scalar types, and '?'
2727        // non-specific tag is only assigned to plain scalars. So, it isn't
2728        // needed to check for 'kind' conformity.
2729
2730        if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
2731          state.result = type.construct(state.result);
2732          state.tag = type.tag;
2733          if (state.anchor !== null) {
2734            state.anchorMap[state.anchor] = state.result;
2735          }
2736          break;
2737        }
2738      }
2739    } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
2740      type = state.typeMap[state.kind || 'fallback'][state.tag];
2741
2742      if (state.result !== null && type.kind !== state.kind) {
2743        throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2744      }
2745
2746      if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
2747        throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
2748      } else {
2749        state.result = type.construct(state.result);
2750        if (state.anchor !== null) {
2751          state.anchorMap[state.anchor] = state.result;
2752        }
2753      }
2754    } else {
2755      throwError(state, 'unknown tag !<' + state.tag + '>');
2756    }
2757  }
2758
2759  if (state.listener !== null) {
2760    state.listener('close', state);
2761  }
2762  return state.tag !== null ||  state.anchor !== null || hasContent;
2763}
2764
2765function readDocument(state) {
2766  var documentStart = state.position,
2767      _position,
2768      directiveName,
2769      directiveArgs,
2770      hasDirectives = false,
2771      ch;
2772
2773  state.version = null;
2774  state.checkLineBreaks = state.legacy;
2775  state.tagMap = {};
2776  state.anchorMap = {};
2777
2778  while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2779    skipSeparationSpace(state, true, -1);
2780
2781    ch = state.input.charCodeAt(state.position);
2782
2783    if (state.lineIndent > 0 || ch !== 0x25/* % */) {
2784      break;
2785    }
2786
2787    hasDirectives = true;
2788    ch = state.input.charCodeAt(++state.position);
2789    _position = state.position;
2790
2791    while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2792      ch = state.input.charCodeAt(++state.position);
2793    }
2794
2795    directiveName = state.input.slice(_position, state.position);
2796    directiveArgs = [];
2797
2798    if (directiveName.length < 1) {
2799      throwError(state, 'directive name must not be less than one character in length');
2800    }
2801
2802    while (ch !== 0) {
2803      while (is_WHITE_SPACE(ch)) {
2804        ch = state.input.charCodeAt(++state.position);
2805      }
2806
2807      if (ch === 0x23/* # */) {
2808        do { ch = state.input.charCodeAt(++state.position); }
2809        while (ch !== 0 && !is_EOL(ch));
2810        break;
2811      }
2812
2813      if (is_EOL(ch)) { break; }
2814
2815      _position = state.position;
2816
2817      while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2818        ch = state.input.charCodeAt(++state.position);
2819      }
2820
2821      directiveArgs.push(state.input.slice(_position, state.position));
2822    }
2823
2824    if (ch !== 0) { readLineBreak(state); }
2825
2826    if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2827      directiveHandlers[directiveName](state, directiveName, directiveArgs);
2828    } else {
2829      throwWarning(state, 'unknown document directive "' + directiveName + '"');
2830    }
2831  }
2832
2833  skipSeparationSpace(state, true, -1);
2834
2835  if (state.lineIndent === 0 &&
2836      state.input.charCodeAt(state.position)     === 0x2D/* - */ &&
2837      state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
2838      state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
2839    state.position += 3;
2840    skipSeparationSpace(state, true, -1);
2841
2842  } else if (hasDirectives) {
2843    throwError(state, 'directives end mark is expected');
2844  }
2845
2846  composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2847  skipSeparationSpace(state, true, -1);
2848
2849  if (state.checkLineBreaks &&
2850      PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2851    throwWarning(state, 'non-ASCII line breaks are interpreted as content');
2852  }
2853
2854  state.documents.push(state.result);
2855
2856  if (state.position === state.lineStart && testDocumentSeparator(state)) {
2857
2858    if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
2859      state.position += 3;
2860      skipSeparationSpace(state, true, -1);
2861    }
2862    return;
2863  }
2864
2865  if (state.position < (state.length - 1)) {
2866    throwError(state, 'end of the stream or a document separator is expected');
2867  } else {
2868    return;
2869  }
2870}
2871
2872
2873function loadDocuments(input, options) {
2874  input = String(input);
2875  options = options || {};
2876
2877  if (input.length !== 0) {
2878
2879    // Add tailing `\n` if not exists
2880    if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
2881        input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
2882      input += '\n';
2883    }
2884
2885    // Strip BOM
2886    if (input.charCodeAt(0) === 0xFEFF) {
2887      input = input.slice(1);
2888    }
2889  }
2890
2891  var state = new State(input, options);
2892
2893  // Use 0 as string terminator. That significantly simplifies bounds check.
2894  state.input += '\0';
2895
2896  while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
2897    state.lineIndent += 1;
2898    state.position += 1;
2899  }
2900
2901  while (state.position < (state.length - 1)) {
2902    readDocument(state);
2903  }
2904
2905  return state.documents;
2906}
2907
2908
2909function loadAll$1(input, iterator, options) {
2910  var documents = loadDocuments(input, options), index, length;
2911
2912  for (index = 0, length = documents.length; index < length; index += 1) {
2913    iterator(documents[index]);
2914  }
2915}
2916
2917
2918function load$1(input, options) {
2919  var documents = loadDocuments(input, options);
2920
2921  if (documents.length === 0) {
2922    /*eslint-disable no-undefined*/
2923    return undefined;
2924  } else if (documents.length === 1) {
2925    return documents[0];
2926  }
2927  throw new YAMLException$1('expected a single document in the stream, but found more');
2928}
2929
2930
2931function safeLoadAll$1(input, output, options) {
2932  loadAll$1(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options));
2933}
2934
2935
2936function safeLoad$1(input, options) {
2937  return load$1(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options));
2938}
2939
2940
2941var loadAll_1 = loadAll$1;
2942var load_1 = load$1;
2943var safeLoadAll_1 = safeLoadAll$1;
2944var safeLoad_1 = safeLoad$1;
2945
2946var loader$1 = {
2947	loadAll: loadAll_1,
2948	load: load_1,
2949	safeLoadAll: safeLoadAll_1,
2950	safeLoad: safeLoad_1
2951};
2952
2953/*eslint-disable no-use-before-define*/
2954
2955var common$7              = common$1;
2956var YAMLException$5       = exception;
2957var DEFAULT_FULL_SCHEMA$2 = default_full;
2958var DEFAULT_SAFE_SCHEMA$2 = default_safe;
2959
2960var _toString$2       = Object.prototype.toString;
2961var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
2962
2963var CHAR_TAB                  = 0x09; /* Tab */
2964var CHAR_LINE_FEED            = 0x0A; /* LF */
2965var CHAR_SPACE                = 0x20; /* Space */
2966var CHAR_EXCLAMATION          = 0x21; /* ! */
2967var CHAR_DOUBLE_QUOTE         = 0x22; /* " */
2968var CHAR_SHARP                = 0x23; /* # */
2969var CHAR_PERCENT              = 0x25; /* % */
2970var CHAR_AMPERSAND            = 0x26; /* & */
2971var CHAR_SINGLE_QUOTE         = 0x27; /* ' */
2972var CHAR_ASTERISK             = 0x2A; /* * */
2973var CHAR_COMMA                = 0x2C; /* , */
2974var CHAR_MINUS                = 0x2D; /* - */
2975var CHAR_COLON                = 0x3A; /* : */
2976var CHAR_GREATER_THAN         = 0x3E; /* > */
2977var CHAR_QUESTION             = 0x3F; /* ? */
2978var CHAR_COMMERCIAL_AT        = 0x40; /* @ */
2979var CHAR_LEFT_SQUARE_BRACKET  = 0x5B; /* [ */
2980var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
2981var CHAR_GRAVE_ACCENT         = 0x60; /* ` */
2982var CHAR_LEFT_CURLY_BRACKET   = 0x7B; /* { */
2983var CHAR_VERTICAL_LINE        = 0x7C; /* | */
2984var CHAR_RIGHT_CURLY_BRACKET  = 0x7D; /* } */
2985
2986var ESCAPE_SEQUENCES = {};
2987
2988ESCAPE_SEQUENCES[0x00]   = '\\0';
2989ESCAPE_SEQUENCES[0x07]   = '\\a';
2990ESCAPE_SEQUENCES[0x08]   = '\\b';
2991ESCAPE_SEQUENCES[0x09]   = '\\t';
2992ESCAPE_SEQUENCES[0x0A]   = '\\n';
2993ESCAPE_SEQUENCES[0x0B]   = '\\v';
2994ESCAPE_SEQUENCES[0x0C]   = '\\f';
2995ESCAPE_SEQUENCES[0x0D]   = '\\r';
2996ESCAPE_SEQUENCES[0x1B]   = '\\e';
2997ESCAPE_SEQUENCES[0x22]   = '\\"';
2998ESCAPE_SEQUENCES[0x5C]   = '\\\\';
2999ESCAPE_SEQUENCES[0x85]   = '\\N';
3000ESCAPE_SEQUENCES[0xA0]   = '\\_';
3001ESCAPE_SEQUENCES[0x2028] = '\\L';
3002ESCAPE_SEQUENCES[0x2029] = '\\P';
3003
3004var DEPRECATED_BOOLEANS_SYNTAX = [
3005  'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
3006  'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
3007];
3008
3009function compileStyleMap(schema, map) {
3010  var result, keys, index, length, tag, style, type;
3011
3012  if (map === null) { return {}; }
3013
3014  result = {};
3015  keys = Object.keys(map);
3016
3017  for (index = 0, length = keys.length; index < length; index += 1) {
3018    tag = keys[index];
3019    style = String(map[tag]);
3020
3021    if (tag.slice(0, 2) === '!!') {
3022      tag = 'tag:yaml.org,2002:' + tag.slice(2);
3023    }
3024    type = schema.compiledTypeMap['fallback'][tag];
3025
3026    if (type && _hasOwnProperty$3.call(type.styleAliases, style)) {
3027      style = type.styleAliases[style];
3028    }
3029
3030    result[tag] = style;
3031  }
3032
3033  return result;
3034}
3035
3036function encodeHex(character) {
3037  var string, handle, length;
3038
3039  string = character.toString(16).toUpperCase();
3040
3041  if (character <= 0xFF) {
3042    handle = 'x';
3043    length = 2;
3044  } else if (character <= 0xFFFF) {
3045    handle = 'u';
3046    length = 4;
3047  } else if (character <= 0xFFFFFFFF) {
3048    handle = 'U';
3049    length = 8;
3050  } else {
3051    throw new YAMLException$5('code point within a string may not be greater than 0xFFFFFFFF');
3052  }
3053
3054  return '\\' + handle + common$7.repeat('0', length - string.length) + string;
3055}
3056
3057function State$1(options) {
3058  this.schema       = options['schema'] || DEFAULT_FULL_SCHEMA$2;
3059  this.indent       = Math.max(1, (options['indent'] || 2));
3060  this.skipInvalid  = options['skipInvalid'] || false;
3061  this.flowLevel    = (common$7.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
3062  this.styleMap     = compileStyleMap(this.schema, options['styles'] || null);
3063  this.sortKeys     = options['sortKeys'] || false;
3064  this.lineWidth    = options['lineWidth'] || 80;
3065  this.noRefs       = options['noRefs'] || false;
3066  this.noCompatMode = options['noCompatMode'] || false;
3067
3068  this.implicitTypes = this.schema.compiledImplicit;
3069  this.explicitTypes = this.schema.compiledExplicit;
3070
3071  this.tag = null;
3072  this.result = '';
3073
3074  this.duplicates = [];
3075  this.usedDuplicates = null;
3076}
3077
3078// Indents every line in a string. Empty lines (\n only) are not indented.
3079function indentString(string, spaces) {
3080  var ind = common$7.repeat(' ', spaces),
3081      position = 0,
3082      next = -1,
3083      result = '',
3084      line,
3085      length = string.length;
3086
3087  while (position < length) {
3088    next = string.indexOf('\n', position);
3089    if (next === -1) {
3090      line = string.slice(position);
3091      position = length;
3092    } else {
3093      line = string.slice(position, next + 1);
3094      position = next + 1;
3095    }
3096
3097    if (line.length && line !== '\n') { result += ind; }
3098
3099    result += line;
3100  }
3101
3102  return result;
3103}
3104
3105function generateNextLine(state, level) {
3106  return '\n' + common$7.repeat(' ', state.indent * level);
3107}
3108
3109function testImplicitResolving(state, str) {
3110  var index, length, type;
3111
3112  for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
3113    type = state.implicitTypes[index];
3114
3115    if (type.resolve(str)) {
3116      return true;
3117    }
3118  }
3119
3120  return false;
3121}
3122
3123// [33] s-white ::= s-space | s-tab
3124function isWhitespace(c) {
3125  return c === CHAR_SPACE || c === CHAR_TAB;
3126}
3127
3128// Returns true if the character can be printed without escaping.
3129// From YAML 1.2: "any allowed characters known to be non-printable
3130// should also be escaped. [However,] This isn’t mandatory"
3131// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
3132function isPrintable(c) {
3133  return  (0x00020 <= c && c <= 0x00007E)
3134      || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
3135      || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
3136      ||  (0x10000 <= c && c <= 0x10FFFF);
3137}
3138
3139// Simplified test for values allowed after the first character in plain style.
3140function isPlainSafe(c) {
3141  // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
3142  // where nb-char ::= c-printable - b-char - c-byte-order-mark.
3143  return isPrintable(c) && c !== 0xFEFF
3144    // - c-flow-indicator
3145    && c !== CHAR_COMMA
3146    && c !== CHAR_LEFT_SQUARE_BRACKET
3147    && c !== CHAR_RIGHT_SQUARE_BRACKET
3148    && c !== CHAR_LEFT_CURLY_BRACKET
3149    && c !== CHAR_RIGHT_CURLY_BRACKET
3150    // - ":" - "#"
3151    && c !== CHAR_COLON
3152    && c !== CHAR_SHARP;
3153}
3154
3155// Simplified test for values allowed as the first character in plain style.
3156function isPlainSafeFirst(c) {
3157  // Uses a subset of ns-char - c-indicator
3158  // where ns-char = nb-char - s-white.
3159  return isPrintable(c) && c !== 0xFEFF
3160    && !isWhitespace(c) // - s-white
3161    // - (c-indicator ::=
3162    // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
3163    && c !== CHAR_MINUS
3164    && c !== CHAR_QUESTION
3165    && c !== CHAR_COLON
3166    && c !== CHAR_COMMA
3167    && c !== CHAR_LEFT_SQUARE_BRACKET
3168    && c !== CHAR_RIGHT_SQUARE_BRACKET
3169    && c !== CHAR_LEFT_CURLY_BRACKET
3170    && c !== CHAR_RIGHT_CURLY_BRACKET
3171    // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
3172    && c !== CHAR_SHARP
3173    && c !== CHAR_AMPERSAND
3174    && c !== CHAR_ASTERISK
3175    && c !== CHAR_EXCLAMATION
3176    && c !== CHAR_VERTICAL_LINE
3177    && c !== CHAR_GREATER_THAN
3178    && c !== CHAR_SINGLE_QUOTE
3179    && c !== CHAR_DOUBLE_QUOTE
3180    // | “%” | “@” | “`”)
3181    && c !== CHAR_PERCENT
3182    && c !== CHAR_COMMERCIAL_AT
3183    && c !== CHAR_GRAVE_ACCENT;
3184}
3185
3186var STYLE_PLAIN   = 1;
3187var STYLE_SINGLE  = 2;
3188var STYLE_LITERAL = 3;
3189var STYLE_FOLDED  = 4;
3190var STYLE_DOUBLE  = 5;
3191
3192// Determines which scalar styles are possible and returns the preferred style.
3193// lineWidth = -1 => no limit.
3194// Pre-conditions: str.length > 0.
3195// Post-conditions:
3196//    STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
3197//    STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
3198//    STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
3199function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
3200  var i;
3201  var char;
3202  var hasLineBreak = false;
3203  var hasFoldableLine = false; // only checked if shouldTrackWidth
3204  var shouldTrackWidth = lineWidth !== -1;
3205  var previousLineBreak = -1; // count the first line correctly
3206  var plain = isPlainSafeFirst(string.charCodeAt(0))
3207          && !isWhitespace(string.charCodeAt(string.length - 1));
3208
3209  if (singleLineOnly) {
3210    // Case: no block styles.
3211    // Check for disallowed characters to rule out plain and single.
3212    for (i = 0; i < string.length; i++) {
3213      char = string.charCodeAt(i);
3214      if (!isPrintable(char)) {
3215        return STYLE_DOUBLE;
3216      }
3217      plain = plain && isPlainSafe(char);
3218    }
3219  } else {
3220    // Case: block styles permitted.
3221    for (i = 0; i < string.length; i++) {
3222      char = string.charCodeAt(i);
3223      if (char === CHAR_LINE_FEED) {
3224        hasLineBreak = true;
3225        // Check if any line can be folded.
3226        if (shouldTrackWidth) {
3227          hasFoldableLine = hasFoldableLine ||
3228            // Foldable line = too long, and not more-indented.
3229            (i - previousLineBreak - 1 > lineWidth &&
3230             string[previousLineBreak + 1] !== ' ');
3231          previousLineBreak = i;
3232        }
3233      } else if (!isPrintable(char)) {
3234        return STYLE_DOUBLE;
3235      }
3236      plain = plain && isPlainSafe(char);
3237    }
3238    // in case the end is missing a \n
3239    hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
3240      (i - previousLineBreak - 1 > lineWidth &&
3241       string[previousLineBreak + 1] !== ' '));
3242  }
3243  // Although every style can represent \n without escaping, prefer block styles
3244  // for multiline, since they're more readable and they don't add empty lines.
3245  // Also prefer folding a super-long line.
3246  if (!hasLineBreak && !hasFoldableLine) {
3247    // Strings interpretable as another type have to be quoted;
3248    // e.g. the string 'true' vs. the boolean true.
3249    return plain && !testAmbiguousType(string)
3250      ? STYLE_PLAIN : STYLE_SINGLE;
3251  }
3252  // Edge case: block indentation indicator can only have one digit.
3253  if (string[0] === ' ' && indentPerLevel > 9) {
3254    return STYLE_DOUBLE;
3255  }
3256  // At this point we know block styles are valid.
3257  // Prefer literal style unless we want to fold.
3258  return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
3259}
3260
3261// Note: line breaking/folding is implemented for only the folded style.
3262// NB. We drop the last trailing newline (if any) of a returned block scalar
3263//  since the dumper adds its own newline. This always works:
3264//    • No ending newline => unaffected; already using strip "-" chomping.
3265//    • Ending newline    => removed then restored.
3266//  Importantly, this keeps the "+" chomp indicator from gaining an extra line.
3267function writeScalar(state, string, level, iskey) {
3268  state.dump = (function () {
3269    if (string.length === 0) {
3270      return "''";
3271    }
3272    if (!state.noCompatMode &&
3273        DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
3274      return "'" + string + "'";
3275    }
3276
3277    var indent = state.indent * Math.max(1, level); // no 0-indent scalars
3278    // As indentation gets deeper, let the width decrease monotonically
3279    // to the lower bound min(state.lineWidth, 40).
3280    // Note that this implies
3281    //  state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
3282    //  state.lineWidth > 40 + state.indent: width decreases until the lower bound.
3283    // This behaves better than a constant minimum width which disallows narrower options,
3284    // or an indent threshold which causes the width to suddenly increase.
3285    var lineWidth = state.lineWidth === -1
3286      ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
3287
3288    // Without knowing if keys are implicit/explicit, assume implicit for safety.
3289    var singleLineOnly = iskey
3290      // No block styles in flow mode.
3291      || (state.flowLevel > -1 && level >= state.flowLevel);
3292    function testAmbiguity(string) {
3293      return testImplicitResolving(state, string);
3294    }
3295
3296    switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
3297      case STYLE_PLAIN:
3298        return string;
3299      case STYLE_SINGLE:
3300        return "'" + string.replace(/'/g, "''") + "'";
3301      case STYLE_LITERAL:
3302        return '|' + blockHeader(string, state.indent)
3303          + dropEndingNewline(indentString(string, indent));
3304      case STYLE_FOLDED:
3305        return '>' + blockHeader(string, state.indent)
3306          + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
3307      case STYLE_DOUBLE:
3308        return '"' + escapeString(string, lineWidth) + '"';
3309      default:
3310        throw new YAMLException$5('impossible error: invalid scalar style');
3311    }
3312  }());
3313}
3314
3315// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
3316function blockHeader(string, indentPerLevel) {
3317  var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : '';
3318
3319  // note the special case: the string '\n' counts as a "trailing" empty line.
3320  var clip =          string[string.length - 1] === '\n';
3321  var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
3322  var chomp = keep ? '+' : (clip ? '' : '-');
3323
3324  return indentIndicator + chomp + '\n';
3325}
3326
3327// (See the note for writeScalar.)
3328function dropEndingNewline(string) {
3329  return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
3330}
3331
3332// Note: a long line without a suitable break point will exceed the width limit.
3333// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
3334function foldString(string, width) {
3335  // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
3336  // unless they're before or after a more-indented line, or at the very
3337  // beginning or end, in which case $k$ maps to $k$.
3338  // Therefore, parse each chunk as newline(s) followed by a content line.
3339  var lineRe = /(\n+)([^\n]*)/g;
3340
3341  // first line (possibly an empty line)
3342  var result = (function () {
3343    var nextLF = string.indexOf('\n');
3344    nextLF = nextLF !== -1 ? nextLF : string.length;
3345    lineRe.lastIndex = nextLF;
3346    return foldLine(string.slice(0, nextLF), width);
3347  }());
3348  // If we haven't reached the first content line yet, don't add an extra \n.
3349  var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
3350  var moreIndented;
3351
3352  // rest of the lines
3353  var match;
3354  while ((match = lineRe.exec(string))) {
3355    var prefix = match[1], line = match[2];
3356    moreIndented = (line[0] === ' ');
3357    result += prefix
3358      + (!prevMoreIndented && !moreIndented && line !== ''
3359        ? '\n' : '')
3360      + foldLine(line, width);
3361    prevMoreIndented = moreIndented;
3362  }
3363
3364  return result;
3365}
3366
3367// Greedy line breaking.
3368// Picks the longest line under the limit each time,
3369// otherwise settles for the shortest line over the limit.
3370// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
3371function foldLine(line, width) {
3372  if (line === '' || line[0] === ' ') { return line; }
3373
3374  // Since a more-indented line adds a \n, breaks can't be followed by a space.
3375  var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
3376  var match;
3377  // start is an inclusive index. end, curr, and next are exclusive.
3378  var start = 0, end, curr = 0, next = 0;
3379  var result = '';
3380
3381  // Invariants: 0 <= start <= length-1.
3382  //   0 <= curr <= next <= max(0, length-2). curr - start <= width.
3383  // Inside the loop:
3384  //   A match implies length >= 2, so curr and next are <= length-2.
3385  while ((match = breakRe.exec(line))) {
3386    next = match.index;
3387    // maintain invariant: curr - start <= width
3388    if (next - start > width) {
3389      end = (curr > start) ? curr : next; // derive end <= length-2
3390      result += '\n' + line.slice(start, end);
3391      // skip the space that was output as \n
3392      start = end + 1;                    // derive start <= length-1
3393    }
3394    curr = next;
3395  }
3396
3397  // By the invariants, start <= length-1, so there is something left over.
3398  // It is either the whole string or a part starting from non-whitespace.
3399  result += '\n';
3400  // Insert a break if the remainder is too long and there is a break available.
3401  if (line.length - start > width && curr > start) {
3402    result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
3403  } else {
3404    result += line.slice(start);
3405  }
3406
3407  return result.slice(1); // drop extra \n joiner
3408}
3409
3410// Escapes a double-quoted string.
3411function escapeString(string) {
3412  var result = '';
3413  var char;
3414  var escapeSeq;
3415
3416  for (var i = 0; i < string.length; i++) {
3417    char = string.charCodeAt(i);
3418    escapeSeq = ESCAPE_SEQUENCES[char];
3419    result += !escapeSeq && isPrintable(char)
3420      ? string[i]
3421      : escapeSeq || encodeHex(char);
3422  }
3423
3424  return result;
3425}
3426
3427function writeFlowSequence(state, level, object) {
3428  var _result = '',
3429      _tag    = state.tag,
3430      index,
3431      length;
3432
3433  for (index = 0, length = object.length; index < length; index += 1) {
3434    // Write only valid elements.
3435    if (writeNode(state, level, object[index], false, false)) {
3436      if (index !== 0) { _result += ', '; }
3437      _result += state.dump;
3438    }
3439  }
3440
3441  state.tag = _tag;
3442  state.dump = '[' + _result + ']';
3443}
3444
3445function writeBlockSequence(state, level, object, compact) {
3446  var _result = '',
3447      _tag    = state.tag,
3448      index,
3449      length;
3450
3451  for (index = 0, length = object.length; index < length; index += 1) {
3452    // Write only valid elements.
3453    if (writeNode(state, level + 1, object[index], true, true)) {
3454      if (!compact || index !== 0) {
3455        _result += generateNextLine(state, level);
3456      }
3457      _result += '- ' + state.dump;
3458    }
3459  }
3460
3461  state.tag = _tag;
3462  state.dump = _result || '[]'; // Empty sequence if no valid values.
3463}
3464
3465function writeFlowMapping(state, level, object) {
3466  var _result       = '',
3467      _tag          = state.tag,
3468      objectKeyList = Object.keys(object),
3469      index,
3470      length,
3471      objectKey,
3472      objectValue,
3473      pairBuffer;
3474
3475  for (index = 0, length = objectKeyList.length; index < length; index += 1) {
3476    pairBuffer = '';
3477
3478    if (index !== 0) { pairBuffer += ', '; }
3479
3480    objectKey = objectKeyList[index];
3481    objectValue = object[objectKey];
3482
3483    if (!writeNode(state, level, objectKey, false, false)) {
3484      continue; // Skip this pair because of invalid key;
3485    }
3486
3487    if (state.dump.length > 1024) { pairBuffer += '? '; }
3488
3489    pairBuffer += state.dump + ': ';
3490
3491    if (!writeNode(state, level, objectValue, false, false)) {
3492      continue; // Skip this pair because of invalid value.
3493    }
3494
3495    pairBuffer += state.dump;
3496
3497    // Both key and value are valid.
3498    _result += pairBuffer;
3499  }
3500
3501  state.tag = _tag;
3502  state.dump = '{' + _result + '}';
3503}
3504
3505function writeBlockMapping(state, level, object, compact) {
3506  var _result       = '',
3507      _tag          = state.tag,
3508      objectKeyList = Object.keys(object),
3509      index,
3510      length,
3511      objectKey,
3512      objectValue,
3513      explicitPair,
3514      pairBuffer;
3515
3516  // Allow sorting keys so that the output file is deterministic
3517  if (state.sortKeys === true) {
3518    // Default sorting
3519    objectKeyList.sort();
3520  } else if (typeof state.sortKeys === 'function') {
3521    // Custom sort function
3522    objectKeyList.sort(state.sortKeys);
3523  } else if (state.sortKeys) {
3524    // Something is wrong
3525    throw new YAMLException$5('sortKeys must be a boolean or a function');
3526  }
3527
3528  for (index = 0, length = objectKeyList.length; index < length; index += 1) {
3529    pairBuffer = '';
3530
3531    if (!compact || index !== 0) {
3532      pairBuffer += generateNextLine(state, level);
3533    }
3534
3535    objectKey = objectKeyList[index];
3536    objectValue = object[objectKey];
3537
3538    if (!writeNode(state, level + 1, objectKey, true, true, true)) {
3539      continue; // Skip this pair because of invalid key.
3540    }
3541
3542    explicitPair = (state.tag !== null && state.tag !== '?') ||
3543                   (state.dump && state.dump.length > 1024);
3544
3545    if (explicitPair) {
3546      if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
3547        pairBuffer += '?';
3548      } else {
3549        pairBuffer += '? ';
3550      }
3551    }
3552
3553    pairBuffer += state.dump;
3554
3555    if (explicitPair) {
3556      pairBuffer += generateNextLine(state, level);
3557    }
3558
3559    if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
3560      continue; // Skip this pair because of invalid value.
3561    }
3562
3563    if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
3564      pairBuffer += ':';
3565    } else {
3566      pairBuffer += ': ';
3567    }
3568
3569    pairBuffer += state.dump;
3570
3571    // Both key and value are valid.
3572    _result += pairBuffer;
3573  }
3574
3575  state.tag = _tag;
3576  state.dump = _result || '{}'; // Empty mapping if no valid pairs.
3577}
3578
3579function detectType(state, object, explicit) {
3580  var _result, typeList, index, length, type, style;
3581
3582  typeList = explicit ? state.explicitTypes : state.implicitTypes;
3583
3584  for (index = 0, length = typeList.length; index < length; index += 1) {
3585    type = typeList[index];
3586
3587    if ((type.instanceOf  || type.predicate) &&
3588        (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
3589        (!type.predicate  || type.predicate(object))) {
3590
3591      state.tag = explicit ? type.tag : '?';
3592
3593      if (type.represent) {
3594        style = state.styleMap[type.tag] || type.defaultStyle;
3595
3596        if (_toString$2.call(type.represent) === '[object Function]') {
3597          _result = type.represent(object, style);
3598        } else if (_hasOwnProperty$3.call(type.represent, style)) {
3599          _result = type.represent[style](object, style);
3600        } else {
3601          throw new YAMLException$5('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
3602        }
3603
3604        state.dump = _result;
3605      }
3606
3607      return true;
3608    }
3609  }
3610
3611  return false;
3612}
3613
3614// Serializes `object` and writes it to global `result`.
3615// Returns true on success, or false on invalid object.
3616//
3617function writeNode(state, level, object, block, compact, iskey) {
3618  state.tag = null;
3619  state.dump = object;
3620
3621  if (!detectType(state, object, false)) {
3622    detectType(state, object, true);
3623  }
3624
3625  var type = _toString$2.call(state.dump);
3626
3627  if (block) {
3628    block = (state.flowLevel < 0 || state.flowLevel > level);
3629  }
3630
3631  var objectOrArray = type === '[object Object]' || type === '[object Array]',
3632      duplicateIndex,
3633      duplicate;
3634
3635  if (objectOrArray) {
3636    duplicateIndex = state.duplicates.indexOf(object);
3637    duplicate = duplicateIndex !== -1;
3638  }
3639
3640  if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
3641    compact = false;
3642  }
3643
3644  if (duplicate && state.usedDuplicates[duplicateIndex]) {
3645    state.dump = '*ref_' + duplicateIndex;
3646  } else {
3647    if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
3648      state.usedDuplicates[duplicateIndex] = true;
3649    }
3650    if (type === '[object Object]') {
3651      if (block && (Object.keys(state.dump).length !== 0)) {
3652        writeBlockMapping(state, level, state.dump, compact);
3653        if (duplicate) {
3654          state.dump = '&ref_' + duplicateIndex + state.dump;
3655        }
3656      } else {
3657        writeFlowMapping(state, level, state.dump);
3658        if (duplicate) {
3659          state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
3660        }
3661      }
3662    } else if (type === '[object Array]') {
3663      if (block && (state.dump.length !== 0)) {
3664        writeBlockSequence(state, level, state.dump, compact);
3665        if (duplicate) {
3666          state.dump = '&ref_' + duplicateIndex + state.dump;
3667        }
3668      } else {
3669        writeFlowSequence(state, level, state.dump);
3670        if (duplicate) {
3671          state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
3672        }
3673      }
3674    } else if (type === '[object String]') {
3675      if (state.tag !== '?') {
3676        writeScalar(state, state.dump, level, iskey);
3677      }
3678    } else {
3679      if (state.skipInvalid) { return false; }
3680      throw new YAMLException$5('unacceptable kind of an object to dump ' + type);
3681    }
3682
3683    if (state.tag !== null && state.tag !== '?') {
3684      state.dump = '!<' + state.tag + '> ' + state.dump;
3685    }
3686  }
3687
3688  return true;
3689}
3690
3691function getDuplicateReferences(object, state) {
3692  var objects = [],
3693      duplicatesIndexes = [],
3694      index,
3695      length;
3696
3697  inspectNode(object, objects, duplicatesIndexes);
3698
3699  for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
3700    state.duplicates.push(objects[duplicatesIndexes[index]]);
3701  }
3702  state.usedDuplicates = new Array(length);
3703}
3704
3705function inspectNode(object, objects, duplicatesIndexes) {
3706  var objectKeyList,
3707      index,
3708      length;
3709
3710  if (object !== null && typeof object === 'object') {
3711    index = objects.indexOf(object);
3712    if (index !== -1) {
3713      if (duplicatesIndexes.indexOf(index) === -1) {
3714        duplicatesIndexes.push(index);
3715      }
3716    } else {
3717      objects.push(object);
3718
3719      if (Array.isArray(object)) {
3720        for (index = 0, length = object.length; index < length; index += 1) {
3721          inspectNode(object[index], objects, duplicatesIndexes);
3722        }
3723      } else {
3724        objectKeyList = Object.keys(object);
3725
3726        for (index = 0, length = objectKeyList.length; index < length; index += 1) {
3727          inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
3728        }
3729      }
3730    }
3731  }
3732}
3733
3734function dump$1(input, options) {
3735  options = options || {};
3736
3737  var state = new State$1(options);
3738
3739  if (!state.noRefs) { getDuplicateReferences(input, state); }
3740
3741  if (writeNode(state, 0, input, true, true)) { return state.dump + '\n'; }
3742
3743  return '';
3744}
3745
3746function safeDump$1(input, options) {
3747  return dump$1(input, common$7.extend({ schema: DEFAULT_SAFE_SCHEMA$2 }, options));
3748}
3749
3750var dump_1 = dump$1;
3751var safeDump_1 = safeDump$1;
3752
3753var dumper$1 = {
3754	dump: dump_1,
3755	safeDump: safeDump_1
3756};
3757
3758var loader = loader$1;
3759var dumper = dumper$1;
3760
3761
3762function deprecated(name) {
3763  return function () {
3764    throw new Error('Function ' + name + ' is deprecated and cannot be used.');
3765  };
3766}
3767
3768
3769var Type = type;
3770var Schema = schema;
3771var FAILSAFE_SCHEMA = failsafe;
3772var JSON_SCHEMA = json;
3773var CORE_SCHEMA = core;
3774var DEFAULT_SAFE_SCHEMA = default_safe;
3775var DEFAULT_FULL_SCHEMA = default_full;
3776var load = loader.load;
3777var loadAll = loader.loadAll;
3778var safeLoad = loader.safeLoad;
3779var safeLoadAll = loader.safeLoadAll;
3780var dump = dumper.dump;
3781var safeDump = dumper.safeDump;
3782var YAMLException = exception;
3783
3784// Deprecated schema names from JS-YAML 2.0.x
3785var MINIMAL_SCHEMA = failsafe;
3786var SAFE_SCHEMA = default_safe;
3787var DEFAULT_SCHEMA = default_full;
3788
3789// Deprecated functions from JS-YAML 1.x.x
3790var scan$1 = deprecated('scan');
3791var parse$1 = deprecated('parse');
3792var compose = deprecated('compose');
3793var addConstructor = deprecated('addConstructor');
3794
3795var jsYaml = {
3796	Type: Type,
3797	Schema: Schema,
3798	FAILSAFE_SCHEMA: FAILSAFE_SCHEMA,
3799	JSON_SCHEMA: JSON_SCHEMA,
3800	CORE_SCHEMA: CORE_SCHEMA,
3801	DEFAULT_SAFE_SCHEMA: DEFAULT_SAFE_SCHEMA,
3802	DEFAULT_FULL_SCHEMA: DEFAULT_FULL_SCHEMA,
3803	load: load,
3804	loadAll: loadAll,
3805	safeLoad: safeLoad,
3806	safeLoadAll: safeLoadAll,
3807	dump: dump,
3808	safeDump: safeDump,
3809	YAMLException: YAMLException,
3810	MINIMAL_SCHEMA: MINIMAL_SCHEMA,
3811	SAFE_SCHEMA: SAFE_SCHEMA,
3812	DEFAULT_SCHEMA: DEFAULT_SCHEMA,
3813	scan: scan$1,
3814	parse: parse$1,
3815	compose: compose,
3816	addConstructor: addConstructor
3817};
3818
3819var yaml = jsYaml;
3820
3821
3822var index = yaml;
3823
3824var frontMatter = function(dom, data) {
3825  var localData = {};
3826  var el = dom.querySelector('script[type="text/front-matter"]');
3827  if (el) {
3828    var text = el.textContent;
3829    localData = index.safeLoad(text);
3830  }
3831
3832  data.title = localData.title ? localData.title : "Untitled";
3833  data.description = localData.description ? localData.description : "No description.";
3834
3835  data.authors = localData.authors ? localData.authors : [];
3836
3837  data.authors = data.authors.map(function (author, i) {
3838    var a = {};
3839    var name = Object.keys(author)[0];
3840    if ((typeof author) === "string") {
3841      name = author;
3842    } else {
3843      a.personalURL = author[name];
3844    }
3845    var names = name.split(" ");
3846    a.name = name;
3847    a.firstName = names.slice(0, names.length - 1).join(" ");
3848    a.lastName = names[names.length -1];
3849    if(localData.affiliations[i]) {
3850      var affiliation = Object.keys(localData.affiliations[i])[0];
3851      if ((typeof localData.affiliations[i]) === "string") {
3852        affiliation = localData.affiliations[i];
3853      } else {
3854        a.affiliationURL = localData.affiliations[i][affiliation];
3855      }
3856      a.affiliation = affiliation;
3857    }
3858    return a;
3859  });
3860  
3861
3862};
3863
3864var bibtexParse = createCommonjsModule(function (module, exports) {
3865/* start bibtexParse 0.0.22 */
3866
3867//Original work by Henrik Muehe (c) 2010
3868//
3869//CommonJS port by Mikola Lysenko 2013
3870//
3871//Port to Browser lib by ORCID / RCPETERS
3872//
3873//Issues:
3874//no comment handling within strings
3875//no string concatenation
3876//no variable values yet
3877//Grammar implemented here:
3878//bibtex -> (string | preamble | comment | entry)*;
3879//string -> '@STRING' '{' key_equals_value '}';
3880//preamble -> '@PREAMBLE' '{' value '}';
3881//comment -> '@COMMENT' '{' value '}';
3882//entry -> '@' key '{' key ',' key_value_list '}';
3883//key_value_list -> key_equals_value (',' key_equals_value)*;
3884//key_equals_value -> key '=' value;
3885//value -> value_quotes | value_braces | key;
3886//value_quotes -> '"' .*? '"'; // not quite
3887//value_braces -> '{' .*? '"'; // not quite
3888(function(exports) {
3889
3890    function BibtexParser() {
3891        
3892        this.months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
3893        this.notKey = [',','{','}',' ','='];
3894        this.pos = 0;
3895        this.input = "";
3896        this.entries = new Array();
3897
3898        this.currentEntry = "";
3899
3900        this.setInput = function(t) {
3901            this.input = t;
3902        };
3903
3904        this.getEntries = function() {
3905            return this.entries;
3906        };
3907
3908        this.isWhitespace = function(s) {
3909            return (s == ' ' || s == '\r' || s == '\t' || s == '\n');
3910        };
3911
3912        this.match = function(s, canCommentOut) {
3913            if (canCommentOut == undefined || canCommentOut == null)
3914                { canCommentOut = true; }
3915            this.skipWhitespace(canCommentOut);
3916            if (this.input.substring(this.pos, this.pos + s.length) == s) {
3917                this.pos += s.length;
3918            } else {
3919                throw "Token mismatch, expected " + s + ", found "
3920                        + this.input.substring(this.pos);
3921            }
3922            this.skipWhitespace(canCommentOut);
3923        };
3924
3925        this.tryMatch = function(s, canCommentOut) {
3926            if (canCommentOut == undefined || canCommentOut == null)
3927                { canCommentOut = true; }
3928            this.skipWhitespace(canCommentOut);
3929            if (this.input.substring(this.pos, this.pos + s.length) == s) {
3930                return true;
3931            } else {
3932                return false;
3933            }
3934            this.skipWhitespace(canCommentOut);
3935        };
3936
3937        /* when search for a match all text can be ignored, not just white space */
3938        this.matchAt = function() {
3939            var this$1 = this;
3940
3941            while (this.input.length > this.pos && this.input[this.pos] != '@') {
3942                this$1.pos++;
3943            }
3944
3945            if (this.input[this.pos] == '@') {
3946                return true;
3947            }
3948            return false;
3949        };
3950
3951        this.skipWhitespace = function(canCommentOut) {
3952            var this$1 = this;
3953
3954            while (this.isWhitespace(this.input[this.pos])) {
3955                this$1.pos++;
3956            }
3957            if (this.input[this.pos] == "%" && canCommentOut == true) {
3958                while (this.input[this.pos] != "\n") {
3959                    this$1.pos++;
3960                }
3961                this.skipWhitespace(canCommentOut);
3962            }
3963        };
3964
3965        this.value_braces = function() {
3966            var this$1 = this;
3967
3968            var bracecount = 0;
3969            this.match("{", false);
3970            var start = this.pos;
3971            var escaped = false;
3972            while (true) {
3973                if (!escaped) {
3974                    if (this$1.input[this$1.pos] == '}') {
3975                        if (bracecount > 0) {
3976                            bracecount--;
3977                        } else {
3978                            var end = this$1.pos;
3979                            this$1.match("}", false);
3980                            return this$1.input.substring(start, end);
3981                        }
3982                    } else if (this$1.input[this$1.pos] == '{') {
3983                        bracecount++;
3984                    } else if (this$1.pos >= this$1.input.length - 1) {
3985                        throw "Unterminated value";
3986                    }
3987                }
3988                if (this$1.input[this$1.pos] == '\\' && escaped == false)
3989                    { escaped = true; }
3990                else
3991                    { escaped = false; }
3992                this$1.pos++;
3993            }
3994        };
3995
3996        this.value_comment = function() {
3997            var this$1 = this;
3998
3999            var str = '';
4000            var brcktCnt = 0;
4001            while (!(this.tryMatch("}", false) && brcktCnt == 0)) {
4002                str = str + this$1.input[this$1.pos];
4003                if (this$1.input[this$1.pos] == '{')
4004                    { brcktCnt++; }
4005                if (this$1.input[this$1.pos] == '}')
4006                    { brcktCnt--; }
4007                if (this$1.pos >= this$1.input.length - 1) {
4008                    throw "Unterminated value:" + this$1.input.substring(start);
4009                }
4010                this$1.pos++;
4011            }
4012            return str;
4013        };
4014
4015        this.value_quotes = function() {
4016            var this$1 = this;
4017
4018            this.match('"', false);
4019            var start = this.pos;
4020            var escaped = false;
4021            while (true) {
4022                if (!escaped) {
4023                    if (this$1.input[this$1.pos] == '"') {
4024                        var end = this$1.pos;
4025                        this$1.match('"', false);
4026                        return this$1.input.substring(start, end);
4027                    } else if (this$1.pos >= this$1.input.length - 1) {
4028                        throw "Unterminated value:" + this$1.input.substring(start);
4029                    }
4030                }
4031                if (this$1.input[this$1.pos] == '\\' && escaped == false)
4032                    { escaped = true; }
4033                else
4034                    { escaped = false; }
4035                this$1.pos++;
4036            }
4037        };
4038
4039        this.single_value = function() {
4040            var start = this.pos;
4041            if (this.tryMatch("{")) {
4042                return this.value_braces();
4043            } else if (this.tryMatch('"')) {
4044                return this.value_quotes();
4045            } else {
4046                var k = this.key();
4047                if (k.match("^[0-9]+$"))
4048                    { return k; }
4049                else if (this.months.indexOf(k.toLowerCase()) >= 0)
4050                    { return k.toLowerCase(); }
4051                else
4052                    { throw "Value expected:" + this.input.substring(start) + ' for key: ' + k; }
4053            
4054            }
4055        };
4056
4057        this.value = function() {
4058            var this$1 = this;
4059
4060            var values = [];
4061            values.push(this.single_value());
4062            while (this.tryMatch("#")) {
4063                this$1.match("#");
4064                values.push(this$1.single_value());
4065            }
4066            return values.join("");
4067        };
4068
4069        this.key = function() {
4070            var this$1 = this;
4071
4072            var start = this.pos;
4073            while (true) {
4074                if (this$1.pos >= this$1.input.length) {
4075                    throw "Runaway key";
4076                }
4077                                // а-яА-Я is Cyrillic
4078                //console.log(this.input[this.pos]);
4079                if (this$1.notKey.indexOf(this$1.input[this$1.pos]) >= 0) {
4080                    return this$1.input.substring(start, this$1.pos);
4081                } else {
4082                    this$1.pos++;
4083                    
4084                }
4085            }
4086        };
4087
4088        this.key_equals_value = function() {
4089            var key = this.key();
4090            if (this.tryMatch("=")) {
4091                this.match("=");
4092                var val = this.value();
4093                return [ key, val ];
4094            } else {
4095                throw "... = value expected, equals sign missing:"
4096                        + this.input.substring(this.pos);
4097            }
4098        };
4099
4100        this.key_value_list = function() {
4101            var this$1 = this;
4102
4103            var kv = this.key_equals_value();
4104            this.currentEntry['entryTags'] = {};
4105            this.currentEntry['entryTags'][kv[0]] = kv[1];
4106            while (this.tryMatch(",")) {
4107                this$1.match(",");
4108                // fixes problems with commas at the end of a list
4109                if (this$1.tryMatch("}")) {
4110                    break;
4111                }
4112                
4113                kv = this$1.key_equals_value();
4114                this$1.currentEntry['entryTags'][kv[0]] = kv[1];
4115            }
4116        };
4117
4118        this.entry_body = function(d) {
4119            this.currentEntry = {};
4120            this.currentEntry['citationKey'] = this.key();
4121            this.currentEntry['entryType'] = d.substring(1);
4122            this.match(",");
4123            this.key_value_list();
4124            this.entries.push(this.currentEntry);
4125        };
4126
4127        this.directive = function() {
4128            this.match("@");
4129            return "@" + this.key();
4130        };
4131
4132        this.preamble = function() {
4133            this.currentEntry = {};
4134            this.currentEntry['entryType'] = 'PREAMBLE';
4135            this.currentEntry['entry'] = this.value_comment();
4136            this.entries.push(this.currentEntry);
4137        };
4138
4139        this.comment = function() {
4140            this.currentEntry = {};
4141            this.currentEntry['entryType'] = 'COMMENT';
4142            this.currentEntry['entry'] = this.value_comment();
4143            this.entries.push(this.currentEntry);
4144        };
4145
4146        this.entry = function(d) {
4147            this.entry_body(d);
4148        };
4149
4150        this.bibtex = function() {
4151            var this$1 = this;
4152
4153            while (this.matchAt()) {
4154                var d = this$1.directive();
4155                this$1.match("{");
4156                if (d == "@STRING") {
4157                    this$1.string();
4158                } else if (d == "@PREAMBLE") {
4159                    this$1.preamble();
4160                } else if (d == "@COMMENT") {
4161                    this$1.comment();
4162                } else {
4163                    this$1.entry(d);
4164                }
4165                this$1.match("}");
4166            }
4167        };
4168    }
4169    
4170    exports.toJSON = function(bibtex) {
4171        var b = new BibtexParser();
4172        b.setInput(bibtex);
4173        b.bibtex();
4174        return b.entries;
4175    };
4176
4177    /* added during hackathon don't hate on me */
4178    exports.toBibtex = function(json) {
4179        var out = '';
4180        for ( var i in json) {
4181            out += "@" + json[i].entryType;
4182            out += '{';
4183            if (json[i].citationKey)
4184                { out += json[i].citationKey + ', '; }
4185            if (json[i].entry)
4186                { out += json[i].entry ; }
4187            if (json[i].entryTags) {
4188                var tags = '';
4189                for (var jdx in json[i].entryTags) {
4190                    if (tags.length != 0)
4191                        { tags += ', '; }
4192                    tags += jdx + '= {' + json[i].entryTags[jdx] + '}';
4193                }
4194                out += tags;
4195            }
4196            out += '}\n\n';
4197        }
4198        return out;
4199        
4200    };
4201
4202})(exports);
4203
4204/* end bibtexParse */
4205});
4206
4207var bibliography = function(dom, data) {
4208  var el = dom.querySelector('script[type="text/bibliography"]');
4209  var bibliography = {};
4210  //TODO If we don't have a local element, make a request for the document.
4211  if (el) {
4212    var rawBib = el.textContent;
4213    var parsed = bibtexParse.toJSON(rawBib);
4214    if(parsed) {
4215      parsed.forEach(function (e) {
4216        for (var k in e.entryTags){
4217          var val = e.entryTags[k];
4218          val = val.replace(/[\t\n ]+/g, " ");
4219          val = val.replace(/{\\["^`\.'acu~Hvs]( )?([a-zA-Z])}/g,
4220                            function (full, x, char) { return char; });
4221          val = val.replace(/{\\([a-zA-Z])}/g,
4222                            function (full, char) { return char; });
4223          e.entryTags[k.toLowerCase()] = val;
4224        }
4225        bibliography[e.citationKey] = e.entryTags;
4226        bibliography[e.citationKey].type = e.entryType;
4227      });
4228    }
4229  }
4230  data.bibliography = bibliography;
4231};
4232
4233var t0 = new Date;
4234var t1 = new Date;
4235
4236function newInterval(floori, offseti, count, field) {
4237
4238  function interval(date) {
4239    return floori(date = new Date(+date)), date;
4240  }
4241
4242  interval.floor = interval;
4243
4244  interval.ceil = function(date) {
4245    return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date;
4246  };
4247
4248  interval.round = function(date) {
4249    var d0 = interval(date),
4250        d1 = interval.ceil(date);
4251    return date - d0 < d1 - date ? d0 : d1;
4252  };
4253
4254  interval.offset = function(date, step) {
4255    return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date;
4256  };
4257
4258  interval.range = function(start, stop, step) {
4259    var range = [];
4260    start = interval.ceil(start);
4261    step = step == null ? 1 : Math.floor(step);
4262    if (!(start < stop) || !(step > 0)) { return range; } // also handles Invalid Date
4263    do { range.push(new Date(+start)); } while (offseti(start, step), floori(start), start < stop)
4264    return range;
4265  };
4266
4267  interval.filter = function(test) {
4268    return newInterval(function(date) {
4269      if (date >= date) { while (floori(date), !test(date)) { date.setTime(date - 1); } }
4270    }, function(date, step) {
4271      if (date >= date) { while (--step >= 0) { while (offseti(date, 1), !test(date)) {} } } // eslint-disable-line no-empty
4272    });
4273  };
4274
4275  if (count) {
4276    interval.count = function(start, end) {
4277      t0.setTime(+start), t1.setTime(+end);
4278      floori(t0), floori(t1);
4279      return Math.floor(count(t0, t1));
4280    };
4281
4282    interval.every = function(step) {
4283      step = Math.floor(step);
4284      return !isFinite(step) || !(step > 0) ? null
4285          : !(step > 1) ? interval
4286          : interval.filter(field
4287              ? function(d) { return field(d) % step === 0; }
4288              : function(d) { return interval.count(0, d) % step === 0; });
4289    };
4290  }
4291
4292  return interval;
4293}
4294
4295var millisecond = newInterval(function() {
4296  // noop
4297}, function(date, step) {
4298  date.setTime(+date + step);
4299}, function(start, end) {
4300  return end - start;
4301});
4302
4303// An optimized implementation for this simple case.
4304millisecond.every = function(k) {
4305  k = Math.floor(k);
4306  if (!isFinite(k) || !(k >
vendor: 7,493 bytes, lines 4306-4555
4306 0)) { return null; }
4307  if (!(k > 1)) { return millisecond; }
4308  return newInterval(function(date) {
4309    date.setTime(Math.floor(date / k) * k);
4310  }, function(date, step) {
4311    date.setTime(+date + step * k);
4312  }, function(start, end) {
4313    return (end - start) / k;
4314  });
4315};
4316
4317var durationSecond = 1e3;
4318var durationMinute = 6e4;
4319var durationHour = 36e5;
4320var durationDay = 864e5;
4321var durationWeek = 6048e5;
4322
4323var second = newInterval(function(date) {
4324  date.setTime(Math.floor(date / durationSecond) * durationSecond);
4325}, function(date, step) {
4326  date.setTime(+date + step * durationSecond);
4327}, function(start, end) {
4328  return (end - start) / durationSecond;
4329}, function(date) {
4330  return date.getUTCSeconds();
4331});
4332
4333var minute = newInterval(function(date) {
4334  date.setTime(Math.floor(date / durationMinute) * durationMinute);
4335}, function(date, step) {
4336  date.setTime(+date + step * durationMinute);
4337}, function(start, end) {
4338  return (end - start) / durationMinute;
4339}, function(date) {
4340  return date.getMinutes();
4341});
4342
4343var hour = newInterval(function(date) {
4344  var offset = date.getTimezoneOffset() * durationMinute % durationHour;
4345  if (offset < 0) { offset += durationHour; }
4346  date.setTime(Math.floor((+date - offset) / durationHour) * durationHour + offset);
4347}, function(date, step) {
4348  date.setTime(+date + step * durationHour);
4349}, function(start, end) {
4350  return (end - start) / durationHour;
4351}, function(date) {
4352  return date.getHours();
4353});
4354
4355var day = newInterval(function(date) {
4356  date.setHours(0, 0, 0, 0);
4357}, function(date, step) {
4358  date.setDate(date.getDate() + step);
4359}, function(start, end) {
4360  return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay;
4361}, function(date) {
4362  return date.getDate() - 1;
4363});
4364
4365function weekday(i) {
4366  return newInterval(function(date) {
4367    date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7);
4368    date.setHours(0, 0, 0, 0);
4369  }, function(date, step) {
4370    date.setDate(date.getDate() + step * 7);
4371  }, function(start, end) {
4372    return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek;
4373  });
4374}
4375
4376var sunday = weekday(0);
4377var monday = weekday(1);
4378var tuesday = weekday(2);
4379var wednesday = weekday(3);
4380var thursday = weekday(4);
4381var friday = weekday(5);
4382var saturday = weekday(6);
4383
4384var month = newInterval(function(date) {
4385  date.setDate(1);
4386  date.setHours(0, 0, 0, 0);
4387}, function(date, step) {
4388  date.setMonth(date.getMonth() + step);
4389}, function(start, end) {
4390  return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12;
4391}, function(date) {
4392  return date.getMonth();
4393});
4394
4395var year = newInterval(function(date) {
4396  date.setMonth(0, 1);
4397  date.setHours(0, 0, 0, 0);
4398}, function(date, step) {
4399  date.setFullYear(date.getFullYear() + step);
4400}, function(start, end) {
4401  return end.getFullYear() - start.getFullYear();
4402}, function(date) {
4403  return date.getFullYear();
4404});
4405
4406// An optimized implementation for this simple case.
4407year.every = function(k) {
4408  return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) {
4409    date.setFullYear(Math.floor(date.getFullYear() / k) * k);
4410    date.setMonth(0, 1);
4411    date.setHours(0, 0, 0, 0);
4412  }, function(date, step) {
4413    date.setFullYear(date.getFullYear() + step * k);
4414  });
4415};
4416
4417var utcMinute = newInterval(function(date) {
4418  date.setUTCSeconds(0, 0);
4419}, function(date, step) {
4420  date.setTime(+date + step * durationMinute);
4421}, function(start, end) {
4422  return (end - start) / durationMinute;
4423}, function(date) {
4424  return date.getUTCMinutes();
4425});
4426
4427var utcHour = newInterval(function(date) {
4428  date.setUTCMinutes(0, 0, 0);
4429}, function(date, step) {
4430  date.setTime(+date + step * durationHour);
4431}, function(start, end) {
4432  return (end - start) / durationHour;
4433}, function(date) {
4434  return date.getUTCHours();
4435});
4436
4437var utcDay = newInterval(function(date) {
4438  date.setUTCHours(0, 0, 0, 0);
4439}, function(date, step) {
4440  date.setUTCDate(date.getUTCDate() + step);
4441}, function(start, end) {
4442  return (end - start) / durationDay;
4443}, function(date) {
4444  return date.getUTCDate() - 1;
4445});
4446
4447function utcWeekday(i) {
4448  return newInterval(function(date) {
4449    date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7);
4450    date.setUTCHours(0, 0, 0, 0);
4451  }, function(date, step) {
4452    date.setUTCDate(date.getUTCDate() + step * 7);
4453  }, function(start, end) {
4454    return (end - start) / durationWeek;
4455  });
4456}
4457
4458var utcSunday = utcWeekday(0);
4459var utcMonday = utcWeekday(1);
4460var utcTuesday = utcWeekday(2);
4461var utcWednesday = utcWeekday(3);
4462var utcThursday = utcWeekday(4);
4463var utcFriday = utcWeekday(5);
4464var utcSaturday = utcWeekday(6);
4465
4466var utcMonth = newInterval(function(date) {
4467  date.setUTCDate(1);
4468  date.setUTCHours(0, 0, 0, 0);
4469}, function(date, step) {
4470  date.setUTCMonth(date.getUTCMonth() + step);
4471}, function(start, end) {
4472  return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12;
4473}, function(date) {
4474  return date.getUTCMonth();
4475});
4476
4477var utcYear = newInterval(function(date) {
4478  date.setUTCMonth(0, 1);
4479  date.setUTCHours(0, 0, 0, 0);
4480}, function(date, step) {
4481  date.setUTCFullYear(date.getUTCFullYear() + step);
4482}, function(start, end) {
4483  return end.getUTCFullYear() - start.getUTCFullYear();
4484}, function(date) {
4485  return date.getUTCFullYear();
4486});
4487
4488// An optimized implementation for this simple case.
4489utcYear.every = function(k) {
4490  return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) {
4491    date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k);
4492    date.setUTCMonth(0, 1);
4493    date.setUTCHours(0, 0, 0, 0);
4494  }, function(date, step) {
4495    date.setUTCFullYear(date.getUTCFullYear() + step * k);
4496  });
4497};
4498
4499function localDate(d) {
4500  if (0 <= d.y && d.y < 100) {
4501    var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L);
4502    date.setFullYear(d.y);
4503    return date;
4504  }
4505  return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L);
4506}
4507
4508function utcDate(d) {
4509  if (0 <= d.y && d.y < 100) {
4510    var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L));
4511    date.setUTCFullYear(d.y);
4512    return date;
4513  }
4514  return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L));
4515}
4516
4517function newYear(y) {
4518  return {y: y, m: 0, d: 1, H: 0, M: 0, S: 0, L: 0};
4519}
4520
4521function formatLocale(locale) {
4522  var locale_dateTime = locale.dateTime,
4523      locale_date = locale.date,
4524      locale_time = locale.time,
4525      locale_periods = locale.periods,
4526      locale_weekdays = locale.days,
4527      locale_shortWeekdays = locale.shortDays,
4528      locale_months = locale.months,
4529      locale_shortMonths = locale.shortMonths;
4530
4531  var periodRe = formatRe(locale_periods),
4532      periodLookup = formatLookup(locale_periods),
4533      weekdayRe = formatRe(locale_weekdays),
4534      weekdayLookup = formatLookup(locale_weekdays),
4535      shortWeekdayRe = formatRe(locale_shortWeekdays),
4536      shortWeekdayLookup = formatLookup(locale_shortWeekdays),
4537      monthRe = formatRe(locale_months),
4538      monthLookup = formatLookup(locale_months),
4539      shortMonthRe = formatRe(locale_shortMonths),
4540      shortMonthLookup = formatLookup(locale_shortMonths);
4541
4542  var formats = {
4543    "a": formatShortWeekday,
4544    "A": formatWeekday,
4545    "b": formatShortMonth,
4546    "B": formatMonth,
4547    "c": null,
4548    "d": formatDayOfMonth,
4549    "e": formatDayOfMonth,
4550    "H": formatHour24,
4551    "I": formatHour12,
4552    "j": formatDayOfYear,
4553    "L": formatMilliseconds,
4554    "m": formatMonthNumber,
4555    "M": formatMinutes,
4556    "p": formatPeriod,
4557    "S": formatSeconds,
4558    "U": formatWeekNumberSunday,
4559    "w": formatWeekdayNumber,
4560    "W": formatWeekNumberMonday,
4561    "x": null,
4562    "X": null,
4563    "y": formatYear,
4564    "Y": formatFullYear,
4565    "Z": formatZone,
4566    "%": formatLiteralPercent
4567  };
4568
4569  var utcFormats = {
4570    "a": formatUTCShortWeekday,
4571    "A": formatUTCWeekday,
4572    "b": formatUTCShortMonth,
4573    "B": formatUTCMonth,
4574    "c": null,
4575    "d": formatUTCDayOfMonth,
4576    "e": formatUTCDayOfMonth,
4577    "H": formatUTCHour24,
4578    "I": formatUTCHour12,
4579    "j": formatUTCDayOfYear,
4580    "L": formatUTCMilliseconds,
4581    "m": formatUTCMonthNumber,
4582    "M": formatUTCMinutes,
4583    "p": formatUTCPeriod,
4584    "S": formatUTCSeconds,
4585    "U": formatUTCWeekNumberSunday,
4586    "w": formatUTCWeekdayNumber,
4587    "W": formatUTCWeekNumberMonday,
4588    "x": null,
4589    "X": null,
4590    "y": formatUTCYear,
4591    "Y": formatUTCFullYear,
4592    "Z": formatUTCZone,
4593    "%": formatLiteralPercent
4594  };
4595
4596  var parses = {
4597    "a": parseShortWeekday,
4598    "A": parseWeekday,
4599    "b": parseShortMonth,
4600    "B": parseMonth,
4601    "c": parseLocaleDateTime,
4602    "d": parseDayOfMonth,
4603    "e": parseDayOfMonth,
4604    "H": parseHour24,
4605    "I": parseHour24,
4606    "j": parseDayOfYear,
4607    "L": parseMilliseconds,
4608    "m": parseMonthNumber,
4609    "M": parseMinutes,
4610    "p": parsePeriod,
4611    "S": parseSeconds,
4612    "U": parseWeekNumberSunday,
4613    "w": parseWeekdayNumber,
4614    "W": parseWeekNumberMonday,
4615    "x": parseLocaleDate,
4616    "X": parseLocaleTime,
4617    "y": parseYear,
4618    "Y": parseFullYear,
4619    "Z": parseZone,
4620    "%": parseLiteralPercent
4621  };
4622
4623  // These recursive directive definitions must be deferred.
4624  formats.x = newFormat(locale_date, formats);
4625  formats.X = newFormat(locale_time, formats);
4626  formats.c = newFormat(locale_dateTime, formats);
4627  utcFormats.x = newFormat(locale_date, utcFormats);
4628  utcFormats.X = newFormat(locale_time, utcFormats);
4629  utcFormats.c = newFormat(locale_dateTime, utcFormats);
4630
4631  function newFormat(specifier, formats) {
4632    return function(date) {
4633      var string = [],
4634          i = -1,
4635          j = 0,
4636          n = specifier.length,
4637          c,
4638          pad,
4639          format;
4640
4641      if (!(date instanceof Date)) { date = new Date(+date); }
4642
4643      while (++i < n) {
4644        if (specifier.charCodeAt(i) === 37) {
4645          string.push(specifier.slice(j, i));
4646          if ((pad = pads[c = specifier.charAt(++i)]) != null) { c = specifier.charAt(++i); }
4647          else { pad = c === "e" ? " " : "0"; }
4648          if (format = formats[c]) { c = format(date, pad); }
4649          string.push(c);
4650          j = i + 1;
4651        }
4652      }
4653
4654      string.push(specifier.slice(j, i));
4655      return string.join("");
4656    };
4657  }
4658
4659  function newParse(specifier, newDate) {
4660    return function(string) {
4661      var d = newYear(1900),
4662          i = parseSpecifier(d, specifier, string += "", 0);
4663      if (i != string.length) { return null; }
4664
4665      // The am-pm flag is 0 for AM, and 1 for PM.
4666      if ("p" in d) { d.H = d.H % 12 + d.p * 12; }
4667
4668      // Convert day-of-week and week-of-year to day-of-year.
4669      if ("W" in d || "U" in d) {
4670        if (!("w" in d)) { d.w = "W" in d ? 1 : 0; }
4671        var day$$1 = "Z" in d ? utcDate(newYear(d.y)).getUTCDay() : newDate(newYear(d.y)).getDay();
4672        d.m = 0;
4673        d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day$$1 + 5) % 7 : d.w + d.U * 7 - (day$$1 + 6) % 7;
4674      }
4675
4676      // If a time zone is specified, all fields are interpreted as UTC and then
4677      // offset according to the specified time zone.
4678      if ("Z" in d) {
4679        d.H += d.Z / 100 | 0;
4680        d.M += d.Z % 100;
4681        return utcDate(d);
4682      }
4683
4684      // Otherwise, all fields are in local time.
4685      return newDate(d);
4686    };
4687  }
4688
4689  function parseSpecifier(d, specifier, string, j) {
4690    var i = 0,
4691        n = specifier.length,
4692        m = string.length,
4693        c,
4694        parse;
4695
4696    while (i < n) {
4697      if (j >= m) { return -1; }
4698      c = specifier.charCodeAt(i++);
4699      if (c === 37) {
4700        c = specifier.charAt(i++);
4701        parse = parses[c in pads ? specifier.charAt(i++) : c];
4702        if (!parse || ((j = parse(d, string, j)) < 0)) { return -1; }
4703      } else if (c != string.charCodeAt(j++)) {
4704        return -1;
4705      }
4706    }
4707
4708    return j;
4709  }
4710
4711  function parsePeriod(d, string, i) {
4712    var n = periodRe.exec(string.slice(i));
4713    return n ? (d.p = periodLookup[n[0].toLowerCase()], i + n[0].length) : -1;
4714  }
4715
4716  function parseShortWeekday(d, string, i) {
4717    var n = shortWeekdayRe.exec(string.slice(i));
4718    return n ? (d.w = shortWeekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
4719  }
4720
4721  function parseWeekday(d, string, i) {
4722    var n = weekdayRe.exec(string.slice(i));
4723    return n ? (d.w = weekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
4724  }
4725
4726  function parseShortMonth(d, string, i) {
4727    var n = shortMonthRe.exec(string.slice(i));
4728    return n ? (d.m = shortMonthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
4729  }
4730
4731  function parseMonth(d, string, i) {
4732    var n = monthRe.exec(string.slice(i));
4733    return n ? (d.m = monthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
4734  }
4735
4736  function parseLocaleDateTime(d, string, i) {
4737    return parseSpecifier(d, locale_dateTime, string, i);
4738  }
4739
4740  function parseLocaleDate(d, string, i) {
4741    return parseSpecifier(d, locale_date, string, i);
4742  }
4743
4744  function parseLocaleTime(d, string, i) {
4745    return parseSpecifier(d, locale_time, string, i);
4746  }
4747
4748  function formatShortWeekday(d) {
4749    return locale_shortWeekdays[d.getDay()];
4750  }
4751
4752  function formatWeekday(d) {
4753    return locale_weekdays[d.getDay()];
4754  }
4755
4756  function formatShortMonth(d) {
4757    return locale_shortMonths[d.getMonth()];
4758  }
4759
4760  function formatMonth(d) {
4761    return locale_months[d.getMonth()];
4762  }
4763
4764  function formatPeriod(d) {
4765    return locale_periods[+(d.getHours() >= 12)];
4766  }
4767
4768  function formatUTCShortWeekday(d) {
4769    return locale_shortWeekdays[d.getUTCDay()];
4770  }
4771
4772  function formatUTCWeekday(d) {
4773    return locale_weekdays[d.getUTCDay()];
4774  }
4775
4776  function formatUTCShortMonth(d) {
4777    return locale_shortMonths[d.getUTCMonth()];
4778  }
4779
4780  function formatUTCMonth(d) {
4781    return locale_months[d.getUTCMonth()];
4782  }
4783
4784  function formatUTCPeriod(d) {
4785    return locale_periods[+(d.getUTCHours() >= 12)];
4786  }
4787
4788  return {
4789    format: function(specifier) {
4790      var f = newFormat(specifier += "", formats);
4791      f.toString = function() { return specifier; };
4792      return f;
4793    },
4794    parse: function(specifier) {
4795      var p = newParse(specifier += "", localDate);
4796      p.toString = function() { return specifier; };
4797      return p;
4798    },
4799    utcFormat: function(specifier) {
4800      var f = newFormat(specifier += "", utcFormats);
4801      f.toString = function() { return specifier; };
4802      return f;
4803    },
4804    utcParse: function(specifier) {
4805      var p = newParse(specifier, utcDate);
4806      p.toString = function() { return specifier; };
4807      return p;
4808    }
4809  };
4810}
4811
4812var pads = {"-": "", "_": " ", "0": "0"};
4813var numberRe = /^\s*\d+/;
4814var percentRe = /^%/;
4815var requoteRe = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
4816
4817function pad(value, fill, width) {
4818  var sign = value < 0 ? "-" : "",
vendor: 5,310 bytes, lines 4819-5040
4819      string = (sign ? -value : value) + "",
4820      length = string.length;
4821  return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);
4822}
4823
4824function requote(s) {
4825  return s.replace(requoteRe, "\\$&");
4826}
4827
4828function formatRe(names) {
4829  return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i");
4830}
4831
4832function formatLookup(names) {
4833  var map = {}, i = -1, n = names.length;
4834  while (++i < n) { map[names[i].toLowerCase()] = i; }
4835  return map;
4836}
4837
4838function parseWeekdayNumber(d, string, i) {
4839  var n = numberRe.exec(string.slice(i, i + 1));
4840  return n ? (d.w = +n[0], i + n[0].length) : -1;
4841}
4842
4843function parseWeekNumberSunday(d, string, i) {
4844  var n = numberRe.exec(string.slice(i));
4845  return n ? (d.U = +n[0], i + n[0].length) : -1;
4846}
4847
4848function parseWeekNumberMonday(d, string, i) {
4849  var n = numberRe.exec(string.slice(i));
4850  return n ? (d.W = +n[0], i + n[0].length) : -1;
4851}
4852
4853function parseFullYear(d, string, i) {
4854  var n = numberRe.exec(string.slice(i, i + 4));
4855  return n ? (d.y = +n[0], i + n[0].length) : -1;
4856}
4857
4858function parseYear(d, string, i) {
4859  var n = numberRe.exec(string.slice(i, i + 2));
4860  return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1;
4861}
4862
4863function parseZone(d, string, i) {
4864  var n = /^(Z)|([+-]\d\d)(?:\:?(\d\d))?/.exec(string.slice(i, i + 6));
4865  return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1;
4866}
4867
4868function parseMonthNumber(d, string, i) {
4869  var n = numberRe.exec(string.slice(i, i + 2));
4870  return n ? (d.m = n[0] - 1, i + n[0].length) : -1;
4871}
4872
4873function parseDayOfMonth(d, string, i) {
4874  var n = numberRe.exec(string.slice(i, i + 2));
4875  return n ? (d.d = +n[0], i + n[0].length) : -1;
4876}
4877
4878function parseDayOfYear(d, string, i) {
4879  var n = numberRe.exec(string.slice(i, i + 3));
4880  return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1;
4881}
4882
4883function parseHour24(d, string, i) {
4884  var n = numberRe.exec(string.slice(i, i + 2));
4885  return n ? (d.H = +n[0], i + n[0].length) : -1;
4886}
4887
4888function parseMinutes(d, string, i) {
4889  var n = numberRe.exec(string.slice(i, i + 2));
4890  return n ? (d.M = +n[0], i + n[0].length) : -1;
4891}
4892
4893function parseSeconds(d, string, i) {
4894  var n = numberRe.exec(string.slice(i, i + 2));
4895  return n ? (d.S = +n[0], i + n[0].length) : -1;
4896}
4897
4898function parseMilliseconds(d, string, i) {
4899  var n = numberRe.exec(string.slice(i, i + 3));
4900  return n ? (d.L = +n[0], i + n[0].length) : -1;
4901}
4902
4903function parseLiteralPercent(d, string, i) {
4904  var n = percentRe.exec(string.slice(i, i + 1));
4905  return n ? i + n[0].length : -1;
4906}
4907
4908function formatDayOfMonth(d, p) {
4909  return pad(d.getDate(), p, 2);
4910}
4911
4912function formatHour24(d, p) {
4913  return pad(d.getHours(), p, 2);
4914}
4915
4916function formatHour12(d, p) {
4917  return pad(d.getHours() % 12 || 12, p, 2);
4918}
4919
4920function formatDayOfYear(d, p) {
4921  return pad(1 + day.count(year(d), d), p, 3);
4922}
4923
4924function formatMilliseconds(d, p) {
4925  return pad(d.getMilliseconds(), p, 3);
4926}
4927
4928function formatMonthNumber(d, p) {
4929  return pad(d.getMonth() + 1, p, 2);
4930}
4931
4932function formatMinutes(d, p) {
4933  return pad(d.getMinutes(), p, 2);
4934}
4935
4936function formatSeconds(d, p) {
4937  return pad(d.getSeconds(), p, 2);
4938}
4939
4940function formatWeekNumberSunday(d, p) {
4941  return pad(sunday.count(year(d), d), p, 2);
4942}
4943
4944function formatWeekdayNumber(d) {
4945  return d.getDay();
4946}
4947
4948function formatWeekNumberMonday(d, p) {
4949  return pad(monday.count(year(d), d), p, 2);
4950}
4951
4952function formatYear(d, p) {
4953  return pad(d.getFullYear() % 100, p, 2);
4954}
4955
4956function formatFullYear(d, p) {
4957  return pad(d.getFullYear() % 10000, p, 4);
4958}
4959
4960function formatZone(d) {
4961  var z = d.getTimezoneOffset();
4962  return (z > 0 ? "-" : (z *= -1, "+"))
4963      + pad(z / 60 | 0, "0", 2)
4964      + pad(z % 60, "0", 2);
4965}
4966
4967function formatUTCDayOfMonth(d, p) {
4968  return pad(d.getUTCDate(), p, 2);
4969}
4970
4971function formatUTCHour24(d, p) {
4972  return pad(d.getUTCHours(), p, 2);
4973}
4974
4975function formatUTCHour12(d, p) {
4976  return pad(d.getUTCHours() % 12 || 12, p, 2);
4977}
4978
4979function formatUTCDayOfYear(d, p) {
4980  return pad(1 + utcDay.count(utcYear(d), d), p, 3);
4981}
4982
4983function formatUTCMilliseconds(d, p) {
4984  return pad(d.getUTCMilliseconds(), p, 3);
4985}
4986
4987function formatUTCMonthNumber(d, p) {
4988  return pad(d.getUTCMonth() + 1, p, 2);
4989}
4990
4991function formatUTCMinutes(d, p) {
4992  return pad(d.getUTCMinutes(), p, 2);
4993}
4994
4995function formatUTCSeconds(d, p) {
4996  return pad(d.getUTCSeconds(), p, 2);
4997}
4998
4999function formatUTCWeekNumberSunday(d, p) {
5000  return pad(utcSunday.count(utcYear(d), d), p, 2);
5001}
5002
5003function formatUTCWeekdayNumber(d) {
5004  return d.getUTCDay();
5005}
5006
5007function formatUTCWeekNumberMonday(d, p) {
5008  return pad(utcMonday.count(utcYear(d), d), p, 2);
5009}
5010
5011function formatUTCYear(d, p) {
5012  return pad(d.getUTCFullYear() % 100, p, 2);
5013}
5014
5015function formatUTCFullYear(d, p) {
5016  return pad(d.getUTCFullYear() % 10000, p, 4);
5017}
5018
5019function formatUTCZone() {
5020  return "+0000";
5021}
5022
5023function formatLiteralPercent() {
5024  return "%";
5025}
5026
5027var locale$1;
5028var timeFormat;
5029var timeParse;
5030var utcFormat;
5031var utcParse;
5032
5033defaultLocale({
5034  dateTime: "%x, %X",
5035  date: "%-m/%-d/%Y",
5036  time: "%-I:%M:%S %p",
5037  periods: ["AM", "PM"],
5038  days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
5039  shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
5040  months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
5040November", "December"],
5041  shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
5042});
5043
5044function defaultLocale(definition) {
5045  locale$1 = formatLocale(definition);
5046  timeFormat = locale$1.format;
5047  timeParse = locale$1.parse;
5048  utcFormat = locale$1.utcFormat;
5049  utcParse = locale$1.utcParse;
5050  return locale$1;
5051}
5052
5053var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ";
5054
5055function formatIsoNative(date) {
5056  return date.toISOString();
5057}
5058
5059var formatIso = Date.prototype.toISOString
5060    ? formatIsoNative
5061    : utcFormat(isoSpecifier);
5062
5063function parseIsoNative(string) {
5064  var date = new Date(string);
5065  return isNaN(date) ? null : date;
5066}
5067
5068var parseIso = +new Date("2000-01-01T00:00:00.000Z")
5069    ? parseIsoNative
5070    : utcParse(isoSpecifier);
5071
5072var expandData = function(dom, data) {
5073
5074  //
5075  // Properties from source
5076  //
5077
5078  //   title: 'Attention and Augmented Recurrent Neural Networks',
5079  //   description: 'A visual overview of neural attention, and the powerful extensions of neural networks being built on top of it.',
5080  //   url: 'http://distill.pub/2016/augmented-rnns',
5081  //   tags: [ 'rnn' ],
5082  //   doiSuffix: 1,
5083  //   doi: '10.23915/distill.00001',
5084  //   volume: 1,
5085  //   issue: 9,
5086  //   distillPath: '2016/augmented-rnns',
5087  //   githubPath: 'distillpub/post--augmented-rnns',
5088  //   githubCompareUpdatesUrl: 'https://github.com/distillpub/post--augmented-rnns/compare/1596e094d8943d2dc0ea445d92071129c6419c59...3bd9209e0c24d020f87cf6152dcecc6017cbc193',
5089  //   updatedDate: 2017-03-21T07:13:16.000Z,
5090  //   publishedDate: 2016-09-08T07:00:00.000Z,
5091  //   journal: {
5092  //     "title": "Distill",
5093  //     "full_title": "Distill",
5094  //     "abbrev_title": "Distill",
5095  //     "url": "http://distill.pub",
5096  //     "doi": "10.23915/distill",
5097  //     "publisherName": "Distill Working Group",
5098  //     "publisherEmail": "[email protected]",
5099  //     "issn": "2476-0757",
5100  //     "editors": [...],
5101  //     "committee": [...]
5102  //   }
5103
5104  //
5105  // Computed Properties
5106  //
5107
5108  //   githubUrl: 'https://github.com/distillpub/post--augmented-rnns',
5109  //   previewURL: 'http://distill.pub/2016/augmented-rnns/thumbnail.jpg',
5110  //   publishedDateRFC: 'Thu, 08 Sep 2016 00:00:00 -0700',
5111  //   publishedYear: 2016,
5112  //   publishedMonth: 'Sept',
5113  //   publishedDay: 8,
5114  //   publishedMonthPadded: '09',
5115  //   publishedDayPadded: '08',
5116  //   updatedDateRFC: 'Tue, 21 Mar 2017 00:13:16 -0700',
5117  //   concatenatedAuthors: 'Olah & Carter',
5118  //   bibtexAuthors: 'Olah, Chris and Carter, Shan',
5119  //   slug: 'olah2016attention'
5120  //   authors: [
5121  //     {
5122  //       "personalURL": null,
5123  //       "name": "Chris Olah",
5124  //       "firstName": "Chris",
5125  //       "lastName": "Olah",
5126  //       "affiliationURL": null,
5127  //       "affiliation": "Google Brain"
5128  //     }
5129  //   ],
5130  //   bibliography: {
5131  //     "gregor2015draw": {
5132  //       "title": "DRAW: A recurrent neural network for image generation",
5133  //       "author": "Gregor, Karol and Danihelka, Ivo and Graves, Alex and Rezende, Danilo Jimenez and Wierstra, Daan",
5134  //       "journal": "arXiv preprint arXiv:1502.04623",
5135  //       "year": "2015",
5136  //       "url": "https://arxiv.org/pdf/1502.04623.pdf",
5137  //       "type": "article"
5138  //     },
5139  //     ...
5140  //   },
5141  //   citations: [
5142  //     "gregor2015draw",
5143  //     "mercier2011humans",
5144  //     "dong2014image",
5145  //     "dumoulin2016guide",
5146  //     "mordvintsev2015inceptionism"
5147  //   ],
5148
5149
5150  // citations:
5151  var citations = [];
5152  var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
5153  citeTags.forEach(function (el) {
5154    var key = el.getAttribute("key");
5155    if (key) {
5156      var citationKeys = key.split(",");
5157      citationKeys.forEach(function (key) {
5158        if (citations.indexOf(key) == -1){
5159          citations.push(key);
5160          if (!(key in data.bibliography)){
5161            console.warn("No bibliography entry found for: " + key);
5162          }
5163        }
5164      });
5165    }
5166  });
5167  data.citations = citations;
5168
5169
5170  data.authors = data.authors || [];
5171
5172  // paths
5173  if (!data.distillPath && !data.url) {
5174    data.url = "http://distill.pub/";
5175  } else if (!data.url) {
5176    data.url = "http://distill.pub/" + data.distillPath;
5177  }
5178  data.githubUrl = "https://github.com/" + data.githubPath;
5179
5180  data.previewURL = data.previewURL ? data.previewURL : data.url + "/thumbnail.jpg";
5181
5182  // Homepage
5183  //data.homepage = !post.noHomepage;
5184  data.journal = data.journal || {};
5185
5186  // Dates
5187  if (data.publishedDate){//} && data.journal) {
5188    data.volume = data.publishedDate.getFullYear() - 2015;
5189    data.issue = data.publishedDate.getMonth() + 1;
5190  }
5191
5192  data.publishedDate = data.publishedDate ? data.publishedDate : new Date("Invalid");
5193  data.updatedDate = data.updatedDate ? data.updatedDate : new Date("Invalid");
5194
5195  data.publishedDateRFC;
5196  var RFC = timeFormat("%a, %d %b %Y %H:%M:%S %Z");
5197  var months = ["Jan", "Feb", "March", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
5198  var zeroPad = function (n) { return n < 10 ? "0" + n : n; };
5199  data.publishedDateRFC = RFC(data.publishedDate);
5200  data.publishedYear = data.publishedDate.getFullYear();
5201  data.publishedMonth = months[data.publishedDate.getMonth()];
5202  data.publishedDay = data.publishedDate.getDate();
5203  data.publishedMonthPadded = zeroPad(data.publishedDate.getMonth() + 1);
5204  data.publishedDayPadded = zeroPad(data.publishedDate.getDate());
5205  data.updatedDateRFC = RFC(data.updatedDate);
5206
5207  if (data.authors.length  > 2) {
5208    data.concatenatedAuthors = data.authors[0].lastName + ", et al.";
5209  } else if (data.authors.length === 2) {
5210    data.concatenatedAuthors = data.authors[0].lastName + " & " + data.authors[1].lastName;
5211  } else if (data.authors.length === 1) {
5212    data.concatenatedAuthors = data.authors[0].lastName;
5213  }
5214
5215  data.bibtexAuthors = data.authors.map(function(author){
5216    return author.lastName + ", " + author.firstName;
5217  }).join(" and ");
5218
5219  data.slug = data.authors.length ? data.authors[0].lastName.toLowerCase() + data.publishedYear + data.title.split(" ")[0].toLowerCase() : "Untitled";
5220
5221};
5222
5223// public domain globe icon from noun project.
5224
5225var favicon = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAmRQTFRFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////D1IORgAAAMp0Uk5TAAIpe67M3vbkvKx+LgM9ltu+h9JNT4zPm2aIspg+HLbjoBoSATqqfwofah07sYGFohamYgaJR1UjszmUdh6wYARdukVIeXc4tzJTG1gMq0RKuA10lwVwvQ4lxCYUCY3nhjytcoJMF5KdQZGTaZ8Yr5pUjkvTUggtwDCAxqRnMXE2B1HNj6iEJ54vtZWcqe1sE2HOISRobnzyv2/D+2SKUCJzWaO5NMo/XDcqme8spWMoxRWQ3aHJEX2LIEYzTmU1Ql546Mjc5f7z2mrbutMAAAABYktHR
5225MuEswZwAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC+klEQVQ4y2VT+yNTcRQ/K6pdmzWyZGYe12tsNGN5bJbXVmx5DEnezzy2hZDmMaFSIqKiB7G8KpUQpff7r+r7vfei9P3hfD/nc8493+/53s8B2FqsPXsdHPft/32ATThxuLB7sZx5B/kurofcBIfdj3gIPUW7Urw8xN4+vn58EZD+AYFBwRKhIOTveKhUFhZ+FLjyCOSEyGUKCI4U+u/Eo8TKY9ExCMTGYVeljgfQHE9I3P5enATJkSRCKZ4UodWdQPYkm6mRqk4DveEUhukZmRSVZcxGNidXhR3SJYwLMQGnMc47k08lnFVHARQUFhWzkFNSivLKyqmAXldBV5XEsiqrqs+xRahAjQQRtXV0oJ7ZTeYUqcAEshoWcAhUgLScpwMNgdQW1NjkeKEZoKX1IrRdygNQWEV0QruVC80dyQZ5rY8CuRp5J1hzhYKKfKKLem9b9+XOnl5zX2OmSXoFM2FXIdr5Wll9v3fpdSOPd2Mg4Wb4YOIQzq1W4oRbw9A6gk64ndEWUTca76bNi05jXq9wDNs7d+FeJZXPtAeWcQYMyvBvmbgPfJwAxgcM3/eQAY+MJHgNWJsgYRK7HlMM/1hto4FoWiGa6bE/AfMsdudqSZrvmPCiwTy7kC9pDuVDQA9ueEFdSfNDfOpFsu2Woh4OuskiZD1dfMYCmzydkd7zJdDb4+RCwtCM75YDL15aE+rH5nkyrkaj0JtapOxYwlysfJW2jOIjUg6QVXX57VVSx9eGlRU5ISxddWwvWUOxNynIxK2jq4WqN4DMnCRi3ybNvhvRb+r01FmeS6hAP9YUGRmJJe7Wu0YF8mnN+DnYQbPcR/Xma55D1rYiYTTTiLfN8AJ4TzAta3VuyHbp7DuaYS22g1L3YUvWH8WfNACjRCqlGSdkEh1UETrRzmDMlzaowOZi9UV4dJoLXtLP64T9n9Hri55S6csNMSSU8P021F/Y5am7hjdUoOblWIZ53RWuvK/f1rX/zze3Zdxz5vuPn79W3QcXWNv0HyS7tfF6BtqkAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE4LTAzLTE4VDAzOjUwOjIwKzAwOjAwGmFsmwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOC0wMy0xOFQwMzo1MDoyMCswMDowMGs81CcAAABGdEVYdHNvZnR3YXJlAEltYWdlTWFnaWNrIDYuNy44LTkgMjAxNC0wNS0xMiBRMTYgaHR0cDovL3d3dy5pbWFnZW1hZ2ljay5vcmfchu0AAAAAGHRFWHRUaHVtYjo6RG9jdW1lbnQ6OlBhZ2VzADGn/7svAAAAGHRFWHRUaHVtYjo6SW1hZ2U6OmhlaWdodAAxOTIPAHKFAAAAF3RFWHRUaHVtYjo6SW1hZ2U6OldpZHRoADE5MtOsIQgAAAAZdEVYdFRodW1iOjpNaW1ldHlwZQBpbWFnZS9wbmc/slZOAAAAF3RFWHRUaHVtYjo6TVRpbWUAMTUyMTM0NTAyMKksCbEAAAAPdEVYdFRodW1iOjpTaXplADBCQpSiPuwAAABWdEVYdFRodW1iOjpVUkkAZmlsZTovLy9tbnRsb2cvZmF2aWNvbnMvMjAxOC0wMy0xOC8zYjM5OTBjZjQ5ZmM0ZDAxN2ZkOWUyMDdlZjVkZmI0My5pY28ucG5nfb1JtgAAAABJRU5ErkJggg==\n";
5226
5227/*!
5228 * escape-html
5229 * Copyright(c) 2012-2013 TJ Holowaychuk
5230 * Copyright(c) 2015 Andreas Lubbe
5231 * Copyright(c) 2015 Tiancheng "Timothy" Gu
5232 * MIT Licensed
5233 */
5234
5235/**
5236 * Module variables.
5237 * @private
5238 */
5239
5240var matchHtmlRegExp = /["'&<>]/;
5241
5242/**
5243 * Module exports.
5244 * @public
5245 */
5246
5247var index$1 = escapeHtml;
5248
5249/**
5250 * Escape special characters in the given string of html.
5251 *
5252 * @param  {string} string The string to escape for inserting into HTML
5253 * @return {string}
5254 * @public
5255 */
5256
5257function escapeHtml(string) {
5258  var str = '' + string;
5259  var match = matchHtmlRegExp.exec(str);
5260
5261  if (!match) {
5262    return str;
5263  }
5264
5265  var escape;
5266  var html = '';
5267  var index = 0;
5268  var lastIndex = 0;
5269
5270  for (index = match.index; index < str.length; index++) {
5271    switch (str.charCodeAt(index)) {
5272      case 34: // "
5273        escape = '&quot;';
5274        break;
5275      case 38: // &
5276        escape = '&amp;';
5277        break;
5278      case 39: // '
5279        escape = '&#39;';
5280        break;
5281      case 60: // <
5282        escape = '&lt;';
5283        break;
5284      case 62: // >
5285        escape = '&gt;';
5286        break;
5287      default:
5288        continue;
5289    }
5290
5291    if (lastIndex !== index) {
5292      html += str.substring(lastIndex, index);
5293    }
5294
5295    lastIndex = index + 1;
5296    html += escape;
5297  }
5298
5299  return lastIndex !== index
5300    ? html + str.substring(lastIndex, index)
5301    : html;
5302}
5303
5304var meta = function(dom, data) {
5305  var head = dom.querySelector("head");
5306  var appendHead = function (html) { return appendHtml(head, html); };
5307
5308  function meta(name, content, force) {
5309    if (content || force)
5310      { appendHead(("    <meta name=\"" + name + "\" content=\"" + (index$1(content)) + "\" >\n")); }
5311  }
5312
5313  appendHead(("\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge,chrome=1\">\n    <link rel=\"icon\" type=\"image/png\" href=\"data:image/png;base64," + favicon + "\">\n    <link href=\"/rss.xml\" rel=\"alternate\" type=\"application/rss+xml\" title=\"Articles from Distill\">\n    <link rel=\"canonical\" href=\"" + (data.url) + "\">\n    <title>" + (data.title) + "</title>\n  "));
5314
5315  appendHead(("\n    <!--  https://schema.org/Article -->\n    <meta property=\"article:published\" itemprop=\"datePublished\" content=\"" + (data.publishedYear) + "-" + (data.publishedMonthPadded) + "-" + (data.publishedDayPadded) + "\" />\n    <meta property=\"article:created\" itemprop=\"dateCreated\" content=\"" + (data.publishedDate) + "\" />\n    <meta property=\"article:modified\" itemprop=\"dateModified\" content=\"" + (data.updatedDate) + "\" />\n  "));
5316  data.authors.forEach(function (a) {
5317    appendHtml(head, ("\n      <meta property=\"article:author\" content=\"" + (a.firstName) + " " + (a.lastName) + "\" />"));
5318  });
5319
5320  /* do this on my own.
5321  appendHead(("\n    <!--  https://developers.facebook.com/docs/sharing/webmasters#markup -->\n    <meta property=\"og:type\" content=\"article\"/>\n    <meta property=\"og:title\" content=\"" + (data.title) + "\"/>\n    <meta property=\"og:description\" content=\"" + (data.description) + "\">\n    <meta property=\"og:url\" content=\"" + (data.url) + "\"/>\n    <meta property=\"og:image\" content=\"" + (data.previewURL) + "\"/>\n    <meta property=\"og:locale\" content=\"en_US\" />\n    <meta property=\"og:site_name\" content=\"Distill\" />\n  "));
5322
5323  appendHead(("\n    <!--  https://dev.twitter.com/cards/types/summary -->\n    <meta name=\"twitter:card\" content=\"summary_large_image\">\n    <meta name=\"twitter:title\" content=\"" + (data.title) + "\">\n    <meta name=\"twitter:description\" content=\"" + (data.description) + "\">\n    <meta name=\"twitter:url\" content=\"" + (data.url) + "\">\n    <meta name=\"twitter:image\" content=\"" + (data.previewURL) + "\">\n    <meta name=\"twitter:image:width\" content=\"560\">\n    <meta name=\"twitter:image:height\" content=\"295\">\n  "));
5324  */
5325
5326  // if this is a proprer article, generate Google Scholar meta data
5327  if (data.doiSuffix){
5328    appendHead("\n      <!--  https://scholar.google.com/intl/en/scholar/inclusion.html#indexing -->\n");
5329
5330    meta("citation_title", data.title);
5331    //meta("citation_fulltext_html_url", data.url);
5332    meta("citation_volume", data.volume);
5333    meta("citation_issue", data.issue);
5334    meta("citation_firstpage", data.doiSuffix? ("e" + (data.doiSuffix)) : undefined);
5335    meta("citation_doi", data.doi);
5336
5337    var journal = data.journal || {};
5338    meta("citation_journal_title", journal.full_title || journal.title);
5339    meta("citation_journal_abbrev", journal.abbrev_title);
5340    meta("citation_issn", journal.issn);
5341    meta("citation_publisher", journal.publisher);
5342    meta("citation_fulltext_world_readable", "", true);
5343
5344    if (data.publishedDate){
5345      var zeroPad = function (n) { return n < 10 ? "0" + n : n; };
5346      meta("citation_online_date", ((data.publishedYear) + "/" + (data.publishedMonthPadded) + "/" + (data.publishedDayPadded)));
5347      // Should we do something different here?
5348      meta("citation_publication_date", ((data.publishedYear) + "/" + (data.publishedMonthPadded) + "/" + (data.publishedDayPadded)));
5349    }
5350
5351    (data.authors || []).forEach(function (a) {
5352        meta("citation_author", ((a.lastName) + ", " + (a.firstName)));
5353        meta("citation_author_institution", a.affiliation);
5354    });
5355
5356    if (data.citations) {
5357      data.citations.forEach(function (key) {
5358        var d = data.bibliography[key];
5359        if(!d) {
5360          console.warn("No bibliography data fround for " + key);
5361        } else {
5362          meta("citation_reference", citation_meta_content(data.bibliography[key]) );
5363        }
5364      });
5365    }
5366  }
5367};
5368
5369function appendHtml(el, html) {
5370  el.innerHTML += html;
5371}
5372
5373function citation_meta_content(ref){
5374  // Special test for arxiv
5375  var content = "citation_title=" + (ref.title) + ";";
5376
5377  var name_strings = ref.author.split(" and ").forEach(function (name) {
5378    name = name.trim();
5379    if (name.indexOf(",") != -1){
5380      var last = name.split(",")[0].trim();
5381      var firsts = name.split(",")[1].trim();
5382    } else {
5383      var last = name.split(" ").slice(-1)[0].trim();
5384      var firsts = name.split(" ").slice(0,-1).join(" ");
5385    }
5386    content += "citation_author=" + firsts + " " + last + ";";
5387  });
5388
5389  if ("year" in ref) {
5390    content += "citation_publication_date=" + (ref.year) + ";";
5391  }
5392
5393  var arxiv_id_search = /https?:\/\/arxiv\.org\/pdf\/([0-9]*\.[0-9]*)\.pdf/.exec(ref.url);
5394  arxiv_id_search = arxiv_id_search || /https?:\/\/arxiv\.org\/abs\/([0-9]*\.[0-9]*)/.exec(ref.url);
5395  arxiv_id_search = arxiv_id_search || /arXiv preprint arXiv:([0-9]*\.[0-9]*)/.exec(ref.journal);
5396  if (arxiv_id_search && arxiv_id_search[1]){
5397    content += "citation_arxiv_id=" + (arxiv_id_search[1]) + ";";
5398    return content;
5399  }
5400  if ("journal" in ref){
5401    content += "citation_journal_title=" + (ref.journal) + ";";
5402  }
5403  if ("volume" in ref) {
5404      content += "citation_volume=" + (ref.volume) + ";";
5405  }
5406  if ("issue" in ref || "number" in ref){
5407      content += "citation_number=" + (ref.issue || ref.number) + ";";
5408  }
5409  /*content += `citation_first_page=${};`;
5410  content += `citation_publication_date=${};`;*/
5411  return content;
5412}
5413
5414var html$1 = "";
5415//var html$1 = "\n<style>\n  dt-banner {\n    background: #FFF59D;\n    display: block;\n    text-align: center;\n    color: black;\n    height: 70px;\n    line-height: 70px;\n  }\n</style>\n<div>This article is a draft. Please do not share the URL. Thanks!</div>\n";
5416
5417var banner = function(dom, data) {
5418  var banner = dom.createElement("dt-banner");
5419  banner.innerHTML = html$1;
5420  var b = dom.querySelector("body");
5421  b.insertBefore(banner, b.firstChild);
5422  banner.addEventListener("click", function() {
5423    banner.style.display = "none";
5424  });
5425};
5426
5427var mustache = createCommonjsModule(function (module, exports) {
5428/*!
5429 * mustache.js - Logic-less {{mustache}} templates with JavaScript
5430 * http://github.com/janl/mustache.js
5431 */
5432
5433/*global define: false Mustache: true*/
5434
5435(function defineMustache (global, factory) {
5436  if ('object' === 'object' && exports && typeof exports.nodeName !== 'string') {
5437    factory(exports); // CommonJS
5438  } else if (typeof undefined === 'function' && undefined.amd) {
5439    undefined(['exports'], factory); // AMD
5440  } else {
5441    global.Mustache = {};
5442    factory(global.Mustache); // script, wsh, asp
5443  }
5444}(commonjsGlobal, function mustacheFactory (mustache) {
5445
5446  var objectToString = Object.prototype.toString;
5447  var isArray = Array.isArray || function isArrayPolyfill (object) {
5448    return objectToString.call(object) === '[object Array]';
5449  };
5450
5451  function isFunction (object) {
5452    return typeof object === 'function';
5453  }
5454
5455  /**
5456   * More correct typeof string handling array
5457   * which normally returns typeof 'object'
5458   */
5459  function typeStr (obj) {
5460    return isArray(obj) ? 'array' : typeof obj;
5461  }
5462
5463  function escapeRegExp (string) {
5464    return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
5465  }
5466
5467  /**
5468   * Null safe way of checking whether or not an object,
5469   * including its prototype, has a given property
5470   */
5471  function hasProperty (obj, propName) {
5472    return obj != null && typeof obj === 'object' && (propName in obj);
5473  }
5474
5475  // Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
5476  // See https://github.com/janl/mustache.js/issues/189
5477  var regExpTest = RegExp.prototype.test;
5478  function testRegExp (re, string) {
5479    return regExpTest.call(re, string);
5480  }
5481
5482  var nonSpaceRe = /\S/;
5483  function isWhitespace (string) {
5484    return !testRegExp(nonSpaceRe, string);
5485  }
5486
5487  var entityMap = {
5488    '&': '&amp;',
5489    '<': '&lt;',
5490    '>': '&gt;',
5491    '"': '&quot;',
5492    "'": '&#39;',
5493    '/': '&#x2F;',
5494    '`': '&#x60;',
5495    '=': '&#x3D;'
5496  };
5497
5498  function escapeHtml (string) {
5499    return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
5500      return entityMap[s];
5501    });
5502  }
5503
5504  var whiteRe = /\s*/;
5505  var spaceRe = /\s+/;
5506  var equalsRe = /\s*=/;
5507  var curlyRe = /\s*\}/;
5508  var tagRe = /#|\^|\/|>|\{|&|=|!/;
5509
5510  /**
5511   * Breaks up the given `template` string into a tree of tokens. If the `tags`
5512   * argument is given here it must be an array with two string values: the
5513   * opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
5514   * course, the default is to use mustaches (i.e. mustache.tags).
5515   *
5516   * A token is an array with at least 4 elements. The first element is the
5517   * mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
5518   * did not contain a symbol (i.e. {{myValue}}) this element is "name". For
5519   * all text that appears outside a symbol this element is "text".
5520   *
5521   * The second element of a token is its "value". For mustache tags this is
5522   * whatever else was inside the tag besides the opening symbol. For text tokens
5523   * this is the text itself.
5524   *
5525   * The third and fourth elements of the token are the start and end indices,
5526   * respectively, of the token in the original template.
5527   *
5528   * Tokens that are the root node of a subtree contain two more elements: 1) an
5529   * array of tokens in the subtree and 2) the index in the original template at
5530   * which the closing tag for that section begins.
5531   */
5532  function parseTemplate (template, tags) {
5533    if (!template)
5534      { return []; }
5535
5536    var sections = [];     // Stack to hold section tokens
5537    var tokens = [];       // Buffer to hold the tokens
5538    var spaces = [];       // Indices of whitespace tokens on the current line
5539    var hasTag = false;    // Is there a {{tag}} on the current line?
5540    var nonSpace = false;  // Is there a non-space char on the current line?
5541
5542    // Strips all whitespace tokens array for the current line
5543    // if there was a {{#tag}} on it and otherwise only space.
5544    function stripSpace () {
5545      if (hasTag && !nonSpace) {
5546        while (spaces.length)
5547          { delete tokens[spaces.pop()]; }
5548      } else {
5549        spaces = [];
5550      }
5551
5552      hasTag = false;
5553      nonSpace = false;
5554    }
5555
5556    var openingTagRe, closingTagRe, closingCurlyRe;
5557    function compileTags (tagsToCompile) {
5558      if (typeof tagsToCompile === 'string')
5559        { tagsToCompile = tagsToCompile.split(spaceRe, 2); }
5560
5561      if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
5562        { throw new Error('Invalid tags: ' + tagsToCompile); }
5563
5564      openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
5565      closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
5566      closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
5567    }
5568
5569    compileTags(tags || mustache.tags);
5570
5571    var scanner = new Scanner(template);
5572
5573    var start, type, value, chr, token, openSection;
5574    while (!scanner.eos()) {
5575      start = scanner.pos;
5576
5577      // Match any text between tags.
5578      value = scanner.scanUntil(openingTagRe);
5579
5580      if (value) {
5581        for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
5582          chr = value.charAt(i);
5583
5584          if (isWhitespace(chr)) {
5585            spaces.push(tokens.length);
5586          } else {
5587            nonSpace = true;
5588          }
5589
5590          tokens.push([ 'text', chr, start, start + 1 ]);
5591          start += 1;
5592
5593          // Check for whitespace on the current line.
5594          if (chr === '\n')
5595            { stripSpace(); }
5596        }
5597      }
5598
5599      // Match the opening tag.
5600      if (!scanner.scan(openingTagRe))
5601        { break; }
5602
5603      hasTag = true;
5604
5605      // Get the tag type.
5606      type = scanner.scan(tagRe) || 'name';
5607      scanner.scan(whiteRe);
5608
5609      // Get the tag value.
5610      if (type === '=') {
5611        value = scanner.scanUntil(equalsRe);
5612        scanner.scan(equalsRe);
5613        scanner.scanUntil(closingTagRe);
5614      } else if (type === '{') {
5615        value = scanner.scanUntil(closingCurlyRe);
5616        scanner.scan(curlyRe);
5617        scanner.scanUntil(closingTagRe);
5618        type = '&';
5619      } else {
5620        value = scanner.scanUntil(closingTagRe);
5621      }
5622
5623      // Match the closing tag.
5624      if (!scanner.scan(closingTagRe))
5625        { throw new Error('Unclosed tag at ' + scanner.pos); }
5626
5627      token = [ type, value, start, scanner.pos ];
5628      tokens.push(token);
5629
5630      if (type === '#' || type === '^') {
5631        sections.push(token);
5632      } else if (type === '/') {
5633        // Check section nesting.
5634        openSection = sections.pop();
5635
5636        if (!openSection)
5637          { throw new Error('Unopened section "' + value + '" at ' + start); }
5638
5639        if (openSection[1] !== value)
5640          { throw new Error('Unclosed section "' + openSection[1] + '" at ' + start); }
5641      } else if (type === 'name' || type === '{' || type === '&') {
5642        nonSpace = true;
5643      } else if (type === '=') {
5644        // Set the tags for the next time around.
5645        compileTags(value);
5646      }
5647    }
5648
5649    // Make sure there are no open sections when we're done.
5650    openSection = sections.pop();
5651
5652    if (openSection)
5653      { throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos); }
5654
5655    return nestTokens(squashTokens(tokens));
5656  }
5657
5658  /**
5659   * Combines the values of consecutive text tokens in the given `tokens` array
5660   * to a single token.
5661   */
5662  function squashTokens (tokens) {
5663    var squashedTokens = [];
5664
5665    var token, lastToken;
5666    for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
5667      token = tokens[i];
5668
5669      if (token) {
5670        if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
5671          lastToken[1] += token[1];
5672          lastToken[3] = token[3];
5673        } else {
5674          squashedTokens.push(token);
5675          lastToken = token;
5676        }
5677      }
5678    }
5679
5680    return squashedTokens;
5681  }
5682
5683  /**
5684   * Forms the given array of `tokens` into a nested tree structure where
5685   * tokens that represent a section have two additional items: 1) an array of
5686   * all tokens that appear in that section and 2) the index in the original
5687   * template that represents the end of that section.
5688   */
5689  function nestTokens (tokens) {
5690    var nestedTokens = [];
5691    var collector = nestedTokens;
5692    var sections = [];
5693
5694    var token, section;
5695    for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
5696      token = tokens[i];
5697
5698      switch (token[0]) {
5699        case '#':
5700        case '^':
5701          collector.push(token);
5702          sections.push(token);
5703          collector = token[4] = [];
5704          break;
5705        case '/':
5706          section = sections.pop();
5707          section[5] = token[2];
5708          collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
5709          break;
5710        default:
5711          collector.push(token);
5712      }
5713    }
5714
5715    return nestedTokens;
5716  }
5717
5718  /**
5719   * A simple string scanner that is used by the template parser to find
5720   * tokens in template strings.
5721   */
5722  function Scanner (string) {
5723    this.string = string;
5724    this.tail = string;
5725    this.pos = 0;
5726  }
5727
5728  /**
5729   * Returns `true` if the tail is empty (end of string).
5730   */
5731  Scanner.prototype.eos = function eos () {
5732    return this.tail === '';
5733  };
5734
5735  /**
5736   * Tries to match the given regular expression at the current position.
5737   * Returns the matched text if it can match, the empty string otherwise.
5738   */
5739  Scanner.prototype.scan = function scan (re) {
5740    var match = this.tail.match(re);
5741
5742    if (!match || match.index !== 0)
5743      { return ''; }
5744
5745    var string = match[0];
5746
5747    this.tail = this.tail.substring(string.length);
5748    this.pos += string.length;
5749
5750    return string;
5751  };
5752
5753  /**
5754   * Skips all text until the given regular expression can be matched. Returns
5755   * the skipped string, which is the entire tail if no match can be made.
5756   */
5757  Scanner.prototype.scanUntil = function scanUntil (re) {
5758    var index = this.tail.search(re), match;
5759
5760    switch (index) {
5761      case -1:
5762        match = this.tail;
5763        this.tail = '';
5764        break;
5765      case 0:
5766        match = '';
5767        break;
5768      default:
5769        match = this.tail.substring(0, index);
5770        this.tail = this.tail.substring(index);
5771    }
5772
5773    this.pos += match.length;
5774
5775    return match;
5776  };
5777
5778  /**
5779   * Represents a rendering context by wrapping a view object and
5780   * maintaining a reference to the parent context.
5781   */
5782  function Context (view, parentContext) {
5783    this.view = view;
5784    this.cache = { '.': this.view };
5785    this.parent = parentContext;
5786  }
5787
5788  /**
5789   * Creates a new context using the given view with this context
5790   * as the parent.
5791   */
5792  Context.prototype.push = function push (view) {
5793    return new Context(view, this);
5794  };
5795
5796  /**
5797   * Returns the value of the given name in this context, traversing
5798   * up the context hierarchy if the value is absent in this context's view.
5799   */
5800  Context.prototype.lookup = function lookup (name) {
5801    var cache = this.cache;
5802
5803    var value;
5804    if (cache.hasOwnProperty(name)) {
5805      value = cache[name];
5806    } else {
5807      var context = this, names, index, lookupHit = false;
5808
5809      while (context) {
5810        if (name.indexOf('.') > 0) {
5811          value = context.view;
5812          names = name.split('.');
5813          index = 0;
5814
5815          /**
5816           * Using the dot notion path in `name`, we descend through the
5817           * nested objects.
5818           *
5819           * To be certain that the lookup has been successful, we have to
5820           * check if the last object in the path actually has the property
5821           * we are looking for. We store the result in `lookupHit`.
5822           *
5823           * This is specially necessary for when the value has been set to
5824           * `undefined` and we want to avoid looking up parent contexts.
5825           **/
5826          while (value != null && index < names.length) {
5827            if (index === names.length - 1)
5828              { lookupHit = hasProperty(value, names[index]); }
5829
5830            value = value[names[index++]];
5831          }
5832        } else {
5833          value = context.view[name];
5834          lookupHit = hasProperty(context.view, name);
5835        }
5836
5837        if (lookupHit)
5838          { break; }
5839
5840        context = context.parent;
5841      }
5842
5843      cache[name] = value;
5844    }
5845
5846    if (isFunction(value))
5847      { value = value.call(this.view); }
5848
5849    return value;
5850  };
5851
5852  /**
5853   * A Writer knows how to take a stream of tokens and render them to a
5854   * string, given a context. It also maintains a cache of templates to
5855   * avoid the need to parse the same template twice.
5856   */
5857  function Writer () {
5858    this.cache = {};
5859  }
5860
5861  /**
5862   * Clears all cached templates in this writer.
5863   */
5864  Writer.prototype.clearCache = function clearCache () {
5865    this.cache = {};
5866  };
5867
5868  /**
5869   * Parses and caches the given `template` and returns the array of tokens
5870   * that is generated from the parse.
5871   */
5872  Writer.prototype.parse = function parse (template, tags) {
5873    var cache = this.cache;
5874    var tokens = cache[template];
5875
5876    if (tokens == null)
5877      { tokens = cache[template] = parseTemplate(template, tags); }
5878
5879    return tokens;
5880  };
5881
5882  /**
5883   * High-level method that is used to render the given `template` with
5884   * the given `view`.
5885   *
5886   * The optional `partials` argument may be an object that contains the
5887   * names and templates of partials that are used in the template. It may
5888   * also be a function that is used to load partial templates on the fly
5889   * that takes a single argument: the name of the partial.
5890   */
5891  Writer.prototype.render = function render (template, view, partials) {
5892    var tokens = this.parse(template);
5893    var context = (view instanceof Context) ? view : new Context(view);
5894    return this.renderTokens(tokens, context, partials, template);
5895  };
5896
5897  /**
5898   * Low-level method that renders the given array of `tokens` using
5899   * the given `context` and `partials`.
5900   *
5901   * Note: The `originalTemplate` is only ever used to extract the portion
5902   * of the original template that was contained in a higher-order section.
5903   * If the template doesn't use higher-order sections, this argument may
5904   * be omitted.
5905   */
5906  Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate) {
5907    var this$1 = this;
5908
5909    var buffer = '';
5910
5911    var token, symbol, value;
5912    for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
5913      value = undefined;
5914      token = tokens[i];
5915      symbol = token[0];
5916
5917      if (symbol === '#') { value = this$1.renderSection(token, context, partials, originalTemplate); }
5918      else if (symbol === '^') { value = this$1.renderInverted(token, context, partials, originalTemplate); }
5919      else if (symbol === '>') { value = this$1.renderPartial(token, context, partials, originalTemplate); }
5920      else if (symbol === '&') { value = this$1.unescapedValue(token, context); }
5921      else if (symbol === 'name') { value = this$1.escapedValue(token, context); }
5922      else if (symbol === 'text') { value = this$1.rawValue(token); }
5923
5924      if (value !== undefined)
5925        { buffer += value; }
5926    }
5927
5928    return buffer;
5929  };
5930
5931  Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate) {
5932    var this$1 = this;
5933
5934    var self = this;
5935    var buffer = '';
5936    var value = context.lookup(token[1]);
5937
5938    // This function is used to render an arbitrary template
5939    // in the current context by higher-order sections.
5940    function subRender (template) {
5941      return self.render(template, context, partials);
5942    }
5943
5944    if (!value) { return; }
5945
5946    if (isArray(value)) {
5947      for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
5948        buffer += this$1.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
5949      }
5950    } else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
5951      buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
5952    } else if (isFunction(value)) {
5953      if (typeof originalTemplate !== 'string')
5954        { throw new Error('Cannot use higher-order sections without the original template'); }
5955
5956      // Extract the portion of the original template that the section contains.
5957      value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
5958
5959      if (value != null)
5960        { buffer += value; }
5961    } else {
5962      buffer += this.renderTokens(token[4], context, partials, originalTemplate);
5963    }
5964    return buffer;
5965  };
5966
5967  Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate) {
5968    var value = context.lookup(token[1]);
5969
5970    // Use JavaScript's definition of falsy. Include empty arrays.
5971    // See https://github.com/janl/mustache.js/issues/186
5972    if (!value || (isArray(value) && value.length === 0))
5973      { return this.renderTokens(token[4], context, partials, originalTemplate); }
5974  };
5975
5976  Writer.prototype.renderPartial = function renderPartial (token, context, partials) {
5977    if (!partials) { return; }
5978
5979    var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
5980    if (value != null)
5981      { return this.renderTokens(this.parse(value), context, partials, value); }
5982  };
5983
5984  Writer.prototype.unescapedValue = function unescapedValue (token, context) {
5985    var value = context.lookup(token[1]);
5986    if (value != null)
5987      { return value; }
5988  };
5989
5990  Writer.prototype.escapedValue = function escapedValue (token, context) {
5991    var value = context.lookup(token[1]);
5992    if (value != null)
5993      { return mustache.escape(value); }
5994  };
5995
5996  Writer.prototype.rawValue = function rawValue (token) {
5997    return token[1];
5998  };
5999
6000  mustache.name = 'mustache.js';
6001  mustache.version = '2.3.0';
6002  mustache.tags = [ '{{', '}}' ];
6003
6004  // All high-level mustache.* functions use this writer.
6005  var defaultWriter = new Writer();
6006
6007  /**
6008   * Clears all cached templates in the default writer.
6009   */
6010  mustache.clearCache = function clearCache () {
6011    return defaultWriter.clearCache();
6012  };
6013
6014  /**
6015   * Parses and caches the given template in the default writer and returns the
6016   * array of tokens it contains. Doing this ahead of time avoids the need to
6017   * parse templates on the fly as they are rendered.
6018   */
6019  mustache.parse = function parse (template, tags) {
6020    return defaultWriter.parse(template, tags);
6021  };
6022
6023  /**
6024   * Renders the `template` with the given `view` and `partials` using the
6025   * default writer.
6026   */
6027  mustache.render = function render (template, view, partials) {
6028    if (typeof template !== 'string') {
6029      throw new TypeError('Invalid template! Template should be a "string" ' +
6030                          'but "' + typeStr(template) + '" was given as the first ' +
6031                          'argument for mustache#render(template, view, partials)');
6032    }
6033
6034    return defaultWriter.render(template, view, partials);
6035  };
6036
6037  // This is here for backwards compatibility with 0.4.x.,
6038  /*eslint-disable */ // eslint wants camel cased function name
6039  mustache.to_html = function to_html (template, view, partials, send) {
6040    /*eslint-enable*/
6041
6042    var result = mustache.render(template, view, partials);
6043
6044    if (isFunction(send)) {
6045      send(result);
6046    } else {
6047      return result;
6048    }
6049  };
6050
6051  // Export the escaping function so that the user may override it.
6052  // See https://github.com/janl/mustache.js/issues/244
6053  mustache.escape = escapeHtml;
6054
6055  // Export these mainly for testing, but also for advanced usage.
6056  mustache.Scanner = Scanner;
6057  mustache.Context = Context;
6058  mustache.Writer = Writer;
6059
6060  return mustache;
6061}));
6062});
6063
6064var html$2 = "\n<style>\n  dt-byline {\n    font-size: 12px;\n    line-height: 18px;\n    display: block;\n    border-top: 1px solid rgba(0, 0, 0, 0.1);\n    border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n    color: rgba(0, 0, 0, 0.5);\n    padding-top: 12px;\n    padding-bottom: 12px;\n  }\n  dt-article.centered dt-byline {\n    text-align: center;\n\n  }\n  dt-byline a,\n  dt-article dt-byline a {\n    text-decoration: none;\n    border-bottom: none;\n  }\n  dt-article dt-byline a:hover {\n    text-decoration: underline;\n    border-bottom: none;\n  }\n  dt-byline .authors {\n    text-align: left;\n  }\n  dt-byline .name {\n    display: inline;\n    text-transform: uppercase;\n  }\n  dt-byline .affiliation {\n    display: inline;\n  }\n  dt-byline .date {\n    display: block;\n    text-align: left;\n  }\n  dt-byline .year, dt-byline .month {\n    display: inline;\n  }\n  dt-byline .citation {\n    display: block;\n    text-align: left;\n  }\n  dt-byline .citation div {\n    display: inline;\n  }\n\n  @media(min-width: 768px) {\n    dt-byline {\n    }\n  }\n\n  @media(min-width: 1080px) {\n    dt-byline {\n      border-bottom: none;\n      margin-bottom: 70px;\n    }\n\n    dt-byline a:hover {\n      color: rgba(0, 0, 0, 0.9);\n    }\n\n    dt-byline .authors {\n      display: inline-block;\n    }\n\n    dt-byline .author {\n      display: inline-block;\n      margin-right: 12px;\n      /*padding-left: 20px;*/\n      /*border-left: 1px solid #ddd;*/\n    }\n\n    dt-byline .affiliation {\n      display: block;\n    }\n\n    dt-byline .author:last-child {\n      margin-right: 0;\n    }\n\n    dt-byline .name {\n      display: block;\n    }\n\n    dt-byline .date {\n      border-left: 1px solid rgba(0, 0, 0, 0.1);\n      padding-left: 15px;\n      margin-left: 15px;\n      display: inline-block;\n    }\n    dt-byline .year, dt-byline .month {\n      display: block;\n    }\n\n    dt-byline .citation {\n      border-left: 1px solid rgba(0, 0, 0, 0.15);\n      padding-left: 15px;\n      margin-left: 15px;\n      display: inline-block;\n    }\n    dt-byline .citation div {\n      display: block;\n    }\n  }\n</style>\n\n";
6065
6066var template = "\n<div class=\"byline\">\n  <div class=\"authors\">\n  {{#authors}}\n    <div class=\"author\">\n      {{#personalURL}}\n        <a class=\"name\" href=\"{{personalURL}}\">{{name}}</a>\n      {{/personalURL}}\n      {{^personalURL}}\n        <div class=\"name\">{{name}}</div>\n      {{/personalURL}}\n      {{#affiliation}}\n        {{#affiliationURL}}\n          <a class=\"affiliation\" href=\"{{affiliationURL}}\">{{affiliation}}</a>\n        {{/affiliationURL}}\n        {{^affiliationURL}}\n          <div class=\"affiliation\">{{affiliation}}</div>\n        {{/affiliationURL}}\n      {{/affiliation}}\n    </div>\n    {{/authors}}\n  </div>\n  {{#publishedYear}}\n  <div class=\"date\">\n    <div class=\"month\">{{publishedMonth}}. {{publishedDay}}</div>\n    <div class=\"year\">{{publishedYear}}</div>\n  </div>\n  {{/publishedYear}}\n  {{#publishedYear}}\n  <a class=\"citation\" href=\"#citation\">\n    <div>Citation:</div>\n    <div>{{concatenatedAuthors}}, {{publishedYear}}</div>\n  </a>\n  {{/publishedYear}}\n</div>\n";
6067
6068var byline = function(dom, data) {
6069  var el = dom.querySelector('dt-byline');
6070  if (el) {
6071    el.innerHTML = html$2 + mustache.render(template, data);
6072  }
6073};
6074
6075var templateHTML = "\n<style>\n  dt-appendix {\n    display: block;\n    font-size: 14px;\n    line-height: 24px;\n    margin-bottom: 0;\n    border-top: 1px solid rgba(0,0,0,0.1);\n    color: rgba(0,0,0,0.5);\n    background: rgb(250, 250, 250);\n    padding-top: 36px;\n    padding-bottom: 60px;\n  }\n  dt-appendix h3 {\n    font-size: 16px;\n    font-weight: 500;\n    margin-top: 18px;\n    margin-bottom: 18px;\n    color: rgba(0,0,0,0.65);\n  }\n  dt-appendix .citation {\n    font-size: 11px;\n    line-height: 15px;\n    border-left: 1px solid rgba(0, 0, 0, 0.1);\n    padding-left: 18px;\n    border: 1px solid rgba(0,0,0,0.1);\n    background: rgba(0, 0, 0, 0.02);\n    padding: 10px 18px;\n    border-radius: 3px;\n    color: rgba(150, 150, 150, 1);\n    overflow: hidden;\n    margin-top: -12px;\n  }\n  dt-appendix .references {\n    font-size: 12px;\n    line-height: 20px;\n  }\n  dt-appendix a {\n    color: rgba(0, 0, 0, 0.6);\n  }\n  dt-appendix ol,\n  dt-appendix ul {\n    padding-left: 24px;\n  }\n</style>\n\n<div class=\"l-body\">\n</div>\n";
6076
6077var appendix = function(dom, data) {
6078  var el = dom.querySelector('dt-appendix');
6079  if (el) {
6080    var userHTML = el.innerHTML;
6081    el.innerHTML = templateHTML;
6082    var newHTML = "";
6083
6084    // If we have some footnotes on the page, render a container for the footnote list.
6085    if (dom.querySelector("dt-fn")) {
6086      newHTML = newHTML + "<h3>Footnotes</h3><dt-fn-list></dt-fn-list>";
6087    }
6088
6089    // If we have any citations on the page, render a container for the bibliography.
6090    if (dom.querySelector("dt-cite")) {
6091      newHTML = newHTML + "<h3>References</h3><dt-bibliography></dt-bibliography>";
6092    }
6093
6094    var div = el.querySelector("div.l-body");
6095    div.innerHTML = userHTML + newHTML;
6096  }
6097
6098};
6099
6100var appendixDistill = function(dom, data) {
6101  var el = dom.querySelector('dt-appendix > div');
6102  if (el) {
6103    var newHTML = "";
6104
6105    newHTML += "<h3>Updates and Corrections</h3>\n    <p><a href=\"" + (data.githubCompareUpdatesUrl) + "\">View all changes</a> to this article since it was first published. If you see a mistake or want to suggest a change, please <a class=\"github-issue\" href=\"" + (data.githubUrl) + "/issues/new\">create an issue on GitHub</a>.</p>";
6106
6107    newHTML += "<h3 id=\"citation\">Citations and Reuse</h3>\n    <p>
6107Diagrams and text are licensed under Creative Commons Attribution <a href=\"https://creativecommons.org/licenses/by/2.0/\">CC-BY 2.0</a>, unless noted otherwise, with the <a class=\"github\" href=\"" + (data.githubUrl) + "\">source available on GitHub</a>. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: “Figure from …”.</p>\n\n    <p>For attribution in academic contexts, please cite this work as</p>\n    <pre class=\"citation short\">" + (data.concatenatedAuthors) + ", \"" + (data.title) + "\", " + (data.journal.title) + ", " + (data.publishedYear) + ". http://doi.org/" + (data.doi) + "</pre>\n\n    <p>BibTeX citation</p>\n<pre class=\"citation long\">@article{" + (data.slug) + ",\n  author = {" + (data.bibtexAuthors) + "},\n  title = {" + (data.title) + "},\n  journal = {" + (data.journal.title) + "},\n  year = {" + (data.publishedYear) + "},\n  url = {" + (data.url) + "},\n  doi = {" + (data.doi) + "}\n}</pre>";
6108
6109    var existingHTML = el.innerHTML;
6110    el.innerHTML = existingHTML + newHTML;
6111  }
6112};
6113
6114var citation = function(dom, data) {
6115  var css = "\n    dt-cite {\n      color: hsla(206, 90%, 20%, 0.7);\n    }\n    dt-cite .citation-number {\n      cursor: default;\n      white-space: nowrap;\n      font-family: -apple-system, BlinkMacSystemFont, \"Roboto\", Helvetica, sans-serif;\n      font-size: 75%;\n      color: hsla(206, 90%, 20%, 0.7);\n      display: inline-block;\n      line-height: 1.1em;\n      text-align: center;\n      position: relative;\n      top: -2px;\n      margin: 0 2px;\n    }\n    figcaption dt-cite .citation-number {\n      font-size: 11px;\n      font-weight: normal;\n      top: -2px;\n      line-height: 1em;\n    }\n  ";
6116
6117  var style = dom.createElement("style");
6118  style.textContent = css;
6119  dom.querySelector("body").appendChild(style);
6120
6121  var citations = data.citations;
6122  /*if (data.citations) {
6123    citations = Object.keys(data.citations).map(c => data.citations[c]);
6124    citations.sort((a, b) => {
6125      return a.author.localeCompare(b.author);
6126    });
6127  }*/
6128  
6129  var appendCiteHoverDiv = (function() {
6130    function nodeFromString(str) {
6131      var div = dom.createElement("div");
6132      div.innerHTML = str;
6133      return div.firstChild;
6134    }
6135    var hover_boxes_container = nodeFromString("<div id=\"cite-hover-boxes-container\"></div>");
6136    dom.querySelector("body").appendChild(hover_boxes_container);
6137    var hover_n = 0;
6138    return function appendHoverDiv(content) {
6139      var id = "dt-cite-hover-box-" + hover_n;
6140      hover_n += 1;
6141      var str = "<div style=\"display:none;\" class=\"dt-hover-box\" id=\"" + id + "\" >" + content + "</div>";
6142      var div = nodeFromString(str);
6143      hover_boxes_container.appendChild(div);
6144      return id;
6145    }
6146  })();
6147
6148  var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
6149  citeTags.forEach(function (el,n) {
6150    var key = el.getAttribute("key");
6151    if (key) {
6152      var keys = key.split(",");
6153      var cite_string = inline_cite_short(keys);
6154      var cite_hover_str = "";
6155      keys.map(function (key,n) {
6156        if (n>0) { cite_hover_str += "<br><br>"; }
6157        cite_hover_str += hover_cite(data.bibliography[key]);
6158      });
6159      var ref_id = appendCiteHoverDiv(cite_hover_str);
6160      //cite_hover_str = cite_hover_str.replace(/"/g, "&#39;")
6161      var orig_string = el.innerHTML;
6162      if (orig_string != "") { orig_string += " "; }
6163      el.innerHTML = "<span id=\"citation-" + n + "\" data-hover-ref=\"" + ref_id + "\">" + orig_string + "<span class=\"citation-number\">" + cite_string + "</span></span>";
6164    }
6165  });
6166
6167  var bibEl = dom.querySelector("dt-bibliography");
6168  if (bibEl) {
6169    var ol = dom.createElement("ol");
6170    citations.forEach(function (key) {
6171      var el = dom.createElement("li");
6172      el.innerHTML = bibliography_cite(data.bibliography[key]);
6173      ol.appendChild(el);
6174    });
6175    bibEl.appendChild(ol);
6176  }
6177
6178  function inline_cite_short(keys){
6179    function cite_string(key){
6180      if (key in data.bibliography){
6181        var n = data.citations.indexOf(key)+1;
6182        return ""+n;
6183      } else {
6184        return "?";
6185      }
6186    }
6187    return "["+keys.map(cite_string).join(", ")+"]";
6188  }
6189
6190  function inline_cite_long(keys){
6191    function cite_string(key){
6192      if (key in data.bibliography){
6193        var ent = data.bibliography[key];
6194        var names = ent.author.split(" and ");
6195        names = names.map(function (name) { return name.split(",")[0].trim(); });
6196        var year = ent.year;
6197        if (names.length == 1) { return names[0] + ", " + year; }
6198        if (names.length == 2) { return names[0] + " & " + names[1] + ", " + year; }
6199        if (names.length  > 2) { return names[0] + ", et al., " + year; }
6200      } else {
6201        return "?";
6202      }
6203    }
6204    return keys.map(cite_string).join(", ");
6205  }
6206
6207  function author_string(ent, template, sep, finalSep){
6208    var names = ent.author.split(" and ");
6209    var name_strings = names.map(function (name) {
6210      name = name.trim();
6211      if (name.indexOf(",") != -1){
6212        var last = name.split(",")[0].trim();
6213        var firsts = name.split(",")[1];
6214      } else {
6215        var last = name.split(" ").slice(-1)[0].trim();
6216        var firsts = name.split(" ").slice(0,-1).join(" ");
6217      }
6218      var initials = "";
6219      if (firsts != undefined) {
6220        initials = firsts.trim().split(" ").map(function (s) { return s.trim()[0]; });
6221        initials = initials.join(".")+".";
6222      }
6223      return template.replace("${F}", firsts)
6224                     .replace("${L}", last)
6225                     .replace("${I}", initials);
6226    });
6227    if (names.length > 1) {
6228      var str = name_strings.slice(0, names.length-1).join(sep);
6229      str += (finalSep || sep) + name_strings[names.length-1];
6230      return str;
6231    } else {
6232      return name_strings[0];
6233    }
6234  }
6235
6236  function venue_string(ent) {
6237    var cite = (ent.journal || ent.booktitle || "");
6238    if ("volume" in ent){
6239      var issue = ent.issue || ent.number;
6240      issue = (issue != undefined)? "("+issue+")" : "";
6241      cite += ", Vol " + ent.volume + issue;
6242    }
6243    if ("pages" in ent){
6244      cite += ", pp. " + ent.pages;
6245    }
6246    if (cite != "") { cite += ". "; }
6247    if ("publisher" in ent){
6248      cite += ent.publisher;
6249      if (cite[cite.length-1] != ".") { cite += "."; }
6250    }
6251    return cite;
6252  }
6253
6254  function link_string(ent){
6255    if ("url" in ent){
6256      var url = ent.url;
6257      var arxiv_match = (/arxiv\.org\/abs\/([0-9\.]*)/).exec(url);
6258      if (arxiv_match != null){
6259        url = "http://arxiv.org/pdf/" + (arxiv_match[1]) + ".pdf";
6260      }
6261
6262      if (url.slice(-4) == ".pdf"){
6263        var label = "PDF";
6264      } else if (url.slice(-5) == ".html") {
6265        var label = "HTML";
6266      }
6267      return (" &ensp;<a href=\"" + url + "\">[" + (label||"link") + "]</a>");
6268    }/* else if ("doi" in ent){
6269      return ` &ensp;<a href="https://doi.org/${ent.doi}" >[DOI]</a>`;
6270    }*/ else {
6271      return "";
6272    }
6273  }
6274  function doi_string(ent, new_line){
6275    if ("doi" in ent) {
6276      return ((new_line?"<br>":"") + " <a href=\"https://doi.org/" + (ent.doi) + "\" style=\"text-decoration:inherit;\">DOI: " + (ent.doi) + "</a>");
6277    } else {
6278      return "";
6279    }
6280  }
6281
6282  function bibliography_cite(ent, fancy){
6283    if (ent){
6284      var cite =  "<b>" + ent.title + "</b> ";
6285      cite += link_string(ent) + "<br>";
6286      cite += author_string(ent, "${L}, ${I}", ", ", " and ");
6287      if (ent.year || ent.date){
6288        cite += ", " + (ent.year || ent.date) + ". ";
6289      } else {
6290        cite += ". ";
6291      }
6292      cite += venue_string(ent);
6293      cite += doi_string(ent);
6294      return cite
6295      /*var cite =  author_string(ent, "${L}, ${I}", ", ", " and ");
6296      if (ent.year || ent.date){
6297        cite += ", " + (ent.year || ent.date) + ". "
6298      } else {
6299        cite += ". "
6300      }
6301      cite += "<b>" + ent.title + "</b>. ";
6302      cite += venue_string(ent);
6303      cite += doi_string(ent);
6304      cite += link_string(ent);
6305      return cite*/
6306    } else {
6307      return "?";
6308    }
6309  }
6310
6311  function hover_cite(ent){
6312    if (ent){
6313      var cite = "";
6314      cite += "<b>" + ent.title + "</b>";
6315      cite += link_string(ent);
6316      cite += "<br>";
6317
6318      var a_str = author_string(ent, "${I} ${L}", ", ") + ".";
6319      var v_str = venue_string(ent).trim() + " " + ent.year + ". " + doi_string(ent, true);
6320
6321      if ((a_str+v_str).length < Math.min(40, ent.title.length)) {
6322        cite += a_str + " " + v_str;
6323      } else {
6324        cite += a_str + "<br>" + v_str;
6325      }
6326      return cite;
6327    } else {
6328      return "?";
6329    }
6330  }
6331
6332
6333  //https://scholar.google.com/scholar?q=allintitle%3ADocument+author%3Aolah
6334  function get_GS_URL(ent){
6335    if (ent){
6336      var names = ent.author.split(" and ");
6337      names = names.map(function (name) { return name.split(",")[0].trim(); });
6338      var title = ent.title.split(" ");//.replace(/[,:]/, "")
6339      var url = "http://search.labs.crossref.org/dois?";//""https://scholar.google.com/scholar?"
6340      url += uris({q: names.join(" ") + " " + title.join(" ")});
6341    }
6342
6343  }
6344};
6345
6346var footnote = function(dom, data) {
6347
6348  var appendFootnoteHoverDiv = (function() {
6349    function nodeFromString(str) {
6350      var div = dom.createElement("div");
6351      div.innerHTML = str;
6352      return div.firstChild;
6353    }
6354    var hover_boxes_container = nodeFromString("<div id=\"footnote-hover-boxes-container\"></div>");
6355    dom.querySelector("body").appendChild(hover_boxes_container);
6356    var hover_n = 0;
6357    return function appendHoverDiv(content) {
6358      var id = "dt-fn-hover-box-" + hover_n;
6359      hover_n += 1;
6360      var str = "<div style=\"display:none;\" class=\"dt-hover-box\" id=\"" + id + "\" >" + content + "</div>";
6361      var div = nodeFromString(str);
6362      hover_boxes_container.appendChild(div);
6363      return id;
6364    }
6365  })();
6366
6367
6368  var fnTags = [].slice.apply(dom.querySelectorAll("dt-fn"));
6369  var fnContent = [];
6370  fnTags.forEach(function (el,n) {
6371    var content = el.innerHTML;
6372    var ref_id = appendFootnoteHoverDiv(content);
6373    fnContent.push(content);
6374    n = (n+1)+"";
6375    var key = "fn-"+n;
6376    var escaped_content = content.replace(/"/g, "&#39;");
6377    el.innerHTML = "<sup><span id=\"" + key + "\" data-hover-ref=\"" + ref_id + "\" style=\"cursor:pointer\">" + n + "</span></sup>";
6378  });
6379
6380  var fnList = dom.querySelector("dt-fn-list");
6381  if (fnList) {
6382    var ol = dom.createElement("ol");
6383    fnContent.forEach(function (content) {
6384      var el = dom.createElement("li");
6385      el.innerHTML = content;
6386      ol.appendChild(el);
6387    });
6388    fnList.appendChild(ol);
6389  }
6390
6391};
6392
6393/**
6394 * This is the ParseError class, which is the main error thrown by KaTeX
6395 * functions when something has gone wrong. This is used to distinguish internal
6396 * errors from errors in the expression that the user provided.
6397 *
6398 * If possible, a caller should provide a Token or ParseNode with information
6399 * about where in the source string the problem occurred.
6400 *
6401 * @param {string} message  The error message
6402 * @param {(Token|ParseNode)=} token  An object providing position information
6403 */
6404function ParseError$1(message, token) {
6405    var error = "KaTeX parse error: " + message;
6406    var start;
6407    var end;
6408
6409    if (token && token.lexer && token.start <= token.end) {
6410        // If we have the input and a position, make the error a bit fancier
6411
6412        // Get the input
6413        var input = token.lexer.input;
6414
6415        // Prepend some information
6416        start = token.start;
6417        end = token.end;
6418        if (start === input.length) {
6419            error += " at end of input: ";
6420        } else {
6421            error += " at position " + (start + 1) + ": ";
6422        }
6423
6424        // Underline token in question using combining underscores
6425        var underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332");
6426
6427        // Extract some context from the input and add it to the error
6428        var left;
6429        if (start > 15) {
6430            left = "…" + input.slice(start - 15, start);
6431        } else {
6432            left = input.slice(0, start);
6433        }
6434        var right;
6435        if (end + 15 < input.length) {
6436            right = input.slice(end, end + 15) + "…";
6437        } else {
6438            right = input.slice(end);
6439        }
6440        error += left + underlined + right;
6441    }
6442
6443    // Some hackery to make ParseError a prototype of Error
6444    // See http://stackoverflow.com/a/8460753
6445    var self = new Error(error);
6446    self.name = "ParseError";
6447    self.__proto__ = ParseError$1.prototype;
6448
6449    self.position = start;
6450    return self;
6451}
6452
6453// More hackery
6454ParseError$1.prototype.__proto__ = Error.prototype;
6455
6456var ParseError_1 = ParseError$1;
6457
6458/**
6459 * This is a module for storing settings passed into KaTeX. It correctly handles
6460 * default settings.
6461 */
6462
6463/**
6464 * Helper function for getting a default value if the value is undefined
6465 */
6466function get(option, defaultValue) {
6467    return option === undefined ? defaultValue : option;
6468}
6469
6470/**
6471 * The main Settings object
6472 *
6473 * The current options stored are:
6474 *  - displayMode: Whether the expression should be typeset by default in
6475 *                 textstyle or displaystyle (default false)
6476 */
6477function Settings$1(options) {
6478    // allow null options
6479    options = options || {};
6480    this.displayMode = get(options.displayMode, false);
6481    this.throwOnError = get(options.throwOnError, true);
6482    this.errorColor = get(options.errorColor, "#cc0000");
6483    this.macros = options.macros || {};
6484}
6485
6486var Settings_1 = Settings$1;
6487
6488var hangulRegex = /[\uAC00-\uD7AF]/;
6489
6490// This regex combines
6491// - Hiragana: [\u3040-\u309F]
6492// - Katakana: [\u30A0-\u30FF]
6493// - CJK ideograms: [\u4E00-\u9FAF]
6494// - Hangul syllables: [\uAC00-\uD7AF]
6495// Notably missing are halfwidth Katakana and Romanji glyphs.
6496var cjkRegex$1 =
6497    /[\u3040-\u309F]|[\u30A0-\u30FF]|[\u4E00-\u9FAF]|[\uAC00-\uD7AF]/;
6498
6499var unicodeRegexes = {
6500    cjkRegex: cjkRegex$1,
6501    hangulRegex: hangulRegex
6502};
6503
6504var fontMetricsData = {
6505    "AMS-Regular": {
6506        "65": [0, 0.68889, 0, 0],
6507        "66": [0, 0.68889, 0, 0],
6508        "67": [0, 0.68889, 0, 0],
6509        "68": [0, 0.68889, 0, 0],
6510        "69": [0, 0.68889, 0, 0],
6511        "70": [0, 0.68889, 0, 0],
6512        "71": [0, 0.68889, 0, 0],
6513        "72": [0, 0.68889, 0, 0],
6514        "73": [0, 0.68889, 0, 0],
6515        "74": [0.16667, 0.68889, 0, 0],
6516        "75": [0, 0.68889, 0, 0],
6517        "76": [0, 0.68889, 0, 0],
6518        "77": [0, 0.68889, 0, 0],
6519        "78": [0, 0.68889, 0, 0],
6520        "79": [0.16667, 0.68889, 0, 0],
6521        "80": [0, 0.68889, 0, 0],
6522        "81": [0.16667, 0.68889, 0, 0],
6523        "82": [0, 0.68889, 0, 0],
6524        "83": [0, 0.68889, 0, 0],
6525        "84": [0, 0.68889, 0, 0],
6526        "85": [0, 0.68889, 0, 0],
6527        "86": [0, 0.68889, 0, 0],
6528        "87": [0, 0.68889, 0, 0],
6529        "88": [0, 0.68889, 0, 0],
6530        "89": [0, 0.68889, 0, 0],
6531        "90": [0, 0.68889, 0, 0],
6532        "107": [0, 0.68889, 0, 0],
6533        "165": [0, 0.675, 0.025, 0],
6534        "174": [0.15559, 0.69224, 0, 0],
6535        "240": [0, 0.68889, 0, 0],
6536        "295": [0, 0.68889, 0, 0],
6537        "710": [0, 0.825, 0, 0],
6538        "732": [0, 0.9, 0, 0],
6539        "770": [0, 0.825, 0, 0],
6540        "771": [0, 0.9, 0, 0],
6541        "989": [0.08167, 0.58167, 0, 0],
6542        "1008": [0, 0.43056, 0.04028, 0],
6543        "8245": [0, 0.54986, 0, 0],
6544        "8463": [0, 0.68889, 0, 0],
6545        "8487": [0, 0.68889, 0, 0],
6546        "8498": [0, 0.68889, 0, 0],
6547        "8502": [0, 0.68889, 0, 0],
6548        "8503": [0, 0.68889, 0, 0],
6549        "8504": [0, 0.68889, 0, 0],
6550        "8513": [0, 0.68889, 0, 0],
6551        "8592": [-0.03598, 0.46402, 0, 0],
6552        "8594": [-0.03598, 0.46402, 0, 0],
6553        "8602": [-0.13313, 0.36687, 0, 0],
6554        "8603": [-0.13313, 0.36687, 0, 0],
6555        "8606": [0.01354, 0.52239, 0, 0],
6556        "8608": [0.01354, 0.52239, 0, 0],
6557        "8610": [0.01354, 0.52239, 0, 0],
6558        "8611": [0.01354, 0.52239, 0, 0],
6559        "8619": [0, 0.54986, 0, 0],
6560        "8620": [0, 0.54986, 0, 0],
6561        "8621": [-0.13313, 0.37788, 0, 0],
6562        "8622": [-0.13313, 0.36687, 0, 0],
6563        "8624": [0, 0.69224, 0, 0],
6564        "8625": [0, 0.69224, 0, 0],
6565        "8630": [0, 0.43056, 0, 0],
6566        "8631": [0, 0.43056, 0, 0],
6567        "8634": [0.08198, 0.58198, 0, 0],
6568        "8635": [0.08198, 0.58198, 0, 0],
6569        "8638": [0.19444, 0.69224, 0, 0],
6570        "8639": [0.19444, 0.69224, 0, 0],
6571        "8642": [0.19444, 0.69224, 0, 0],
6572        "8643": [0.19444, 0.69224, 0, 0],
6573        "8644": [0.1808, 0.675, 0, 0],
6574        "8646": [0.1808, 0.675, 0, 0],
6575        "8647": [0.1808, 0.675, 0, 0],
6576        "8648": [0.19444, 0.69224, 0, 0],
6577        "8649": [0.1808, 0.675, 0, 0],
6578        "8650": [0.19444, 0.69224, 0, 0],
6579        "8651": [0.01354, 0.52239, 0, 0],
6580        "8652": [0.01354, 0.52239, 0, 0],
6581        "8653": [-0.13313, 0.36687, 0, 0],
6582        "8654": [-0.13313, 0.36687, 0, 0],
6583        "8655": [-0.13313, 0.36687, 0, 0],
6584        "8666": [0.13667, 0.63667, 0, 0],
6585        "8667": [0.13667, 0.63667, 0, 0],
6586        "8669": [-0.13313, 0.37788, 0, 0],
6587        "8672": [-0.064, 0.437, 0, 0],
6588        "8674": [-0.064, 0.437, 0, 0],
6589        "8705": [0, 0.825, 0, 0],
6590        "8708": [0, 0.68889, 0, 0],
6591        "8709": [0.08167, 0.58167, 0, 0],
6592        "8717": [0, 0.43056, 0, 0],
6593        "8722": [-0.03598, 0.46402, 0, 0],
6594        "8724": [0.08198, 0.69224, 0, 0],
6595        "8726": [0.08167, 0.58167, 0, 0],
6596        "8733": [0, 0.69224, 0, 0],
6597        "8736": [0, 0.69224, 0, 0],
6598        "8737": [0, 0.69224, 0, 0],
6599        "8738": [0.03517, 0.52239, 0, 0],
6600        "8739": [0.08167, 0.58167, 0, 0],
6601        "8740": [0.25142, 0.74111, 0, 0],
6602        "8741": [0.08167, 0.58167, 0, 0],
6603        "8742": [0.25142, 0.74111, 0, 0],
6604        "8756": [0, 0.69224, 0, 0],
6605        "8757": [0, 0.69224, 0, 0],
6606        "8764": [-0.13313, 0.36687, 0, 0],
6607        "8765": [-0.13313, 0.37788, 0, 0],
6608        "8769": [-0.13313, 0.36687, 0, 0],
6609        "8770": [-0.03625, 0.46375, 0, 0],
6610        "8774": [0.30274, 0.79383, 0, 0],
6611        "8776": [-0.01688, 0.48312, 0, 0],
6612        "8778": [0.08167, 0.58167, 0, 0],
6613        "8782": [0.06062, 0.54986, 0, 0],
6614        "8783": [0.06062, 0.54986, 0, 0],
6615        "8785": [0.08198, 0.58198, 0, 0],
6616        "8786": [0.08198, 0.58198, 0, 0],
6617        "8787": [0.08198, 0.58198, 0, 0],
6618        "8790": [0, 0.69224, 0, 0],
6619        "8791": [0.22958, 0.72958, 0, 0],
6620        "8796": [0.08198, 0.91667, 0, 0],
6621        "8806": [0.25583, 0.75583, 0, 0],
6622        "8807": [0.25583, 0.75583, 0, 0],
6623        "8808": [0.25142, 0.75726, 0, 0],
6624        "8809": [0.25142, 0.75726, 0, 0],
6625        "8812": [0.25583, 0.75583, 0, 0],
6626        "8814": [0.20576, 0.70576, 0, 0],
6627        "8815": [0.20576, 0.70576, 0, 0],
6628        "8816": [0.30274, 0.79383, 0, 0],
6629        "8817": [0.30274, 0.79383, 0, 0],
6630        "8818": [0.22958, 0.72958, 0, 0],
6631        "8819": [0.22958, 0.72958, 0, 0],
6632        "8822": [0.1808, 0.675, 0, 0],
6633        "8823": [0.1808, 0.675, 0, 0],
6634        "8828": [0.13667, 0.63667, 0, 0],
6635        "8829": [0.13667, 0.63667, 0, 0],
6636        "8830": [0.22958, 0.72958, 0, 0],
6637        "8831": [0.22958, 0.72958, 0, 0],
6638        "8832": [0.20576, 0.70576, 0, 0],
6639        "8833": [0.20576, 0.70576, 0, 0],
6640        "8840": [0.30274, 0.79383, 0, 0],
6641        "8841": [0.30274, 0.79383, 0, 0],
6642        "8842": [0.13597, 0.63597, 0, 0],
6643        "8843": [0.13597, 0.63597, 0, 0],
6644        "8847": [0.03517, 0.54986, 0, 0],
6645        "8848": [0.03517, 0.54986, 0, 0],
6646        "8858": [0.08198, 0.58198, 0, 0],
6647        "8859": [0.08198, 0.58198, 0, 0],
6648        "8861": [0.08198, 0.58198, 0, 0],
6649        "8862": [0, 0.675, 0, 0],
6650        "8863": [0, 0.675, 0, 0],
6651        "8864": [0, 0.675, 0, 0],
6652        "8865": [0, 0.675, 0, 0],
6653        "8872": [0, 0.69224, 0, 0],
6654        "8873": [0, 0.69224, 0, 0],
6655        "8874": [0, 0.69224, 0, 0],
6656        "8876": [0, 0.68889, 0, 0],
6657        "8877": [0, 0.68889, 0, 0],
6658        "8878": [0, 0.68889, 0, 0],
6659        "8879": [0, 0.68889, 0, 0],
6660        "8882": [0.03517, 0.54986, 0, 0],
6661        "8883": [0.03517, 0.54986, 0, 0],
6662        "8884": [0.13667, 0.63667, 0, 0],
6663        "8885": [0.13667, 0.63667, 0, 0],
6664        "8888": [0, 0.54986, 0, 0],
6665        "8890": [0.19444, 0.43056, 0, 0],
6666        "8891": [0.19444, 0.69224, 0, 0],
6667        "8892": [0.19444, 0.69224, 0, 0],
6668        "8901": [0, 0.54986, 0, 0],
6669        "8903": [0.08167, 0.58167, 0, 0],
6670        "8905": [0.08167, 0.58167, 0, 0],
6671        "8906": [0.08167, 0.58167, 0, 0],
6672        "8907": [0, 0.69224, 0, 0],
6673        "8908": [0, 0.69224, 0, 0],
6674        "8909": [-0.03598, 0.46402, 0, 0],
6675        "8910": [0, 0.54986, 0, 0],
6676        "8911": [0, 0.54986, 0, 0],
6677        "8912": [0.03517, 0.54986, 0, 0],
6678        "8913": [0.03517, 0.54986, 0, 0],
6679        "8914": [0, 0.54986, 0, 0],
6680        "8915": [0, 0.54986, 0, 0],
6681        "8916": [0, 0.69224, 0, 0],
6682        "8918": [0.0391, 0.5391, 0, 0],
6683        "8919": [0.0391, 0.5391, 0, 0],
6684        "8920": [0.03517, 0.54986, 0, 0],
6685        "8921": [0.03517, 0.54986, 0, 0],
6686        "8922": [0.38569, 0.88569, 0, 0],
6687        "8923": [0.38569, 0.88569, 0, 0],
6688        "8926": [0.13667, 0.63667, 0, 0],
6689        "8927": [0.13667, 0.63667, 0, 0],
6690        "8928": [0.30274, 0.79383, 0, 0],
6691        "8929": [0.30274, 0.79383, 0, 0],
6692        "8934": [0.23222, 0.74111, 0, 0],
6693        "8935": [0.23222, 0.74111, 0, 0],
6694        "8936": [0.23222, 0.74111, 0, 0],
6695        "8937": [0.23222, 0.74111, 0, 0],
6696        "8938": [0.20576, 0.70576, 0, 0],
6697        "8939": [0.20576, 0.70576, 0, 0],
6698        "8940": [0.30274, 0.79383, 0, 0],
6699        "8941": [0.30274, 0.79383, 0, 0],
6700        "8994": [0.19444, 0.69224, 0, 0],
6701        "8995": [0.19444, 0.69224, 0, 0],
6702        "9416": [0.15559, 0.69224, 0, 0],
6703        "9484": [0, 0.69224, 0, 0],
6704        "9488": [0, 0.69224, 0, 0],
6705        "9492": [0, 0.37788, 0, 0],
6706        "9496": [0, 0.37788, 0, 0],
6707        "9585": [0.19444, 0.68889, 0, 0],
6708        "9586": [0.19444, 0.74111, 0, 0],
6709        "9632": [0, 0.675, 0, 0],
6710        "9633": [0, 0.675, 0, 0],
6711        "9650": [0, 0.54986, 0, 0],
6712        "9651": [0, 0.54986, 0, 0],
6713        "9654": [0.03517, 0.54986, 0, 0],
6714        "9660": [0, 0.54986, 0, 0],
6715        "9661": [0, 0.54986, 0, 0],
6716        "9664": [0.03517, 0.54986, 0, 0],
6717        "9674": [0.11111, 0.69224, 0, 0],
6718        "9733": [0.19444, 0.69224, 0, 0],
6719        "10003": [0, 0.69224, 0, 0],
6720        "10016": [0, 0.69224, 0, 0],
6721        "10731": [0.11111, 0.69224, 0, 0],
6722        "10846": [0.19444, 0.75583, 0, 0],
6723        "10877": [0.13667, 0.63667, 0, 0],
6724        "10878": [0.13667, 0.63667, 0, 0],
6725        "10885": [0.25583, 0.75583, 0, 0],
6726        "10886": [0.25583, 0.75583, 0, 0],
6727        "10887": [0.13597, 0.63597, 0, 0],
6728        "10888": [0.13597, 0.63597, 0, 0],
6729        "10889": [0.26167, 0.75726, 0, 0],
6730        "10890": [0.26167, 0.75726, 0, 0],
6731        "10891": [0.48256, 0.98256, 0, 0],
6732        "10892": [0.48256, 0.98256, 0, 0],
6733        "10901": [0.13667, 0.63667, 0, 0],
6734        "10902": [0.13667, 0.63667, 0, 0],
6735        "10933": [0.25142, 0.75726, 0, 0],
6736        "10934": [0.25142, 0.75726, 0, 0],
6737        "10935": [0.26167, 0.75726, 0, 0],
6738        "10936": [0.26167, 0.75726, 0, 0],
6739        "10937": [0.26167, 0.75726, 0, 0],
6740        "10938": [0.26167, 0.75726, 0, 0],
6741        "10949": [0.25583, 0.75583, 0, 0],
6742        "10950": [0.25583, 0.75583, 0, 0],
6743        "10955": [0.28481, 0.79383, 0, 0],
6744        "10956": [0.28481, 0.79383, 0, 0],
6745        "57350": [0.08167, 0.58167, 0, 0],
6746        "57351": [0.08167, 0.58167, 0, 0],
6747        "57352": [0.08167, 0.58167, 0, 0],
6748        "57353": [0, 0.43056, 0.04028, 0],
6749        "57356": [0.25142, 0.75726, 0, 0],
6750        "57357": [0.25142, 0.75726, 0, 0],
6751        "57358": [0.41951, 0.91951, 0, 0],
6752        "57359": [0.30274, 0.79383, 0, 0],
6753        "57360": [0.30274, 0.79383, 0, 0],
6754        "57361": [0.41951, 0.91951, 0, 0],
6755        "57366": [0.25142, 0.75726, 0, 0],
6756        "57367": [0.25142, 0.75726, 0, 0],
6757        "57368": [0.25142, 0.75726, 0, 0],
6758        "57369": [0.25142, 0.75726, 0, 0],
6759        "57370": [0.13597, 0.63597, 0, 0],
6760        "57371": [0.13597, 0.63597, 0, 0]
6761    },
6762    "Caligraphic-Regular": {
6763        "48": [0, 0.43056, 0, 0],
6764        "49": [0, 0.43056, 0, 0],
6765        "50": [0, 0.43056, 0, 0],
6766        "51": [0.19444, 0.43056, 0, 0],
6767        "52": [0.19444, 0.43056, 0, 0],
6768        "53": [0.19444, 0.43056, 0, 0],
6769        "54": [0, 0.64444, 0, 0],
6770        "55": [0.19444, 0.43056, 0, 0],
6771        "56": [0, 0.64444, 0, 0],
6772        "57": [0.19444, 0.43056, 0, 0],
6773        "65": [0, 0.68333, 0, 0.19445],
6774        "66": [0, 0.68333, 0.03041, 0.13889],
6775        "67": [0, 0.68333, 0.05834, 0.13889],
6776        "68": [0, 0.68333, 0.02778, 0.08334],
6777        "69": [0, 0.68333, 0.08944, 0.11111],
6778        "70": [0, 0.68333, 0.09931, 0.11111],
6779        "71": [0.09722, 0.68333, 0.0593, 0.11111],
6780        "72": [0, 0.68333, 0.00965, 0.11111],
6781        "73": [0, 0.68333, 0.07382, 0],
6782        "74": [0.09722, 0.68333, 0.18472, 0.16667],
6783        "75": [0, 0.68333, 0.01445, 0.05556],
6784        "76": [0, 0.68333, 0, 0.13889],
6785        "77": [0, 0.68333, 0, 0.13889],
6786        "78": [0, 0.68333, 0.14736, 0.08334],
6787        "79": [0, 0.68333, 0.02778, 0.11111],
6788        "80": [0, 0.68333, 0.08222, 0.08334],
6789        "81": [0.09722, 0.68333, 0, 0.11111],
6790        "82": [0, 0.68333, 0, 0.08334],
6791        "83": [0, 0.68333, 0.075, 0.13889],
6792        "84": [0, 0.68333, 0.25417, 0],
6793        "85": [0, 0.68333, 0.09931, 0.08334],
6794        "86": [0, 0.68333, 0.08222, 0],
6795        "87": [0, 0.68333, 0.08222, 0.08334],
6796        "88": [0, 0.68333, 0.14643, 0.13889],
6797        "89": [0.09722, 0.68333, 0.08222, 0.08334],
6798        "90": [0, 0.68333, 0.07944, 0.13889]
6799    },
6800    "Fraktur-Regular": {
6801        "33": [0, 0.69141, 0, 0],
6802        "34": [0, 0.69141, 0, 0],
6803        "38": [0, 0.69141, 0, 0],
6804        "39": [0, 0.69141, 0, 0],
6805        "40": [0.24982, 0.74947, 0, 0],
6806        "41": [0.24982, 0.74947, 0, 0],
6807        "42": [0, 0.62119, 0, 0],
6808        "43": [0.08319, 0.58283, 0, 0],
6809        "44": [0, 0.10803, 0, 0],
6810        "45": [0.08319, 0.58283, 0, 0],
6811        "46": [0, 0.10803, 0, 0],
6812        "47": [0.24982, 0.74947, 0, 0],
6813        "48": [0, 0.47534, 0, 0],
6814        "49": [0, 0.47534, 0, 0],
6815        "50": [0, 0.47534, 0, 0],
6816        "51": [0.18906, 0.47534, 0, 0],
6817        "52": [0.18906, 0.47534, 0, 0],
6818        "53": [0.18906, 0.47534, 0, 0],
6819        "54": [0, 0.69141, 0, 0],
6820        "55": [0.18906, 0.47534, 0, 0],
6821        "56": [0, 0.69141, 0, 0],
6822        "57": [0.18906, 0.47534, 0, 0],
6823        "58": [0, 0.47534, 0, 0],
6824        "59": [0.12604, 0.47534, 0, 0],
6825        "61": [-0.13099, 0.36866, 0, 0],
6826        "63": [0, 0.69141, 0, 0],
6827        "65": [0, 0.69141, 0, 0],
6828        "66": [0, 0.69141, 0, 0],
6829        "67": [0, 0.69141, 0, 0],
6830        "68": [0, 0.69141, 0, 0],
6831        "69": [0, 0.69141, 0, 0],
6832        "70": [0.12604, 0.69141, 0, 0],
6833        "71": [0, 0.69141, 0, 0],
6834        "72": [0.06302, 0.69141, 0, 0],
6835        "73": [0, 0.69141, 0, 0],
6836        "74": [0.12604, 0.69141, 0, 0],
6837        "75": [0, 0.69141, 0, 0],
6838        "76": [0, 0.69141, 0, 0],
6839        "77": [0, 0.69141, 0, 0],
6840        "78": [0, 0.69141, 0, 0],
6841        "79": [0, 0.69141, 0, 0],
6842        "80": [0.18906, 0.69141, 0, 0],
6843        "81": [0.03781, 0.69141, 0, 0],
6844        "82": [0, 0.69141, 0, 0],
6845        "83": [0, 0.69141, 0, 0],
6846        "84": [0, 0.69141, 0, 0],
6847        "85": [0, 0.69141, 0, 0],
6848        "86": [0, 0.69141, 0, 0],
6849        "87": [0, 0.69141, 0, 0],
6850        "88": [0, 0.69141, 0, 0],
6851        "89": [0.18906, 0.69141, 0, 0],
6852        "90": [0.12604, 0.69141, 0, 0],
6853        "91": [0.24982, 0.74947, 0, 0],
6854        "93": [0.24982, 0.74947, 0, 0],
6855        "94": [0, 0.69141, 0, 0],
6856        "97": [0, 0.47534, 0, 0],
6857        "98": [0, 0.69141, 0, 0],
6858        "99": [0, 0.47534, 0, 0],
6859        "100": [0, 0.62119, 0, 0],
6860        "101": [0, 0.47534, 0, 0],
6861        "102": [0.18906, 0.69141, 0, 0],
6862        "103": [0.18906, 0.47534, 0, 0],
6863        "104": [0.18906, 0.69141, 0, 0],
6864        "105": [0, 0.69141, 0, 0],
6865        "106": [0, 0.69141, 0, 0],
6866        "107": [0, 0.69141, 0, 0],
6867        "108": [0, 0.69141, 0, 0],
6868        "109": [0, 0.47534, 0, 0],
6869        "110": [0, 0.47534, 0, 0],
6870        "111": [0, 0.47534, 0, 0],
6871        "112": [0.18906, 0.52396, 0, 0],
6872        "113": [0.18906, 0.47534, 0, 0],
6873        "114": [0, 0.47534, 0, 0],
6874        "115": [0, 0.47534, 0, 0],
6875        "116": [0, 0.62119, 0, 0],
6876        "117": [0, 0.47534, 0, 0],
6877        "118": [0, 0.52396, 0, 0],
6878        "119": [0, 0.52396, 0, 0],
6879        "120": [0.18906, 0.47534, 0, 0],
6880        "121": [0.18906, 0.47534, 0, 0],
6881        "122": [0.18906, 0.47534, 0, 0],
6882        "8216": [0, 0.69141, 0, 0],
6883        "8217": [0, 0.69141, 0, 0],
6884        "58112": [0, 0.62119, 0, 0],
6885        "58113": [0, 0.62119, 0, 0],
6886        "58114": [0.18906, 0.69141, 0, 0],
6887        "58115": [0.18906, 0.69141, 0, 0],
6888        "58116": [0.18906, 0.47534, 0, 0],
6889        "58117": [0, 0.69141, 0, 0],
6890        "58118": [0, 0.62119, 0, 0],
6891        "58119": [0, 0.47534, 0, 0]
6892    },
6893    "Main-Bold": {
6894        "33": [0, 0.69444, 0, 0],
6895        "34": [0, 0.69444, 0, 0],
6896        "35": [0.19444, 0.69444, 0, 0],
6897        "36": [0.05556, 0.75, 0, 0],
6898        "37": [0.05556, 0.75, 0, 0],
6899        "38": [0, 0.69444, 0, 0],
6900        "39": [0, 0.69444, 0, 0],
6901        "40": [0.25, 0.75, 0, 0],
6902        "41": [0.25, 0.75, 0, 0],
6903        "42": [0, 0.75, 0, 0],
6904        "43": [0.13333, 0.63333, 0, 0],
6905        "44": [0.19444, 0.15556, 0, 0],
6906        "45": [0, 0.44444, 0, 0],
6907        "46": [0, 0.15556, 0, 0],
6908        "47": [0.25, 0.75, 0, 0],
6909        "48": [0, 0.64444, 0, 0],
6910        "49": [0, 0.64444, 0, 0],
6911        "50": [0, 0.64444, 0, 0],
6912        "51": [0, 0.64444, 0, 0],
6913        "52": [0, 0.64444, 0, 0],
6914        "53": [0, 0.64444, 0, 0],
6915        "54": [0, 0.64444, 0, 0],
6916        "55": [0, 0.64444, 0, 0],
6917        "56": [0, 0.64444, 0, 0],
6918        "57": [0, 0.64444, 0, 0],
6919        "58": [0, 0.44444, 0, 0],
6920        "59": [0.19444, 0.44444, 0, 0],
6921        "60": [0.08556, 0.58556, 0, 0],
6922        "61": [-0.10889, 0.39111, 0, 0],
6923        "62": [0.08556, 0.58556, 0, 0],
6924        "63": [0, 0.69444, 0, 0],
6925        "64": [0, 0.69444, 0, 0],
6926        "65": [0, 0.68611, 0, 0],
6927        "66": [0, 0.68611, 0, 0],
6928        "67": [0, 0.68611, 0, 0],
6929        "68": [0, 0.68611, 0, 0],
6930        "69": [0, 0.68611, 0, 0],
6931        "70": [0, 0.68611, 0, 0],
6932        "71": [0, 0.68611, 0, 0],
6933        "72": [0, 0.68611, 0, 0],
6934        "73": [0, 0.68611, 0, 0],
6935        "74": [0, 0.68611, 0, 0],
6936        "75": [0, 0.68611, 0, 0],
6937        "76": [0, 0.68611, 0, 0],
6938        "77": [0, 0.68611, 0, 0],
6939        "78": [0, 0.68611, 0, 0],
6940        "79": [0, 0.68611, 0, 0],
6941        "80": [0, 0.68611, 0, 0],
6942        "81": [0.19444, 0.68611, 0, 0],
6943        "82": [0, 0.68611, 0, 0],
6944        "83": [0, 0.68611, 0, 0],
6945        "84": [0, 0.68611, 0, 0],
6946        "85": [0, 0.68611, 0, 0],
6947        "86": [0, 0.68611, 0.01597, 0],
6948        "87": [0, 0.68611, 0.01597, 0],
6949        "88": [0, 0.68611, 0, 0],
6950        "89": [0, 0.68611, 0.02875, 0],
6951        "90": [0, 0.68611, 0, 0],
6952        "91": [0.25, 0.75, 0, 0],
6953        "92": [0.25, 0.75, 0, 0],
6954        "93": [0.25, 0.75, 0, 0],
6955        "94": [0, 0.69444, 0, 0],
6956        "95": [0.31, 0.13444, 0.03194, 0],
6957        "96": [0, 0.69444, 0, 0],
6958        "97": [0, 0.44444, 0, 0],
6959        "98": [0, 0.69444, 0, 0],
6960        "99": [0, 0.44444, 0, 0],
6961        "100": [0, 0.69444, 0, 0],
6962        "101": [0, 0.44444, 0, 0],
6963        "102": [0, 0.69444, 0.10903, 0],
6964        "103": [0.19444, 0.44444, 0.01597, 0],
6965        "104": [0, 0.69444, 0, 0],
6966        "105": [0, 0.69444, 0, 0],
6967        "106": [0.19444, 0.69444, 0, 0],
6968        "107": [0, 0.69444, 0, 0],
6969        "108": [0, 0.69444, 0, 0],
6970        "109": [0, 0.44444, 0, 0],
6971        "110": [0, 0.44444, 0, 0],
6972        "111": [0, 0.44444, 0, 0],
6973        "112": [0.19444, 0.44444, 0, 0],
6974        "113": [0.19444, 0.44444, 0, 0],
6975        "114": [0, 0.44444, 0, 0],
6976        "115": [0, 0.44444, 0, 0],
6977        "116": [0, 0.63492, 0, 0],
6978        "117": [0, 0.44444, 0, 0],
6979        "118": [0, 0.44444, 0.01597, 0],
6980        "119": [0, 0.44444, 0.01597, 0],
6981        "120": [0, 0.44444, 0, 0],
6982        "121": [0.19444, 0.44444, 0.01597, 0],
6983        "122": [0, 0.44444, 0, 0],
6984        "123": [0.25, 0.75, 0, 0],
6985        "124": [0.25, 0.75, 0, 0],
6986        "125": [0.25, 0.75, 0, 0],
6987        "126": [0.35, 0.34444, 0, 0],
6988        "168": [0, 0.69444, 0, 0],
6989        "172": [0, 0.44444, 0, 0],
6990        "175": [0, 0.59611, 0, 0],
6991        "176": [0, 0.69444, 0, 0],
6992        "177": [0.13333, 0.63333, 0, 0],
6993        "180": [0, 0.69444, 0, 0],
6994        "215": [0.13333, 0.63333, 0, 0],
6995        "247": [0.13333, 0.63333, 0, 0],
6996        "305": [0, 0.44444, 0, 0],
6997        "567": [0.19444, 0.44444, 0, 0],
6998        "710": [0, 0.69444, 0, 0],
6999        "711": [0, 0.63194, 0, 0],
7000        "713": [0, 0.59611, 0, 0],
7001        "714": [0, 0.69444, 0, 0],
7002        "715": [0, 0.69444, 0, 0],
7003        "728": [0, 0.69444, 0, 0],
7004        "729": [0, 0.69444, 0, 0],
7005        "730": [0, 0.69444, 0, 0],
7006        "732": [0, 0.69444, 0, 0],
7007        "768": [0, 0.69444, 0, 0],
7008        "769": [0, 0.69444, 0, 0],
7009        "770": [0, 0.69444, 0, 0],
7010        "771": [0, 0.69444, 0, 0],
7011        "772": [0, 0.59611, 0, 0],
7012        "774": [0, 0.69444, 0, 0],
7013        "775": [0, 0.69444, 0, 0],
7014        "776": [0, 0.69444, 0, 0],
7015        "778": [0, 0.69444, 0, 0],
7016        "779": [0, 0.69444, 0, 0],
7017        "780": [0, 0.63194, 0, 0],
7018        "824": [0.19444, 0.69444, 0, 0],
7019        "915": [0, 0.68611, 0, 0],
7020        "916": [0, 0.68611, 0, 0],
7021        "920": [0, 0.68611, 0, 0],
7022        "923": [0, 0.68611, 0, 0],
7023        "926": [0, 0.68611, 0, 0],
7024        "928": [0, 0.68611, 0, 0],
7025        "931": [0, 0.68611, 0, 0],
7026        "933": [0, 0.68611, 0, 0],
7027        "934": [0, 0.68611, 0, 0],
7028        "936": [0, 0.68611, 0, 0],
7029        "937": [0, 0.68611, 0, 0],
7030        "8211": [0, 0.44444, 0.03194, 0],
7031        "8212": [0, 0.44444, 0.03194, 0],
7032        "8216": [0, 0.69444, 0, 0],
7033        "8217": [0, 0.69444, 0, 0],
7034        "8220": [0, 0.69444, 0, 0],
7035        "8221": [0, 0.69444, 0, 0],
7036        "8224": [0.19444, 0.69444, 0, 0],
7037        "8225": [0.19444, 0.69444, 0, 0],
7038        "8242": [0, 0.55556, 0, 0],
7039        "8407": [0, 0.72444, 0.15486, 0],
7040        "8463": [0, 0.69444, 0, 0],
7041        "8465": [0, 0.69444, 0, 0],
7042        "8467": [0, 0.69444, 0, 0],
7043        "8472": [0.19444, 0.44444, 0, 0],
7044        "8476": [0, 0.69444, 0, 0],
7045        "8501": [0, 0.69444, 0, 0],
7046        "8592": [-0.10889, 0.39111, 0, 0],
7047        "8593": [0.19444, 0.69444, 0, 0],
7048        "8594": [-0.10889, 0.39111, 0, 0],
7049        "8595": [0.19444, 0.69444, 0, 0],
7050        "8596": [-0.10889, 0.39111, 0, 0],
7051        "8597": [0.25, 0.75, 0, 0],
7052        "8598": [0.19444, 0.69444, 0, 0],
7053        "8599": [0.19444, 0.69444, 0, 0],
7054        "8600": [0.19444, 0.69444, 0, 0],
7055        "8601": [0.19444, 0.69444, 0, 0],
7056        "8636": [-0.10889, 0.39111, 0, 0],
7057        "8637": [-0.10889, 0.39111, 0, 0],
7058        "8640": [-0.10889, 0.39111, 0, 0],
7059        "8641": [-0.10889, 0.39111, 0, 0],
7060        "8656": [-0.10889, 0.39111, 0, 0],
7061        "8657": [0.19444, 0.69444, 0, 0],
7062        "8658": [-0.10889, 0.39111, 0, 0],
7063        "8659": [0.19444, 0.69444, 0, 0],
7064        "8660": [-0.10889, 0.39111, 0, 0],
7065        "8661": [0.25, 0.75, 0, 0],
7066        "8704": [0, 0.69444, 0, 0],
7067        "8706": [0, 0.69444, 0.06389, 0],
7068        "8707": [0, 0.69444, 0, 0],
7069        "8709": [0.05556, 0.75, 0, 0],
7070        "8711": [0, 0.68611, 0, 0],
7071        "8712": [0.08556, 0.58556, 0, 0],
7072        "8715": [0.08556, 0.58556, 0, 0],
7073        "8722": [0.13333, 0.63333, 0, 0],
7074        "8723": [0.13333, 0.63333, 0, 0],
7075        "8725": [0.25, 0.75, 0, 0],
7076        "8726": [0.25, 0.75, 0, 0],
7077        "8727": [-0.02778, 0.47222, 0, 0],
7078        "8728": [-0.02639, 0.47361, 0, 0],
7079        "8729": [-0.02639, 0.47361, 0, 0],
7080        "8730": [0.18, 0.82, 0, 0],
7081        "8733": [0, 0.44444, 0, 0],
7082        "8734": [0, 0.44444, 0, 0],
7083        "8736": [0, 0.69224, 0, 0],
7084        "8739": [0.25, 0.75, 0, 0],
7085        "8741": [0.25, 0.75, 0, 0],
7086        "8743": [0, 0.55556, 0, 0],
7087        "8744": [0, 0.55556, 0, 0],
7088        "8745": [0, 0.55556, 0, 0],
7089        "8746": [0, 0.55556, 0, 0],
7090        "8747": [0.19444, 0.69444, 0.12778, 0],
7091        "8764": [-0.10889, 0.39111, 0, 0],
7092        "8768": [0.19444, 0.69444, 0, 0],
7093        "8771": [0.00222, 0.50222, 0, 0],
7094        "8776": [0.02444, 0.52444, 0, 0],
7095        "8781": [0.00222, 0.50222, 0, 0],
7096        "8801": [0.00222, 0.50222, 0, 0],
7097        "8804": [0.19667, 0.69667, 0, 0],
7098        "8805": [0.19667, 0.69667, 0, 0],
7099        "8810": [0.08556, 0.58556, 0, 0],
7100        "8811": [0.08556, 0.58556, 0, 0],
7101        "8826": [0.08556, 0.58556, 0, 0],
7102        "8827": [0.08556, 0.58556, 0, 0],
7103        "8834": [0.08556, 0.58556, 0, 0],
7104        "8835": [0.08556, 0.58556, 0, 0],
7105        "8838": [0.19667, 0.69667, 0, 0],
7106        "8839": [0.19667, 0.69667, 0, 0],
7107        "8846": [0, 0.55556, 0, 0],
7108        "8849": [0.19667, 0.69667, 0, 0],
7109        "8850": [0.19667, 0.69667, 0, 0],
7110        "8851": [0, 0.55556, 0, 0],
7111        "8852": [0, 0.55556, 0, 0],
7112        "8853": [0.13333, 0.63333, 0, 0],
7113        "8854": [0.13333, 0.63333, 0, 0],
7114        "8855": [0.13333, 0.63333, 0, 0],
7115        "8856": [0.13333, 0.63333, 0, 0],
7116        "8857": [0.13333, 0.63333, 0, 0],
7117        "8866": [0, 0.69444, 0, 0],
7118        "8867": [0, 0.69444, 0, 0],
7119        "8868": [0, 0.69444, 0, 0],
7120        "8869": [0, 0.69444, 0, 0],
7121        "8900": [-0.02639, 0.47361, 0, 0],
7122        "8901": [-0.02639, 0.47361, 0, 0],
7123        "8902": [-0.02778, 0.47222, 0, 0],
7124        "8968": [0.25, 0.75, 0, 0],
7125        "8969": [0.25, 0.75, 0, 0],
7126        "8970": [0.25, 0.75, 0, 0],
7127        "8971": [0.25, 0.75, 0, 0],
7128        "8994": [-0.13889, 0.36111, 0, 0],
7129        "8995": [-0.13889, 0.36111, 0, 0],
7130        "9651": [0.19444, 0.69444, 0, 0],
7131        "9657": [-0.02778, 0.47222, 0, 0],
7132        "9661": [0.19444, 0.69444, 0, 0],
7133        "9667": [-0.02778, 0.47222, 0, 0],
7134        "9711": [0.19444, 0.69444, 0, 0],
7135        "9824": [0.12963, 0.69444, 0, 0],
7136        "9825": [0.12963, 0.69444, 0, 0],
7137        "9826": [0.12963, 0.69444, 0, 0],
7138        "9827": [0.12963, 0.69444, 0, 0],
7139        "9837": [0, 0.75, 0, 0],
7140        "9838": [0.19444, 0.69444, 0, 0],
7141        "9839": [0.19444, 0.69444, 0, 0],
7142        "10216": [0.25, 0.75, 0, 0],
7143        "10217": [0.25, 0.75, 0, 0],
7144        "10815": [0, 0.68611, 0, 0],
7145        "10927": [0.19667, 0.69667, 0, 0],
7146        "10928": [0.19667, 0.69667, 0, 0]
7147    },
7148    "Main-Italic": {
7149        "33": [0, 0.69444, 0.12417, 0],
7150        "34": [0, 0.69444, 0.06961, 0],
7151        "35": [0.19444, 0.69444, 0.06616, 0],
7152        "37": [0.05556, 0.75, 0.13639, 0],
7153        "38": [0, 0.69444, 0.09694, 0],
7154        "39": [0, 0.69444, 0.12417, 0],
7155        "40": [0.25, 0.75, 0.16194, 0],
7156        "41": [0.25, 0.75, 0.03694, 0],
7157        "42": [0, 0.75, 0.14917, 0],
7158        "43": [0.05667, 0.56167, 0.03694, 0],
7159        "44": [0.19444, 0.10556, 0, 0],
7160        "45": [0, 0.43056, 0.02826, 0],
7161        "46": [0, 0.10556, 0, 0],
7162        "47": [0.25, 0.75, 0.16194, 0],
7163        "48": [0, 0.64444, 0.13556, 0],
7164        "49": [0, 0.64444, 0.13556, 0],
7165        "50": [0, 0.64444, 0.13556, 0],
7166        "51": [0, 0.64444, 0.13556, 0],
7167        "52": [0.19444, 0.64444, 0.13556, 0],
7168        "53": [0, 0.64444, 0.13556, 0],
7169        "54": [0, 0.64444, 0.13556, 0],
7170        "55": [0.19444, 0.64444, 0.13556, 0],
7171        "56": [0, 0.64444, 0.13556, 0],
7172        "57": [0, 0.64444, 0.13556, 0],
7173        "58": [0, 0.43056, 0.0582, 0],
7174        "59": [0.19444, 0.43056, 0.0582, 0],
7175        "61": [-0.13313, 0.36687, 0.06616, 0],
7176        "63": [0, 0.69444, 0.1225, 0],
7177        "64": [0, 0.69444, 0.09597, 0],
7178        "65": [0, 0.68333, 0, 0],
7179        "66": [0, 0.68333, 0.10257, 0],
7180        "67": [0, 0.68333, 0.14528, 0],
7181        "68": [0, 0.68333, 0.09403, 0],
7182        "69": [0, 0.68333, 0.12028, 0],
7183        "70": [0, 0.68333, 0.13305, 0],
7184        "71": [0, 0.68333, 0.08722, 0],
7185        "72": [0, 0.68333, 0.16389, 0],
7186        "73": [0, 0.68333, 0.15806, 0],
7187        "74": [0, 0.68333, 0.14028, 0],
7188        "75": [0, 0.68333, 0.14528, 0],
7189        "76": [0, 0.68333, 0, 0],
7190        "77": [0, 0.68333, 0.16389, 0],
7191        "78": [0, 0.68333, 0.16389, 0],
7192        "79": [0, 0.68333, 0.09403, 0],
7193        "80": [0, 0.68333, 0.10257, 0],
7194        "81": [0.19444, 0.68333, 0.09403, 0],
7195        "82": [0, 0.68333, 0.03868, 0],
7196        "83": [0, 0.68333, 0.11972, 0],
7197        "84": [0, 0.68333, 0.13305, 0],
7198        "85": [0, 0.68333, 0.16389, 0],
7199        "86": [0, 0.68333, 0.18361, 0],
7200        "87": [0, 0.68333, 0.18361, 0],
7201        "88": [0, 0.68333, 0.15806, 0],
7202        "89": [0, 0.68333, 0.19383, 0],
7203        "90": [0, 0.68333, 0.14528, 0],
7204        "91": [0.25, 0.75, 0.1875, 0],
7205        "93": [0.25, 0.75, 0.10528, 0],
7206        "94": [0, 0.69444, 0.06646, 0],
7207        "95": [0.31, 0.12056, 0.09208, 0],
7208        "97": [0, 0.43056, 0.07671, 0],
7209        "98": [0, 0.69444, 0.06312, 0],
7210        "99": [0, 0.43056, 0.05653, 0],
7211        "100": [0, 0.69444, 0.10333, 0],
7212        "101": [0, 0.43056, 0.07514, 0],
7213        "102": [0.19444, 0.69444, 0.21194, 0],
7214        "103": [0.19444, 0.43056, 0.08847, 0],
7215        "104": [0, 0.69444, 0.07671, 0],
7216        "105": [0, 0.65536, 0.1019, 0],
7217        "106": [0.19444, 0.65536, 0.14467, 0],
7218        "107": [0, 0.69444, 0.10764, 0],
7219        "108": [0, 0.69444, 0.10333, 0],
7220        "109": [0, 0.43056, 0.07671, 0],
7221        "110": [0, 0.43056, 0.07671, 0],
7222        "111": [0, 0.43056, 0.06312, 0],
7223        "112": [0.19444, 0.43056, 0.06312, 0],
7224        "113": [0.19444, 0.43056, 0.08847, 0],
7225        "114": [0, 0.43056, 0.10764, 0],
7226        "115": [0, 0.43056, 0.08208, 0],
7227        "116": [0, 0.61508, 0.09486, 0],
7228        "117": [0, 0.43056, 0.07671, 0],
7229        "118": [0, 0.43056, 0.10764, 0],
7230        "119": [0, 0.43056, 0.10764, 0],
7231        "120": [0, 0.43056, 0.12042, 0],
7232        "121": [0.19444, 0.43056, 0.08847, 0],
7233        "122": [0, 0.43056, 0.12292, 0],
7234        "126": [0.35, 0.31786, 0.11585, 0],
7235        "163": [0, 0.69444, 0, 0],
7236        "305": [0, 0.43056, 0, 0.02778],
7237        "567": [0.19444, 0.43056, 0, 0.08334],
7238        "768": [0, 0.69444, 0, 0],
7239        "769": [0, 0.69444, 0.09694, 0],
7240        "770": [0, 0.69444, 0.06646, 0],
7241        "771": [0, 0.66786, 0.11585, 0],
7242        "772": [0, 0.56167, 0.10333, 0],
7243        "774": [0, 0.69444, 0.10806, 0],
7244        "775": [0, 0.66786, 0.11752, 0],
7245        "776": [0, 0.66786, 0.10474, 0],
7246        "778": [0, 0.69444, 0, 0],
7247        "779": [0, 0.69444, 0.1225, 0],
7248        "780": [0, 0.62847, 0.08295, 0],
7249        "915": [0, 0.68333, 0.13305, 0],
7250        "916": [0, 0.68333, 0, 0],
7251        "920": [0, 0.68333, 0.09403, 0],
7252        "923": [0, 0.68333, 0, 0],
7253        "926": [0, 0.68333, 0.15294, 0],
7254        "928": [0, 0.68333, 0.16389, 0],
7255        "931": [0, 0.68333, 0.12028, 0],
7256        "933": [0, 0.68333, 0.11111, 0],
7257        "934": [0, 0.68333, 0.05986, 0],
7258        "936": [0, 0.68333, 0.11111, 0],
7259        "937": [0, 0.68333, 0.10257, 0],
7260        "8211": [0, 0.43056, 0.09208, 0],
7261        "8212": [0, 0.43056, 0.09208, 0],
7262        "8216": [0, 0.69444, 0.12417, 0],
7263        "8217": [0, 0.69444, 0.12417, 0],
7264        "8220": [0, 0.69444, 0.1685, 0],
7265        "8221": [0, 0.69444, 0.06961, 0],
7266        "8463": [0, 0.68889, 0, 0]
7267    },
7268    "Main-Regular": {
7269        "32": [0, 0, 0, 0],
7270        "33": [0, 0.69444, 0, 0],
7271        "34": [0, 0.69444, 0, 0],
7272        "35": [0.19444, 0.69444, 0, 0],
7273        "36": [0.05556, 0.75, 0, 0],
7274        "37": [0.05556, 0.75, 0, 0],
7275        "38": [0, 0.69444, 0, 0],
7276        "39": [0, 0.69444, 0, 0],
7277        "40": [0.25, 0.75, 0, 0],
7278        "41": [0.25, 0.75, 0, 0],
7279        "42": [0, 0.75, 0, 0],
7280        "43": [0.08333, 0.58333, 0, 0],
7281        "44": [0.19444, 0.10556, 0, 0],
7282        "45": [0, 0.43056, 0, 0],
7283        "46": [0, 0.10556, 0, 0],
7284        "47": [0.25, 0.75, 0, 0],
7285        "48": [0, 0.64444, 0, 0],
7286        "49": [0, 0.64444, 0, 0],
7287        "50": [0, 0.64444, 0, 0],
7288        "51": [0, 0.64444, 0, 0],
7289        "52": [0, 0.64444, 0, 0],
7290        "53": [0, 0.64444, 0, 0],
7291        "54": [0, 0.64444, 0, 0],
7292        "55": [0, 0.64444, 0, 0],
7293        "56": [0, 0.64444, 0, 0],
7294        "57": [0, 0.64444, 0, 0],
7295        "58": [0, 0.43056, 0, 0],
7296        "59": [0.19444, 0.43056, 0, 0],
7297        "60": [0.0391, 0.5391, 0, 0],
7298        "61": [-0.13313, 0.36687, 0, 0],
7299        "62": [0.0391, 0.5391, 0, 0],
7300        "63": [0, 0.69444, 0, 0],
7301        "64": [0, 0.69444, 0, 0],
7302        "65": [0, 0.68333, 0, 0],
7303        "66": [0, 0.68333, 0, 0],
7304        "67": [0, 0.68333, 0, 0],
7305        "68": [0, 0.68333, 0, 0],
7306        "69": [0, 0.68333, 0, 0],
7307        "70": [0, 0.68333, 0, 0],
7308        "71": [0, 0.68333, 0, 0],
7309        "72": [0, 0.68333, 0, 0],
7310        "73": [0, 0.68333, 0, 0],
7311        "74": [0, 0.68333, 0, 0],
7312        "75": [0, 0.68333, 0, 0],
7313        "76": [0, 0.68333, 0, 0],
7314        "77": [0, 0.68333, 0, 0],
7315        "78": [0, 0.68333, 0, 0],
7316        "79": [0, 0.68333, 0, 0],
7317        "80": [0, 0.68333, 0, 0],
7318        "81": [0.19444, 0.68333, 0, 0],
7319        "82": [0, 0.68333, 0, 0],
7320        "83": [0, 0.68333, 0, 0],
7321        "84": [0, 0.68333, 0, 0],
7322        "85": [0, 0.68333, 0, 0],
7323        "86": [0, 0.68333, 0.01389, 0],
7324        "87": [0, 0.68333, 0.01389, 0],
7325        "88": [0, 0.68333, 0, 0],
7326        "89": [0, 0.68333, 0.025, 0],
7327        "90": [0, 0.68333, 0, 0],
7328        "91": [0.25, 0.75, 0, 0],
7329        "92": [0.25, 0.75, 0, 0],
7330        "93": [0.25, 0.75, 0, 0],
7331        "94": [0, 0.69444, 0, 0],
7332        "95": [0.31, 0.12056, 0.02778, 0],
7333        "96": [0, 0.69444, 0, 0],
7334        "97": [0, 0.43056, 0, 0],
7335        "98": [0, 0.69444, 0, 0],
7336        "99": [0, 0.43056, 0, 0],
7337        "100": [0, 0.69444, 0, 0],
7338        "101": [0, 0.43056, 0, 0],
7339        "102": [0, 0.69444, 0.07778, 0],
7340        "103": [0.19444, 0.43056, 0.01389, 0],
7341        "104": [0, 0.69444, 0, 0],
7342        "105": [0, 0.66786, 0, 0],
7343        "106": [0.19444, 0.66786, 0, 0],
7344        "107": [0, 0.69444, 0, 0],
7345        "108": [0, 0.69444, 0, 0],
7346        "109": [0, 0.43056, 0, 0],
7347        "110": [0, 0.43056, 0, 0],
7348        "111": [0, 0.43056, 0, 0],
7349        "112": [0.19444, 0.43056, 0, 0],
7350        "113": [0.19444, 0.43056, 0, 0],
7351        "114": [0, 0.43056, 0, 0],
7352        "115": [0, 0.43056, 0, 0],
7353        "116": [0, 0.61508, 0, 0],
7354        "117": [0, 0.43056, 0, 0],
7355        "118": [0, 0.43056, 0.01389, 0],
7356        "119": [0, 0.43056, 0.01389, 0],
7357        "120": [0, 0.43056, 0, 0],
7358        "121": [0.19444, 0.43056, 0.01389, 0],
7359        "122": [0, 0.43056, 0, 0],
7360        "123": [0.25, 0.75, 0, 0],
7361        "124": [0.25, 0.75, 0, 0],
7362        "125": [0.25, 0.75, 0, 0],
7363        "126": [0.35, 0.31786, 0, 0],
7364        "160": [0, 0, 0, 0],
7365        "168": [0, 0.66786, 0, 0],
7366        "172": [0, 0.43056, 0, 0],
7367        "175": [0, 0.56778, 0, 0],
7368        "176": [0, 0.69444, 0, 0],
7369        "177": [0.08333, 0.58333, 0, 0],
7370        "180": [0, 0.69444, 0, 0],
7371        "215": [0.08333, 0.58333, 0, 0],
7372        "247": [0.08333, 0.58333, 0, 0],
7373        "305": [0, 0.43056, 0, 0],
7374        "567": [0.19444, 0.43056, 0, 0],
7375        "710": [0, 0.69444, 0, 0],
7376        "711": [0, 0.62847, 0, 0],
7377        "713": [0, 0.56778, 0, 0],
7378        "714": [0, 0.69444, 0, 0],
7379        "715": [0, 0.69444, 0, 0],
7380        "728": [0, 0.69444, 0, 0],
7381        "729": [0, 0.66786, 0, 0],
7382        "730": [0, 0.69444, 0, 0],
7383        "732": [0, 0.66786, 0, 0],
7384        "768": [0, 0.69444, 0, 0],
7385        "769": [0, 0.69444, 0, 0],
7386        "770": [0, 0.69444, 0, 0],
7387        "771": [0, 0.66786, 0, 0],
7388        "772": [0, 0.56778, 0, 0],
7389        "774": [0, 0.69444, 0, 0],
7390        "775": [0, 0.66786, 0, 0],
7391        "776": [0, 0.66786, 0, 0],
7392        "778": [0, 0.69444, 0, 0],
7393        "779": [0, 0.69444, 0, 0],
7394        "780": [0, 0.62847, 0, 0],
7395        "824": [0.19444, 0.69444, 0, 0],
7396        "915": [0, 0.68333, 0, 0],
7397        "916": [0, 0.68333, 0, 0],
7398        "920": [0, 0.68333, 0, 0],
7399        "923": [0, 0.68333, 0, 0],
7400        "926": [0, 0.68333, 0, 0],
7401        "928": [0, 0.68333, 0, 0],
7402        "931": [0, 0.68333, 0, 0],
7403        "933": [0, 0.68333, 0, 0],
7404        "934": [0, 0.68333, 0, 0],
7405        "936": [0, 0.68333, 0, 0],
7406        "937": [0, 0.68333, 0, 0],
7407        "8211": [0, 0.43056, 0.02778, 0],
7408        "8212": [0, 0.43056, 0.02778, 0],
7409        "8216": [0, 0.69444, 0, 0],
7410        "8217": [0, 0.69444, 0, 0],
7411        "8220": [0, 0.69444, 0, 0],
7412        "8221": [0, 0.69444, 0, 0],
7413        "8224": [0.19444, 0.69444, 0, 0],
7414        "8225": [0.19444, 0.69444, 0, 0],
7415        "8230": [0, 0.12, 0, 0],
7416        "8242": [0, 0.55556, 0, 0],
7417        "8407": [0, 0.71444, 0.15382, 0],
7418        "8463": [0, 0.68889, 0, 0],
7419        "8465": [0, 0.69444, 0, 0],
7420        "8467": [0, 0.69444, 0, 0.11111],
7421        "8472": [0.19444, 0.43056, 0, 0.11111],
7422        "8476": [0, 0.69444, 0, 0],
7423        "8501": [0, 0.69444, 0, 0],
7424        "8592": [-0.13313, 0.36687, 0, 0],
7425        "8593": [0.19444, 0.69444, 0, 0],
7426        "8594": [-0.13313, 0.36687, 0, 0],
7427        "8595": [0.19444, 0.69444, 0, 0],
7428        "8596": [-0.13313, 0.36687, 0, 0],
7429        "8597": [0.25, 0.75, 0, 0],
7430        "8598": [0.19444, 0.69444, 0, 0],
7431        "8599": [0.19444, 0.69444, 0, 0],
7432        "8600": [0.19444, 0.69444, 0, 0],
7433        "8601": [0.19444, 0.69444, 0, 0],
7434        "8614": [0.011, 0.511, 0, 0],
7435        "8617": [0.011, 0.511, 0, 0],
7436        "8618": [0.011, 0.511, 0, 0],
7437        "8636": [-0.13313, 0.36687, 0, 0],
7438        "8637": [-0.13313, 0.36687, 0, 0],
7439        "8640": [-0.13313, 0.36687, 0, 0],
7440        "8641": [-0.13313, 0.36687, 0, 0],
7441        "8652": [0.011, 0.671, 0, 0],
7442        "8656": [-0.13313, 0.36687, 0, 0],
7443        "8657": [0.19444, 0.69444, 0, 0],
7444        "8658": [-0.13313, 0.36687, 0, 0],
7445        "8659": [0.19444, 0.69444, 0, 0],
7446        "8660": [-0.13313, 0.36687, 0, 0],
7447        "8661": [0.25, 0.75, 0, 0],
7448        "8704": [0, 0.69444, 0, 0],
7449        "8706": [0, 0.69444, 0.05556, 0.08334],
7450        "8707": [0, 0.69444, 0, 0],
7451        "8709": [0.05556, 0.75, 0, 0],
7452        "8711": [0, 0.68333, 0, 0],
7453        "8712": [0.0391, 0.5391, 0, 0],
7454        "8715": [0.0391, 0.5391, 0, 0],
7455        "8722": [0.08333, 0.58333, 0, 0],
7456        "8723": [0.08333, 0.58333, 0, 0],
7457        "8725": [0.25, 0.75, 0, 0],
7458        "8726": [0.25, 0.75, 0, 0],
7459        "8727": [-0.03472, 0.46528, 0, 0],
7460        "8728": [-0.05555, 0.44445, 0, 0],
7461        "8729": [-0.05555, 0.44445, 0, 0],
7462        "8730": [0.2, 0.8, 0, 0],
7463        "8733": [0, 0.43056, 0, 0],
7464        "8734": [0, 0.43056, 0, 0],
7465        "8736": [0, 0.69224, 0, 0],
7466        "8739": [0.25, 0.75, 0, 0],
7467        "8741": [0.25, 0.75, 0, 0],
7468        "8743": [0, 0.55556, 0, 0],
7469        "8744": [0, 0.55556, 0, 0],
7470        "8745": [0, 0.55556, 0, 0],
7471        "8746": [0, 0.55556, 0, 0],
7472        "8747": [0.19444, 0.69444, 0.11111, 0],
7473        "8764": [-0.13313, 0.36687, 0, 0],
7474        "8768": [0.19444, 0.69444, 0, 0],
7475        "8771": [-0.03625, 0.46375, 0, 0],
7476        "8773": [-0.022, 0.589, 0, 0],
7477        "8776": [-0.01688, 0.48312, 0, 0],
7478        "8781": [-0.03625, 0.46375, 0, 0],
7479        "8784": [-0.133, 0.67, 0, 0],
7480        "8800": [0.215, 0.716, 0, 0],
7481        "8801": [-0.03625, 0.46375, 0, 0],
7482        "8804": [0.13597, 0.63597, 0, 0],
7483        "8805": [0.13597, 0.63597, 0, 0],
7484        "8810": [0.0391, 0.5391, 0, 0],
7485        "8811": [0.0391, 0.5391, 0, 0],
7486        "8826": [0.0391, 0.5391, 0, 0],
7487        "8827": [0.0391, 0.5391, 0, 0],
7488        "8834": [0.0391, 0.5391, 0, 0],
7489        "8835": [0.0391, 0.5391, 0, 0],
7490        "8838": [0.13597, 0.63597, 0, 0],
7491        "8839": [0.13597, 0.63597, 0, 0],
7492        "8846": [0, 0.55556, 0, 0],
7493        "8849": [0.13597, 0.63597, 0, 0],
7494        "8850": [0.13597, 0.63597, 0, 0],
7495        "8851": [0, 0.55556, 0, 0],
7496        "8852": [0, 0.55556, 0, 0],
7497        "8853": [0.08333, 0.58333, 0, 0],
7498        "8854": [0.08333, 0.58333, 0, 0],
7499        "8855": [0.08333, 0.58333, 0, 0],
7500        "8856": [0.08333, 0.58333, 0, 0],
7501        "8857": [0.08333, 0.58333, 0, 0],
7502        "8866": [0, 0.69444, 0, 0],
7503        "8867": [0, 0.69444, 0, 0],
7504        "8868": [0, 0.69444, 0, 0],
7505        "8869": [0, 0.69444, 0, 0],
7506        "8872": [0.249, 0.75, 0, 0],
7507        "8900": [-0.05555, 0.44445, 0, 0],
7508        "8901": [-0.05555, 0.44445, 0, 0],
7509        "8902": [-0.03472, 0.46528, 0, 0],
7510        "8904": [0.005, 0.505, 0, 0],
7511        "8942": [0.03, 0.9, 0, 0],
7512        "8943": [-0.19, 0.31, 0, 0],
7513        "8945": [-0.1, 0.82, 0, 0],
7514        "8968": [0.25, 0.75, 0, 0],
7515        "8969": [0.25, 0.75, 0, 0],
7516        "8970": [0.25, 0.75, 0, 0],
7517        "8971": [0.25, 0.75, 0, 0],
7518        "8994": [-0.14236, 0.35764, 0, 0],
7519        "8995": [-0.14236, 0.35764, 0, 0],
7520        "9136": [0.244, 0.744, 0, 0],
7521        "9137": [0.244, 0.744, 0, 0],
7522        "9651": [0.19444, 0.69444, 0, 0],
7523        "9657": [-0.03472, 0.46528, 0, 0],
7524        "9661": [0.19444, 0.69444, 0, 0],
7525        "9667": [-0.03472, 0.46528, 0, 0],
7526        "9711": [0.19444, 0.69444, 0, 0],
7527        "9824": [0.12963, 0.69444, 0, 0],
7528        "9825": [0.12963, 0.69444, 0, 0],
7529        "9826": [0.12963, 0.69444, 0, 0],
7530        "9827": [0.12963, 0.69444, 0, 0],
7531        "9837": [0, 0.75, 0, 0],
7532        "9838": [0.19444, 0.69444, 0, 0],
7533        "9839": [0.19444, 0.69444, 0, 0],
7534        "10216": [0.25, 0.75, 0, 0],
7535        "10217": [0.25, 0.75, 0, 0],
7536        "10222": [0.244, 0.744, 0, 0],
7537        "10223": [0.244, 0.744, 0, 0],
7538        "10229": [0.011, 0.511, 0, 0],
7539        "10230": [0.011, 0.511, 0, 0],
7540        "10231": [0.011, 0.511, 0, 0],
7541        "10232": [0.024, 0.525, 0, 0],
7542        "10233": [0.024, 0.525, 0, 0],
7543        "10234": [0.024, 0.525, 0, 0],
7544        "10236": [0.011, 0.511, 0, 0],
7545        "10815": [0, 0.68333, 0, 0],
7546        "10927": [0.13597, 0.63597, 0, 0],
7547        "10928": [0.13597, 0.63597, 0, 0]
7548    },
7549    "Math-BoldItalic": {
7550        "47": [0.19444, 0.69444, 0, 0],
7551        "65": [0, 0.68611, 0, 0],
7552        "66": [0, 0.68611, 0.04835, 0],
7553        "67": [0, 0.68611, 0.06979, 0],
7554        "68": [0, 0.68611, 0.03194, 0],
7555        "69": [0, 0.68611, 0.05451, 0],
7556        "70": [0, 0.68611, 0.15972, 0],
7557        "71": [0, 0.68611, 0, 0],
7558        "72": [0, 0.68611, 0.08229, 0],
7559        "73": [0, 0.68611, 0.07778, 0],
7560        "74": [0, 0.68611, 0.10069, 0],
7561        "75": [0, 0.68611, 0.06979, 0],
7562        "76": [0, 0.68611, 0, 0],
7563        "77": [0, 0.68611, 0.11424, 0],
7564        "78": [0, 0.68611, 0.11424, 0],
7565        "79": [0, 0.68611, 0.03194, 0],
7566        "80": [0, 0.68611, 0.15972, 0],
7567        "81": [0.19444, 0.68611, 0, 0],
7568        "82": [0, 0.68611, 0.00421, 0],
7569        "83": [0, 0.68611, 0.05382, 0],
7570        "84": [0, 0.68611, 0.15972, 0],
7571        "85": [0, 0.68611, 0.11424, 0],
7572        "86": [0, 0.68611, 0.25555, 0],
7573        "87": [0, 0.68611, 0.15972, 0],
7574        "88": [0, 0.68611, 0.07778, 0],
7575        "89": [0, 0.68611, 0.25555, 0],
7576        "90": [0, 0.68611, 0.06979, 0],
7577        "97": [0, 0.44444, 0, 0],
7578        "98": [0, 0.69444, 0, 0],
7579        "99": [0, 0.44444, 0, 0],
7580        "100": [0, 0.69444, 0, 0],
7581        "101": [0, 0.44444, 0, 0],
7582        "102": [0.19444, 0.69444, 0.11042, 0],
7583        "103": [0.19444, 0.44444, 0.03704, 0],
7584        "104": [0, 0.69444, 0, 0],
7585        "105": [0, 0.69326, 0, 0],
7586        "106": [0.19444, 0.69326, 0.0622, 0],
7587        "107": [0, 0.69444, 0.01852, 0],
7588        "108": [0, 0.69444, 0.0088, 0],
7589        "109": [0, 0.44444, 0, 0],
7590        "110": [0, 0.44444, 0, 0],
7591        "111": [0, 0.44444, 0, 0],
7592        "112": [0.19444, 0.44444, 0, 0],
7593        "113": [0.19444, 0.44444, 0.03704, 0],
7594        "114": [0, 0.44444, 0.03194, 0],
7595        "115": [0, 0.44444, 0, 0],
7596        "116": [0, 0.63492, 0, 0],
7597        "117": [0, 0.44444, 0, 0],
7598        "118": [0, 0.44444, 0.03704, 0],
7599        "119": [0, 0.44444, 0.02778, 0],
7600        "120": [0, 0.44444, 0, 0],
7601        "121": [0.19444, 0.44444, 0.03704, 0],
7602        "122": [0, 0.44444, 0.04213, 0],
7603        "915": [0, 0.68611, 0.15972, 0],
7604        "916": [0, 0.68611, 0, 0],
7605        "920": [0, 0.68611, 0.03194, 0],
7606        "923": [0, 0.68611, 0, 0],
7607        "926": [0, 0.68611, 0.07458, 0],
7608        "928": [0, 0.68611, 0.08229, 0],
7609        "931": [0, 0.68611, 0.05451, 0],
7610        "933": [0, 0.68611, 0.15972, 0],
7611        "934": [0, 0.68611, 0, 0],
7612        "936": [0, 0.68611, 0.11653, 0],
7613        "937": [0, 0.68611, 0.04835, 0],
7614        "945": [0, 0.44444, 0, 0],
7615        "946": [0.19444, 0.69444, 0.03403, 0],
7616        "947": [0.19444, 0.44444, 0.06389, 0],
7617        "948": [0, 0.69444, 0.03819, 0],
7618        "949": [0, 0.44444, 0, 0],
7619        "950": [0.19444, 0.69444, 0.06215, 0],
7620        "951": [0.19444, 0.44444, 0.03704, 0],
7621        "952": [0, 0.69444, 0.03194, 0],
7622        "953": [0, 0.44444, 0, 0],
7623        "954": [0, 0.44444, 0, 0],
7624        "955": [0, 0.69444, 0, 0],
7625        "956": [0.19444, 0.44444, 0, 0],
7626        "957": [0, 0.44444, 0.06898, 0],
7627        "958": [0.19444, 0.69444, 0.03021, 0],
7628        "959": [0, 0.44444, 0, 0],
7629        "960": [0, 0.44444, 0.03704, 0],
7630        "961": [0.19444, 0.44444, 0, 0],
7631        "962": [0.09722, 0.44444, 0.07917, 0],
7632        "963": [0, 0.44444, 0.03704, 0],
7633        "964": [0, 0.44444, 0.13472, 0],
7634        "965": [0, 0.44444, 0.03704, 0],
7635        "966": [0.19444, 0.44444, 0, 0],
7636        "967": [0.19444, 0.44444, 0, 0],
7637        "968": [0.19444, 0.69444, 0.03704, 0],
7638        "969": [0, 0.44444, 0.03704, 0],
7639        "977": [0, 0.69444, 0, 0],
7640        "981": [0.19444, 0.69444, 0, 0],
7641        "982": [0, 0.44444, 0.03194, 0],
7642        "1009": [0.19444, 0.44444, 0, 0],
7643        "1013": [0, 0.44444, 0, 0]
7644    },
7645    "Math-Italic": {
7646        "47": [0.19444, 0.69444, 0, 0],
7647        "65": [0, 0.68333, 0, 0.13889],
7648        "66": [0, 0.68333, 0.05017, 0.08334],
7649        "67": [0, 0.68333, 0.07153, 0.08334],
7650        "68": [0, 0.68333, 0.02778, 0.05556],
7651        "69": [0, 0.68333, 0.05764, 0.08334],
7652        "70": [0, 0.68333, 0.13889, 0.08334],
7653        "71": [0, 0.68333, 0, 0.08334],
7654        "72": [0, 0.68333, 0.08125, 0.05556],
7655        "73": [0, 0.68333, 0.07847, 0.11111],
7656        "74": [0, 0.68333, 0.09618, 0.16667],
7657        "75": [0, 0.68333, 0.07153, 0.05556],
7658        "76": [0, 0.68333, 0, 0.02778],
7659        "77": [0, 0.68333, 0.10903, 0.08334],
7660        "78": [0, 0.68333, 0.10903, 0.08334],
7661        "79": [0, 0.68333, 0.02778, 0.08334],
7662        "80": [0, 0.68333, 0.13889, 0.08334],
7663        "81": [0.19444, 0.68333, 0, 0.08334],
7664        "82": [0, 0.68333, 0.00773, 0.08334],
7665        "83": [0, 0.68333, 0.05764, 0.08334],
7666        "84": [0, 0.68333, 0.13889, 0.08334],
7667        "85": [0, 0.68333, 0.10903, 0.02778],
7668        "86": [0, 0.68333, 0.22222, 0],
7669        "87": [0, 0.68333, 0.13889, 0],
7670        "88": [0, 0.68333, 0.07847, 0.08334],
7671        "89": [0, 0.68333, 0.22222, 0],
7672        "90": [0, 0.68333, 0.07153, 0.08334],
7673        "97": [0, 0.43056, 0, 0],
7674        "98": [0, 0.69444, 0, 0],
7675        "99": [0, 0.43056, 0, 0.05556],
7676        "100": [0, 0.69444, 0, 0.16667],
7677        "101": [0, 0.43056, 0, 0.05556],
7678        "102": [0.19444, 0.69444, 0.10764, 0.16667],
7679        "103": [0.19444, 0.43056, 0.03588, 0.02778],
7680        "104": [0, 0.69444, 0, 0],
7681        "105": [0, 0.65952, 0, 0],
7682        "106": [0.19444, 0.65952, 0.05724, 0],
7683        "107": [0, 0.69444, 0.03148, 0],
7684        "108": [0, 0.69444, 0.01968, 0.08334],
7685        "109": [0, 0.43056, 0, 0],
7686        "110": [0, 0.43056, 0, 0],
7687        "111": [0, 0.43056, 0, 0.05556],
7688        "112": [0.19444, 0.43056, 0, 0.08334],
7689        "113": [0.19444, 0.43056, 0.03588, 0.08334],
7690        "114": [0, 0.43056, 0.02778, 0.05556],
7691        "115": [0, 0.43056, 0, 0.05556],
7692        "116": [0, 0.61508, 0, 0.08334],
7693        "117": [0, 0.43056, 0, 0.02778],
7694        "118": [0, 0.43056, 0.03588, 0.02778],
7695        "119": [0, 0.43056, 0.02691, 0.08334],
7696        "120": [0, 0.43056, 0, 0.02778],
7697        "121": [0.19444, 0.43056, 0.03588, 0.05556],
7698        "122": [0, 0.43056, 0.04398, 0.05556],
7699        "915": [0, 0.68333, 0.13889, 0.08334],
7700        "916": [0, 0.68333, 0, 0.16667],
7701        "920": [0, 0.68333, 0.02778, 0.08334],
7702        "923": [0, 0.68333, 0, 0.16667],
7703        "926": [0, 0.68333, 0.07569, 0.08334],
7704        "928": [0, 0.68333, 0.08125, 0.05556],
7705        "931": [0, 0.68333, 0.05764, 0.08334],
7706        "933": [0, 0.68333, 0.13889, 0.05556],
7707        "934": [0, 0.68333, 0, 0.08334],
7708        "936": [0, 0.68333, 0.11, 0.05556],
7709        "937": [0, 0.68333, 0.05017, 0.08334],
7710        "945": [0, 0.43056, 0.0037, 0.02778],
7711        "946": [0.19444, 0.69444, 0.05278, 0.08334],
7712        "947": [0.19444, 0.43056, 0.05556, 0],
7713        "948": [0, 0.69444, 0.03785, 0.05556],
7714        "949": [0, 0.43056, 0, 0.08334],
7715        "950": [0.19444, 0.69444, 0.07378, 0.08334],
7716        "951": [0.19444, 0.43056, 0.03588, 0.05556],
7717        "952": [0, 0.69444, 0.02778, 0.08334],
7718        "953": [0, 0.43056, 0, 0.05556],
7719        "954": [0, 0.43056, 0, 0],
7720        "955": [0, 0.69444, 0, 0],
7721        "956": [0.19444, 0.43056, 0, 0.02778],
7722        "957": [0, 0.43056, 0.06366, 0.02778],
7723        "958": [0.19444, 0.69444, 0.04601, 0.11111],
7724        "959": [0, 0.43056, 0, 0.05556],
7725        "960": [0, 0.43056, 0.03588, 0],
7726        "961": [0.19444, 0.43056, 0, 0.08334],
7727        "962": [0.09722, 0.43056, 0.07986, 0.08334],
7728        "963": [0, 0.43056, 0.03588, 0],
7729        "964": [0, 0.43056, 0.1132, 0.02778],
7730        "965": [0, 0.43056, 0.03588, 0.02778],
7731        "966": [0.19444, 0.43056, 0, 0.08334],
7732        "967": [0.19444, 0.43056, 0, 0.05556],
7733        "968": [0.19444, 0.69444, 0.03588, 0.11111],
7734        "969": [0, 0.43056, 0.03588, 0],
7735        "977": [0, 0.69444, 0, 0.08334],
7736        "981": [0.19444, 0.69444, 0, 0.08334],
7737        "982": [0, 0.43056, 0.02778, 0],
7738        "1009": [0.19444, 0.43056, 0, 0.08334],
7739        "1013": [0, 0.43056, 0, 0.05556]
7740    },
7741    "Math-Regular": {
7742        "65": [0, 0.68333, 0, 0.13889],
7743        "66": [0, 0.68333, 0.05017, 0.08334],
7744        "67": [0, 0.68333, 0.07153, 0.08334],
7745        "68": [0, 0.68333, 0.02778, 0.05556],
7746        "69": [0, 0.68333, 0.05764, 0.08334],
7747        "70": [0, 0.68333, 0.13889, 0.08334],
7748        "71": [0, 0.68333, 0, 0.08334],
7749        "72": [0, 0.68333, 0.08125, 0.05556],
7750        "73": [0, 0.68333, 0.07847, 0.11111],
7751        "74": [0, 0.68333, 0.09618, 0.16667],
7752        "75": [0, 0.68333, 0.07153, 0.05556],
7753        "76": [0, 0.68333, 0, 0.02778],
7754        "77": [0, 0.68333, 0.10903, 0.08334],
7755        "78": [0, 0.68333, 0.10903, 0.08334],
7756        "79": [0, 0.68333, 0.02778, 0.08334],
7757        "80": [0, 0.68333, 0.13889, 0.08334],
7758        "81": [0.19444, 0.68333, 0, 0.08334],
7759        "82": [0, 0.68333, 0.00773, 0.08334],
7760        "83": [0, 0.68333, 0.05764, 0.08334],
7761        "84": [0, 0.68333, 0.13889, 0.08334],
7762        "85": [0, 0.68333, 0.10903, 0.02778],
7763        "86": [0, 0.68333, 0.22222, 0],
7764        "87": [0, 0.68333, 0.13889, 0],
7765        "88": [0, 0.68333, 0.07847, 0.08334],
7766        "89": [0, 0.68333, 0.22222, 0],
7767        "90": [0, 0.68333, 0.07153, 0.08334],
7768        "97": [0, 0.43056, 0, 0],
7769        "98": [0, 0.69444, 0, 0],
7770        "99": [0, 0.43056, 0, 0.05556],
7771        "100": [0, 0.69444, 0, 0.16667],
7772        "101": [0, 0.43056, 0, 0.05556],
7773        "102": [0.19444, 0.69444, 0.10764, 0.16667],
7774        "103": [0.19444, 0.43056, 0.03588, 0.02778],
7775        "104": [0, 0.69444, 0, 0],
7776        "105": [0, 0.65952, 0, 0],
7777        "106": [0.19444, 0.65952, 0.05724, 0],
7778        "107": [0, 0.69444, 0.03148, 0],
7779        "108": [0, 0.69444, 0.01968, 0.08334],
7780        "109": [0, 0.43056, 0, 0],
7781        "110": [0, 0.43056, 0, 0],
7782        "111": [0, 0.43056, 0, 0.05556],
7783        "112": [0.19444, 0.43056, 0, 0.08334],
7784        "113": [0.19444, 0.43056, 0.03588, 0.08334],
7785        "114": [0, 0.43056, 0.02778, 0.05556],
7786        "115": [0, 0.43056, 0, 0.05556],
7787        "116": [0, 0.61508, 0, 0.08334],
7788        "117": [0, 0.43056, 0, 0.02778],
7789        "118": [0, 0.43056, 0.03588, 0.02778],
7790        "119": [0, 0.43056, 0.02691, 0.08334],
7791        "120": [0, 0.43056, 0, 0.02778],
7792        "121": [0.19444, 0.43056, 0.03588, 0.05556],
7793        "122": [0, 0.43056, 0.04398, 0.05556],
7794        "915": [0, 0.68333, 0.13889, 0.08334],
7795        "916": [0, 0.68333, 0, 0.16667],
7796        "920": [0, 0.68333, 0.02778, 0.08334],
7797        "923": [0, 0.68333, 0, 0.16667],
7798        "926": [0, 0.68333, 0.07569, 0.08334],
7799        "928": [0, 0.68333, 0.08125, 0.05556],
7800        "931": [0, 0.68333, 0.05764, 0.08334],
7801        "933": [0, 0.68333, 0.13889, 0.05556],
7802        "934": [0, 0.68333, 0, 0.08334],
7803        "936": [0, 0.68333, 0.11, 0.05556],
7804        "937": [0, 0.68333, 0.05017, 0.08334],
7805        "945": [0, 0.43056, 0.0037, 0.02778],
7806        "946": [0.19444, 0.69444, 0.05278, 0.08334],
7807        "947": [0.19444, 0.43056, 0.05556, 0],
7808        "948": [0, 0.69444, 0.03785, 0.05556],
7809        "949": [0, 0.43056, 0, 0.08334],
7810        "950": [0.19444, 0.69444, 0.07378, 0.08334],
7811        "951": [0.19444, 0.43056, 0.03588, 0.05556],
7812        "952": [0, 0.69444, 0.02778, 0.08334],
7813        "953": [0, 0.43056, 0, 0.05556],
7814        "954": [0, 0.43056, 0, 0],
7815        "955": [0, 0.69444, 0, 0],
7816        "956": [0.19444, 0.43056, 0, 0.02778],
7817        "957": [0, 0.43056, 0.06366, 0.02778],
7818        "958": [0.19444, 0.69444, 0.04601, 0.11111],
7819        "959": [0, 0.43056, 0, 0.05556],
7820        "960": [0, 0.43056, 0.03588, 0],
7821        "961": [0.19444, 0.43056, 0, 0.08334],
7822        "962": [0.09722, 0.43056, 0.07986, 0.08334],
7823        "963": [0, 0.43056, 0.03588, 0],
7824        "964": [0, 0.43056, 0.1132, 0.02778],
7825        "965": [0, 0.43056, 0.03588, 0.02778],
7826        "966": [0.19444, 0.43056, 0, 0.08334],
7827        "967": [0.19444, 0.43056, 0, 0.05556],
7828        "968": [0.19444, 0.69444, 0.03588, 0.11111],
7829        "969": [0, 0.43056, 0.03588, 0],
7830        "977": [0, 0.69444, 0, 0.08334],
7831        "981": [0.19444, 0.69444, 0, 0.08334],
7832        "982": [0, 0.43056, 0.02778, 0],
7833        "1009": [0.19444, 0.43056, 0, 0.08334],
7834        "1013": [0, 0.43056, 0, 0.05556]
7835    },
7836    "SansSerif-Regular": {
7837        "33": [0, 0.69444, 0, 0],
7838        "34": [0, 0.69444, 0, 0],
7839        "35": [0.19444, 0.69444, 0, 0],
7840        "36": [0.05556, 0.75, 0, 0],
7841        "37": [0.05556, 0.75, 0, 0],
7842        "38": [0, 0.69444, 0, 0],
7843        "39": [0, 0.69444, 0, 0],
7844        "40": [0.25, 0.75, 0, 0],
7845        "41": [0.25, 0.75, 0, 0],
7846        "42": [0, 0.75, 0, 0],
7847        "43": [0.08333, 0.58333, 0, 0],
7848        "44": [0.125, 0.08333, 0, 0],
7849        "45": [0, 0.44444, 0, 0],
7850        "46": [0, 0.08333, 0, 0],
7851        "47": [0.25, 0.75, 0, 0],
7852        "48": [0, 0.65556, 0, 0],
7853        "49": [0, 0.65556, 0, 0],
7854        "50": [0, 0.65556, 0, 0],
7855        "51": [0, 0.65556, 0, 0],
7856        "52": [0, 0.65556, 0, 0],
7857        "53": [0, 0.65556, 0, 0],
7858        "54": [0, 0.65556, 0, 0],
7859        "55": [0, 0.65556, 0, 0],
7860        "56": [0, 0.65556, 0, 0],
7861        "57": [0, 0.65556, 0, 0],
7862        "58": [0, 0.44444, 0, 0],
7863        "59": [0.125, 0.44444, 0, 0],
7864        "61": [-0.13, 0.37, 0, 0],
7865        "63": [0, 0.69444, 0, 0],
7866        "64": [0, 0.69444, 0, 0],
7867        "65": [0, 0.69444, 0, 0],
7868        "66": [0, 0.69444, 0, 0],
7869        "67": [0, 0.69444, 0, 0],
7870        "68": [0, 0.69444, 0, 0],
7871        "69": [0, 0.69444, 0, 0],
7872        "70": [0, 0.69444, 0, 0],
7873        "71": [0, 0.69444, 0, 0],
7874        "72": [0, 0.69444, 0, 0],
7875        "73": [0, 0.69444, 0, 0],
7876        "74": [0, 0.69444, 0, 0],
7877        "75": [0, 0.69444, 0, 0],
7878        "76": [0, 0.69444, 0, 0],
7879        "77": [0, 0.69444, 0, 0],
7880        "78": [0, 0.69444, 0, 0],
7881        "79": [0, 0.69444, 0, 0],
7882        "80": [0, 0.69444, 0, 0],
7883        "81": [0.125, 0.69444, 0, 0],
7884        "82": [0, 0.69444, 0, 0],
7885        "83": [0, 0.69444, 0, 0],
7886        "84": [0, 0.69444, 0, 0],
7887        "85": [0, 0.69444, 0, 0],
7888        "86": [0, 0.69444, 0.01389, 0],
7889        "87": [0, 0.69444, 0.01389, 0],
7890        "88": [0, 0.69444, 0, 0],
7891        "89": [0, 0.69444, 0.025, 0],
7892        "90": [0, 0.69444, 0, 0],
7893        "91": [0.25, 0.75, 0, 0],
7894        "93": [0.25, 0.75, 0, 0],
7895        "94": [0, 0.69444, 0, 0],
7896        "95": [0.35, 0.09444, 0.02778, 0],
7897        "97": [0, 0.44444, 0, 0],
7898        "98": [0, 0.69444, 0, 0],
7899        "99": [0, 0.44444, 0, 0],
7900        "100": [0, 0.69444, 0, 0],
7901        "101": [0, 0.44444, 0, 0],
7902        "102": [0, 0.69444, 0.06944, 0],
7903        "103": [0.19444, 0.44444, 0.01389, 0],
7904        "104": [0, 0.69444, 0, 0],
7905        "105": [0, 0.67937, 0, 0],
7906        "106": [0.19444, 0.67937, 0, 0],
7907        "107": [0, 0.69444, 0, 0],
7908        "108": [0, 0.69444, 0, 0],
7909        "109": [0, 0.44444, 0, 0],
7910        "110": [0, 0.44444, 0, 0],
7911        "111": [0, 0.44444, 0, 0],
7912        "112": [0.19444, 0.44444, 0, 0],
7913        "113": [0.19444, 0.44444, 0, 0],
7914        "114": [0, 0.44444, 0.01389, 0],
7915        "115": [0, 0.44444, 0, 0],
7916        "116": [0, 0.57143, 0, 0],
7917        "117": [0, 0.44444, 0, 0],
7918        "118": [0, 0.44444, 0.01389, 0],
7919        "119": [0, 0.44444, 0.01389, 0],
7920        "120": [0, 0.44444, 0, 0],
7921        "121": [0.19444, 0.44444, 0.01389, 0],
7922        "122": [0, 0.44444, 0, 0],
7923        "126": [0.35, 0.32659, 0, 0],
7924        "305": [0, 0.44444, 0, 0],
7925        "567": [0.19444, 0.44444, 0, 0],
7926        "768": [0, 0.69444, 0, 0],
7927        "769": [0, 0.69444, 0, 0],
7928        "770": [0, 0.69444, 0, 0],
7929        "771": [0, 0.67659, 0, 0],
7930        "772": [0, 0.60889, 0, 0],
7931        "774": [0, 0.69444, 0, 0],
7932        "775": [0, 0.67937, 0, 0],
7933        "776": [0, 0.67937, 0, 0],
7934        "778": [0, 0.69444, 0, 0],
7935        "779": [0, 0.69444, 0, 0],
7936        "780": [0, 0.63194, 0, 0],
7937        "915": [0, 0.69444, 0, 0],
7938        "916": [0, 0.69444, 0, 0],
7939        "920": [0, 0.69444, 0, 0],
7940        "923": [0, 0.69444, 0, 0],
7941        "926": [0, 0.69444, 0, 0],
7942        "928": [0, 0.69444, 0, 0],
7943        "931": [0, 0.69444, 0, 0],
7944        "933": [0, 0.69444, 0, 0],
7945        "934": [0, 0.69444, 0, 0],
7946        "936": [0, 0.69444, 0, 0],
7947        "937": [0, 0.69444, 0, 0],
7948        "8211": [0, 0.44444, 0.02778, 0],
7949        "8212": [0, 0.44444, 0.02778, 0],
7950        "8216": [0, 0.69444, 0, 0],
7951        "8217": [0, 0.69444, 0, 0],
7952        "8220": [0, 0.69444, 0, 0],
7953        "8221": [0, 0.69444, 0, 0]
7954    },
7955    "Script-Regular": {
7956        "65": [0, 0.7, 0.22925, 0],
7957        "66": [0, 0.7, 0.04087, 0],
7958        "67": [0, 0.7, 0.1689, 0],
7959        "68": [0, 0.7, 0.09371, 0],
7960        "69": [0, 0.7, 0.18583, 0],
7961        "70": [0, 0.7, 0.13634, 0],
7962        "71": [0, 0.7, 0.17322, 0],
7963        "72": [0, 0.7, 0.29694, 0],
7964        "73": [0, 0.7, 0.19189, 0],
7965        "74": [0.27778, 0.7, 0.19189, 0],
7966        "75": [0, 0.7, 0.31259, 0],
7967        "76": [0, 0.7, 0.19189, 0],
7968        "77": [0, 0.7, 0.15981, 0],
7969        "78": [0, 0.7, 0.3525, 0],
7970        "79": [0, 0.7, 0.08078, 0],
7971        "80": [0, 0.7, 0.08078, 0],
7972        "81": [0, 0.7, 0.03305, 0],
7973        "82": [0, 0.7, 0.06259, 0],
7974        "83": [0, 0.7, 0.19189, 0],
7975        "84": [0, 0.7, 0.29087, 0],
7976        "85": [0, 0.7, 0.25815, 0],
7977        "86": [0, 0.7, 0.27523, 0],
7978        "87": [0, 0.7, 0.27523, 0],
7979        "88": [0, 0.7, 0.26006, 0],
7980        "89": [0, 0.7, 0.2939, 0],
7981        "90": [0, 0.7, 0.24037, 0]
7982    },
7983    "Size1-Regular": {
7984        "40": [0.35001, 0.85, 0, 0],
7985        "41": [0.35001, 0.85, 0, 0],
7986        "47": [0.35001, 0.85, 0, 0],
7987        "91": [0.35001, 0.85, 0, 0],
7988        "92": [0.35001, 0.85, 0, 0],
7989        "93": [0.35001, 0.85, 0, 0],
7990        "123": [0.35001, 0.85, 0, 0],
7991        "125": [0.35001, 0.85, 0, 0],
7992        "710": [0, 0.72222, 0, 0],
7993        "732": [0, 0.72222, 0, 0],
7994        "770": [0, 0.72222, 0, 0],
7995        "771": [0, 0.72222, 0, 0],
7996        "8214": [-0.00099, 0.601, 0, 0],
7997        "8593": [1e-05, 0.6, 0, 0],
7998        "8595": [1e-05, 0.6, 0, 0],
7999        "8657": [1e-05, 0.6, 0, 0],
8000        "8659": [1e-05, 0.6, 0, 0],
8001        "8719": [0.25001, 0.75, 0, 0],
8002        "8720": [0.25001, 0.75, 0, 0],
8003        "8721": [0.25001, 0.75, 0, 0],
8004        "8730": [0.35001, 0.85, 0, 0],
8005        "8739": [-0.00599, 0.606, 0, 0],
8006        "8741": [-0.00599, 0.606, 0, 0],
8007        "8747": [0.30612, 0.805, 0.19445, 0],
8008        "8748": [0.306, 0.805, 0.19445, 0],
8009        "8749": [0.306, 0.805, 0.19445, 0],
8010        "8750": [0.30612, 0.805, 0.19445, 0],
8011        "8896": [0.25001, 0.75, 0, 0],
8012        "8897": [0.25001, 0.75, 0, 0],
8013        "8898": [0.25001, 0.75, 0, 0],
8014        "8899": [0.25001, 0.75, 0, 0],
8015        "8968": [0.35001, 0.85, 0, 0],
8016        "8969": [0.35001, 0.85, 0, 0],
8017        "8970": [0.35001, 0.85, 0, 0],
8018        "8971": [0.35001, 0.85, 0, 0],
8019        "9168": [-0.00099, 0.601, 0, 0],
8020        "10216": [0.35001, 0.85, 0, 0],
8021        "10217": [0.35001, 0.85, 0, 0],
8022        "10752": [0.25001, 0.75, 0, 0],
8023        "10753": [0.25001, 0.75, 0, 0],
8024        "10754": [0.25001, 0.75, 0, 0],
8025        "10756": [0.25001, 0.75, 0, 0],
8026        "10758": [0.25001, 0.75, 0, 0]
8027    },
8028    "Size2-Regular": {
8029        "40": [0.65002, 1.15, 0, 0],
8030        "41": [0.65002, 1.15, 0, 0],
8031        "47": [0.65002, 1.15, 0, 0],
8032        "91": [0.65002, 1.15, 0, 0],
8033        "92": [0.65002, 1.15, 0, 0],
8034        "93": [0.65002, 1.15, 0, 0],
8035        "123": [0.65002, 1.15, 0, 0],
8036        "125": [0.65002, 1.15, 0, 0],
8037        "710": [0, 0.75, 0, 0],
8038        "732": [0, 0.75, 0, 0],
8039        "770": [0, 0.75, 0, 0],
8040        "771": [0, 0.75, 0, 0],
8041        "8719": [0.55001, 1.05, 0, 0],
8042        "8720": [0.55001, 1.05, 0, 0],
8043        "8721": [0.55001, 1.05, 0, 0],
8044        "8730": [0.65002, 1.15, 0, 0],
8045        "8747": [0.86225, 1.36, 0.44445, 0],
8046        "8748": [0.862, 1.36, 0.44445, 0],
8047        "8749": [0.862, 1.36, 0.44445, 0],
8048        "8750": [0.86225, 1.36, 0.44445, 0],
8049        "8896": [0.55001, 1.05, 0, 0],
8050        "8897": [0.55001, 1.05, 0, 0],
8051        "8898": [0.55001, 1.05, 0, 0],
8052        "8899": [0.55001, 1.05, 0, 0],
8053        "8968": [0.65002, 1.15, 0, 0],
8054        "8969": [0.65002, 1.15, 0, 0],
8055        "8970": [0.65002, 1.15, 0, 0],
8056        "8971": [0.65002, 1.15, 0, 0],
8057        "10216": [0.65002, 1.15, 0, 0],
8058        "10217": [0.65002, 1.15, 0, 0],
8059        "10752": [0.55001, 1.05, 0, 0],
8060        "10753": [0.55001, 1.05, 0, 0],
8061        "10754": [0.55001, 1.05, 0, 0],
8062        "10756": [0.55001, 1.05, 0, 0],
8063        "10758": [0.55001, 1.05, 0, 0]
8064    },
8065    "Size3-Regular": {
8066        "40": [0.95003, 1.45, 0, 0],
8067        "41": [0.95003, 1.45, 0, 0],
8068        "47": [0.95003, 1.45, 0, 0],
8069        "91": [0.95003, 1.45, 0, 0],
8070        "92": [0.95003, 1.45, 0, 0],
8071        "93": [0.95003, 1.45, 0, 0],
8072        "123": [0.95003, 1.45, 0, 0],
8073        "125": [0.95003, 1.45, 0, 0],
8074        "710": [0, 0.75, 0, 0],
8075        "732": [0, 0.75, 0, 0],
8076        "770": [0, 0.75, 0, 0],
8077        "771": [0, 0.75, 0, 0],
8078        "8730": [0.95003, 1.45, 0, 0],
8079        "8968": [0.95003, 1.45, 0, 0],
8080        "8969": [0.95003, 1.45, 0, 0],
8081        "8970": [0.95003, 1.45, 0, 0],
8082        "8971": [0.95003, 1.45, 0, 0],
8083        "10216": [0.95003, 1.45, 0, 0],
8084        "10217": [0.95003, 1.45, 0, 0]
8085    },
8086    "Size4-Regular": {
8087        "40": [1.25003, 1.75, 0, 0],
8088        "41": [1.25003, 1.75, 0, 0],
8089        "47": [1.25003, 1.75, 0, 0],
8090        "91": [1.25003, 1.75, 0, 0],
8091        "92": [1.25003, 1.75, 0, 0],
8092        "93": [1.25003, 1.75, 0, 0],
8093        "123": [1.25003, 1.75, 0, 0],
8094        "125": [1.25003, 1.75, 0, 0],
8095        "710": [0, 0.825, 0, 0],
8096        "732": [0, 0.825, 0, 0],
8097        "770": [0, 0.825, 0, 0],
8098        "771": [0, 0.825, 0, 0],
8099        "8730": [1.25003, 1.75, 0, 0],
8100        "8968": [1.25003, 1.75, 0, 0],
8101        "8969": [1.25003, 1.75, 0, 0],
8102        "8970": [1.25003, 1.75, 0, 0],
8103        "8971": [1.25003, 1.75, 0, 0],
8104        "9115": [0.64502, 1.155, 0, 0],
8105        "9116": [1e-05, 0.6, 0, 0],
8106        "9117": [0.64502, 1.155, 0, 0],
8107        "9118": [0.64502, 1.155, 0, 0],
8108        "9119": [1e-05, 0.6, 0, 0],
8109        "9120": [0.64502, 1.155, 0, 0],
8110        "9121": [0.64502, 1.155, 0, 0],
8111        "9122": [-0.00099, 0.601, 0, 0],
8112        "9123": [0.64502, 1.155, 0, 0],
8113        "9124": [0.64502, 1.155, 0, 0],
8114        "9125": [-0.00099, 0.601, 0, 0],
8115        "9126": [0.64502, 1.155, 0, 0],
8116        "9127": [1e-05, 0.9, 0, 0],
8117        "9128": [0.65002, 1.15, 0, 0],
8118        "9129": [0.90001, 0, 0, 0],
8119        "9130": [0, 0.3, 0, 0],
8120        "9131": [1e-05, 0.9, 0, 0],
8121        "9132": [0.65002, 1.15, 0, 0],
8122        "9133": [0.90001, 0, 0, 0],
8123        "9143": [0.88502, 0.915, 0, 0],
8124        "10216": [1.25003, 1.75, 0, 0],
8125        "10217": [1.25003, 1.75, 0, 0],
8126        "57344": [-0.00499, 0.605, 0, 0],
8127        "57345": [-0.00499, 0.605, 0, 0],
8128        "57680": [0, 0.12, 0, 0],
8129        "57681": [0, 0.12, 0, 0],
8130        "57682": [0, 0.12, 0, 0],
8131        "57683": [0, 0.12, 0, 0]
8132    },
8133    "Typewriter-Regular": {
8134        "33": [0, 0.61111, 0, 0],
8135        "34": [0, 0.61111, 0, 0],
8136        "35": [0, 0.61111, 0, 0],
8137        "36": [0.08333, 0.69444, 0, 0],
8138        "37": [0.08333, 0.69444, 0, 0],
8139        "38": [0, 0.61111, 0, 0],
8140        "39": [0, 0.61111, 0, 0],
8141        "40": [0.08333, 0.69444, 0, 0],
8142        "41": [0.08333, 0.69444, 0, 0],
8143        "42": [0, 0.52083, 0, 0],
8144        "43": [-0.08056, 0.53055, 0, 0],
8145        "44": [0.13889, 0.125, 0, 0],
8146        "45": [-0.08056, 0.53055, 0, 0],
8147        "46": [0, 0.125, 0, 0],
8148        "47": [0.08333, 0.69444, 0, 0],
8149        "48": [0, 0.61111, 0, 0],
8150        "49": [0, 0.61111, 0, 0],
8151        "50": [0, 0.61111, 0, 0],
8152        "51": [0, 0.61111, 0, 0],
8153        "52": [0, 0.61111, 0, 0],
8154        "53": [0, 0.61111, 0, 0],
8155        "54": [0, 0.61111, 0, 0],
8156        "55": [0, 0.61111, 0, 0],
8157        "56": [0, 0.61111, 0, 0],
8158        "57": [0, 0.61111, 0, 0],
8159        "58": [0, 0.43056, 0, 0],
8160        "59": [0.13889, 0.43056, 0, 0],
8161        "60": [-0.05556, 0.55556, 0, 0],
8162        "61": [-0.19549, 0.41562, 0, 0],
8163        "62": [-0.05556, 0.55556, 0, 0],
8164        "63": [0, 0.61111, 0, 0],
8165        "64": [0, 0.61111, 0, 0],
8166        "65": [0, 0.61111, 0, 0],
8167        "66": [0, 0.61111, 0, 0],
8168        "67": [0, 0.61111, 0, 0],
8169        "68": [0, 0.61111, 0, 0],
8170        "69": [0, 0.61111, 0, 0],
8171        "70": [0, 0.61111, 0, 0],
8172        "71": [0, 0.61111, 0, 0],
8173        "72": [0, 0.61111, 0, 0],
8174        "73": [0, 0.61111, 0, 0],
8175        "74": [0, 0.61111, 0, 0],
8176        "75": [0, 0.61111, 0, 0],
8177        "76": [0, 0.61111, 0, 0],
8178        "77": [0, 0.61111, 0, 0],
8179        "78": [0, 0.61111, 0, 0],
8180        "79": [0, 0.61111, 0, 0],
8181        "80": [0, 0.61111, 0, 0],
8182        "81": [0.13889, 0.61111, 0, 0],
8183        "82": [0, 0.61111, 0, 0],
8184        "83": [0, 0.61111, 0, 0],
8185        "84": [0, 0.61111, 0, 0],
8186        "85": [0, 0.61111, 0, 0],
8187        "86": [0, 0.61111, 0, 0],
8188        "87": [0, 0.61111, 0, 0],
8189        "88": [0, 0.61111, 0, 0],
8190        "89": [0, 0.61111, 0, 0],
8191        "90": [0, 0.61111, 0, 0],
8192        "91": [0.08333, 0.69444, 0, 0],
8193        "92": [0.08333, 0.69444, 0, 0],
8194        "93": [0.08333, 0.69444, 0, 0],
8195        "94": [0, 0.61111, 0, 0],
8196        "95": [0.09514, 0, 0, 0],
8197        "96": [0, 0.61111, 0, 0],
8198        "97": [0, 0.43056, 0, 0],
8199        "98": [0, 0.61111, 0, 0],
8200        "99": [0, 0.43056, 0, 0],
8201        "100": [0, 0.61111, 0, 0],
8202        "101": [0, 0.43056, 0, 0],
8203        "102": [0, 0.61111, 0, 0],
8204        "103": [0.22222, 0.43056, 0, 0],
8205        "104": [0, 0.61111, 0, 0],
8206        "105": [0, 0.61111, 0, 0],
8207        "106": [0.22222, 0.61111, 0, 0],
8208        "107": [0, 0.61111, 0, 0],
8209        "108": [0, 0.61111, 0, 0],
8210        "109": [0, 0.43056, 0, 0],
8211        "110": [0, 0.43056, 0, 0],
8212        "111": [0, 0.43056, 0, 0],
8213        "112": [0.22222, 0.43056, 0, 0],
8214        "113": [0.22222, 0.43056, 0, 0],
8215        "114": [0, 0.43056, 0, 0],
8216        "115": [0, 0.43056, 0, 0],
8217        "116": [0, 0.55358, 0, 0],
8218        "117": [0, 0.43056, 0, 0],
8219        "118": [0, 0.43056, 0, 0],
8220        "119": [0, 0.43056, 0, 0],
8221        "120": [0, 0.43056, 0, 0],
8222        "121": [0.22222, 0.43056, 0, 0],
8223        "122": [0, 0.43056, 0, 0],
8224        "123": [0.08333, 0.69444, 0, 0],
8225        "124": [0.08333, 0.69444, 0, 0],
8226        "125": [0.08333, 0.69444, 0, 0],
8227        "126": [0, 0.61111, 0, 0],
8228        "127": [0, 0.61111, 0, 0],
8229        "305": [0, 0.43056, 0, 0],
8230        "567": [0.22222, 0.43056, 0, 0],
8231        "768": [0, 0.61111, 0, 0],
8232        "769": [0, 0.61111, 0, 0],
8233        "770": [0, 0.61111, 0, 0],
8234        "771": [0, 0.61111, 0, 0],
8235        "772": [0, 0.56555, 0, 0],
8236        "774": [0, 0.61111, 0, 0],
8237        "776": [0, 0.61111, 0, 0],
8238        "778": [0, 0.61111, 0, 0],
8239        "780": [0, 0.56597, 0, 0],
8240        "915": [0, 0.61111, 0, 0],
8241        "916": [0, 0.61111, 0, 0],
8242        "920": [0, 0.61111, 0, 0],
8243        "923": [0, 0.61111, 0, 0],
8244        "926": [0, 0.61111, 0, 0],
8245        "928": [0, 0.61111, 0, 0],
8246        "931": [0, 0.61111, 0, 0],
8247        "933": [0, 0.61111, 0, 0],
8248        "934": [0, 0.61111, 0, 0],
8249        "936": [0, 0.61111, 0, 0],
8250        "937": [0, 0.61111, 0, 0],
8251        "2018": [0, 0.61111, 0, 0],
8252        "2019": [0, 0.61111, 0, 0],
8253        "8242": [0, 0.61111, 0, 0]
8254    }
8255};
8256
8257var cjkRegex = unicodeRegexes.cjkRegex;
8258
8259/**
8260 * This file contains metrics regarding fonts and individual symbols. The sigma
8261 * and xi variables, as well as the metricMap map contain data extracted from
8262 * TeX, TeX font metrics, and the TTF files. These data are then exposed via the
8263 * `metrics` variable and the getCharacterMetrics function.
8264 */
8265
8266// In TeX, there are actually three sets of dimensions, one for each of
8267// textstyle, scriptstyle, and scriptscriptstyle.  These are provided in the
8268// the arrays below, in that order.
8269//
8270// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
8271// This was determined by running the folllowing script:
8272//
8273//     latex -interaction=nonstopmode \
8274//     '\documentclass{article}\usepackage{amsmath}\begin{document}' \
8275//     '$a$ \expandafter\show\the\textfont2' \
8276//     '\expandafter\show\the\scriptfont2' \
8277//     '\expandafter\show\the\scriptscriptfont2' \
8278//     '\stop'
8279//
8280// The metrics themselves were retreived using the following commands:
8281//
8282//     tftopl cmsy10
8283//     tftopl cmsy7
8284//     tftopl cmsy5
8285//
8286// The output of each of these commands is quite lengthy.  The only part we
8287// care about is the FONTDIMEN section. Each value is measured in EMs.
8288var sigmas$1 = {
8289    slant: [0.250, 0.250, 0.250],       // sigma1
8290    space: [0.000, 0.000, 0.000],       // sigma2
8291    stretch: [0.000, 0.000, 0.000],     // sigma3
8292    shrink: [0.000, 0.000, 0.000],      // sigma4
8293    xHeight: [0.431, 0.431, 0.431],     // sigma5
8294    quad: [1.000, 1.171, 1.472],        // sigma6
8295    extraSpace: [0.000, 0.000, 0.000],  // sigma7
8296    num1: [0.677, 0.732, 0.925],        // sigma8
8297    num2: [0.394, 0.384, 0.387],        // sigma9
8298    num3: [0.444, 0.471, 0.504],        // sigma10
8299    denom1: [0.686, 0.752, 1.025],      // sigma11
8300    denom2: [0.345, 0.344, 0.532],      // sigma12
8301    sup1: [0.413, 0.503, 0.504],        // sigma13
8302    sup2: [0.363, 0.431, 0.404],        // sigma14
8303    sup3: [0.289, 0.286, 0.294],        // sigma15
8304    sub1: [0.150, 0.143, 0.200],        // sigma16
8305    sub2: [0.247, 0.286, 0.400],        // sigma17
8306    supDrop: [0.386, 0.353, 0.494],     // sigma18
8307    subDrop: [0.050, 0.071, 0.100],     // sigma19
8308    delim1: [2.390, 1.700, 1.980],      // sigma20
8309    delim2: [1.010, 1.157, 1.420],      // sigma21
8310    axisHeight: [0.250, 0.250, 0.250]  // sigma22
8311};
8312
8313var xi8 = 0.04;
8314var xi9 = 0.111;
8315var xi10 = 0.166;
8316var xi11 = 0.2;
8317var xi12 = 0.6;
8318var xi13 = 0.1;
8319
8320// This value determines how large a pt is, for metrics which are defined in
8321// terms of pts.
8322// This value is also used in katex.less; if you change it make sure the values
8323// match.
8324var ptPerEm = 10.0;
8325
8326// The space between adjacent `|` columns in an array definition. From
8327// `\showthe\doublerulesep` in LaTeX.
8328var doubleRuleSep = 2.0 / ptPerEm;
8329
8330/**
8331 * This is just a mapping from common names to real metrics
8332 */
8333var metrics$1 = {
8334    defaultRuleThickness: xi8,
8335    bigOpSpacing1: xi9,
8336    bigOpSpacing2: xi10,
8337    bigOpSpacing3: xi11,
8338    bigOpSpacing4: xi12,
8339    bigOpSpacing5: xi13,
8340    ptPerEm: ptPerEm,
8341    doubleRuleSep: doubleRuleSep
8342};
8343
8344// This map contains a mapping from font name and character code to character
8345// metrics, including height, depth, italic correction, and skew (kern from the
8346// character to the corresponding \skewchar)
8347// This map is generated via `make metrics`. It should not be changed manually.
8348var metricMap = fontMetricsData;
8349
8350// These are very rough approximations.  We default to Times New Roman which
8351// should have Latin-1 and Cyrillic characters, but may not depending on the
8352// operating system.  The metrics do not account for extra height from the
8353// accents.  In the case of Cyrillic characters which have both ascenders and
8354// descenders we prefer approximations with ascenders, primarily to prevent
8355// the fraction bar or root line from intersecting the glyph.
8356// TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
8357var extraCharacterMap = {
8358    // Latin-1
8359    'À': 'A',
8360    'Á': 'A',
8361    'Â': 'A',
8362    'Ã': 'A',
8363    'Ä': 'A',
8364    'Å': 'A',
8365    'Æ': 'A',
8366    'Ç': 'C',
8367    'È': 'E',
8368    'É': 'E',
8369    'Ê': 'E',
8370    'Ë': 'E',
8371    'Ì': 'I',
8372    'Í': 'I',
8373    'Î': 'I',
8374    'Ï': 'I',
8375    'Ð': 'D',
8376    'Ñ': 'N',
8377    'Ò': 'O',
8378    'Ó': 'O',
8379    'Ô': 'O',
8380    'Õ': 'O',
8381    'Ö': 'O',
8382    'Ø': 'O',
8383    'Ù': 'U',
8384    'Ú': 'U',
8385    'Û': 'U',
8386    'Ü': 'U',
8387    'Ý': 'Y',
8388    'Þ': 'o',
8389    'ß': 'B',
8390    'à': 'a',
8391    'á': 'a',
8392    'â': 'a',
8393    'ã': 'a',
8394    'ä': 'a',
8395    'Ã¥': 'a',
8396    'æ': 'a',
8397    'ç': 'c',
8398    'è': 'e',
8399    'é': 'e',
8400    'ê': 'e',
8401    'ë': 'e',
8402    'ì': 'i',
8403    'í': 'i',
8404    'î': 'i',
8405    'ï': 'i',
8406    'ð': 'd',
8407    'ñ': 'n',
8408    'ò': 'o',
8409    'ó': 'o',
8410    'ô': 'o',
8411    'õ': 'o',
8412    'ö': 'o',
8413    'ø': 'o',
8414    'ù': 'u',
8415    'ú': 'u',
8416    'û': 'u',
8417    'ü': 'u',
8418    'ý': 'y',
8419    'þ': 'o',
8420    'ÿ': 'y',
8421
8422    // Cyrillic
8423    'А': 'A',
8424    'Б': 'B',
8425    'В': 'B',
8426    'Г': 'F',
8427    'Д': 'A',
8428    'Е': 'E',
8429    'Ж': 'K',
8430    'З': '3',
8431    'И': 'N',
8432    'Й': 'N',
8433    'К': 'K',
8434    'Л': 'N',
8435    'М': 'M',
8436    'Н': 'H',
8437    'О': 'O',
8438    'П': 'N',
8439    'Р': 'P',
8440    'С': 'C',
8441    'Т': 'T',
8442    'У': 'y',
8443    'Ф': 'O',
8444    'Ð¥': 'X',
8445    'Ц': 'U',
8446    'Ч': 'h',
8447    'Ш': 'W',
8448    'Щ': 'W',
8449    'Ъ': 'B',
8450    'Ы': 'X',
8451    'Ь': 'B',
8452    'Э': '3',
8453    'Ю': 'X',
8454    'Я': 'R',
8455    'а': 'a',
8456    'б': 'b',
8457    'в': 'a',
8458    'г': 'r',
8459    'д': 'y',
8460    'е': 'e',
8461    'ж': 'm',
8462    'з': 'e',
8463    'и': 'n',
8464    'й': 'n',
8465    'к': 'n',
8466    'л': 'n',
8467    'м': 'm',
8468    'н': 'n',
8469    'о': 'o',
8470    'п': 'n',
8471    'р': 'p',
8472    'с': 'c',
8473    'т': 'o',
8474    'у': 'y',
8475    'ф': 'b',
8476    'х': 'x',
8477    'ц': 'n',
8478    'ч': 'n',
8479    'ш': 'w',
8480    'щ': 'w',
8481    'ъ': 'a',
8482    'ы': 'm',
8483    'ь': 'a',
8484    'э': 'e',
8485    'ю': 'm',
8486    'я': 'r'
8487};
8488
8489/**
8490 * This function is a convenience function for looking up information in the
8491 * metricMap table. It takes a character as a string, and a style.
8492 *
8493 * Note: the `width` property may be undefined if fontMetricsData.js wasn't
8494 * built using `Make extended_metrics`.
8495 */
8496var getCharacterMetrics = function(character, style) {
8497    var ch = character.charCodeAt(0);
8498    if (character[0] in extraCharacterMap) {
8499        ch = extraCharacterMap[character[0]].charCodeAt(0);
8500    } else if (cjkRegex.test(character[0])) {
8501        ch = 'M'.charCodeAt(0);
8502    }
8503    var metrics = metricMap[style][ch];
8504    if (metrics) {
8505        return {
8506            depth: metrics[0],
8507            height: metrics[1],
8508            italic: metrics[2],
8509            skew: metrics[3],
8510            width: metrics[4]
8511        };
8512    }
8513};
8514
8515var fontMetrics$1 = {
8516    metrics: metrics$1,
8517    sigmas: sigmas$1,
8518    getCharacterMetrics: getCharacterMetrics
8519};
8520
8521/**
8522 * This file contains information and classes for the various kinds of styles
8523 * used in TeX. It provides a generic `Style` class, which holds information
8524 * about a specific style. It then provides instances of all the different kinds
8525 * of styles possible, and provides functions to move between them and get
8526 * information about them.
8527 */
8528
8529var sigmas = fontMetrics$1.sigmas;
8530
8531var metrics = [{}, {}, {}];
8532var i$1;
8533for (var key in sigmas) {
8534    if (sigmas.hasOwnProperty(key)) {
8535        for (i$1 = 0; i$1 < 3; i$1++) {
8536            metrics[i$1][key] = sigmas[key][i$1];
8537        }
8538    }
8539}
8540for (i$1 = 0; i$1 < 3; i$1++) {
8541    metrics[i$1].emPerEx = sigmas.xHeight[i$1] / sigmas.quad[i$1];
8542}
8543
8544/**
8545 * The main style class. Contains a unique id for the style, a size (which is
8546 * the same for cramped and uncramped version of a style), a cramped flag, and a
8547 * size multiplier, which gives the size difference between a style and
8548 * textstyle.
8549 */
8550function Style$2(id, size, multiplier, cramped) {
8551    this.id = id;
8552    this.size = size;
8553    this.cramped = cramped;
8554    this.sizeMultiplier = multiplier;
8555    this.metrics = metrics[size > 0 ? size - 1 : 0];
8556}
8557
8558/**
8559 * Get the style of a superscript given a base in the current style.
8560 */
8561Style$2.prototype.sup = function() {
8562    return styles$1[sup[this.id]];
8563};
8564
8565/**
8566 * Get the style of a subscript given a base in the current style.
8567 */
8568Style$2.prototype.sub = function() {
8569    return styles$1[sub[this.id]];
8570};
8571
8572/**
8573 * Get the style of a fraction numerator given the fraction in the current
8574 * style.
8575 */
8576Style$2.prototype.fracNum = function() {
8577    return styles$1[fracNum[this.id]];
8578};
8579
8580/**
8581 * Get the style of a fraction denominator given the fraction in the current
8582 * style.
8583 */
8584Style$2.prototype.fracDen = function() {
8585    return styles$1[fracDen[this.id]];
8586};
8587
8588/**
8589 * Get the cramped version of a style (in particular, cramping a cramped style
8590 * doesn't change the style).
8591 */
8592Style$2.prototype.cramp = function() {
8593    return styles$1[cramp[this.id]];
8594};
8595
8596/**
8597 * HTML class name, like "displaystyle cramped"
8598 */
8599Style$2.prototype.cls = function() {
8600    return sizeNames[this.size] + (this.cramped ? " cramped" : " uncramped");
8601};
8602
8603/**
8604 * HTML Reset class name, like "reset-textstyle"
8605 */
8606Style$2.prototype.reset = function() {
8607    return resetNames[this.size];
8608};
8609
8610/**
8611 * Return if this style is tightly spaced (scriptstyle/scriptscriptstyle)
8612 */
8613Style$2.prototype.isTight = function() {
8614    return this.size >= 2;
8615};
8616
8617// IDs of the different styles
8618var D = 0;
8619var Dc = 1;
8620var T = 2;
8621var Tc = 3;
8622var S = 4;
8623var Sc = 5;
8624var SS = 6;
8625var SSc = 7;
8626
8627// String names for the different sizes
8628var sizeNames = [
8629    "displaystyle textstyle",
8630    "textstyle",
8631    "scriptstyle",
8632    "scriptscriptstyle"
8633];
8634
8635// Reset names for the different sizes
8636var resetNames = [
8637    "reset-textstyle",
8638    "reset-textstyle",
8639    "reset-scriptstyle",
8640    "reset-scriptscriptstyle"
8641];
8642
8643// Instances of the different styles
8644var styles$1 = [
8645    new Style$2(D, 0, 1.0, false),
8646    new Style$2(Dc, 0, 1.0, true),
8647    new Style$2(T, 1, 1.0, false),
8648    new Style$2(Tc, 1, 1.0, true),
8649    new Style$2(S, 2, 0.7, false),
8650    new Style$2(Sc, 2, 0.7, true),
8651    new Style$2(SS, 3, 0.5, false),
8652    new Style$2(SSc, 3, 0.5, true)
8653];
8654
8655// Lookup tables for switching from one style to another
8656var sup = [S, Sc, S, Sc, SS, SSc, SS, SSc];
8657var sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc];
8658var fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc];
8659var fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc];
8660var cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc];
8661
8662// We only export some of the styles. Also, we don't export the `Style` class so
8663// no more styles can be generated.
8664var Style_1 = {
8665    DISPLAY: styles$1[D],
8666    TEXT: styles$1[T],
8667    SCRIPT: styles$1[S],
8668    SCRIPTSCRIPT: styles$1[SS]
8669};
8670
8671/**
8672 * This file contains a list of utility functions which are useful in other
8673 * files.
8674 */
8675
8676/**
8677 * Provide an `indexOf` function which works in IE8, but defers to native if
8678 * possible.
8679 */
8680var nativeIndexOf = Array.prototype.indexOf;
8681var indexOf = function(list, elem) {
8682    if (list == null) {
8683        return -1;
8684    }
8685    if (nativeIndexOf && list.indexOf === nativeIndexOf) {
8686        return list.indexOf(elem);
8687    }
8688    var i = 0;
8689    var l = list.length;
8690    for (; i < l; i++) {
8691        if (list[i] === elem) {
8692            return i;
8693        }
8694    }
8695    return -1;
8696};
8697
8698/**
8699 * Return whether an element is contained in a list
8700 */
8701var contains = function(list, elem) {
8702    return indexOf(list, elem) !== -1;
8703};
8704
8705/**
8706 * Provide a default value if a setting is undefined
8707 */
8708var deflt = function(setting, defaultIfUndefined) {
8709    return setting === undefined ? defaultIfUndefined : setting;
8710};
8711
8712// hyphenate and escape adapted from Facebook's React under Apache 2 license
8713
8714var uppercase = /([A-Z])/g;
8715var hyphenate = function(str) {
8716    return str.replace(uppercase, "-$1").toLowerCase();
8717};
8718
8719var ESCAPE_LOOKUP = {
8720    "&": "&amp;",
8721    ">": "&gt;",
8722    "<": "&lt;",
8723    "\"": "&quot;",
8724    "'": "&#x27;"
8725};
8726
8727var ESCAPE_REGEX = /[&><"']/g;
8728
8729function escaper(match) {
8730    return ESCAPE_LOOKUP[match];
8731}
8732
8733/**
8734 * Escapes text to prevent scripting attacks.
8735 *
8736 * @param {*} text Text value to escape.
8737 * @return {string} An escaped string.
8738 */
8739function escape$1(text) {
8740    return ("" + text).replace(ESCAPE_REGEX, escaper);
8741}
8742
8743/**
8744 * A function to set the text content of a DOM element in all supported
8745 * browsers. Note that we don't define this if there is no document.
8746 */
8747var setTextContent;
8748if (typeof document !== "undefined") {
8749    var testNode = document.createElement("span");
8750    if ("textContent" in testNode) {
8751        setTextContent = function(node, text) {
8752            node.textContent = text;
8753        };
8754    } else {
8755        setTextContent = function(node, text) {
8756            node.innerText = text;
8757        };
8758    }
8759}
8760
8761/**
8762 * A function to clear a node.
8763 */
8764function clearNode(node) {
8765    setTextContent(node, "");
8766}
8767
8768var utils$4 = {
8769    contains: contains,
8770    deflt: deflt,
8771    escape: escape$1,
8772    hyphenate: hyphenate,
8773    indexOf: indexOf,
8774    setTextContent: setTextContent,
8775    clearNode: clearNode
8776};
8777
8778/**
8779 * These objects store the data about the DOM nodes we create, as well as some
8780 * extra data. They can then be transformed into real DOM nodes with the
8781 * `toNode` function or HTML markup using `toMarkup`. They are useful for both
8782 * storing extra properties on the nodes, as well as providing a way to easily
8783 * work with the DOM.
8784 *
8785 * Similar functions for working with MathML nodes exist in mathMLTree.js.
8786 */
8787var unicodeRegexes$2 = unicodeRegexes;
8788var utils$3 = utils$4;
8789
8790/**
8791 * Create an HTML className based on a list of classes. In addition to joining
8792 * with spaces, we also remove null or empty classes.
8793 */
8794var createClass = function(classes) {
8795    classes = classes.slice();
8796    for (var i = classes.length - 1; i >= 0; i--) {
8797        if (!classes[i]) {
8798            classes.splice(i, 1);
8799        }
8800    }
8801
8802    return classes.join(" ");
8803};
8804
8805/**
8806 * This node represents a span node, with a className, a list of children, and
8807 * an inline style. It also contains information about its height, depth, and
8808 * maxFontSize.
8809 */
8810function span(classes, children, options) {
8811    this.classes = classes || [];
8812    this.children = children || [];
8813    this.height = 0;
8814    this.depth = 0;
8815    this.maxFontSize = 0;
8816    this.style = {};
8817    this.attributes = {};
8818    if (options) {
8819        if (options.style.isTight()) {
8820            this.classes.push("mtight");
8821        }
8822        if (options.getColor()) {
8823            this.style.color = options.getColor();
8824        }
8825    }
8826}
8827
8828/**
8829 * Sets an arbitrary attribute on the span. Warning: use this wisely. Not all
8830 * browsers support attributes the same, and having too many custom attributes
8831 * is probably bad.
8832 */
8833span.prototype.setAttribute = function(attribute, value) {
8834    this.attributes[attribute] = value;
8835};
8836
8837span.prototype.tryCombine = function(sibling) {
8838    return false;
8839};
8840
8841/**
8842 * Convert the span into an HTML node
8843 */
8844span.prototype.toNode = function() {
8845    var this$1 = this;
8846
8847    var span = document.createElement("span");
8848
8849    // Apply the class
8850    span.className = createClass(this.classes);
8851
8852    // Apply inline styles
8853    for (var style in this.style) {
8854        if (Object.prototype.hasOwnProperty.call(this$1.style, style)) {
8855            span.style[style] = this$1.style[style];
8856        }
8857    }
8858
8859    // Apply attributes
8860    for (var attr in this.attributes) {
8861        if (Object.prototype.hasOwnProperty.call(this$1.attributes, attr)) {
8862            span.setAttribute(attr, this$1.attributes[attr]);
8863        }
8864    }
8865
8866    // Append the children, also as HTML nodes
8867    for (var i = 0; i < this.children.length; i++) {
8868        span.appendChild(this$1.children[i].toNode());
8869    }
8870
8871    return span;
8872};
8873
8874/**
8875 * Convert the span into an HTML markup string
8876 */
8877span.prototype.toMarkup = function() {
8878    var this$1 = this;
8879
8880    var markup = "<span";
8881
8882    // Add the class
8883    if (this.classes.length) {
8884        markup += " class=\"";
8885        markup += utils$3.escape(createClass(this.classes));
8886        markup += "\"";
8887    }
8888
8889    var styles = "";
8890
8891    // Add the styles, after hyphenation
8892    for (var style in this.style) {
8893        if (this$1.style.hasOwnProperty(style)) {
8894            styles += utils$3.hyphenate(style) + ":" + this$1.style[style] + ";";
8895        }
8896    }
8897
8898    if (styles) {
8899        markup += " style=\"" + utils$3.escape(styles) + "\"";
8900    }
8901
8902    // Add the attributes
8903    for (var attr in this.attributes) {
8904        if (Object.prototype.hasOwnProperty.call(this$1.attributes, attr)) {
8905            markup += " " + attr + "=\"";
8906            markup += utils$3.escape(this$1.attributes[attr]);
8907            markup += "\"";
8908        }
8909    }
8910
8911    markup += ">";
8912
8913    // Add the markup of the children, also as markup
8914    for (var i = 0; i < this.children.length; i++) {
8915        markup += this$1.children[i].toMarkup();
8916    }
8917
8918    markup += "</span>";
8919
8920    return markup;
8921};
8922
8923/**
8924 * This node represents a document fragment, which contains elements, but when
8925 * placed into the DOM doesn't have any representation itself. Thus, it only
8926 * contains children and doesn't have any HTML properties. It also keeps track
8927 * of a height, depth, and maxFontSize.
8928 */
8929function documentFragment(children) {
8930    this.children = children || [];
8931    this.height = 0;
8932    this.depth = 0;
8933    this.maxFontSize = 0;
8934}
8935
8936/**
8937 * Convert the fragment into a node
8938 */
8939documentFragment.prototype.toNode = function() {
8940    var this$1 = this;
8941
8942    // Create a fragment
8943    var frag = document.createDocumentFragment();
8944
8945    // Append the children
8946    for (var i = 0; i < this.children.length; i++) {
8947        frag.appendChild(this$1.children[i].toNode());
8948    }
8949
8950    return frag;
8951};
8952
8953/**
8954 * Convert the fragment into HTML markup
8955 */
8956documentFragment.prototype.toMarkup = function() {
8957    var this$1 = this;
8958
8959    var markup = "";
8960
8961    // Simply concatenate the markup for the children together
8962    for (var i = 0; i < this.children.length; i++) {
8963        markup += this$1.children[i].toMarkup();
8964    }
8965
8966    return markup;
8967};
8968
8969var iCombinations = {
8970    'î': '\u0131\u0302',
8971    'ï': '\u0131\u0308',
8972    'í': '\u0131\u0301',
8973    // 'Ä«': '\u0131\u0304', // enable when we add Extended Latin
8974    'ì': '\u0131\u0300'
8975};
8976
8977/**
8978 * A symbol node contains information about a single symbol. It either renders
8979 * to a single text node, or a span with a single text node in it, depending on
8980 * whether it has CSS classes, styles, or needs italic correction.
8981 */
8982function symbolNode(value, height, depth, italic, skew, classes, style) {
8983    this.value = value || "";
8984    this.height = height || 0;
8985    this.depth = depth || 0;
8986    this.italic = italic || 0;
8987    this.skew = skew || 0;
8988    this.classes = classes || [];
8989    this.style = style || {};
8990    this.maxFontSize = 0;
8991
8992    // Mark CJK characters with specific classes so that we can specify which
8993    // fonts to use.  This allows us to render these characters with a serif
8994    // font in situations where the browser would either default to a sans serif
8995    // or render a placeholder character.
8996    if (unicodeRegexes$2.cjkRegex.test(value)) {
8997        // I couldn't find any fonts that contained Hangul as well as all of
8998        // the other characters we wanted to test there for it gets its own
8999        // CSS class.
9000        if (unicodeRegexes$2.hangulRegex.test(value)) {
9001            this.classes.push('hangul_fallback');
9002        } else {
9003            this.classes.push('cjk_fallback');
9004        }
9005    }
9006
9007    if (/[îïíì]/.test(this.value)) {    // add ī when we add Extended Latin
9008        this.value = iCombinations[this.value];
9009    }
9010}
9011
9012symbolNode.prototype.tryCombine = function(sibling) {
9013    var this$1 = this;
9014
9015    if (!sibling
9016        || !(sibling instanceof symbolNode)
9017        || this.italic > 0
9018        || createClass(this.classes) !== createClass(sibling.classes)
9019        || this.skew !== sibling.skew
9020        || this.maxFontSize !== sibling.maxFontSize) {
9021        return false;
9022    }
9023    for (var style in this.style) {
9024        if (this$1.style.hasOwnProperty(style)
9025            && this$1.style[style] !== sibling.style[style]) {
9026            return false;
9027        }
9028    }
9029    for (style in sibling.style) {
9030        if (sibling.style.hasOwnProperty(style)
9031            && this$1.style[style] !== sibling.style[style]) {
9032            return false;
9033        }
9034    }
9035    this.value += sibling.value;
9036    this.height = Math.max(this.height, sibling.height);
9037    this.depth = Math.max(this.depth, sibling.depth);
9038    this.italic = sibling.italic;
9039    return true;
9040};
9041
9042/**
9043 * Creates a text node or span from a symbol node. Note that a span is only
9044 * created if it is needed.
9045 */
9046symbolNode.prototype.toNode = function() {
9047    var this$1 = this;
9048
9049    var node = document.createTextNode(this.value);
9050    var span = null;
9051
9052    if (this.italic > 0) {
9053        span = document.createElement("span");
9054        span.style.marginRight = this.italic + "em";
9055    }
9056
9057    if (this.classes.length > 0) {
9058        span = span || document.createElement("span");
9059        span.className = createClass(this.classes);
9060    }
9061
9062    for (var style in this.style) {
9063        if (this$1.style.hasOwnProperty(style)) {
9064            span = span || document.createElement("span");
9065            span.style[style] = this$1.style[style];
9066        }
9067    }
9068
9069    if (span) {
9070        span.appendChild(node);
9071        return span;
9072    } else {
9073        return node;
9074    }
9075};
9076
9077/**
9078 * Creates markup for a symbol node.
9079 */
9080symbolNode.prototype.toMarkup = function() {
9081    var this$1 = this;
9082
9083    // TODO(alpert): More duplication than I'd like from
9084    // span.prototype.toMarkup and symbolNode.prototype.toNode...
9085    var needsSpan = false;
9086
9087    var markup = "<span";
9088
9089    if (this.classes.length) {
9090        needsSpan = true;
9091        markup += " class=\"";
9092        markup += utils$3.escape(createClass(this.classes));
9093        markup += "\"";
9094    }
9095
9096    var styles = "";
9097
9098    if (this.italic > 0) {
9099        styles += "margin-right:" + this.italic + "em;";
9100    }
9101    for (var style in this.style) {
9102        if (this$1.style.hasOwnProperty(style)) {
9103            styles += utils$3.hyphenate(style) + ":" + this$1.style[style] + ";";
9104        }
9105    }
9106
9107    if (styles) {
9108        needsSpan = true;
9109        markup += " style=\"" + utils$3.escape(styles) + "\"";
9110    }
9111
9112    var escaped = utils$3.escape(this.value);
9113    if (needsSpan) {
9114        markup += ">";
9115        markup += escaped;
9116        markup += "</span>";
9117        return markup;
9118    } else {
9119        return escaped;
9120    }
9121};
9122
9123var domTree$2 = {
9124    span: span,
9125    documentFragment: documentFragment,
9126    symbolNode: symbolNode
9127};
9128
9129var symbols$1 = createCommonjsModule(function (module) {
9130/**
9131 * This file holds a list of all no-argument functions and single-character
9132 * symbols (like 'a' or ';').
9133 *
9134 * For each of the symbols, there are three properties they can have:
9135 * - font (required): the font to be used for this symbol. Either "main" (the
9136     normal font), or "ams" (the ams fonts).
9137 * - group (required): the ParseNode group type the symbol should have (i.e.
9138     "textord", "mathord", etc).
9139     See https://github.com/Khan/KaTeX/wiki/Examining-TeX#group-types
9140 * - replace: the character that this symbol or function should be
9141 *   replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi
9142 *   character in the main font).
9143 *
9144 * The outermost map in the table indicates what mode the symbols should be
9145 * accepted in (e.g. "math" or "text").
9146 */
9147
9148module.exports = {
9149    math: {},
9150    text: {}
9151};
9152
9153function defineSymbol(mode, font, group, replace, name) {
9154    module.exports[mode][name] = {
9155        font: font,
9156        group: group,
9157        replace: replace
9158    };
9159}
9160
9161// Some abbreviations for commonly used strings.
9162// This helps minify the code, and also spotting typos using jshint.
9163
9164// modes:
9165var math = "math";
9166var text = "text";
9167
9168// fonts:
9169var main = "main";
9170var ams = "ams";
9171
9172// groups:
9173var accent = "accent";
9174var bin = "bin";
9175var close = "close";
9176var inner = "inner";
9177var mathord = "mathord";
9178var op = "op";
9179var open = "open";
9180var punct = "punct";
9181var rel = "rel";
9182var spacing = "spacing";
9183var textord = "textord";
9184
9185// Now comes the symbol table
9186
9187// Relation Symbols
9188defineSymbol(math, main, rel, "\u2261", "\\equiv");
9189defineSymbol(math, main, rel, "\u227a", "\\prec");
9190defineSymbol(math, main, rel, "\u227b", "\\succ");
9191defineSymbol(math, main, rel, "\u223c", "\\sim");
9192defineSymbol(math, main, rel, "\u22a5", "\\perp");
9193defineSymbol(math, main, rel, "\u2aaf", "\\preceq");
9194defineSymbol(math, main, rel, "\u2ab0", "\\succeq");
9195defineSymbol(math, main, rel, "\u2243", "\\simeq");
9196defineSymbol(math, main, rel, "\u2223", "\\mid");
9197defineSymbol(math, main, rel, "\u226a", "\\ll");
9198defineSymbol(math, main, rel, "\u226b", "\\gg");
9199defineSymbol(math, main, rel, "\u224d", "\\asymp");
9200defineSymbol(math, main, rel, "\u2225", "\\parallel");
9201defineSymbol(math, main, rel, "\u22c8", "\\bowtie");
9202defineSymbol(math, main, rel, "\u2323", "\\smile");
9203defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq");
9204defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq");
9205defineSymbol(math, main, rel, "\u2250", "\\doteq");
9206defineSymbol(math, main, rel, "\u2322", "\\frown");
9207defineSymbol(math, main, rel, "\u220b", "\\ni");
9208defineSymbol(math, main, rel, "\u221d", "\\propto");
9209defineSymbol(math, main, rel, "\u22a2", "\\vdash");
9210defineSymbol(math, main, rel, "\u22a3", "\\dashv");
9211defineSymbol(math, main, rel, "\u220b", "\\owns");
9212
9213// Punctuation
9214defineSymbol(math, main, punct, "\u002e", "\\ldotp");
9215defineSymbol(math, main, punct, "\u22c5", "\\cdotp");
9216
9217// Misc Symbols
9218defineSymbol(math, main, textord, "\u0023", "\\#");
9219defineSymbol(text, main, textord, "\u0023", "\\#");
9220defineSymbol(math, main, textord, "\u0026", "\\&");
9221defineSymbol(text, main, textord, "\u0026", "\\&");
9222defineSymbol(math, main, textord, "\u2135", "\\aleph");
9223defineSymbol(math, main, textord, "\u2200", "\\forall");
9224defineSymbol(math, main, textord, "\u210f", "\\hbar");
9225defineSymbol(math, main, textord, "\u2203", "\\exists");
9226defineSymbol(math, main, textord, "\u2207", "\\nabla");
9227defineSymbol(math, main, textord, "\u266d", "\\flat");
9228defineSymbol(math, main, textord, "\u2113", "\\ell");
9229defineSymbol(math, main, textord, "\u266e", "\\natural");
9230defineSymbol(math, main, textord, "\u2663", "\\clubsuit");
9231defineSymbol(math, main, textord, "\u2118", "\\wp");
9232defineSymbol(math, main, textord, "\u266f", "\\sharp");
9233defineSymbol(math, main, textord, "\u2662", "\\diamondsuit");
9234defineSymbol(math, main, textord, "\u211c", "\\Re");
9235defineSymbol(math, main, textord, "\u2661", "\\heartsuit");
9236defineSymbol(math, main, textord, "\u2111", "\\Im");
9237defineSymbol(math, main, textord, "\u2660", "\\spadesuit");
9238
9239// Math and Text
9240defineSymbol(math, main, textord, "\u2020", "\\dag");
9241defineSymbol(math, main, textord, "\u2021", "\\ddag");
9242
9243// Large Delimiters
9244defineSymbol(math, main, close, "\u23b1", "\\rmoustache");
9245defineSymbol(math, main, open, "\u23b0", "\\lmoustache");
9246defineSymbol(math, main, close, "\u27ef", "\\rgroup");
9247defineSymbol(math, main, open, "\u27ee", "\\lgroup");
9248
9249// Binary Operators
9250defineSymbol(math, main, bin, "\u2213", "\\mp");
9251defineSymbol(math, main, bin, "\u2296", "\\ominus");
9252defineSymbol(math, main, bin, "\u228e", "\\uplus");
9253defineSymbol(math, main, bin, "\u2293", "\\sqcap");
9254defineSymbol(math, main, bin, "\u2217", "\\ast");
9255defineSymbol(math, main, bin, "\u2294", "\\sqcup");
9256defineSymbol(math, main, bin, "\u25ef", "\\bigcirc");
9257defineSymbol(math, main, bin, "\u2219", "\\bullet");
9258defineSymbol(math, main, bin, "\u2021", "\\ddagger");
9259defineSymbol(math, main, bin, "\u2240", "\\wr");
9260defineSymbol(math, main, bin, "\u2a3f", "\\amalg");
9261
9262// Arrow Symbols
9263defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow");
9264defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow");
9265defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow");
9266defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow");
9267defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow");
9268defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow");
9269defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow");
9270defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow");
9271defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow");
9272defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow");
9273defineSymbol(math, main, rel, "\u21a6", "\\mapsto");
9274defineSymbol(math, main, rel, "\u27fc", "\\longmapsto");
9275defineSymbol(math, main, rel, "\u2197", "\\nearrow");
9276defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow");
9277defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow");
9278defineSymbol(math, main, rel, "\u2198", "\\searrow");
9279defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup");
9280defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup");
9281defineSymbol(math, main, rel, "\u2199", "\\swarrow");
9282defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown");
9283defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown");
9284defineSymbol(math, main, rel, "\u2196", "\\nwarrow");
9285defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons");
9286
9287// AMS Negated Binary Relations
9288defineSymbol(math, ams, rel, "\u226e", "\\nless");
9289defineSymbol(math, ams, rel, "\ue010", "\\nleqslant");
9290defineSymbol(math, ams, rel, "\ue011", "\\nleqq");
9291defineSymbol(math, ams, rel, "\u2a87", "\\lneq");
9292defineSymbol(math, ams, rel, "\u2268", "\\lneqq");
9293defineSymbol(math, ams, rel, "\ue00c", "\\lvertneqq");
9294defineSymbol(math, ams, rel, "\u22e6", "\\lnsim");
9295defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox");
9296defineSymbol(math, ams, rel, "\u2280", "\\nprec");
9297defineSymbol(math, ams, rel, "\u22e0", "\\npreceq");
9298defineSymbol(math, ams, rel, "\u22e8", "\\precnsim");
9299defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox");
9300defineSymbol(math, ams, rel, "\u2241", "\\nsim");
9301defineSymbol(math, ams, rel, "\ue006", "\\nshortmid");
9302defineSymbol(math, ams, rel, "\u2224", "\\nmid");
9303defineSymbol(math, ams, rel, "\u22ac", "\\nvdash");
9304defineSymbol(math, ams, rel, "\u22ad", "\\nvDash");
9305defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft");
9306defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq");
9307defineSymbol(math, ams, rel, "\u228a", "\\subsetneq");
9308defineSymbol(math, ams, rel, "\ue01a", "\\varsubsetneq");
9309defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq");
9310defineSymbol(math, ams, rel, "\ue017", "\\varsubsetneqq");
9311defineSymbol(math, ams, rel, "\u226f", "\\ngtr");
9312defineSymbol(math, ams, rel, "\ue00f", "\\ngeqslant");
9313defineSymbol(math, ams, rel, "\ue00e", "\\ngeqq");
9314defineSymbol(math, ams, rel, "\u2a88", "\\gneq");
9315defineSymbol(math, ams, rel, "\u2269", "\\gneqq");
9316defineSymbol(math, ams, rel, "\ue00d", "\\gvertneqq");
9317defineSymbol(math, ams, rel, "\u22e7", "\\gnsim");
9318defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox");
9319defineSymbol(math, ams, rel, "\u2281", "\\nsucc");
9320defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq");
9321defineSymbol(math, ams, rel, "\u22e9", "\\succnsim");
9322defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox");
9323defineSymbol(math, ams, rel, "\u2246", "\\ncong");
9324defineSymbol(math, ams, rel, "\ue007", "\\nshortparallel");
9325defineSymbol(math, ams, rel, "\u2226", "\\nparallel");
9326defineSymbol(math, ams, rel, "\u22af", "\\nVDash");
9327defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright");
9328defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq");
9329defineSymbol(math, ams, rel, "\ue018", "\\nsupseteqq");
9330defineSymbol(math, ams, rel, "\u228b", "\\supsetneq");
9331defineSymbol(math, ams, rel, "\ue01b", "\\varsupsetneq");
9332defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq");
9333defineSymbol(math, ams, rel, "\ue019", "\\varsupsetneqq");
9334defineSymbol(math, ams, rel, "\u22ae", "\\nVdash");
9335defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq");
9336defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq");
9337defineSymbol(math, ams, rel, "\ue016", "\\nsubseteqq");
9338defineSymbol(math, ams, bin, "\u22b4", "\\unlhd");
9339defineSymbol(math, ams, bin, "\u22b5", "\\unrhd");
9340
9341// AMS Negated Arrows
9342defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow");
9343defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow");
9344defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow");
9345defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow");
9346defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow");
9347defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow");
9348
9349// AMS Misc
9350defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle");
9351defineSymbol(math, ams, textord, "\u210f", "\\hslash");
9352defineSymbol(math, ams, textord, "\u25bd", "\\triangledown");
9353defineSymbol(math, ams, textord, "\u25ca", "\\lozenge");
9354defineSymbol(math, ams, textord, "\u24c8", "\\circledS");
9355defineSymbol(math, ams, textord, "\u00ae", "\\circledR");
9356defineSymbol(math, ams, textord, "\u2221", "\\measuredangle");
9357defineSymbol(math, ams, textord, "\u2204", "\\nexists");
9358defineSymbol(math, ams, textord, "\u2127", "\\mho");
9359defineSymbol(math, ams, textord, "\u2132", "\\Finv");
9360defineSymbol(math, ams, textord, "\u2141", "\\Game");
9361defineSymbol(math, ams, textord, "\u006b", "\\Bbbk");
9362defineSymbol(math, ams, textord, "\u2035", "\\backprime");
9363defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle");
9364defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown");
9365defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare");
9366defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge");
9367defineSymbol(math, ams, textord, "\u2605", "\\bigstar");
9368defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle");
9369defineSymbol(math, ams, textord, "\u2201", "\\complement");
9370defineSymbol(math, ams, textord, "\u00f0", "\\eth");
9371defineSymbol(math, ams, textord, "\u2571", "\\diagup");
9372defineSymbol(math, ams, textord, "\u2572", "\\diagdown");
9373defineSymbol(math, ams, textord, "\u25a1", "\\square");
9374defineSymbol(math, ams, textord, "\u25a1", "\\Box");
9375defineSymbol(math, ams, textord, "\u25ca", "\\Diamond");
9376defineSymbol(math, ams, textord, "\u00a5", "\\yen");
9377defineSymbol(math, ams, textord, "\u2713", "\\checkmark");
9378
9379// AMS Hebrew
9380defineSymbol(math, ams, textord, "\u2136", "\\beth");
9381defineSymbol(math, ams, textord, "\u2138", "\\daleth");
9382defineSymbol(math, ams, textord, "\u2137", "\\gimel");
9383
9384// AMS Greek
9385defineSymbol(math, ams, textord, "\u03dd", "\\digamma");
9386defineSymbol(math, ams, textord, "\u03f0", "\\varkappa");
9387
9388// AMS Delimiters
9389defineSymbol(math, ams, open, "\u250c", "\\ulcorner");
9390defineSymbol(math, ams, close, "\u2510", "\\urcorner");
9391defineSymbol(math, ams, open, "\u2514", "\\llcorner");
9392defineSymbol(math, ams, close, "\u2518", "\\lrcorner");
9393
9394// AMS Binary Relations
9395defineSymbol(math, ams, rel, "\u2266", "\\leqq");
9396defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant");
9397defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless");
9398defineSymbol(math, ams, rel, "\u2272", "\\lesssim");
9399defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox");
9400defineSymbol(math, ams, rel, "\u224a", "\\approxeq");
9401defineSymbol(math, ams, bin, "\u22d6", "\\lessdot");
9402defineSymbol(math, ams, rel, "\u22d8", "\\lll");
9403defineSymbol(math, ams, rel, "\u2276", "\\lessgtr");
9404defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr");
9405defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr");
9406defineSymbol(math, ams, rel, "\u2251", "\\doteqdot");
9407defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq");
9408defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq");
9409defineSymbol(math, ams, rel, "\u223d", "\\backsim");
9410defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq");
9411defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq");
9412defineSymbol(math, ams, rel, "\u22d0", "\\Subset");
9413defineSymbol(math, ams, rel, "\u228f", "\\sqsubset");
9414defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq");
9415defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec");
9416defineSymbol(math, ams, rel, "\u227e", "\\precsim");
9417defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox");
9418defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft");
9419defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq");
9420defineSymbol(math, ams, rel, "\u22a8", "\\vDash");
9421defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash");
9422defineSymbol(math, ams, rel, "\u2323", "\\smallsmile");
9423defineSymbol(math, ams, rel, "\u2322", "\\smallfrown");
9424defineSymbol(math, ams, rel, "\u224f", "\\bumpeq");
9425defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq");
9426defineSymbol(math, ams, rel, "\u2267", "\\geqq");
9427defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant");
9428defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr");
9429defineSymbol(math, ams, rel, "\u2273", 
9429"\\gtrsim");
9430defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox");
9431defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot");
9432defineSymbol(math, ams, rel, "\u22d9", "\\ggg");
9433defineSymbol(math, ams, rel, "\u2277", "\\gtrless");
9434defineSymbol(math, ams, rel, "\u22db", "\\gtreqless");
9435defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless");
9436defineSymbol(math, ams, rel, "\u2256", "\\eqcirc");
9437defineSymbol(math, ams, rel, "\u2257", "\\circeq");
9438defineSymbol(math, ams, rel, "\u225c", "\\triangleq");
9439defineSymbol(math, ams, rel, "\u223c", "\\thicksim");
9440defineSymbol(math, ams, rel, "\u2248", "\\thickapprox");
9441defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq");
9442defineSymbol(math, ams, rel, "\u22d1", "\\Supset");
9443defineSymbol(math, ams, rel, "\u2290", "\\sqsupset");
9444defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq");
9445defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc");
9446defineSymbol(math, ams, rel, "\u227f", "\\succsim");
9447defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox");
9448defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright");
9449defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq");
9450defineSymbol(math, ams, rel, "\u22a9", "\\Vdash");
9451defineSymbol(math, ams, rel, "\u2223", "\\shortmid");
9452defineSymbol(math, ams, rel, "\u2225", "\\shortparallel");
9453defineSymbol(math, ams, rel, "\u226c", "\\between");
9454defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork");
9455defineSymbol(math, ams, rel, "\u221d", "\\varpropto");
9456defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft");
9457defineSymbol(math, ams, rel, "\u2234", "\\therefore");
9458defineSymbol(math, ams, rel, "\u220d", "\\backepsilon");
9459defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright");
9460defineSymbol(math, ams, rel, "\u2235", "\\because");
9461defineSymbol(math, ams, rel, "\u22d8", "\\llless");
9462defineSymbol(math, ams, rel, "\u22d9", "\\gggtr");
9463defineSymbol(math, ams, bin, "\u22b2", "\\lhd");
9464defineSymbol(math, ams, bin, "\u22b3", "\\rhd");
9465defineSymbol(math, ams, rel, "\u2242", "\\eqsim");
9466defineSymbol(math, main, rel, "\u22c8", "\\Join");
9467defineSymbol(math, ams, rel, "\u2251", "\\Doteq");
9468
9469// AMS Binary Operators
9470defineSymbol(math, ams, bin, "\u2214", "\\dotplus");
9471defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus");
9472defineSymbol(math, ams, bin, "\u22d2", "\\Cap");
9473defineSymbol(math, ams, bin, "\u22d3", "\\Cup");
9474defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge");
9475defineSymbol(math, ams, bin, "\u229f", "\\boxminus");
9476defineSymbol(math, ams, bin, "\u229e", "\\boxplus");
9477defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes");
9478defineSymbol(math, ams, bin, "\u22c9", "\\ltimes");
9479defineSymbol(math, ams, bin, "\u22ca", "\\rtimes");
9480defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes");
9481defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes");
9482defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge");
9483defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee");
9484defineSymbol(math, ams, bin, "\u229d", "\\circleddash");
9485defineSymbol(math, ams, bin, "\u229b", "\\circledast");
9486defineSymbol(math, ams, bin, "\u22c5", "\\centerdot");
9487defineSymbol(math, ams, bin, "\u22ba", "\\intercal");
9488defineSymbol(math, ams, bin, "\u22d2", "\\doublecap");
9489defineSymbol(math, ams, bin, "\u22d3", "\\doublecup");
9490defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes");
9491
9492// AMS Arrows
9493defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow");
9494defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow");
9495defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows");
9496defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows");
9497defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow");
9498defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow");
9499defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail");
9500defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft");
9501defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons");
9502defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft");
9503defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft");
9504defineSymbol(math, ams, rel, "\u21b0", "\\Lsh");
9505defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows");
9506defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft");
9507defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft");
9508defineSymbol(math, ams, rel, "\u22b8", "\\multimap");
9509defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow");
9510defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows");
9511defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows");
9512defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow");
9513defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail");
9514defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright");
9515defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright");
9516defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright");
9517defineSymbol(math, ams, rel, "\u21b1", "\\Rsh");
9518defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows");
9519defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright");
9520defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright");
9521defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow");
9522defineSymbol(math, ams, rel, "\u21dd", "\\leadsto");
9523defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow");
9524defineSymbol(math, ams, rel, "\u21be", "\\restriction");
9525
9526defineSymbol(math, main, textord, "\u2018", "`");
9527defineSymbol(math, main, textord, "$", "\\$");
9528defineSymbol(text, main, textord, "$", "\\$");
9529defineSymbol(math, main, textord, "%", "\\%");
9530defineSymbol(text, main, textord, "%", "\\%");
9531defineSymbol(math, main, textord, "_", "\\_");
9532defineSymbol(text, main, textord, "_", "\\_");
9533defineSymbol(math, main, textord, "\u2220", "\\angle");
9534defineSymbol(math, main, textord, "\u221e", "\\infty");
9535defineSymbol(math, main, textord, "\u2032", "\\prime");
9536defineSymbol(math, main, textord, "\u25b3", "\\triangle");
9537defineSymbol(math, main, textord, "\u0393", "\\Gamma");
9538defineSymbol(math, main, textord, "\u0394", "\\Delta");
9539defineSymbol(math, main, textord, "\u0398", "\\Theta");
9540defineSymbol(math, main, textord, "\u039b", "\\Lambda");
9541defineSymbol(math, main, textord, "\u039e", "\\Xi");
9542defineSymbol(math, main, textord, "\u03a0", "\\Pi");
9543defineSymbol(math, main, textord, "\u03a3", "\\Sigma");
9544defineSymbol(math, main, textord, "\u03a5", "\\Upsilon");
9545defineSymbol(math, main, textord, "\u03a6", "\\Phi");
9546defineSymbol(math, main, textord, "\u03a8", "\\Psi");
9547defineSymbol(math, main, textord, "\u03a9", "\\Omega");
9548defineSymbol(math, main, textord, "\u00ac", "\\neg");
9549defineSymbol(math, main, textord, "\u00ac", "\\lnot");
9550defineSymbol(math, main, textord, "\u22a4", "\\top");
9551defineSymbol(math, main, textord, "\u22a5", "\\bot");
9552defineSymbol(math, main, textord, "\u2205", "\\emptyset");
9553defineSymbol(math, ams, textord, "\u2205", "\\varnothing");
9554defineSymbol(math, main, mathord, "\u03b1", "\\alpha");
9555defineSymbol(math, main, mathord, "\u03b2", "\\beta");
9556defineSymbol(math, main, mathord, "\u03b3", "\\gamma");
9557defineSymbol(math, main, mathord, "\u03b4", "\\delta");
9558defineSymbol(math, main, mathord, "\u03f5", "\\epsilon");
9559defineSymbol(math, main, mathord, "\u03b6", "\\zeta");
9560defineSymbol(math, main, mathord, "\u03b7", "\\eta");
9561defineSymbol(math, main, mathord, "\u03b8", "\\theta");
9562defineSymbol(math, main, mathord, "\u03b9", "\\iota");
9563defineSymbol(math, main, mathord, "\u03ba", "\\kappa");
9564defineSymbol(math, main, mathord, "\u03bb", "\\lambda");
9565defineSymbol(math, main, mathord, "\u03bc", "\\mu");
9566defineSymbol(math, main, mathord, "\u03bd", "\\nu");
9567defineSymbol(math, main, mathord, "\u03be", "\\xi");
9568defineSymbol(math, main, mathord, "o", "\\omicron");
9569defineSymbol(math, main, mathord, "\u03c0", "\\pi");
9570defineSymbol(math, main, mathord, "\u03c1", "\\rho");
9571defineSymbol(math, main, mathord, "\u03c3", "\\sigma");
9572defineSymbol(math, main, mathord, "\u03c4", "\\tau");
9573defineSymbol(math, main, mathord, "\u03c5", "\\upsilon");
9574defineSymbol(math, main, mathord, "\u03d5", "\\phi");
9575defineSymbol(math, main, mathord, "\u03c7", "\\chi");
9576defineSymbol(math, main, mathord, "\u03c8", "\\psi");
9577defineSymbol(math, main, mathord, "\u03c9", "\\omega");
9578defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon");
9579defineSymbol(math, main, mathord, "\u03d1", "\\vartheta");
9580defineSymbol(math, main, mathord, "\u03d6", "\\varpi");
9581defineSymbol(math, main, mathord, "\u03f1", "\\varrho");
9582defineSymbol(math, main, mathord, "\u03c2", "\\varsigma");
9583defineSymbol(math, main, mathord, "\u03c6", "\\varphi");
9584defineSymbol(math, main, bin, "\u2217", "*");
9585defineSymbol(math, main, bin, "+", "+");
9586defineSymbol(math, main, bin, "\u2212", "-");
9587defineSymbol(math, main, bin, "\u22c5", "\\cdot");
9588defineSymbol(math, main, bin, "\u2218", "\\circ");
9589defineSymbol(math, main, bin, "\u00f7", "\\div");
9590defineSymbol(math, main, bin, "\u00b1", "\\pm");
9591defineSymbol(math, main, bin, "\u00d7", "\\times");
9592defineSymbol(math, main, bin, "\u2229", "\\cap");
9593defineSymbol(math, main, bin, "\u222a", "\\cup");
9594defineSymbol(math, main, bin, "\u2216", "\\setminus");
9595defineSymbol(math, main, bin, "\u2227", "\\land");
9596defineSymbol(math, main, bin, "\u2228", "\\lor");
9597defineSymbol(math, main, bin, "\u2227", "\\wedge");
9598defineSymbol(math, main, bin, "\u2228", "\\vee");
9599defineSymbol(math, main, textord, "\u221a", "\\surd");
9600defineSymbol(math, main, open, "(", "(");
9601defineSymbol(math, main, open, "[", "[");
9602defineSymbol(math, main, open, "\u27e8", "\\langle");
9603defineSymbol(math, main, open, "\u2223", "\\lvert");
9604defineSymbol(math, main, open, "\u2225", "\\lVert");
9605defineSymbol(math, main, close, ")", ")");
9606defineSymbol(math, main, close, "]", "]");
9607defineSymbol(math, main, close, "?", "?");
9608defineSymbol(math, main, close, "!", "!");
9609defineSymbol(math, main, close, "\u27e9", "\\rangle");
9610defineSymbol(math, main, close, "\u2223", "\\rvert");
9611defineSymbol(math, main, close, "\u2225", "\\rVert");
9612defineSymbol(math, main, rel, "=", "=");
9613defineSymbol(math, main, rel, "<", "<");
9614defineSymbol(math, main, rel, ">", ">");
9615defineSymbol(math, main, rel, ":", ":");
9616defineSymbol(math, main, rel, "\u2248", "\\approx");
9617defineSymbol(math, main, rel, "\u2245", "\\cong");
9618defineSymbol(math, main, rel, "\u2265", "\\ge");
9619defineSymbol(math, main, rel, "\u2265", "\\geq");
9620defineSymbol(math, main, rel, "\u2190", "\\gets");
9621defineSymbol(math, main, rel, ">", "\\gt");
9622defineSymbol(math, main, rel, "\u2208", "\\in");
9623defineSymbol(math, main, rel, "\u2209", "\\notin");
9624defineSymbol(math, main, rel, "\u2282", "\\subset");
9625defineSymbol(math, main, rel, "\u2283", "\\supset");
9626defineSymbol(math, main, rel, "\u2286", "\\subseteq");
9627defineSymbol(math, main, rel, "\u2287", "\\supseteq");
9628defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq");
9629defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq");
9630defineSymbol(math, main, rel, "\u22a8", "\\models");
9631defineSymbol(math, main, rel, "\u2190", "\\leftarrow");
9632defineSymbol(math, main, rel, "\u2264", "\\le");
9633defineSymbol(math, main, rel, "\u2264", "\\leq");
9634defineSymbol(math, main, rel, "<", "\\lt");
9635defineSymbol(math, main, rel, "\u2260", "\\ne");
9636defineSymbol(math, main, rel, "\u2260", "\\neq");
9637defineSymbol(math, main, rel, "\u2192", "\\rightarrow");
9638defineSymbol(math, main, rel, "\u2192", "\\to");
9639defineSymbol(math, ams, rel, "\u2271", "\\ngeq");
9640defineSymbol(math, ams, rel, "\u2270", "\\nleq");
9641defineSymbol(math, main, spacing, null, "\\!");
9642defineSymbol(math, main, spacing, "\u00a0", "\\ ");
9643defineSymbol(math, main, spacing, "\u00a0", "~");
9644defineSymbol(math, main, spacing, null, "\\,");
9645defineSymbol(math, main, spacing, null, "\\:");
9646defineSymbol(math, main, spacing, null, "\\;");
9647defineSymbol(math, main, spacing, null, "\\enspace");
9648defineSymbol(math, main, spacing, null, "\\qquad");
9649defineSymbol(math, main, spacing, null, "\\quad");
9650defineSymbol(math, main, spacing, "\u00a0", "\\space");
9651defineSymbol(math, main, punct, ",", ",");
9652defineSymbol(math, main, punct, ";", ";");
9653defineSymbol(math, main, punct, ":", "\\colon");
9654defineSymbol(math, ams, bin, "\u22bc", "\\barwedge");
9655defineSymbol(math, ams, bin, "\u22bb", "\\veebar");
9656defineSymbol(math, main, bin, "\u2299", "\\odot");
9657defineSymbol(math, main, bin, "\u2295", "\\oplus");
9658defineSymbol(math, main, bin, "\u2297", "\\otimes");
9659defineSymbol(math, main, textord, "\u2202", "\\partial");
9660defineSymbol(math, main, bin, "\u2298", "\\oslash");
9661defineSymbol(math, ams, bin, "\u229a", "\\circledcirc");
9662defineSymbol(math, ams, bin, "\u22a1", "\\boxdot");
9663defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup");
9664defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown");
9665defineSymbol(math, main, bin, "\u2020", "\\dagger");
9666defineSymbol(math, main, bin, "\u22c4", "\\diamond");
9667defineSymbol(math, main, bin, "\u22c6", "\\star");
9668defineSymbol(math, main, bin, "\u25c3", "\\triangleleft");
9669defineSymbol(math, main, bin, "\u25b9", "\\triangleright");
9670defineSymbol(math, main, open, "{", "\\{");
9671defineSymbol(text, main, textord, "{", "\\{");
9672defineSymbol(math, main, close, "}", "\\}");
9673defineSymbol(text, main, textord, "}", "\\}");
9674defineSymbol(math, main, open, "{", "\\lbrace");
9675defineSymbol(math, main, close, "}", "\\rbrace");
9676defineSymbol(math, main, open, "[", "\\lbrack");
9677defineSymbol(math, main, close, "]", "\\rbrack");
9678defineSymbol(math, main, open, "\u230a", "\\lfloor");
9679defineSymbol(math, main, close, "\u230b", "\\rfloor");
9680defineSymbol(math, main, open, "\u2308", "\\lceil");
9681defineSymbol(math, main, close, "\u2309", "\\rceil");
9682defineSymbol(math, main, textord, "\\", "\\backslash");
9683defineSymbol(math, main, textord, "\u2223", "|");
9684defineSymbol(math, main, textord, "\u2223", "\\vert");
9685defineSymbol(math, main, textord, "\u2225", "\\|");
9686defineSymbol(math, main, textord, "\u2225", "\\Vert");
9687defineSymbol(math, main, rel, "\u2191", "\\uparrow");
9688defineSymbol(math, main, rel, "\u21d1", "\\Uparrow");
9689defineSymbol(math, main, rel, "\u2193", "\\downarrow");
9690defineSymbol(math, main, rel, "\u21d3", "\\Downarrow");
9691defineSymbol(math, main, rel, "\u2195", "\\updownarrow");
9692defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow");
9693defineSymbol(math, math, op, "\u2210", "\\coprod");
9694defineSymbol(math, math, op, "\u22c1", "\\bigvee");
9695defineSymbol(math, math, op, "\u22c0", "\\bigwedge");
9696defineSymbol(math, math, op, "\u2a04", "\\biguplus");
9697defineSymbol(math, math, op, "\u22c2", "\\bigcap");
9698defineSymbol(math, math, op, "\u22c3", "\\bigcup");
9699defineSymbol(math, math, op, "\u222b", "\\int");
9700defineSymbol(math, math, op, "\u222b", "\\intop");
9701defineSymbol(math, math, op, "\u222c", "\\iint");
9702defineSymbol(math, math, op, "\u222d", "\\iiint");
9703defineSymbol(math, math, op, "\u220f", "\\prod");
9704defineSymbol(math, math, op, "\u2211", "\\sum");
9705defineSymbol(math, math, op, "\u2a02", "\\bigotimes");
9706defineSymbol(math, math, op, "\u2a01", "\\bigoplus");
9707defineSymbol(math, math, op, "\u2a00", "\\bigodot");
9708defineSymbol(math, math, op, "\u222e", "\\oint");
9709defineSymbol(math, math, op, "\u2a06", "\\bigsqcup");
9710defineSymbol(math, math, op, "\u222b", "\\smallint");
9711defineSymbol(text, main, inner, "\u2026", "\\textellipsis");
9712defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
9713defineSymbol(text, main, inner, "\u2026", "\\ldots");
9714defineSymbol(math, main, inner, "\u2026", "\\ldots");
9715defineSymbol(math, main, inner, "\u22ef", "\\cdots");
9716defineSymbol(math, main, inner, "\u22f1", "\\ddots");
9717defineSymbol(math, main, textord, "\u22ee", "\\vdots");
9718defineSymbol(math, main, accent, "\u00b4", "\\acute");
9719defineSymbol(math, main, accent, "\u0060", "\\grave");
9720defineSymbol(math, main, accent, "\u00a8", "\\ddot");
9721defineSymbol(math, main, accent, "\u007e", "\\tilde");
9722defineSymbol(math, main, accent, "\u00af", "\\bar");
9723defineSymbol(math, main, accent, "\u02d8", "\\breve");
9724defineSymbol(math, main, accent, "\u02c7", "\\check");
9725defineSymbol(math, main, accent, "\u005e", "\\hat");
9726defineSymbol(math, main, accent, "\u20d7", "\\vec");
9727defineSymbol(math, main, accent, "\u02d9", "\\dot");
9728defineSymbol(math, main, mathord, "\u0131", "\\imath");
9729defineSymbol(math, main, mathord, "\u0237", "\\jmath");
9730
9731defineSymbol(text, main, textord, "\u2013", "--");
9732defineSymbol(text, main, textord, "\u2014", "---");
9733defineSymbol(text, main, textord, "\u2018", "`");
9734defineSymbol(text, main, textord, "\u2019", "'");
9735defineSymbol(text, main, textord, "\u201c", "``");
9736defineSymbol(text, main, textord, "\u201d", "''");
9737defineSymbol(math, main, textord, "\u00b0", "\\degree");
9738defineSymbol(text, main, textord, "\u00b0", "\\degree");
9739defineSymbol(math, main, mathord, "\u00a3", "\\pounds");
9740defineSymbol(math, ams, textord, "\u2720", "\\maltese");
9741defineSymbol(text, ams, textord, "\u2720", "\\maltese");
9742
9743defineSymbol(text, main, spacing, "\u00a0", "\\ ");
9744defineSymbol(text, main, spacing, "\u00a0", " ");
9745defineSymbol(text, main, spacing, "\u00a0", "~");
9746
9747// There are lots of symbols which are the same, so we add them in afterwards.
9748var i;
9749var ch;
9750
9751// All of these are textords in math mode
9752var mathTextSymbols = "0123456789/@.\"";
9753for (i = 0; i < mathTextSymbols.length; i++) {
9754    ch = mathTextSymbols.charAt(i);
9755    defineSymbol(math, main, textord, ch, ch);
9756}
9757
9758// All of these are textords in text mode
9759var textSymbols = "0123456789!@*()-=+[]\";:?/.,";
9760for (i = 0; i < textSymbols.length; i++) {
9761    ch = textSymbols.charAt(i);
9762    defineSymbol(text, main, textord, ch, ch);
9763}
9764
9765// All of these are textords in text mode, and mathords in math mode
9766var letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
9767for (i = 0; i < letters.length; i++) {
9768    ch = letters.charAt(i);
9769    defineSymbol(math, main, mathord, ch, ch);
9770    defineSymbol(text, main, textord, ch, ch);
9771}
9772
9773// Latin-1 letters
9774for (i = 0x00C0; i <= 0x00D6; i++) {
9775    ch = String.fromCharCode(i);
9776    defineSymbol(text, main, textord, ch, ch);
9777}
9778
9779for (i = 0x00D8; i <= 0x00F6; i++) {
9780    ch = String.fromCharCode(i);
9781    defineSymbol(text, main, textord, ch, ch);
9782}
9783
9784for (i = 0x00F8; i <= 0x00FF; i++) {
9785    ch = String.fromCharCode(i);
9786    defineSymbol(text, main, textord, ch, ch);
9787}
9788
9789// Cyrillic
9790for (i = 0x0410; i <= 0x044F; i++) {
9791    ch = String.fromCharCode(i);
9792    defineSymbol(text, main, textord, ch, ch);
9793}
9794
9795// Unicode versions of existing characters
9796defineSymbol(text, main, textord, "\u2013", "–");
9797defineSymbol(text, main, textord, "\u2014", "—");
9798defineSymbol(text, main, textord, "\u2018", "‘");
9799defineSymbol(text, main, textord, "\u2019", "’");
9800defineSymbol(text, main, textord, "\u201c", "“");
9801defineSymbol(text, main, textord, "\u201d", "”");
9802});
9803
9804/* eslint no-console:0 */
9805/**
9806 * This module contains general functions that can be used for building
9807 * different kinds of domTree nodes in a consistent manner.
9808 */
9809
9810var domTree$1 = domTree$2;
9811var fontMetrics$3 = fontMetrics$1;
9812var symbols = symbols$1;
9813var utils$2 = utils$4;
9814
9815var greekCapitals = [
9816    "\\Gamma",
9817    "\\Delta",
9818    "\\Theta",
9819    "\\Lambda",
9820    "\\Xi",
9821    "\\Pi",
9822    "\\Sigma",
9823    "\\Upsilon",
9824    "\\Phi",
9825    "\\Psi",
9826    "\\Omega"
9827];
9828
9829// The following have to be loaded from Main-Italic font, using class mainit
9830var mainitLetters = [
9831    "\u0131",   // dotless i, \imath
9832    "\u0237",   // dotless j, \jmath
9833    "\u00a3"   // \pounds
9834];
9835
9836/**
9837 * Makes a symbolNode after translation via the list of symbols in symbols.js.
9838 * Correctly pulls out metrics for the character, and optionally takes a list of
9839 * classes to be attached to the node.
9840 *
9841 * TODO: make argument order closer to makeSpan
9842 * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
9843 * should if present come first in `classes`.
9844 */
9845var makeSymbol = function(value, fontFamily, mode, options, classes) {
9846    // Replace the value with its replaced value from symbol.js
9847    if (symbols[mode][value] && symbols[mode][value].replace) {
9848        value = symbols[mode][value].replace;
9849    }
9850
9851    var metrics = fontMetrics$3.getCharacterMetrics(value, fontFamily);
9852
9853    var symbolNode;
9854    if (metrics) {
9855        var italic = metrics.italic;
9856        if (mode === "text") {
9857            italic = 0;
9858        }
9859        symbolNode = new domTree$1.symbolNode(
9860            value, metrics.height, metrics.depth, italic, metrics.skew,
9861            classes);
9862    } else {
9863        // TODO(emily): Figure out a good way to only print this in development
9864        typeof console !== "undefined" && console.warn(
9865            "No character metrics for '" + value + "' in style '" +
9866                fontFamily + "'");
9867        symbolNode = new domTree$1.symbolNode(value, 0, 0, 0, 0, classes);
9868    }
9869
9870    if (options) {
9871        if (options.style.isTight()) {
9872            symbolNode.classes.push("mtight");
9873        }
9874        if (options.getColor()) {
9875            symbolNode.style.color = options.getColor();
9876        }
9877    }
9878
9879    return symbolNode;
9880};
9881
9882/**
9883 * Makes a symbol in Main-Regular or AMS-Regular.
9884 * Used for rel, bin, open, close, inner, and punct.
9885 */
9886var mathsym = function(value, mode, options, classes) {
9887    // Decide what font to render the symbol in by its entry in the symbols
9888    // table.
9889    // Have a special case for when the value = \ because the \ is used as a
9890    // textord in unsupported command errors but cannot be parsed as a regular
9891    // text ordinal and is therefore not present as a symbol in the symbols
9892    // table for text
9893    if (value === "\\" || symbols[mode][value].font === "main") {
9894        return makeSymbol(value, "Main-Regular", mode, options, classes);
9895    } else {
9896        return makeSymbol(
9897            value, "AMS-Regular", mode, options, classes.concat(["amsrm"]));
9898    }
9899};
9900
9901/**
9902 * Makes a symbol in the default font for mathords and textords.
9903 */
9904var mathDefault = function(value, mode, options, classes, type) {
9905    if (type === "mathord") {
9906        return mathit(value, mode, options, classes);
9907    } else if (type === "textord") {
9908        return makeSymbol(
9909            value, "Main-Regular", mode, options, classes.concat(["mathrm"]));
9910    } else {
9911        throw new Error("unexpected type: " + type + " in mathDefault");
9912    }
9913};
9914
9915/**
9916 * Makes a symbol in the italic math font.
9917 */
9918var mathit = function(value, mode, options, classes) {
9919    if (/[0-9]/.test(value.charAt(0)) ||
9920            // glyphs for \imath and \jmath do not exist in Math-Italic so we
9921            // need to use Main-Italic instead
9922            utils$2.contains(mainitLetters, value) ||
9923            utils$2.contains(greekCapitals, value)) {
9924        return makeSymbol(
9925            value, "Main-Italic", mode, options, classes.concat(["mainit"]));
9926    } else {
9927        return makeSymbol(
9928            value, "Math-Italic", mode, options, classes.concat(["mathit"]));
9929    }
9930};
9931
9932/**
9933 * Makes either a mathord or textord in the correct font and color.
9934 */
9935var makeOrd = function(group, options, type) {
9936    var mode = group.mode;
9937    var value = group.value;
9938    if (symbols[mode][value] && symbols[mode][value].replace) {
9939        value = symbols[mode][value].replace;
9940    }
9941
9942    var classes = ["mord"];
9943
9944    var font = options.font;
9945    if (font) {
9946        if (font === "mathit" || utils$2.contains(mainitLetters, value)) {
9947            return mathit(value, mode, options, classes);
9948        } else {
9949            var fontName = fontMap[font].fontName;
9950            if (fontMetrics$3.getCharacterMetrics(value, fontName)) {
9951                return makeSymbol(
9952                    value, fontName, mode, options, classes.concat([font]));
9953            } else {
9954                return mathDefault(value, mode, options, classes, type);
9955            }
9956        }
9957    } else {
9958        return mathDefault(value, mode, options, classes, type);
9959    }
9960};
9961
9962/**
9963 * Calculate the height, depth, and maxFontSize of an element based on its
9964 * children.
9965 */
9966var sizeElementFromChildren = function(elem) {
9967    var height = 0;
9968    var depth = 0;
9969    var maxFontSize = 0;
9970
9971    if (elem.children) {
9972        for (var i = 0; i < elem.children.length; i++) {
9973            if (elem.children[i].height > height) {
9974                height = elem.children[i].height;
9975            }
9976            if (elem.children[i].depth > depth) {
9977                depth = elem.children[i].depth;
9978            }
9979            if (elem.children[i].maxFontSize > maxFontSize) {
9980                maxFontSize = elem.children[i].maxFontSize;
9981            }
9982        }
9983    }
9984
9985    elem.height = height;
9986    elem.depth = depth;
9987    elem.maxFontSize = maxFontSize;
9988};
9989
9990/**
9991 * Makes a span with the given list of classes, list of children, and options.
9992 *
9993 * TODO: Ensure that `options` is always provided (currently some call sites
9994 * don't pass it).
9995 * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which
9996 * should if present come first in `classes`.
9997 */
9998var makeSpan$2 = function(classes, children, options) {
9999    var span = new domTree$1.span(classes, children, options);
10000
10001    sizeElementFromChildren(span);
10002
10003    return span;
10004};
10005
10006/**
10007 * Prepends the given children to the given span, updating height, depth, and
10008 * maxFontSize.
10009 */
10010var prependChildren = function(span, children) {
10011    span.children = children.concat(span.children);
10012
10013    sizeElementFromChildren(span);
10014};
10015
10016/**
10017 * Makes a document fragment with the given list of children.
10018 */
10019var makeFragment = function(children) {
10020    var fragment = new domTree$1.documentFragment(children);
10021
10022    sizeElementFromChildren(fragment);
10023
10024    return fragment;
10025};
10026
10027/**
10028 * Makes an element placed in each of the vlist elements to ensure that each
10029 * element has the same max font size. To do this, we create a zero-width space
10030 * with the correct font size.
10031 */
10032var makeFontSizer = function(options, fontSize) {
10033    var fontSizeInner = makeSpan$2([], [new domTree$1.symbolNode("\u200b")]);
10034    fontSizeInner.style.fontSize =
10035        (fontSize / options.style.sizeMultiplier) + "em";
10036
10037    var fontSizer = makeSpan$2(
10038        ["fontsize-ensurer", "reset-" + options.size, "size5"],
10039        [fontSizeInner]);
10040
10041    return fontSizer;
10042};
10043
10044/**
10045 * Makes a vertical list by stacking elements and kerns on top of each other.
10046 * Allows for many different ways of specifying the positioning method.
10047 *
10048 * Arguments:
10049 *  - children: A list of child or kern nodes to be stacked on top of each other
10050 *              (i.e. the first element will be at the bottom, and the last at
10051 *              the top). Element nodes are specified as
10052 *                {type: "elem", elem: node}
10053 *              while kern nodes are specified as
10054 *                {type: "kern", size: size}
10055 *  - positionType: The method by which the vlist should be positioned. Valid
10056 *                  values are:
10057 *                   - "individualShift": The children list only contains elem
10058 *                                        nodes, and each node contains an extra
10059 *                                        "shift" value of how much it should be
10060 *                                        shifted (note that shifting is always
10061 *                                        moving downwards). positionData is
10062 *                                        ignored.
10063 *                   - "top": The positionData specifies the topmost point of
10064 *                            the vlist (note this is expected to be a height,
10065 *                            so positive values move up)
10066 *                   - "bottom": The positionData specifies the bottommost point
10067 *                               of the vlist (note this is expected to be a
10068 *                               depth, so positive values move down
10069 *                   - "shift": The vlist will be positioned such that its
10070 *                              baseline is positionData away from the baseline
10071 *                              of the first child. Positive values move
10072 *                              downwards.
10073 *                   - "firstBaseline": The vlist will be positioned such that
10074 *                                      its baseline is aligned with the
10075 *                                      baseline of the first child.
10076 *                                      positionData is ignored. (this is
10077 *                                      equivalent to "shift" with
10078 *                                      positionData=0)
10079 *  - positionData: Data used in different ways depending on positionType
10080 *  - options: An Options object
10081 *
10082 */
10083var makeVList = function(children, positionType, positionData, options) {
10084    var depth;
10085    var currPos;
10086    var i;
10087    if (positionType === "individualShift") {
10088        var oldChildren = children;
10089        children = [oldChildren[0]];
10090
10091        // Add in kerns to the list of children to get each element to be
10092        // shifted to the correct specified shift
10093        depth = -oldChildren[0].shift - oldChildren[0].elem.depth;
10094        currPos = depth;
10095        for (i = 1; i < oldChildren.length; i++) {
10096            var diff = -oldChildren[i].shift - currPos -
10097                oldChildren[i].elem.depth;
10098            var size = diff -
10099                (oldChildren[i - 1].elem.height +
10100                 oldChildren[i - 1].elem.depth);
10101
10102            currPos = currPos + diff;
10103
10104            children.push({type: "kern", size: size});
10105            children.push(oldChildren[i]);
10106        }
10107    } else if (positionType === "top") {
10108        // We always start at the bottom, so calculate the bottom by adding up
10109        // all the sizes
10110        var bottom = positionData;
10111        for (i = 0; i < children.length; i++) {
10112            if (children[i].type === "kern") {
10113                bottom -= children[i].size;
10114            } else {
10115                bottom -= children[i].elem.height + children[i].elem.depth;
10116            }
10117        }
10118        depth = bottom;
10119    } else if (positionType === "bottom") {
10120        depth = -positionData;
10121    } else if (positionType === "shift") {
10122        depth = -children[0].elem.depth - positionData;
10123    } else if (positionType === "firstBaseline") {
10124        depth = -children[0].elem.depth;
10125    } else {
10126        depth = 0;
10127    }
10128
10129    // Make the fontSizer
10130    var maxFontSize = 0;
10131    for (i = 0; i < children.length; i++) {
10132        if (children[i].type === "elem") {
10133            maxFontSize = Math.max(maxFontSize, children[i].elem.maxFontSize);
10134        }
10135    }
10136    var fontSizer = makeFontSizer(options, maxFontSize);
10137
10138    // Create a new list of actual children at the correct offsets
10139    var realChildren = [];
10140    currPos = depth;
10141    for (i = 0; i < children.length; i++) {
10142        if (children[i].type === "kern") {
10143            currPos += children[i].size;
10144        } else {
10145            var child = children[i].elem;
10146
10147            var shift = -child.depth - currPos;
10148            currPos += child.height + child.depth;
10149
10150            var childWrap = makeSpan$2([], [fontSizer, child]);
10151            childWrap.height -= shift;
10152            childWrap.depth += shift;
10153            childWrap.style.top = shift + "em";
10154
10155            realChildren.push(childWrap);
10156        }
10157    }
10158
10159    // Add in an element at the end with no offset to fix the calculation of
10160    // baselines in some browsers (namely IE, sometimes safari)
10161    var baselineFix = makeSpan$2(
10162        ["baseline-fix"], [fontSizer, new domTree$1.symbolNode("\u200b")]);
10163    realChildren.push(baselineFix);
10164
10165    var vlist = makeSpan$2(["vlist"], realChildren);
10166    // Fix the final height and depth, in case there were kerns at the ends
10167    // since the makeSpan calculation won't take that in to account.
10168    vlist.height = Math.max(currPos, vlist.height);
10169    vlist.depth = Math.max(-depth, vlist.depth);
10170    return vlist;
10171};
10172
10173// A table of size -> font size for the different sizing functions
10174var sizingMultiplier = {
10175    size1: 0.5,
10176    size2: 0.7,
10177    size3: 0.8,
10178    size4: 0.9,
10179    size5: 1.0,
10180    size6: 1.2,
10181    size7: 1.44,
10182    size8: 1.73,
10183    size9: 2.07,
10184    size10: 2.49
10185};
10186
10187// A map of spacing functions to their attributes, like size and corresponding
10188// CSS class
10189var spacingFunctions = {
10190    "\\qquad": {
10191        size: "2em",
10192        className: "qquad"
10193    },
10194    "\\quad": {
10195        size: "1em",
10196        className: "quad"
10197    },
10198    "\\enspace": {
10199        size: "0.5em",
10200        className: "enspace"
10201    },
10202    "\\;": {
10203        size: "0.277778em",
10204        className: "thickspace"
10205    },
10206    "\\:": {
10207        size: "0.22222em",
10208        className: "mediumspace"
10209    },
10210    "\\,": {
10211        size: "0.16667em",
10212        className: "thinspace"
10213    },
10214    "\\!": {
10215        size: "-0.16667em",
10216        className: "negativethinspace"
10217    }
10218};
10219
10220/**
10221 * Maps TeX font commands to objects containing:
10222 * - variant: string used for "mathvariant" attribute in buildMathML.js
10223 * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics
10224 */
10225// A map between tex font commands an MathML mathvariant attribute values
10226var fontMap = {
10227    // styles
10228    "mathbf": {
10229        variant: "bold",
10230        fontName: "Main-Bold"
10231    },
10232    "mathrm": {
10233        variant: "normal",
10234        fontName: "Main-Regular"
10235    },
10236    "textit": {
10237        variant: "italic",
10238        fontName: "Main-Italic"
10239    },
10240
10241    // "mathit" is missing because it requires the use of two fonts: Main-Italic
10242    // and Math-Italic.  This is handled by a special case in makeOrd which ends
10243    // up calling mathit.
10244
10245    // families
10246    "mathbb": {
10247        variant: "double-struck",
10248        fontName: "AMS-Regular"
10249    },
10250    "mathcal": {
10251        variant: "script",
10252        fontName: "Caligraphic-Regular"
10253    },
10254    "mathfrak": {
10255        variant: "fraktur",
10256        fontName: "Fraktur-Regular"
10257    },
10258    "mathscr": {
10259        variant: "script",
10260        fontName: "Script-Regular"
10261    },
10262    "mathsf": {
10263        variant: "sans-serif",
10264        fontName: "SansSerif-Regular"
10265    },
10266    "mathtt": {
10267        variant: "monospace",
10268        fontName: "Typewriter-Regular"
10269    }
10270};
10271
10272var buildCommon$2 = {
10273    fontMap: fontMap,
10274    makeSymbol: makeSymbol,
10275    mathsym: mathsym,
10276    makeSpan: makeSpan$2,
10277    makeFragment: makeFragment,
10278    makeVList: makeVList,
10279    makeOrd: makeOrd,
10280    prependChildren: prependChildren,
10281    sizingMultiplier: sizingMultiplier,
10282    spacingFunctions: spacingFunctions
10283};
10284
10285/**
10286 * This file deals with creating delimiters of various sizes. The TeXbook
10287 * discusses these routines on page 441-442, in the "Another subroutine sets box
10288 * x to a specified variable delimiter" paragraph.
10289 *
10290 * There are three main routines here. `makeSmallDelim` makes a delimiter in the
10291 * normal font, but in either text, script, or scriptscript style.
10292 * `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1,
10293 * Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of
10294 * smaller pieces that are stacked on top of one another.
10295 *
10296 * The functions take a parameter `center`, which determines if the delimiter
10297 * should be centered around the axis.
10298 *
10299 * Then, there are three exposed functions. `sizedDelim` makes a delimiter in
10300 * one of the given sizes. This is used for things like `\bigl`.
10301 * `customSizedDelim` makes a delimiter with a given total height+depth. It is
10302 * called in places like `\sqrt`. `leftRightDelim` makes an appropriate
10303 * delimiter which surrounds an expression of a given height an depth. It is
10304 * used in `\left` and `\right`.
10305 */
10306
10307var ParseError$3 = ParseError_1;
10308var Style$4 = Style_1;
10309
10310var buildCommon$4 = buildCommon$2;
10311var fontMetrics$4 = fontMetrics$1;
10312var symbols$3 = symbols$1;
10313var utils$6 = utils$4;
10314
10315var makeSpan$3 = buildCommon$4.makeSpan;
10316
10317/**
10318 * Get the metrics for a given symbol and font, after transformation (i.e.
10319 * after following replacement from symbols.js)
10320 */
10321var getMetrics = function(symbol, font) {
10322    if (symbols$3.math[symbol] && symbols$3.math[symbol].replace) {
10323        return fontMetrics$4.getCharacterMetrics(
10324            symbols$3.math[symbol].replace, font);
10325    } else {
10326        return fontMetrics$4.getCharacterMetrics(
10327            symbol, font);
10328    }
10329};
10330
10331/**
10332 * Builds a symbol in the given font size (note size is an integer)
10333 */
10334var mathrmSize = function(value, size, mode, options) {
10335    return buildCommon$4.makeSymbol(value, "Size" + size + "-Regular",
10336        mode, options);
10337};
10338
10339/**
10340 * Puts a delimiter span in a given style, and adds appropriate height, depth,
10341 * and maxFontSizes.
10342 */
10343var styleWrap = function(delim, toStyle, options, classes) {
10344    classes = classes || [];
10345    var span = makeSpan$3(
10346        classes.concat(["style-wrap", options.style.reset(), toStyle.cls()]),
10347        [delim], options);
10348
10349    var multiplier = toStyle.sizeMultiplier / options.style.sizeMultiplier;
10350
10351    span.height *= multiplier;
10352    span.depth *= multiplier;
10353    span.maxFontSize = toStyle.sizeMultiplier;
10354
10355    return span;
10356};
10357
10358/**
10359 * Makes a small delimiter. This is a delimiter that comes in the Main-Regular
10360 * font, but is restyled to either be in textstyle, scriptstyle, or
10361 * scriptscriptstyle.
10362 */
10363var makeSmallDelim = function(delim, style, center, options, mode, classes) {
10364    var text = buildCommon$4.makeSymbol(delim, "Main-Regular", mode, options);
10365
10366    var span = styleWrap(text, style, options, classes);
10367
10368    if (center) {
10369        var shift =
10370            (1 - options.style.sizeMultiplier / style.sizeMultiplier) *
10371            options.style.metrics.axisHeight;
10372
10373        span.style.top = shift + "em";
10374        span.height -= shift;
10375        span.depth += shift;
10376    }
10377
10378    return span;
10379};
10380
10381/**
10382 * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2,
10383 * Size3, or Size4 fonts. It is always rendered in textstyle.
10384 */
10385var makeLargeDelim = function(delim, size, center, options, mode, classes) {
10386    var inner = mathrmSize(delim, size, mode, options);
10387
10388    var span = styleWrap(
10389        makeSpan$3(["delimsizing", "size" + size], [inner], options),
10390        Style$4.TEXT, options, classes);
10391
10392    if (center) {
10393        var shift = (1 - options.style.sizeMultiplier) *
10394            options.style.metrics.axisHeight;
10395
10396        span.style.top = shift + "em";
10397        span.height -= shift;
10398        span.depth += shift;
10399    }
10400
10401    return span;
10402};
10403
10404/**
10405 * Make an inner span with the given offset and in the given font. This is used
10406 * in `makeStackedDelim` to make the stacking pieces for the delimiter.
10407 */
10408var makeInner = function(symbol, font, mode) {
10409    var sizeClass;
10410    // Apply the correct CSS class to choose the right font.
10411    if (font === "Size1-Regular") {
10412        sizeClass = "delim-size1";
10413    } else if (font === "Size4-Regular") {
10414        sizeClass = "delim-size4";
10415    }
10416
10417    var inner = makeSpan$3(
10418        ["delimsizinginner", sizeClass],
10419        [makeSpan$3([], [buildCommon$4.makeSymbol(symbol, font, mode)])]);
10420
10421    // Since this will be passed into `makeVList` in the end, wrap the element
10422    // in the appropriate tag that VList uses.
10423    return {type: "elem", elem: inner};
10424};
10425
10426/**
10427 * Make a stacked delimiter out of a given delimiter, with the total height at
10428 * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook.
10429 */
10430var makeStackedDelim = function(delim, heightTotal, center, options, mode,
10431                                classes) {
10432    // There are four parts, the top, an optional middle, a repeated part, and a
10433    // bottom.
10434    var top;
10435    var middle;
10436    var repeat;
10437    var bottom;
10438    top = repeat = bottom = delim;
10439    middle = null;
10440    // Also keep track of what font the delimiters are in
10441    var font = "Size1-Regular";
10442
10443    // We set the parts and font based on the symbol. Note that we use
10444    // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the
10445    // repeats of the arrows
10446    if (delim === "\\uparrow") {
10447        repeat = bottom = "\u23d0";
10448    } else if (delim === "\\Uparrow") {
10449        repeat = bottom = "\u2016";
10450    } else if (delim === "\\downarrow") {
10451        top = repeat = "\u23d0";
10452    } else if (delim === "\\Downarrow") {
10453        top = repeat = "\u2016";
10454    } else if (delim === "\\updownarrow") {
10455        top = "\\uparrow";
10456        repeat = "\u23d0";
10457        bottom = "\\downarrow";
10458    } else if (delim === "\\Updownarrow") {
10459        top = "\\Uparrow";
10460        repeat = "\u2016";
10461        bottom = "\\Downarrow";
10462    } else if (delim === "[" || delim === "\\lbrack") {
10463        top = "\u23a1";
10464        repeat = "\u23a2";
10465        bottom = "\u23a3";
10466        font = "Size4-Regular";
10467    } else if (delim === "]" || delim === "\\rbrack") {
10468        top = "\u23a4";
10469        repeat = "\u23a5";
10470        bottom = "\u23a6";
10471        font = "Size4-Regular";
10472    } else if (delim === "\\lfloor") {
10473        repeat = top = "\u23a2";
10474        bottom = "\u23a3";
10475        font = "Size4-Regular";
10476    } else if (delim === "\\lceil") {
10477        top = "\u23a1";
10478        repeat = bottom = "\u23a2";
10479        font = "Size4-Regular";
10480    } else if (delim === "\\rfloor") {
10481        repeat = top = "\u23a5";
10482        bottom = "\u23a6";
10483        font = "Size4-Regular";
10484    } else if (delim === "\\rceil") {
10485        top = "\u23a4";
10486        repeat = bottom = "\u23a5";
10487        font = "Size4-Regular";
10488    } else if (delim === "(") {
10489        top = "\u239b";
10490        repeat = "\u239c";
10491        bottom = "\u239d";
10492        font = "Size4-Regular";
10493    } else if (delim === ")") {
10494        top = "\u239e";
10495        repeat = "\u239f";
10496        bottom = "\u23a0";
10497        font = "Size4-Regular";
10498    } else if (delim === "\\{" || delim === "\\lbrace") {
10499        top = "\u23a7";
10500        middle = "\u23a8";
10501        bottom = "\u23a9";
10502        repeat = "\u23aa";
10503        font = "Size4-Regular";
10504    } else if (delim === "\\}" || delim === "\\rbrace") {
10505        top = "\u23ab";
10506        middle = "\u23ac";
10507        bottom = "\u23ad";
10508        repeat = "\u23aa";
10509        font = "Size4-Regular";
10510    } else if (delim === "\\lgroup") {
10511        top = "\u23a7";
10512        bottom = "\u23a9";
10513        repeat = "\u23aa";
10514        font = "Size4-Regular";
10515    } else if (delim === "\\rgroup") {
10516        top = "\u23ab";
10517        bottom = "\u23ad";
10518        repeat = "\u23aa";
10519        font = "Size4-Regular";
10520    } else if (delim === "\\lmoustache") {
10521        top = "\u23a7";
10522        bottom = "\u23ad";
10523        repeat = "\u23aa";
10524        font = "Size4-Regular";
10525    } else if (delim === "\\rmoustache") {
10526        top = "\u23ab";
10527        bottom = "\u23a9";
10528        repeat = "\u23aa";
10529        font = "Size4-Regular";
10530    } else if (delim === "\\surd") {
10531        top = "\ue001";
10532        bottom = "\u23b7";
10533        repeat = "\ue000";
10534        font = "Size4-Regular";
10535    }
10536
10537    // Get the metrics of the four sections
10538    var topMetrics = getMetrics(top, font);
10539    var topHeightTotal = topMetrics.height + topMetrics.depth;
10540    var repeatMetrics = getMetrics(repeat, font);
10541    var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth;
10542    var bottomMetrics = getMetrics(bottom, font);
10543    var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth;
10544    var middleHeightTotal = 0;
10545    var middleFactor = 1;
10546    if (middle !== null) {
10547        var middleMetrics = getMetrics(middle, font);
10548        middleHeightTotal = middleMetrics.height + middleMetrics.depth;
10549        middleFactor = 2; // repeat symmetrically above and below middle
10550    }
10551
10552    // Calcuate the minimal height that the delimiter can have.
10553    // It is at least the size of the top, bottom, and optional middle combined.
10554    var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal;
10555
10556    // Compute the number of copies of the repeat symbol we will need
10557    var repeatCount = Math.ceil(
10558        (heightTotal - minHeight) / (middleFactor * repeatHeightTotal));
10559
10560    // Compute the total height of the delimiter including all the symbols
10561    var realHeightTotal =
10562        minHeight + repeatCount * middleFactor * repeatHeightTotal;
10563
10564    // The center of the delimiter is placed at the center of the axis. Note
10565    // that in this context, "center" means that the delimiter should be
10566    // centered around the axis in the current style, while normally it is
10567    // centered around the axis in textstyle.
10568    var axisHeight = options.style.metrics.axisHeight;
10569    if (center) {
10570        axisHeight *= options.style.sizeMultiplier;
10571    }
10572    // Calculate the depth
10573    var depth = realHeightTotal / 2 - axisHeight;
10574
10575    // Now, we start building the pieces that will go into the vlist
10576
10577    // Keep a list of the inner pieces
10578    var inners = [];
10579
10580    // Add the bottom symbol
10581    inners.push(makeInner(bottom, font, mode));
10582
10583    var i;
10584    if (middle === null) {
10585        // Add that many symbols
10586        for (i = 0; i < repeatCount; i++) {
10587            inners.push(makeInner(repeat, font, mode));
10588        }
10589    } else {
10590        // When there is a middle bit, we need the middle part and two repeated
10591        // sections
10592        for (i = 0; i < repeatCount; i++) {
10593            inners.push(makeInner(repeat, font, mode));
10594        }
10595        inners.push(makeInner(middle, font, mode));
10596        for (i = 0; i < repeatCount; i++) {
10597            inners.push(makeInner(repeat, font, mode));
10598        }
10599    }
10600
10601    // Add the top symbol
10602    inners.push(makeInner(top, font, mode));
10603
10604    // Finally, build the vlist
10605    var inner = buildCommon$4.makeVList(inners, "bottom", depth, options);
10606
10607    return styleWrap(
10608        makeSpan$3(["delimsizing", "mult"], [inner], options),
10609        Style$4.TEXT, options, classes);
10610};
10611
10612// There are three kinds of delimiters, delimiters that stack when they become
10613// too large
10614var stackLargeDelimiters = [
10615    "(", ")", "[", "\\lbrack", "]", "\\rbrack",
10616    "\\{", "\\lbrace", "\\}", "\\rbrace",
10617    "\\lfloor", "\\rfloor", "\\lceil", "\\rceil",
10618    "\\surd"
10619];
10620
10621// delimiters that always stack
10622var stackAlwaysDelimiters = [
10623    "\\uparrow", "\\downarrow", "\\updownarrow",
10624    "\\Uparrow", "\\Downarrow", "\\Updownarrow",
10625    "|", "\\|", "\\vert", "\\Vert",
10626    "\\lvert", "\\rvert", "\\lVert", "\\rVert",
10627    "\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache"
10628];
10629
10630// and delimiters that never stack
10631var stackNeverDelimiters = [
10632    "<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"
10633];
10634
10635// Metrics of the different sizes. Found by looking at TeX's output of
10636// $\bigl| // \Bigl| \biggl| \Biggl| \showlists$
10637// Used to create stacked delimiters of appropriate sizes in makeSizedDelim.
10638var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0];
10639
10640/**
10641 * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4.
10642 */
10643var makeSizedDelim = function(delim, size, options, mode, classes) {
10644    // < and > turn into \langle and \rangle in delimiters
10645    if (delim === "<" || delim === "\\lt") {
10646        delim = "\\langle";
10647    } else if (delim === ">" || delim === "\\gt") {
10648        delim = "\\rangle";
10649    }
10650
10651    // Sized delimiters are never centered.
10652    if (utils$6.contains(stackLargeDelimiters, delim) ||
10653        utils$6.contains(stackNeverDelimiters, delim)) {
10654        return makeLargeDelim(delim, size, false, options, mode, classes);
10655    } else if (utils$6.contains(stackAlwaysDelimiters, delim)) {
10656        return makeStackedDelim(
10657            delim, sizeToMaxHeight[size], false, options, mode, classes);
10658    } else {
10659        throw new ParseError$3("Illegal delimiter: '" + delim + "'");
10660    }
10661};
10662
10663/**
10664 * There are three different sequences of delimiter sizes that the delimiters
10665 * follow depending on the kind of delimiter. This is used when creating custom
10666 * sized delimiters to decide whether to create a small, large, or stacked
10667 * delimiter.
10668 *
10669 * In real TeX, these sequences aren't explicitly defined, but are instead
10670 * defined inside the font metrics. Since there are only three sequences that
10671 * are possible for the delimiters that TeX defines, it is easier to just encode
10672 * them explicitly here.
10673 */
10674
10675// Delimiters that never stack try small delimiters and large delimiters only
10676var stackNeverDelimiterSequence = [
10677    {type: "small", style: Style$4.SCRIPTSCRIPT},
10678    {type: "small", style: Style$4.SCRIPT},
10679    {type: "small", style: Style$4.TEXT},
10680    {type: "large", size: 1},
10681    {type: "large", size: 2},
10682    {type: "large", size: 3},
10683    {type: "large", size: 4}
10684];
10685
10686// Delimiters that always stack try the small delimiters first, then stack
10687var stackAlwaysDelimiterSequence = [
10688    {type: "small", style: Style$4.SCRIPTSCRIPT},
10689    {type: "small", style: Style$4.SCRIPT},
10690    {type: "small", style: Style$4.TEXT},
10691    {type: "stack"}
10692];
10693
10694// Delimiters that stack when large try the small and then large delimiters, and
10695// stack afterwards
10696var stackLargeDelimiterSequence = [
10697    {type: "small", style: Style$4.SCRIPTSCRIPT},
10698    {type: "small", style: Style$4.SCRIPT},
10699    {type: "small", style: Style$4.TEXT},
10700    {type: "large", size: 1},
10701    {type: "large", size: 2},
10702    {type: "large", size: 3},
10703    {type: "large", size: 4},
10704    {type: "stack"}
10705];
10706
10707/**
10708 * Get the font used in a delimiter based on what kind of delimiter it is.
10709 */
10710var delimTypeToFont = function(type) {
10711    if (type.type === "small") {
10712        return "Main-Regular";
10713    } else if (type.type === "large") {
10714        return "Size" + type.size + "-Regular";
10715    } else if (type.type === "stack") {
10716        return "Size4-Regular";
10717    }
10718};
10719
10720/**
10721 * Traverse a sequence of types of delimiters to decide what kind of delimiter
10722 * should be used to create a delimiter of the given height+depth.
10723 */
10724var traverseSequence = function(delim, height, sequence, options) {
10725    // Here, we choose the index we should start at in the sequences. In smaller
10726    // sizes (which correspond to larger numbers in style.size) we start earlier
10727    // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts
10728    // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2
10729    var start = Math.min(2, 3 - options.style.size);
10730    for (var i = start; i < sequence.length; i++) {
10731        if (sequence[i].type === "stack") {
10732            // This is always the last delimiter, so we just break the loop now.
10733            break;
10734        }
10735
10736        var metrics = getMetrics(delim, delimTypeToFont(sequence[i]));
10737        var heightDepth = metrics.height + metrics.depth;
10738
10739        // Small delimiters are scaled down versions of the same font, so we
10740        // account for the style change size.
10741
10742        if (sequence[i].type === "small") {
10743            heightDepth *= sequence[i].style.sizeMultiplier;
10744        }
10745
10746        // Check if the delimiter at this size works for the given height.
10747        if (heightDepth > height) {
10748            return sequence[i];
10749        }
10750    }
10751
10752    // If we reached the end of the sequence, return the last sequence element.
10753    return sequence[sequence.length - 1];
10754};
10755
10756/**
10757 * Make a delimiter of a given height+depth, with optional centering. Here, we
10758 * traverse the sequences, and create a delimiter that the sequence tells us to.
10759 */
10760var makeCustomSizedDelim = function(delim, height, center, options, mode,
10761                                    classes) {
10762    if (delim === "<" || delim === "\\lt") {
10763        delim = "\\langle";
10764    } else if (delim === ">" || delim === "\\gt") {
10765        delim = "\\rangle";
10766    }
10767
10768    // Decide what sequence to use
10769    var sequence;
10770    if (utils$6.contains(stackNeverDelimiters, delim)) {
10771        sequence = stackNeverDelimiterSequence;
10772    } else if (utils$6.contains(stackLargeDelimiters, delim)) {
10773        sequence = stackLargeDelimiterSequence;
10774    } else {
10775        sequence = stackAlwaysDelimiterSequence;
10776    }
10777
10778    // Look through the sequence
10779    var delimType = traverseSequence(delim, height, sequence, options);
10780
10781    // Depending on the sequence element we decided on, call the appropriate
10782    // function.
10783    if (delimType.type === "small") {
10784        return makeSmallDelim(delim, delimType.style, center, options, mode,
10785                              classes);
10786    } else if (delimType.type === "large") {
10787        return makeLargeDelim(delim, delimType.size, center, options, mode,
10788                              classes);
10789    } else if (delimType.type === "stack") {
10790        return makeStackedDelim(delim, height, center, options, mode, classes);
10791    }
10792};
10793
10794/**
10795 * Make a delimiter for use with `\left` and `\right`, given a height and depth
10796 * of an expression that the delimiters surround.
10797 */
10798var makeLeftRightDelim = function(delim, height, depth, options, mode,
10799                                  classes) {
10800    // We always center \left/\right delimiters, so the axis is always shifted
10801    var axisHeight =
10802        options.style.metrics.axisHeight * options.style.sizeMultiplier;
10803
10804    // Taken from TeX source, tex.web, function make_left_right
10805    var delimiterFactor = 901;
10806    var delimiterExtend = 5.0 / fontMetrics$4.metrics.ptPerEm;
10807
10808    var maxDistFromAxis = Math.max(
10809        height - axisHeight, depth + axisHeight);
10810
10811    var totalHeight = Math.max(
10812        // In real TeX, calculations are done using integral values which are
10813        // 65536 per pt, or 655360 per em. So, the division here truncates in
10814        // TeX but doesn't here, producing different results. If we wanted to
10815        // exactly match TeX's calculation, we could do
10816        //   Math.floor(655360 * maxDistFromAxis / 500) *
10817        //    delimiterFactor / 655360
10818        // (To see the difference, compare
10819        //    x^{x^{\left(\rule{0.1em}{0.68em}\right)}}
10820        // in TeX and KaTeX)
10821        maxDistFromAxis / 500 * delimiterFactor,
10822        2 * maxDistFromAxis - delimiterExtend);
10823
10824    // Finally, we defer to `makeCustomSizedDelim` with our calculated total
10825    // height
10826    return makeCustomSizedDelim(delim, totalHeight, true, options, mode,
10827                                classes);
10828};
10829
10830var delimiter$1 = {
10831    sizedDelim: makeSizedDelim,
10832    customSizedDelim: makeCustomSizedDelim,
10833    leftRightDelim: makeLeftRightDelim
10834};
10835
10836/* eslint no-console:0 */
10837/**
10838 * This file does the main work of building a domTree structure from a parse
10839 * tree. The entry point is the `buildHTML` function, which takes a parse tree.
10840 * Then, the buildExpression, buildGroup, and various groupTypes functions are
10841 * called, to produce a final HTML tree.
10842 */
10843
10844var ParseError$2 = ParseError_1;
10845var Style$1 = Style_1;
10846
10847var buildCommon$1 = buildCommon$2;
10848var delimiter = delimiter$1;
10849var domTree = domTree$2;
10850var fontMetrics = fontMetrics$1;
10851var utils$1 = utils$4;
10852
10853var makeSpan$1 = buildCommon$1.makeSpan;
10854
10855var isSpace = function(node) {
10856    return node instanceof domTree.span && node.classes[0] === "mspace";
10857};
10858
10859// Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
10860// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
10861// and the text before Rule 19.
10862
10863var isBin = function(node) {
10864    return node && node.classes[0] === "mbin";
10865};
10866
10867var isBinLeftCanceller = function(node, isRealGroup) {
10868    // TODO: This code assumes that a node's math class is the first element
10869    // of its `classes` array. A later cleanup should ensure this, for
10870    // instance by changing the signature of `makeSpan`.
10871    if (node) {
10872        return utils$1.contains(["mbin", "mopen", "mrel", "mop", "mpunct"],
10873                              node.classes[0]);
10874    } else {
10875        return isRealGroup;
10876    }
10877};
10878
10879var isBinRightCanceller = function(node, isRealGroup) {
10880    if (node) {
10881        return utils$1.contains(["mrel", "mclose", "mpunct"], node.classes[0]);
10882    } else {
10883        return isRealGroup;
10884    }
10885};
10886
10887/**
10888 * Take a list of nodes, build them in order, and return a list of the built
10889 * nodes. documentFragments are flattened into their contents, so the
10890 * returned list contains no fragments. `isRealGroup` is true if `expression`
10891 * is a real group (no atoms will be added on either side), as opposed to
10892 * a partial group (e.g. one created by \color).
10893 */
10894var buildExpression = function(expression, options, isRealGroup) {
10895    // Parse expressions into `groups`.
10896    var groups = [];
10897    for (var i = 0; i < expression.length; i++) {
10898        var group = expression[i];
10899        var output = buildGroup(group, options);
10900        if (output instanceof domTree.documentFragment) {
10901            Array.prototype.push.apply(groups, output.children);
10902        } else {
10903            groups.push(output);
10904        }
10905    }
10906    // At this point `groups` consists entirely of `symbolNode`s and `span`s.
10907
10908    // Explicit spaces (e.g., \;, \,) should be ignored with respect to atom
10909    // spacing (e.g., "add thick space between mord and mrel"). Since CSS
10910    // adjacency rules implement atom spacing, spaces should be invisible to
10911    // CSS. So we splice them out of `groups` and into the atoms themselves.
10912    var spaces = null;
10913    for (i = 0; i < groups.length; i++) {
10914        if (isSpace(groups[i])) {
10915            spaces = spaces || [];
10916            spaces.push(groups[i]);
10917            groups.splice(i, 1);
10918            i--;
10919        } else if (spaces) {
10920            if (groups[i] instanceof domTree.symbolNode) {
10921                groups[i] = makeSpan$1([].concat(groups[i].classes), [groups[i]]);
10922            }
10923            buildCommon$1.prependChildren(groups[i], spaces);
10924            spaces = null;
10925        }
10926    }
10927    if (spaces) {
10928        Array.prototype.push.apply(groups, spaces);
10929    }
10930
10931    // Binary operators change to ordinary symbols in some contexts.
10932    for (i = 0; i < groups.length; i++) {
10933        if (isBin(groups[i])
10934            && (isBinLeftCanceller(groups[i - 1], isRealGroup)
10935                || isBinRightCanceller(groups[i + 1], isRealGroup))) {
10936            groups[i].classes[0] = "mord";
10937        }
10938    }
10939
10940    return groups;
10941};
10942
10943// Return math atom class (mclass) of a domTree.
10944var getTypeOfDomTree = function(node) {
10945    if (node instanceof domTree.documentFragment) {
10946        if (node.children.length) {
10947            return getTypeOfDomTree(
10948                node.children[node.children.length - 1]);
10949        }
10950    } else {
10951        if (utils$1.contains(["mord", "mop", "mbin", "mrel", "mopen", "mclose",
10952            "mpunct", "minner"], node.classes[0])) {
10953            return node.classes[0];
10954        }
10955    }
10956    return null;
10957};
10958
10959/**
10960 * Sometimes, groups perform special rules when they have superscripts or
10961 * subscripts attached to them. This function lets the `supsub` group know that
10962 * its inner element should handle the superscripts and subscripts instead of
10963 * handling them itself.
10964 */
10965var shouldHandleSupSub = function(group, options) {
10966    if (!group) {
10967        return false;
10968    } else if (group.type === "op") {
10969        // Operators handle supsubs differently when they have limits
10970        // (e.g. `\displaystyle\sum_2^3`)
10971        return group.value.limits &&
10972            (options.style.size === Style$1.DISPLAY.size ||
10973            group.value.alwaysHandleSupSub);
10974    } else if (group.type === "accent") {
10975        return isCharacterBox(group.value.base);
10976    } else {
10977        return null;
10978    }
10979};
10980
10981/**
10982 * Sometimes we want to pull out the innermost element of a group. In most
10983 * cases, this will just be the group itself, but when ordgroups and colors have
10984 * a single element, we want to pull that out.
10985 */
10986var getBaseElem = function(group) {
10987    if (!group) {
10988        return false;
10989    } else if (group.type === "ordgroup") {
10990        if (group.value.length === 1) {
10991            return getBaseElem(group.value[0]);
10992        } else {
10993            return group;
10994        }
10995    } else if (group.type === "color") {
10996        if (group.value.value.length === 1) {
10997            return getBaseElem(group.value.value[0]);
10998        } else {
10999            return group;
11000        }
11001    } else if (group.type === "font") {
11002        return getBaseElem(group.value.body);
11003    } else {
11004        return group;
11005    }
11006};
11007
11008/**
11009 * TeXbook algorithms often reference "character boxes", which are simply groups
11010 * with a single character in them. To decide if something is a character box,
11011 * we find its innermost group, and see if it is a single character.
11012 */
11013var isCharacterBox = function(group) {
11014    var baseElem = getBaseElem(group);
11015
11016    // These are all they types of groups which hold single characters
11017    return baseElem.type === "mathord" ||
11018        baseElem.type === "textord" ||
11019        baseElem.type === "bin" ||
11020        baseElem.type === "rel" ||
11021        baseElem.type === "inner" ||
11022        baseElem.type === "open" ||
11023        baseElem.type === "close" ||
11024        baseElem.type === "punct";
11025};
11026
11027var makeNullDelimiter = function(options, classes) {
11028    return makeSpan$1(classes.concat([
11029        "sizing", "reset-" + options.size, "size5",
11030        options.style.reset(), Style$1.TEXT.cls(),
11031        "nulldelimiter"]));
11032};
11033
11034/**
11035 * This is a map of group types to the function used to handle that type.
11036 * Simpler types come at the beginning, while complicated types come afterwards.
11037 */
11038var groupTypes = {};
11039
11040groupTypes.mathord = function(group, options) {
11041    return buildCommon$1.makeOrd(group, options, "mathord");
11042};
11043
11044groupTypes.textord = function(group, options) {
11045    return buildCommon$1.makeOrd(group, options, "textord");
11046};
11047
11048groupTypes.bin = function(group, options) {
11049    return buildCommon$1.mathsym(
11050        group.value, group.mode, options, ["mbin"]);
11051};
11052
11053groupTypes.rel = function(group, options) {
11054    return buildCommon$1.mathsym(
11055        group.value, group.mode, options, ["mrel"]);
11056};
11057
11058groupTypes.open = function(group, options) {
11059    return buildCommon$1.mathsym(
11060        group.value, group.mode, options, ["mopen"]);
11061};
11062
11063groupTypes.close = function(group, options) {
11064    return buildCommon$1.mathsym(
11065        group.value, group.mode, options, ["mclose"]);
11066};
11067
11068groupTypes.inner = function(group, options) {
11069    return buildCommon$1.mathsym(
11070        group.value, group.mode, options, ["minner"]);
11071};
11072
11073groupTypes.punct = function(group, options) {
11074    return buildCommon$1.mathsym(
11075        group.value, group.mode, options, ["mpunct"]);
11076};
11077
11078groupTypes.ordgroup = function(group, options) {
11079    return makeSpan$1(
11080        ["mord", options.style.cls()],
11081        buildExpression(group.value, options.reset(), true),
11082        options
11083    );
11084};
11085
11086groupTypes.text = function(group, options) {
11087    var newOptions = options.withFont(group.value.style);
11088    var inner = buildExpression(group.value.body, newOptions, true);
11089    for (var i = 0; i < inner.length - 1; i++) {
11090        if (inner[i].tryCombine(inner[i + 1])) {
11091            inner.splice(i + 1, 1);
11092            i--;
11093        }
11094    }
11095    return makeSpan$1(["mord", "text", newOptions.style.cls()],
11096        inner, newOptions);
11097};
11098
11099groupTypes.color = function(group, options) {
11100    var elements = buildExpression(
11101        group.value.value,
11102        options.withColor(group.value.color),
11103        false
11104    );
11105
11106    // \color isn't supposed to affect the type of the elements it contains.
11107    // To accomplish this, we wrap the results in a fragment, so the inner
11108    // elements will be able to directly interact with their neighbors. For
11109    // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3`
11110    return new buildCommon$1.makeFragment(elements);
11111};
11112
11113groupTypes.supsub = function(group, options) {
11114    // Superscript and subscripts are handled in the TeXbook on page
11115    // 445-446, rules 18(a-f).
11116
11117    // Here is where we defer to the inner group if it should handle
11118    // superscripts and subscripts itself.
11119    if (shouldHandleSupSub(group.value.base, options)) {
11120        return groupTypes[group.value.base.type](group, options);
11121    }
11122
11123    var base = buildGroup(group.value.base, options.reset());
11124    var supmid;
11125    var submid;
11126    var sup;
11127    var sub;
11128
11129    var style = options.style;
11130    var newOptions;
11131
11132    if (group.value.sup) {
11133        newOptions = options.withStyle(style.sup());
11134        sup = buildGroup(group.value.sup, newOptions);
11135        supmid = makeSpan$1([style.reset(), style.sup().cls()],
11136            [sup], newOptions);
11137    }
11138
11139    if (group.value.sub) {
11140        newOptions = options.withStyle(style.sub());
11141        sub = buildGroup(group.value.sub, newOptions);
11142        submid = makeSpan$1([style.reset(), style.sub().cls()],
11143            [sub], newOptions);
11144    }
11145
11146    // Rule 18a
11147    var supShift;
11148    var subShift;
11149    if (isCharacterBox(group.value.base)) {
11150        supShift = 0;
11151        subShift = 0;
11152    } else {
11153        supShift = base.height - style.metrics.supDrop;
11154        subShift = base.depth + style.metrics.subDrop;
11155    }
11156
11157    // Rule 18c
11158    var minSupShift;
11159    if (style === Style$1.DISPLAY) {
11160        minSupShift = style.metrics.sup1;
11161    } else if (style.cramped) {
11162        minSupShift = style.metrics.sup3;
11163    } else {
11164        minSupShift = style.metrics.sup2;
11165    }
11166
11167    // scriptspace is a font-size-independent size, so scale it
11168    // appropriately
11169    var multiplier = Style$1.TEXT.sizeMultiplier *
11170            style.sizeMultiplier;
11171    var scriptspace =
11172        (0.5 / fontMetrics.metrics.ptPerEm) / multiplier + "em";
11173
11174    var supsub;
11175    if (!group.value.sup) {
11176        // Rule 18b
11177        subShift = Math.max(
11178            subShift, style.metrics.sub1,
11179            sub.height - 0.8 * style.metrics.xHeight);
11180
11181        supsub = buildCommon$1.makeVList([
11182            {type: "elem", elem: submid}
11183        ], "shift", subShift, options);
11184
11185        supsub.children[0].style.marginRight = scriptspace;
11186
11187        // Subscripts shouldn't be shifted by the base's italic correction.
11188        // Account for that by shifting the subscript back the appropriate
11189        // amount. Note we only do this when the base is a single symbol.
11190        if (base instanceof domTree.symbolNode) {
11191            supsub.children[0].style.marginLeft = -base.italic + "em";
11192        }
11193    } else if (!group.value.sub) {
11194        // Rule 18c, d
11195        supShift = Math.max(supShift, minSupShift,
11196            sup.depth + 0.25 * style.metrics.xHeight);
11197
11198        supsub = buildCommon$1.makeVList([
11199            {type: "elem", elem: supmid}
11200        ], "shift", -supShift, options);
11201
11202        supsub.children[0].style.marginRight = scriptspace;
11203    } else {
11204        supShift = Math.max(
11205            supShift, minSupShift, sup.depth + 0.25 * style.metrics.xHeight);
11206        subShift = Math.max(subShift, style.metrics.sub2);
11207
11208        var ruleWidth = fontMetrics.metrics.defaultRuleThickness;
11209
11210        // Rule 18e
11211        if ((supShift - sup.depth) - (sub.height - subShift) <
11212                4 * ruleWidth) {
11213            subShift = 4 * ruleWidth - (supShift - sup.depth) + sub.height;
11214            var psi = 0.8 * style.metrics.xHeight - (supShift - sup.depth);
11215            if (psi > 0) {
11216                supShift += psi;
11217                subShift -= psi;
11218            }
11219        }
11220
11221        supsub = buildCommon$1.makeVList([
11222            {type: "elem", elem: submid, shift: subShift},
11223            {type: "elem", elem: supmid, shift: -supShift}
11224        ], "individualShift", null, options);
11225
11226        // See comment above about subscripts not being shifted
11227        if (base instanceof domTree.symbolNode) {
11228            supsub.children[0].style.marginLeft = -base.italic + "em";
11229        }
11230
11231        supsub.children[0].style.marginRight = scriptspace;
11232        supsub.children[1].style.marginRight = scriptspace;
11233    }
11234
11235    // We ensure to wrap the supsub vlist in a span.msupsub to reset text-align
11236    var mclass = getTypeOfDomTree(base) || "mord";
11237    return makeSpan$1([mclass],
11238        [base, makeSpan$1(["msupsub"], [supsub])],
11239        options);
11240};
11241
11242groupTypes.genfrac = function(group, options) {
11243    // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e).
11244    // Figure out what style this fraction should be in based on the
11245    // function used
11246    var style = options.style;
11247    if (group.value.size === "display") {
11248        style = Style$1.DISPLAY;
11249    } else if (group.value.size === "text") {
11250        style = Style$1.TEXT;
11251    }
11252
11253    var nstyle = style.fracNum();
11254    var dstyle = style.fracDen();
11255    var newOptions;
11256
11257    newOptions = options.withStyle(nstyle);
11258    var numer = buildGroup(group.value.numer, newOptions);
11259    var numerreset = makeSpan$1([style.reset(), nstyle.cls()],
11260        [numer], newOptions);
11261
11262    newOptions = options.withStyle(dstyle);
11263    var denom = buildGroup(group.value.denom, newOptions);
11264    var denomreset = makeSpan$1([style.reset(), dstyle.cls()],
11265        [denom], newOptions);
11266
11267    var ruleWidth;
11268    if (group.value.hasBarLine) {
11269        ruleWidth = fontMetrics.metrics.defaultRuleThickness /
11270            options.style.sizeMultiplier;
11271    } else {
11272        ruleWidth = 0;
11273    }
11274
11275    // Rule 15b
11276    var numShift;
11277    var clearance;
11278    var denomShift;
11279    if (style.size === Style$1.DISPLAY.size) {
11280        numShift = style.metrics.num1;
11281        if (ruleWidth > 0) {
11282            clearance = 3 * ruleWidth;
11283        } else {
11284            clearance = 7 * fontMetrics.metrics.defaultRuleThickness;
11285        }
11286        denomShift = style.metrics.denom1;
11287    } else {
11288        if (ruleWidth > 0) {
11289            numShift = style.metrics.num2;
11290            clearance = ruleWidth;
11291        } else {
11292            numShift = style.metrics.num3;
11293            clearance = 3 * fontMetrics.metrics.defaultRuleThickness;
11294        }
11295        denomShift = style.metrics.denom2;
11296    }
11297
11298    var frac;
11299    if (ruleWidth === 0) {
11300        // Rule 15c
11301        var candidateClearance =
11302            (numShift - numer.depth) - (denom.height - denomShift);
11303        if (candidateClearance < clearance) {
11304            numShift += 0.5 * (clearance - candidateClearance);
11305            denomShift += 0.5 * (clearance - candidateClearance);
11306        }
11307
11308        frac = buildCommon$1.makeVList([
11309            {type: "elem", elem: denomreset, shift: denomShift},
11310            {type: "elem", elem: numerreset, shift: -numShift}
11311        ], "individualShift", null, options);
11312    } else {
11313        // Rule 15d
11314        var axisHeight = style.metrics.axisHeight;
11315
11316        if ((numShift - numer.depth) - (axisHeight + 0.5 * ruleWidth) <
11317                clearance) {
11318            numShift +=
11319                clearance - ((numShift - numer.depth) -
11320                             (axisHeight + 0.5 * ruleWidth));
11321        }
11322
11323        if ((axisHeight - 0.5 * ruleWidth) - (denom.height - denomShift) <
11324                clearance) {
11325            denomShift +=
11326                clearance - ((axisHeight - 0.5 * ruleWidth) -
11327                             (denom.height - denomShift));
11328        }
11329
11330        var mid = makeSpan$1(
11331            [options.style.reset(), Style$1.TEXT.cls(), "frac-line"]);
11332        // Manually set the height of the line because its height is
11333        // created in CSS
11334        mid.height = ruleWidth;
11335
11336        var midShift = -(axisHeight - 0.5 * ruleWidth);
11337
11338        frac = buildCommon$1.makeVList([
11339            {type: "elem", elem: denomreset, shift: denomShift},
11340            {type: "elem", elem: mid,        shift: midShift},
11341            {type: "elem", elem: numerreset, shift: -numShift}
11342        ], "individualShift", null, options);
11343    }
11344
11345    // Since we manually change the style sometimes (with \dfrac or \tfrac),
11346    // account for the possible size change here.
11347    frac.height *= style.sizeMultiplier / options.style.sizeMultiplier;
11348    frac.depth *= style.sizeMultiplier / options.style.sizeMultiplier;
11349
11350    // Rule 15e
11351    var delimSize;
11352    if (style.size === Style$1.DISPLAY.size) {
11353        delimSize = style.metrics.delim1;
11354    } else {
11355        delimSize = style.metrics.delim2;
11356    }
11357
11358    var leftDelim;
11359    var rightDelim;
11360    if (group.value.leftDelim == null) {
11361        leftDelim = makeNullDelimiter(options, ["mopen"]);
11362    } else {
11363        leftDelim = delimiter.customSizedDelim(
11364            group.value.leftDelim, delimSize, true,
11365            options.withStyle(style), group.mode, ["mopen"]);
11366    }
11367    if (group.value.rightDelim == null) {
11368        rightDelim = makeNullDelimiter(options, ["mclose"]);
11369    } else {
11370        rightDelim = delimiter.customSizedDelim(
11371            group.value.rightDelim, delimSize, true,
11372            options.withStyle(style), group.mode, ["mclose"]);
11373    }
11374
11375    return makeSpan$1(
11376        ["mord", options.style.reset(), style.cls()],
11377        [leftDelim, makeSpan$1(["mfrac"], [frac]), rightDelim],
11378        options);
11379};
11380
11381var calculateSize = function(sizeValue, style) {
11382    var x = sizeValue.number;
11383    if (sizeValue.unit === "ex") {
11384        x *= style.metrics.emPerEx;
11385    } else if (sizeValue.unit === "mu") {
11386        x /= 18;
11387    }
11388    return x;
11389};
11390
11391groupTypes.array = function(group, options) {
11392    var r;
11393    var c;
11394    var nr = group.value.body.length;
11395    var nc = 0;
11396    var body = new Array(nr);
11397
11398    var style = options.style;
11399
11400    // Horizontal spacing
11401    var pt = 1 / fontMetrics.metrics.ptPerEm;
11402    var arraycolsep = 5 * pt; // \arraycolsep in article.cls
11403
11404    // Vertical spacing
11405    var baselineskip = 12 * pt; // see size10.clo
11406    // Default \arraystretch from lttab.dtx
11407    // TODO(gagern): may get redefined once we have user-defined macros
11408    var arraystretch = utils$1.deflt(group.value.arraystretch, 1);
11409    var arrayskip = arraystretch * baselineskip;
11410    var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and
11411    var arstrutDepth = 0.3 * arrayskip;  // \@arstrutbox in lttab.dtx
11412
11413    var totalHeight = 0;
11414    for (r = 0; r < group.value.body.length; ++r) {
11415        var inrow = group.value.body[r];
11416        var height = arstrutHeight; // \@array adds an \@arstrut
11417        var depth = arstrutDepth;   // to each tow (via the template)
11418
11419        if (nc < inrow.length) {
11420            nc = inrow.length;
11421        }
11422
11423        var outrow = new Array(inrow.length);
11424        for (c = 0; c < inrow.length; ++c) {
11425            var elt = buildGroup(inrow[c], options);
11426            if (depth < elt.depth) {
11427                depth = elt.depth;
11428            }
11429            if (height < elt.height) {
11430                height = elt.height;
11431            }
11432            outrow[c] = elt;
11433        }
11434
11435        var gap = 0;
11436        if (group.value.rowGaps[r]) {
11437            gap = calculateSize(group.value.rowGaps[r].value, style);
11438            if (gap > 0) { // \@argarraycr
11439                gap += arstrutDepth;
11440                if (depth < gap) {
11441                    depth = gap; // \@xargarraycr
11442                }
11443                gap = 0;
11444            }
11445        }
11446
11447        outrow.height = height;
11448        outrow.depth = depth;
11449        totalHeight += height;
11450        outrow.pos = totalHeight;
11451        totalHeight += depth + gap; // \@yargarraycr
11452        body[r] = outrow;
11453    }
11454
11455    var offset = totalHeight / 2 + style.metrics.axisHeight;
11456    var colDescriptions = group.value.cols || [];
11457    var cols = [];
11458    var colSep;
11459    var colDescrNum;
11460    for (c = 0, colDescrNum = 0;
11461         // Continue while either there are more columns or more column
11462         // descriptions, so trailing separators don't get lost.
11463         c < nc || colDescrNum < colDescriptions.length;
11464         ++c, ++colDescrNum) {
11465
11466        var colDescr = colDescriptions[colDescrNum] || {};
11467
11468        var firstSeparator = true;
11469        while (colDescr.type === "separator") {
11470            // If there is more than one separator in a row, add a space
11471            // between them.
11472            if (!firstSeparator) {
11473                colSep = makeSpan$1(["arraycolsep"], []);
11474                colSep.style.width =
11475                    fontMetrics.metrics.doubleRuleSep + "em";
11476                cols.push(colSep);
11477            }
11478
11479            if (colDescr.separator === "|") {
11480                var separator = makeSpan$1(
11481                    ["vertical-separator"],
11482                    []);
11483                separator.style.height = totalHeight + "em";
11484                separator.style.verticalAlign =
11485                    -(totalHeight - offset) + "em";
11486
11487                cols.push(separator);
11488            } else {
11489                throw new ParseError$2(
11490                    "Invalid separator type: " + colDescr.separator);
11491            }
11492
11493            colDescrNum++;
11494            colDescr = colDescriptions[colDescrNum] || {};
11495            firstSeparator = false;
11496        }
11497
11498        if (c >= nc) {
11499            continue;
11500        }
11501
11502        var sepwidth;
11503        if (c > 0 || group.value.hskipBeforeAndAfter) {
11504            sepwidth = utils$1.deflt(colDescr.pregap, arraycolsep);
11505            if (sepwidth !== 0) {
11506                colSep = makeSpan$1(["arraycolsep"], []);
11507                colSep.style.width = sepwidth + "em";
11508                cols.push(colSep);
11509            }
11510        }
11511
11512        var col = [];
11513        for (r = 0; r < nr; ++r) {
11514            var row = body[r];
11515            var elem = row[c];
11516            if (!elem) {
11517                continue;
11518            }
11519            var shift = row.pos - offset;
11520            elem.depth = row.depth;
11521            elem.height = row.height;
11522            col.push({type: "elem", elem: elem, shift: shift});
11523        }
11524
11525        col = buildCommon$1.makeVList(col, "individualShift", null, options);
11526        col = makeSpan$1(
11527            ["col-align-" + (colDescr.align || "c")],
11528            [col]);
11529        cols.push(col);
11530
11531        if (c < nc - 1 || group.value.hskipBeforeAndAfter) {
11532            sepwidth = utils$1.deflt(colDescr.postgap, arraycolsep);
11533            if (sepwidth !== 0) {
11534                colSep = makeSpan$1(["arraycolsep"], []);
11535                colSep.style.width = sepwidth + "em";
11536                cols.push(colSep);
11537            }
11538        }
11539    }
11540    body = makeSpan$1(["mtable"], cols);
11541    return makeSpan$1(["mord"], [body], options);
11542};
11543
11544groupTypes.spacing = function(group, options) {
11545    if (group.value === "\\ " || group.value === "\\space" ||
11546        group.value === " " || group.value === "~") {
11547        // Spaces are generated by adding an actual space. Each of these
11548        // things has an entry in the symbols table, so these will be turned
11549        // into appropriate outputs.
11550        if (group.mode === "text") {
11551            return buildCommon$1.makeOrd(group, options, "textord");
11552        } else {
11553            return makeSpan$1(["mspace"],
11554                [buildCommon$1.mathsym(group.value, group.mode, options)],
11555                options);
11556        }
11557    } else {
11558        // Other kinds of spaces are of arbitrary width. We use CSS to
11559        // generate these.
11560        return makeSpan$1(
11561            ["mspace",
11562                buildCommon$1.spacingFunctions[group.value].className],
11563            [], options);
11564    }
11565};
11566
11567groupTypes.llap = function(group, options) {
11568    var inner = makeSpan$1(
11569        ["inner"], [buildGroup(group.value.body, options.reset())]);
11570    var fix = makeSpan$1(["fix"], []);
11571    return makeSpan$1(
11572        ["mord", "llap", options.style.cls()], [inner, fix], options);
11573};
11574
11575groupTypes.rlap = function(group, options) {
11576    var inner = makeSpan$1(
11577        ["inner"], [buildGroup(group.value.body, options.reset())]);
11578    var fix = makeSpan$1(["fix"], []);
11579    return makeSpan$1(
11580        ["mord", "rlap", options.style.cls()], [inner, fix], options);
11581};
11582
11583groupTypes.op = function(group, options) {
11584    // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
11585    var supGroup;
11586    var subGroup;
11587    var hasLimits = false;
11588    if (group.type === "supsub") {
11589        // If we have limits, supsub will pass us its group to handle. Pull
11590        // out the superscript and subscript and set the group to the op in
11591        // its base.
11592        supGroup = group.value.sup;
11593        subGroup = group.value.sub;
11594        group = group.value.base;
11595        hasLimits = true;
11596    }
11597
11598    var style = options.style;
11599
11600    // Most operators have a large successor symbol, but these don't.
11601    var noSuccessor = [
11602        "\\smallint"
11603    ];
11604
11605    var large = false;
11606    if (style.size === Style$1.DISPLAY.size &&
11607        group.value.symbol &&
11608        !utils$1.contains(noSuccessor, group.value.body)) {
11609
11610        // Most symbol operators get larger in displaystyle (rule 13)
11611        large = true;
11612    }
11613
11614    var base;
11615    var baseShift = 0;
11616    var slant = 0;
11617    if (group.value.symbol) {
11618        // If this is a symbol, create the symbol.
11619        var fontName = large ? "Size2-Regular" : "Size1-Regular";
11620        base = buildCommon$1.makeSymbol(
11621            group.value.body, fontName, "math", options,
11622            ["mop", "op-symbol", large ? "large-op" : "small-op"]);
11623
11624        // Shift the symbol so its center lies on the axis (rule 13). It
11625        // appears that our fonts have the centers of the symbols already
11626        // almost on the axis, so these numbers are very small. Note we
11627        // don't actually apply this here, but instead it is used either in
11628        // the vlist creation or separately when there are no limits.
11629        baseShift = (base.height - base.depth) / 2 -
11630            style.metrics.axisHeight * style.sizeMultiplier;
11631
11632        // The slant of the symbol is just its italic correction.
11633        slant = base.italic;
11634    } else if (group.value.value) {
11635        // If this is a list, compose that list.
11636        var inner = buildExpression(group.value.value, options, true);
11637
11638        base = makeSpan$1(["mop"], inner, options);
11639    } else {
11640        // Otherwise, this is a text operator. Build the text from the
11641        // operator's name.
11642        // TODO(emily): Add a space in the middle of some of these
11643        // operators, like \limsup
11644        var output = [];
11645        for (var i = 1; i < group.value.body.length; i++) {
11646            output.push(buildCommon$1.mathsym(group.value.body[i], group.mode));
11647        }
11648        base = makeSpan$1(["mop"], output, options);
11649    }
11650
11651    if (hasLimits) {
11652        // IE 8 clips \int if it is in a display: inline-block. We wrap it
11653        // in a new span so it is an inline, and works.
11654        base = makeSpan$1([], [base]);
11655
11656        var supmid;
11657        var supKern;
11658        var submid;
11659        var subKern;
11660        var newOptions;
11661        // We manually have to handle the superscripts and subscripts. This,
11662        // aside from the kern calculations, is copied from supsub.
11663        if (supGroup) {
11664            newOptions = options.withStyle(style.sup());
11665            var sup = buildGroup(supGroup, newOptions);
11666            supmid = makeSpan$1([style.reset(), style.sup().cls()],
11667                [sup], newOptions);
11668
11669            supKern = Math.max(
11670                fontMetrics.metrics.bigOpSpacing1,
11671                fontMetrics.metrics.bigOpSpacing3 - sup.depth);
11672        }
11673
11674        if (subGroup) {
11675            newOptions = options.withStyle(style.sub());
11676            var sub = buildGroup(subGroup, newOptions);
11677            submid = makeSpan$1([style.reset(), style.sub().cls()],
11678                [sub], newOptions);
11679
11680            subKern = Math.max(
11681                fontMetrics.metrics.bigOpSpacing2,
11682                fontMetrics.metrics.bigOpSpacing4 - sub.height);
11683        }
11684
11685        // Build the final group as a vlist of the possible subscript, base,
11686        // and possible superscript.
11687        var finalGroup;
11688        var top;
11689        var bottom;
11690        if (!supGroup) {
11691            top = base.height - baseShift;
11692
11693            finalGroup = buildCommon$1.makeVList([
11694                {type: "kern", size: fontMetrics.metrics.bigOpSpacing5},
11695                {type: "elem", elem: submid},
11696                {type: "kern", size: subKern},
11697                {type: "elem", elem: base}
11698            ], "top", top, options);
11699
11700            // Here, we shift the limits by the slant of the symbol. Note
11701            // that we are supposed to shift the limits by 1/2 of the slant,
11702            // but since we are centering the limits adding a full slant of
11703            // margin will shift by 1/2 that.
11704            finalGroup.children[0].style.marginLeft = -slant + "em";
11705        } else if (!subGroup) {
11706            bottom = base.depth + baseShift;
11707
11708            finalGroup = buildCommon$1.makeVList([
11709                {type: "elem", elem: base},
11710                {type: "kern", size: supKern},
11711                {type: "elem", elem: supmid},
11712                {type: "kern", size: fontMetrics.metrics.bigOpSpacing5}
11713            ], "bottom", bottom, options);
11714
11715            // See comment above about slants
11716            finalGroup.children[1].style.marginLeft = slant + "em";
11717        } else if (!supGroup && !subGroup) {
11718            // This case probably shouldn't occur (this would mean the
11719            // supsub was sending us a group with no superscript or
11720            // subscript) but be safe.
11721            return base;
11722        } else {
11723            bottom = fontMetrics.metrics.bigOpSpacing5 +
11724                submid.height + submid.depth +
11725                subKern +
11726                base.depth + baseShift;
11727
11728            finalGroup = buildCommon$1.makeVList([
11729                {type: "kern", size: fontMetrics.metrics.bigOpSpacing5},
11730                {type: "elem", elem: submid},
11731                {type: "kern", size: subKern},
11732                {type: "elem", elem: base},
11733                {type: "kern", size: supKern},
11734                {type: "elem", elem: supmid},
11735                {type: "kern", size: fontMetrics.metrics.bigOpSpacing5}
11736            ], "bottom", bottom, options);
11737
11738            // See comment above about slants
11739            finalGroup.children[0].style.marginLeft = -slant + "em";
11740            finalGroup.children[2].style.marginLeft = slant + "em";
11741        }
11742
11743        return makeSpan$1(["mop", "op-limits"], [finalGroup], options);
11744    } else {
11745        if (group.value.symbol) {
11746            base.style.top = baseShift + "em";
11747        }
11748
11749        return base;
11750    }
11751};
11752
11753groupTypes.mod = function(group, options) {
11754    var inner = [];
11755
11756    if (group.value.modType === "bmod") {
11757        // “\nonscript\mskip-\medmuskip\mkern5mu”
11758        if (!options.style.isTight()) {
11759            inner.push(makeSpan$1(
11760                ["mspace", "negativemediumspace"], [], options));
11761        }
11762        inner.push(makeSpan$1(["mspace", "thickspace"], [], options));
11763    } else if (options.style.size === Style$1.DISPLAY.size) {
11764        inner.push(makeSpan$1(["mspace", "quad"], [], options));
11765    } else if (group.value.modType === "mod") {
11766        inner.push(makeSpan$1(["mspace", "twelvemuspace"], [], options));
11767    } else {
11768        inner.push(makeSpan$1(["mspace", "eightmuspace"], [], options));
11769    }
11770
11771    if (group.value.modType === "pod" || group.value.modType === "pmod") {
11772        inner.push(buildCommon$1.mathsym("(", group.mode));
11773    }
11774
11775    if (group.value.modType !== "pod") {
11776        var modInner = [
11777            buildCommon$1.mathsym("m", group.mode),
11778            buildCommon$1.mathsym("o", group.mode),
11779            buildCommon$1.mathsym("d", group.mode)];
11780        if (group.value.modType === "bmod") {
11781            inner.push(makeSpan$1(["mbin"], modInner, options));
11782            // “\mkern5mu\nonscript\mskip-\medmuskip”
11783            inner.push(makeSpan$1(["mspace", "thickspace"], [], options));
11784            if (!options.style.isTight()) {
11785                inner.push(makeSpan$1(
11786                    ["mspace", "negativemediumspace"], [], options));
11787            }
11788        } else {
11789            Array.prototype.push.apply(inner, modInner);
11790            inner.push(makeSpan$1(["mspace", "sixmuspace"], [], options));
11791        }
11792    }
11793
11794    if (group.value.value) {
11795        Array.prototype.push.apply(inner,
11796            buildExpression(group.value.value, options, false));
11797    }
11798
11799    if (group.value.modType === "pod" || group.value.modType === "pmod") {
11800        inner.push(buildCommon$1.mathsym(")", group.mode));
11801    }
11802
11803    return buildCommon$1.makeFragment(inner);
11804};
11805
11806groupTypes.katex = function(group, options) {
11807    // The KaTeX logo. The offsets for the K and a were chosen to look
11808    // good, but the offsets for the T, E, and X were taken from the
11809    // definition of \TeX in TeX (see TeXbook pg. 356)
11810    var k = makeSpan$1(
11811        ["k"], [buildCommon$1.mathsym("K", group.mode)], options);
11812    var a = makeSpan$1(
11813        ["a"], [buildCommon$1.mathsym("A", group.mode)], options);
11814
11815    a.height = (a.height + 0.2) * 0.75;
11816    a.depth = (a.height - 0.2) * 0.75;
11817
11818    var t = makeSpan$1(
11819        ["t"], [buildCommon$1.mathsym("T", group.mode)], options);
11820    var e = makeSpan$1(
11821        ["e"], [buildCommon$1.mathsym("E", group.mode)], options);
11822
11823    e.height = (e.height - 0.2155);
11824    e.depth = (e.depth + 0.2155);
11825
11826    var x = makeSpan$1(
11827        ["x"], [buildCommon$1.mathsym("X", group.mode)], options);
11828
11829    return makeSpan$1(
11830        ["mord", "katex-logo"], [k, a, t, e, x], options);
11831};
11832
11833groupTypes.overline = function(group, options) {
11834    // Overlines are handled in the TeXbook pg 443, Rule 9.
11835    var style = options.style;
11836
11837    // Build the inner group in the cramped style.
11838    var innerGroup = buildGroup(group.value.body,
11839            options.withStyle(style.cramp()));
11840
11841    var ruleWidth = fontMetrics.metrics.defaultRuleThickness /
11842        style.sizeMultiplier;
11843
11844    // Create the line above the body
11845    var line = makeSpan$1(
11846        [style.reset(), Style$1.TEXT.cls(), "overline-line"]);
11847    line.height = ruleWidth;
11848    line.maxFontSize = 1.0;
11849
11850    // Generate the vlist, with the appropriate kerns
11851    var vlist = buildCommon$1.makeVList([
11852        {type: "elem", elem: innerGroup},
11853        {type: "kern", size: 3 * ruleWidth},
11854        {type: "elem", elem: line},
11855        {type: "kern", size: ruleWidth}
11856    ], "firstBaseline", null, options);
11857
11858    return makeSpan$1(["mord", "overline"], [vlist], options);
11859};
11860
11861groupTypes.underline = function(group, options) {
11862    // Underlines are handled in the TeXbook pg 443, Rule 10.
11863    var style = options.style;
11864
11865    // Build the inner group.
11866    var innerGroup = buildGroup(group.value.body, options);
11867
11868    var ruleWidth = fontMetrics.metrics.defaultRuleThickness /
11869        style.sizeMultiplier;
11870
11871    // Create the line above the body
11872    var line = makeSpan$1([style.reset(), Style$1.TEXT.cls(), "underline-line"]);
11873    line.height = ruleWidth;
11874    line.maxFontSize = 1.0;
11875
11876    // Generate the vlist, with the appropriate kerns
11877    var vlist = buildCommon$1.makeVList([
11878        {type: "kern", size: ruleWidth},
11879        {type: "elem", elem: line},
11880        {type: "kern", size: 3 * ruleWidth},
11881        {type: "elem", elem: innerGroup}
11882    ], "top", innerGroup.height, options);
11883
11884    return makeSpan$1(["mord", "underline"], [vlist], options);
11885};
11886
11887groupTypes.sqrt = function(group, options) {
11888    // Square roots are handled in the TeXbook pg. 443, Rule 11.
11889    var style = options.style;
11890
11891    // First, we do the same steps as in overline to build the inner group
11892    // and line
11893    var inner = buildGroup(group.value.body, options.withStyle(style.cramp()));
11894
11895    var ruleWidth = fontMetrics.metrics.defaultRuleThickness /
11896        style.sizeMultiplier;
11897
11898    var line = makeSpan$1(
11899        [style.reset(), Style$1.TEXT.cls(), "sqrt-line"], [],
11900        options);
11901    line.height = ruleWidth;
11902    line.maxFontSize = 1.0;
11903
11904    var phi = ruleWidth;
11905    if (style.id < Style$1.TEXT.id) {
11906        phi = style.metrics.xHeight;
11907    }
11908
11909    // Calculate the clearance between the body and line
11910    var lineClearance = ruleWidth + phi / 4;
11911
11912    var innerHeight = (inner.height + inner.depth) * style.sizeMultiplier;
11913    var minDelimiterHeight = innerHeight + lineClearance + ruleWidth;
11914
11915    // Create a \surd delimiter of the required minimum size
11916    var delim = makeSpan$1(["sqrt-sign"], [
11917        delimiter.customSizedDelim("\\surd", minDelimiterHeight,
11918                                   false, options, group.mode)],
11919                         options);
11920
11921    var delimDepth = (delim.height + delim.depth) - ruleWidth;
11922
11923    // Adjust the clearance based on the delimiter size
11924    if (delimDepth > inner.height + inner.depth + lineClearance) {
11925        lineClearance =
11926            (lineClearance + delimDepth - inner.height - inner.depth) / 2;
11927    }
11928
11929    // Shift the delimiter so that its top lines up with the top of the line
11930    var delimShift = -(inner.height + lineClearance + ruleWidth) + delim.height;
11931    delim.style.top = delimShift + "em";
11932    delim.height -= delimShift;
11933    delim.depth += delimShift;
11934
11935    // We add a special case here, because even when `inner` is empty, we
11936    // still get a line. So, we use a simple heuristic to decide if we
11937    // should omit the body entirely. (note this doesn't work for something
11938    // like `\sqrt{\rlap{x}}`, but if someone is doing that they deserve for
11939    // it not to work.
11940    var body;
11941    if (inner.height === 0 && inner.depth === 0) {
11942        body = makeSpan$1();
11943    } else {
11944        body = buildCommon$1.makeVList([
11945            {type: "elem", elem: inner},
11946            {type: "kern", size: lineClearance},
11947            {type: "elem", elem: line},
11948            {type: "kern", size: ruleWidth}
11949        ], "firstBaseline", null, options);
11950    }
11951
11952    if (!group.value.index) {
11953        return makeSpan$1(["mord", "sqrt"], [delim, body], options);
11954    } else {
11955        // Handle the optional root index
11956
11957        // The index is always in scriptscript style
11958        var newOptions = options.withStyle(Style$1.SCRIPTSCRIPT);
11959        var root = buildGroup(group.value.index, newOptions);
11960        var rootWrap = makeSpan$1(
11961            [style.reset(), Style$1.SCRIPTSCRIPT.cls()],
11962            [root],
11963            newOptions);
11964
11965        // Figure out the height and depth of the inner part
11966        var innerRootHeight = Math.max(delim.height, body.height);
11967        var innerRootDepth = Math.max(delim.depth, body.depth);
11968
11969        // The amount the index is shifted by. This is taken from the TeX
11970        // source, in the definition of `\r@@t`.
11971        var toShift = 0.6 * (innerRootHeight - innerRootDepth);
11972
11973        // Build a VList with the superscript shifted up correctly
11974        var rootVList = buildCommon$1.makeVList(
11975            [{type: "elem", elem: rootWrap}],
11976            "shift", -toShift, options);
11977        // Add a class surrounding it so we can add on the appropriate
11978        // kerning
11979        var rootVListWrap = makeSpan$1(["root"], [rootVList]);
11980
11981        return makeSpan$1(["mord", "sqrt"],
11982            [rootVListWrap, delim, body], options);
11983    }
11984};
11985
11986groupTypes.sizing = function(group, options) {
11987    // Handle sizing operators like \Huge. Real TeX doesn't actually allow
11988    // these functions inside of math expressions, so we do some special
11989    // handling.
11990    var inner = buildExpression(group.value.value,
11991            options.withSize(group.value.size), false);
11992
11993    // Compute the correct maxFontSize.
11994    var style = options.style;
11995    var fontSize = buildCommon$1.sizingMultiplier[group.value.size];
11996    fontSize = fontSize * style.sizeMultiplier;
11997
11998    // Add size-resetting classes to the inner list and set maxFontSize
11999    // manually. Handle nested size changes.
12000    for (var i = 0; i < inner.length; i++) {
12001        var pos = utils$1.indexOf(inner[i].classes, "sizing");
12002        if (pos < 0) {
12003            inner[i].classes.push("sizing", "reset-" + options.size,
12004                                  group.value.size, style.cls());
12005            inner[i].maxFontSize = fontSize;
12006        } else if (inner[i].classes[pos + 1] === "reset-" + group.value.size) {
12007            // This is a nested size change: e.g., inner[i] is the "b" in
12008            // `\Huge a \small b`. Override the old size (the `reset-` class)
12009            // but not the new size.
12010            inner[i].classes[pos + 1] = "reset-" + options.size;
12011        }
12012    }
12013
12014    return buildCommon$1.makeFragment(inner);
12015};
12016
12017groupTypes.styling = function(group, options) {
12018    // Style changes are handled in the TeXbook on pg. 442, Rule 3.
12019
12020    // Figure out what style we're changing to.
12021    var styleMap = {
12022        "display": Style$1.DISPLAY,
12023        "text": Style$1.TEXT,
12024        "script": Style$1.SCRIPT,
12025        "scriptscript": Style$1.SCRIPTSCRIPT
12026    };
12027
12028    var newStyle = styleMap[group.value.style];
12029    var newOptions = options.withStyle(newStyle);
12030
12031    // Build the inner expression in the new style.
12032    var inner = buildExpression(
12033        group.value.value, newOptions, false);
12034
12035    // Add style-resetting classes to the inner list. Handle nested changes.
12036    for (var i = 0; i < inner.length; i++) {
12037        var pos = utils$1.indexOf(inner[i].classes, newStyle.reset());
12038        if (pos < 0) {
12039            inner[i].classes.push(options.style.reset(), newStyle.cls());
12040        } else {
12041            // This is a nested style change, as `\textstyle a\scriptstyle b`.
12042            // Only override the old style (the reset class).
12043            inner[i].classes[pos] = options.style.reset();
12044        }
12045    }
12046
12047    return new buildCommon$1.makeFragment(inner);
12048};
12049
12050groupTypes.font = function(group, options) {
12051    var font = group.value.font;
12052    return buildGroup(group.value.body, options.withFont(font));
12053};
12054
12055groupTypes.delimsizing = function(group, options) {
12056    var delim = group.value.value;
12057
12058    if (delim === ".") {
12059        // Empty delimiters still count as elements, even though they don't
12060        // show anything.
12061        return makeSpan$1([group.value.mclass]);
12062    }
12063
12064    // Use delimiter.sizedDelim to generate the delimiter.
12065    return delimiter.sizedDelim(
12066            delim, group.value.size, options, group.mode,
12067            [group.value.mclass]);
12068};
12069
12070groupTypes.leftright = function(group, options) {
12071    // Build the inner expression
12072    var inner = buildExpression(group.value.body, options.reset(), true);
12073
12074    var innerHeight = 0;
12075    var innerDepth = 0;
12076    var hadMiddle = false;
12077
12078    // Calculate its height and depth
12079    for (var i = 0; i < inner.length; i++) {
12080        if (inner[i].isMiddle) {
12081            hadMiddle = true;
12082        } else {
12083            innerHeight = Math.max(inner[i].height, innerHeight);
12084            innerDepth = Math.max(inner[i].depth, innerDepth);
12085        }
12086    }
12087
12088    var style = options.style;
12089
12090    // The size of delimiters is the same, regardless of what style we are
12091    // in. Thus, to correctly calculate the size of delimiter we need around
12092    // a group, we scale down the inner size based on the size.
12093    innerHeight *= style.sizeMultiplier;
12094    innerDepth *= style.sizeMultiplier;
12095
12096    var leftDelim;
12097    if (group.value.left === ".") {
12098        // Empty delimiters in \left and \right make null delimiter spaces.
12099        leftDelim = makeNullDelimiter(options, ["mopen"]);
12100    } else {
12101        // Otherwise, use leftRightDelim to generate the correct sized
12102        // delimiter.
12103        leftDelim = delimiter.leftRightDelim(
12104            group.value.left, innerHeight, innerDepth, options,
12105            group.mode, ["mopen"]);
12106    }
12107    // Add it to the beginning of the expression
12108    inner.unshift(leftDelim);
12109
12110    // Handle middle delimiters
12111    if (hadMiddle) {
12112        for (i = 1; i < inner.length; i++) {
12113            if (inner[i].isMiddle) {
12114                // Apply the options that were active when \middle was called
12115                inner[i] = delimiter.leftRightDelim(
12116                    inner[i].isMiddle.value, innerHeight, innerDepth,
12117                    inner[i].isMiddle.options, group.mode, []);
12118            }
12119        }
12120    }
12121
12122    var rightDelim;
12123    // Same for the right delimiter
12124    if (group.value.right === ".") {
12125        rightDelim = makeNullDelimiter(options, ["mclose"]);
12126    } else {
12127        rightDelim = delimiter.leftRightDelim(
12128            group.value.right, innerHeight, innerDepth, options,
12129            group.mode, ["mclose"]);
12130    }
12131    // Add it to the end of the expression.
12132    inner.push(rightDelim);
12133
12134    return makeSpan$1(
12135        ["minner", style.cls()], inner, options);
12136};
12137
12138groupTypes.middle = function(group, options) {
12139    var middleDelim;
12140    if (group.value.value === ".") {
12141        middleDelim = makeNullDelimiter(options, []);
12142    } else {
12143        middleDelim = delimiter.sizedDelim(
12144            group.value.value, 1, options,
12145            group.mode, []);
12146        middleDelim.isMiddle = {value: group.value.value, options: options};
12147    }
12148    return middleDelim;
12149};
12150
12151groupTypes.rule = function(group, options) {
12152    // Make an empty span for the rule
12153    var rule = makeSpan$1(["mord", "rule"], [], options);
12154    var style = options.style;
12155
12156    // Calculate the shift, width, and height of the rule, and account for units
12157    var shift = 0;
12158    if (group.value.shift) {
12159        shift = calculateSize(group.value.shift, style);
12160    }
12161
12162    var width = calculateSize(group.value.width, style);
12163    var height = calculateSize(group.value.height, style);
12164
12165    // The sizes of rules are absolute, so make it larger if we are in a
12166    // smaller style.
12167    shift /= style.sizeMultiplier;
12168    width /= style.sizeMultiplier;
12169    height /= style.sizeMultiplier;
12170
12171    // Style the rule to the right size
12172    rule.style.borderRightWidth = width + "em";
12173    rule.style.borderTopWidth = height + "em";
12174    rule.style.bottom = shift + "em";
12175
12176    // Record the height and width
12177    rule.width = width;
12178    rule.height = height + shift;
12179    rule.depth = -shift;
12180
12181    return rule;
12182};
12183
12184groupTypes.kern = function(group, options) {
12185    // Make an empty span for the rule
12186    var rule = makeSpan$1(["mord", "rule"], [], options);
12187    var style = options.style;
12188
12189    var dimension = 0;
12190    if (group.value.dimension) {
12191        dimension = calculateSize(group.value.dimension, style);
12192    }
12193
12194    dimension /= style.sizeMultiplier;
12195
12196    rule.style.marginLeft = dimension + "em";
12197
12198    return rule;
12199};
12200
12201groupTypes.accent = function(group, options) {
12202    // Accents are handled in the TeXbook pg. 443, rule 12.
12203    var base = group.value.base;
12204    var style = options.style;
12205
12206    var supsubGroup;
12207    if (group.type === "supsub") {
12208        // If our base is a character box, and we have superscripts and
12209        // subscripts, the supsub will defer to us. In particular, we want
12210        // to attach the superscripts and subscripts to the inner body (so
12211        // that the position of the superscripts and subscripts won't be
12212        // affected by the height of the accent). We accomplish this by
12213        // sticking the base of the accent into the base of the supsub, and
12214        // rendering that, while keeping track of where the accent is.
12215
12216        // The supsub group is the group that was passed in
12217        var supsub = group;
12218        // The real accent group is the base of the supsub group
12219        group = supsub.value.base;
12220        // The character box is the base of the accent group
12221        base = group.value.base;
12222        // Stick the character box into the base of the supsub group
12223        supsub.value.base = base;
12224
12225        // Rerender the supsub group with its new base, and store that
12226        // result.
12227        supsubGroup = buildGroup(
12228            supsub, options.reset());
12229    }
12230
12231    // Build the base group
12232    var body = buildGroup(
12233        base, options.withStyle(style.cramp()));
12234
12235    // Calculate the skew of the accent. This is based on the line "If the
12236    // nucleus is not a single character, let s = 0; otherwise set s to the
12237    // kern amount for the nucleus followed by the \skewchar of its font."
12238    // Note that our skew metrics are just the kern between each character
12239    // and the skewchar.
12240    var skew;
12241    if (isCharacterBox(base)) {
12242        // If the base is a character box, then we want the skew of the
12243        // innermost character. To do that, we find the innermost character:
12244        var baseChar = getBaseElem(base);
12245        // Then, we render its group to get the symbol inside it
12246        var baseGroup = buildGroup(
12247            baseChar, options.withStyle(style.cramp()));
12248        // Finally, we pull the skew off of the symbol.
12249        skew = baseGroup.skew;
12250        // Note that we now throw away baseGroup, because the layers we
12251        // removed with getBaseElem might contain things like \color which
12252        // we can't get rid of.
12253        // TODO(emily): Find a better way to get the skew
12254    } else {
12255        skew = 0;
12256    }
12257
12258    // calculate the amount of space between the body and the accent
12259    var clearance = Math.min(
12260        body.height,
12261        style.metrics.xHeight);
12262
12263    // Build the accent
12264    var accent = buildCommon$1.makeSymbol(
12265        group.value.accent, "Main-Regular", "math", options);
12266    // Remove the italic correction of the accent, because it only serves to
12267    // shift the accent over to a place we don't want.
12268    accent.italic = 0;
12269
12270    // The \vec character that the fonts use is a combining character, and
12271    // thus shows up much too far to the left. To account for this, we add a
12272    // specific class which shifts the accent over to where we want it.
12273    // TODO(emily): Fix this in a better way, like by changing the font
12274    var vecClass = group.value.accent === "\\vec" ? "accent-vec" : null;
12275
12276    var accentBody = makeSpan$1(["accent-body", vecClass], [
12277        makeSpan$1([], [accent])]);
12278
12279    accentBody = buildCommon$1.makeVList([
12280        {type: "elem", elem: body},
12281        {type: "kern", size: -clearance},
12282        {type: "elem", elem: accentBody}
12283    ], "firstBaseline", null, options);
12284
12285    // Shift the accent over by the skew. Note we shift by twice the skew
12286    // because we are centering the accent, so by adding 2*skew to the left,
12287    // we shift it to the right by 1*skew.
12288    accentBody.children[1].style.marginLeft = 2 * skew + "em";
12289
12290    var accentWrap = makeSpan$1(["mord", "accent"], [accentBody], options);
12291
12292    if (supsubGroup) {
12293        // Here, we replace the "base" child of the supsub with our newly
12294        // generated accent.
12295        supsubGroup.children[0] = accentWrap;
12296
12297        // Since we don't rerun the height calculation after replacing the
12298        // accent, we manually recalculate height.
12299        supsubGroup.height = Math.max(accentWrap.height, supsubGroup.height);
12300
12301        // Accents should always be ords, even when their innards are not.
12302        supsubGroup.classes[0] = "mord";
12303
12304        return supsubGroup;
12305    } else {
12306        return accentWrap;
12307    }
12308};
12309
12310groupTypes.phantom = function(group, options) {
12311    var elements = buildExpression(
12312        group.value.value,
12313        options.withPhantom(),
12314        false
12315    );
12316
12317    // \phantom isn't supposed to affect the elements it contains.
12318    // See "color" for more details.
12319    return new buildCommon$1.makeFragment(elements);
12320};
12321
12322groupTypes.mclass = function(group, options) {
12323    var elements = buildExpression(group.value.value, options, true);
12324
12325    return makeSpan$1([group.value.mclass], elements, options);
12326};
12327
12328/**
12329 * buildGroup is the function that takes a group and calls the correct groupType
12330 * function for it. It also handles the interaction of size and style changes
12331 * between parents and children.
12332 */
12333var buildGroup = function(group, options) {
12334    if (!group) {
12335        return makeSpan$1();
12336    }
12337
12338    if (groupTypes[group.type]) {
12339        // Call the groupTypes function
12340        var groupNode = groupTypes[group.type](group, options);
12341        var multiplier;
12342
12343        // If the style changed between the parent and the current group,
12344        // account for the size difference
12345        if (options.style !== options.parentStyle) {
12346            multiplier = options.style.sizeMultiplier /
12347                    options.parentStyle.sizeMultiplier;
12348
12349            groupNode.height *= multiplier;
12350            groupNode.depth *= multiplier;
12351        }
12352
12353        // If the size changed between the parent and the current group, account
12354        // for that size difference.
12355        if (options.size !== options.parentSize) {
12356            multiplier = buildCommon$1.sizingMultiplier[options.size] /
12357                    buildCommon$1.sizingMultiplier[options.parentSize];
12358
12359            groupNode.height *= multiplier;
12360            groupNode.depth *= multiplier;
12361        }
12362
12363        return groupNode;
12364    } else {
12365        throw new ParseError$2(
12366            "Got group of unknown type: '" + group.type + "'");
12367    }
12368};
12369
12370/**
12371 * Take an entire parse tree, and build it into an appropriate set of HTML
12372 * nodes.
12373 */
12374var buildHTML$1 = function(tree, options) {
12375    // buildExpression is destructive, so we need to make a clone
12376    // of the incoming tree so that it isn't accidentally changed
12377    tree = JSON.parse(JSON.stringify(tree));
12378
12379    // Build the expression contained in the tree
12380    var expression = buildExpression(tree, options, true);
12381    var body = makeSpan$1(["base", options.style.cls()], expression, options);
12382
12383    // Add struts, which ensure that the top of the HTML element falls at the
12384    // height of the expression, and the bottom of the HTML element falls at the
12385    // depth of the expression.
12386    var topStrut = makeSpan$1(["strut"]);
12387    var bottomStrut = makeSpan$1(["strut", "bottom"]);
12388
12389    topStrut.style.height = body.height + "em";
12390    bottomStrut.style.height = (body.height + body.depth) + "em";
12391    // We'd like to use `vertical-align: top` but in IE 9 this lowers the
12392    // baseline of the box to the bottom of this strut (instead staying in the
12393    // normal place) so we use an absolute value for vertical-align instead
12394    bottomStrut.style.verticalAlign = -body.depth + "em";
12395
12396    // Wrap the struts and body together
12397    var htmlNode = makeSpan$1(["katex-html"], [topStrut, bottomStrut, body]);
12398
12399    htmlNode.setAttribute("aria-hidden", "true");
12400
12401    return htmlNode;
12402};
12403
12404var buildHTML_1 = buildHTML$1;
12405
12406/**
12407 * These objects store data about MathML nodes. This is the MathML equivalent
12408 * of the types in domTree.js. Since MathML handles its own rendering, and
12409 * since we're mainly using MathML to improve accessibility, we don't manage
12410 * any of the styling state that the plain DOM nodes do.
12411 *
12412 * The `toNode` and `toMarkup` functions work simlarly to how they do in
12413 * domTree.js, creating namespaced DOM nodes and HTML text markup respectively.
12414 */
12415
12416var utils$8 = utils$4;
12417
12418/**
12419 * This node represents a general purpose MathML node of any type. The
12420 * constructor requires the type of node to create (for example, `"mo"` or
12421 * `"mspace"`, corresponding to `<mo>` and `<mspace>` tags).
12422 */
12423function MathNode(type, children) {
12424    this.type = type;
12425    this.attributes = {};
12426    this.children = children || [];
12427}
12428
12429/**
12430 * Sets an attribute on a MathML node. MathML depends on attributes to convey a
12431 * semantic content, so this is used heavily.
12432 */
12433MathNode.prototype.setAttribute = function(name, value) {
12434    this.attributes[name] = value;
12435};
12436
12437/**
12438 * Converts the math node into a MathML-namespaced DOM element.
12439 */
12440MathNode.prototype.toNode = function() {
12441    var this$1 = this;
12442
12443    var node = document.createElementNS(
12444        "http://www.w3.org/1998/Math/MathML", this.type);
12445
12446    for (var attr in this.attributes) {
12447        if (Object.prototype.hasOwnProperty.call(this$1.attributes, attr)) {
12448            node.setAttribute(attr, this$1.attributes[attr]);
12449        }
12450    }
12451
12452    for (var i = 0; i < this.children.length; i++) {
12453        node.appendChild(this$1.children[i].toNode());
12454    }
12455
12456    return node;
12457};
12458
12459/**
12460 * Converts the math node into an HTML markup string.
12461 */
12462MathNode.prototype.toMarkup = function() {
12463    var this$1 = this;
12464
12465    var markup = "<" + this.type;
12466
12467    // Add the attributes
12468    for (var attr in this.attributes) {
12469        if (Object.prototype.hasOwnProperty.call(this$1.attributes, attr)) {
12470            markup += " " + attr + "=\"";
12471            markup += utils$8.escape(this$1.attributes[attr]);
12472            markup += "\"";
12473        }
12474    }
12475
12476    markup += ">";
12477
12478    for (var i = 0; i < this.children.length; i++) {
12479        markup += this$1.children[i].toMarkup();
12480    }
12481
12482    markup += "</" + this.type + ">";
12483
12484    return markup;
12485};
12486
12487/**
12488 * This node represents a piece of text.
12489 */
12490function TextNode(text) {
12491    this.text = text;
12492}
12493
12494/**
12495 * Converts the text node into a DOM text node.
12496 */
12497TextNode.prototype.toNode = function() {
12498    return document.createTextNode(this.text);
12499};
12500
12501/**
12502 * Converts the text node into HTML markup (which is just the text itself).
12503 */
12504TextNode.prototype.toMarkup = function() {
12505    return utils$8.escape(this.text);
12506};
12507
12508var mathMLTree$1 = {
12509    MathNode: MathNode,
12510    TextNode: TextNode
12511};
12512
12513/**
12514 * This file converts a parse tree into a cooresponding MathML tree. The main
12515 * entry point is the `buildMathML` function, which takes a parse tree from the
12516 * parser.
12517 */
12518
12519var buildCommon$5 = buildCommon$2;
12520var fontMetrics$5 = fontMetrics$1;
12521var mathMLTree = mathMLTree$1;
12522var ParseError$4 = ParseError_1;
12523var symbols$4 = symbols$1;
12524var utils$7 = utils$4;
12525
12526var makeSpan$4 = buildCommon$5.makeSpan;
12527var fontMap$1 = buildCommon$5.fontMap;
12528
12529/**
12530 * Takes a symbol and converts it into a MathML text node after performing
12531 * optional replacement from symbols.js.
12532 */
12533var makeText = function(text, mode) {
12534    if (symbols$4[mode][text] && symbols$4[mode][text].replace) {
12535        text = symbols$4[mode][text].replace;
12536    }
12537
12538    return new mathMLTree.TextNode(text);
12539};
12540
12541/**
12542 * Returns the math variant as a string or null if none is required.
12543 */
12544var getVariant = function(group, options) {
12545    var font = options.font;
12546    if (!font) {
12547        return null;
12548    }
12549
12550    var mode = group.mode;
12551    if (font === "mathit") {
12552        return "italic";
12553    }
12554
12555    var value = group.value;
12556    if (utils$7.contains(["\\imath", "\\jmath"], value)) {
12557        return null;
12558    }
12559
12560    if (symbols$4[mode][value] && symbols$4[mode][value].replace) {
12561        value = symbols$4[mode][value].replace;
12562    }
12563
12564    var fontName = fontMap$1[font].fontName;
12565    if (fontMetrics$5.getCharacterMetrics(value, fontName)) {
12566        return fontMap$1[options.font].variant;
12567    }
12568
12569    return null;
12570};
12571
12572/**
12573 * Functions for handling the different types of groups found in the parse
12574 * tree. Each function should take a parse group and return a MathML node.
12575 */
12576var groupTypes$1 = {};
12577
12578groupTypes$1.mathord = function(group, options) {
12579    var node = new mathMLTree.MathNode(
12580        "mi",
12581        [makeText(group.value, group.mode)]);
12582
12583    var variant = getVariant(group, options);
12584    if (variant) {
12585        node.setAttribute("mathvariant", variant);
12586    }
12587    return node;
12588};
12589
12590groupTypes$1.textord = function(group, options) {
12591    var text = makeText(group.value, group.mode);
12592
12593    var variant = getVariant(group, options) || "normal";
12594
12595    var node;
12596    if (/[0-9]/.test(group.value)) {
12597        // TODO(kevinb) merge adjacent <mn> nodes
12598        // do it as a post processing step
12599        node = new mathMLTree.MathNode("mn", [text]);
12600        if (options.font) {
12601            node.setAttribute("mathvariant", variant);
12602        }
12603    } else {
12604        node = new mathMLTree.MathNode("mi", [text]);
12605        node.setAttribute("mathvariant", variant);
12606    }
12607
12608    return node;
12609};
12610
12611groupTypes$1.bin = function(group) {
12612    var node = new mathMLTree.MathNode(
12613        "mo", [makeText(group.value, group.mode)]);
12614
12615    return node;
12616};
12617
12618groupTypes$1.rel = function(group) {
12619    var node = new mathMLTree.MathNode(
12620        "mo", [makeText(group.value, group.mode)]);
12621
12622    return node;
12623};
12624
12625groupTypes$1.open = function(group) {
12626    var node = new mathMLTree.MathNode(
12627        "mo", [makeText(group.value, group.mode)]);
12628
12629    return node;
12630};
12631
12632groupTypes$1.close = function(group) {
12633    var node = new mathMLTree.MathNode(
12634        "mo", [makeText(group.value, group.mode)]);
12635
12636    return node;
12637};
12638
12639groupTypes$1.inner = function(group) {
12640    var node = new mathMLTree.MathNode(
12641        "mo", [makeText(group.value, group.mode)]);
12642
12643    return node;
12644};
12645
12646groupTypes$1.punct = function(group) {
12647    var node = new mathMLTree.MathNode(
12648        "mo", [makeText(group.value, group.mode)]);
12649
12650    node.setAttribute("separator", "true");
12651
12652    return node;
12653};
12654
12655groupTypes$1.ordgroup = function(group, options) {
12656    var inner = buildExpression$1(group.value, options);
12657
12658    var node = new mathMLTree.MathNode("mrow", inner);
12659
12660    return node;
12661};
12662
12663groupTypes$1.text = function(group, options) {
12664    var inner = buildExpression$1(group.value.body, options);
12665
12666    var node = new mathMLTree.MathNode("mtext", inner);
12667
12668    return node;
12669};
12670
12671groupTypes$1.color = function(group, options) {
12672    var inner = buildExpression$1(group.value.value, options);
12673
12674    var node = new mathMLTree.MathNode("mstyle", inner);
12675
12676    node.setAttribute("mathcolor", group.value.color);
12677
12678    return node;
12679};
12680
12681groupTypes$1.supsub = function(group, options) {
12682    var children = [buildGroup$1(group.value.base, options)];
12683
12684    if (group.value.sub) {
12685        children.push(buildGroup$1(group.value.sub, options));
12686    }
12687
12688    if (group.value.sup) {
12689        children.push(buildGroup$1(group.value.sup, options));
12690    }
12691
12692    var nodeType;
12693    if (!group.value.sub) {
12694        nodeType = "msup";
12695    } else if (!group.value.sup) {
12696        nodeType = "msub";
12697    } else {
12698        nodeType = "msubsup";
12699    }
12700
12701    var node = new mathMLTree.MathNode(nodeType, children);
12702
12703    return node;
12704};
12705
12706groupTypes$1.genfrac = function(group, options) {
12707    var node = new mathMLTree.MathNode(
12708        "mfrac",
12709        [buildGroup$1(group.value.numer, options),
12710            buildGroup$1(group.value.denom, options)]);
12711
12712    if (!group.value.hasBarLine) {
12713        node.setAttribute("linethickness", "0px");
12714    }
12715
12716    if (group.value.leftDelim != null || group.value.rightDelim != null) {
12717        var withDelims = [];
12718
12719        if (group.value.leftDelim != null) {
12720            var leftOp = new mathMLTree.MathNode(
12721                "mo", [new mathMLTree.TextNode(group.value.leftDelim)]);
12722
12723            leftOp.setAttribute("fence", "true");
12724
12725            withDelims.push(leftOp);
12726        }
12727
12728        withDelims.push(node);
12729
12730        if (group.value.rightDelim != null) {
12731            var rightOp = new mathMLTree.MathNode(
12732                "mo", [new mathMLTree.TextNode(group.value.rightDelim)]);
12733
12734            rightOp.setAttribute("fence", "true");
12735
12736            withDelims.push(rightOp);
12737        }
12738
12739        var outerNode = new mathMLTree.MathNode("mrow", withDelims);
12740
12741        return outerNode;
12742    }
12743
12744    return node;
12745};
12746
12747groupTypes$1.array = function(group, options) {
12748    return new mathMLTree.MathNode(
12749        "mtable", group.value.body.map(function(row) {
12750            return new mathMLTree.MathNode(
12751                "mtr", row.map(function(cell) {
12752                    return new mathMLTree.MathNode(
12753                        "mtd", [buildGroup$1(cell, options)]);
12754                }));
12755        }));
12756};
12757
12758groupTypes$1.sqrt = function(group, options) {
12759    var node;
12760    if (group.value.index) {
12761        node = new mathMLTree.MathNode(
12762            "mroot", [
12763                buildGroup$1(group.value.body, options),
12764                buildGroup$1(group.value.index, options)
12765            ]);
12766    } else {
12767        node = new mathMLTree.MathNode(
12768            "msqrt", [buildGroup$1(group.value.body, options)]);
12769    }
12770
12771    return node;
12772};
12773
12774groupTypes$1.leftright = function(group, options) {
12775    var inner = buildExpression$1(group.value.body, options);
12776
12777    if (group.value.left !== ".") {
12778        var leftNode = new mathMLTree.MathNode(
12779            "mo", [makeText(group.value.left, group.mode)]);
12780
12781        leftNode.setAttribute("fence", "true");
12782
12783        inner.unshift(leftNode);
12784    }
12785
12786    if (group.value.right !== ".") {
12787        var rightNode = new mathMLTree.MathNode(
12788            "mo", [makeText(group.value.right, group.mode)]);
12789
12790        rightNode.setAttribute("fence", "true");
12791
12792        inner.push(rightNode);
12793    }
12794
12795    var outerNode = new mathMLTree.MathNode("mrow", inner);
12796
12797    return outerNode;
12798};
12799
12800groupTypes$1.middle = function(group, options) {
12801    var middleNode = new mathMLTree.MathNode(
12802        "mo", [makeText(group.value.middle, group.mode)]);
12803    middleNode.setAttribute("fence", "true");
12804    return middleNode;
12805};
12806
12807groupTypes$1.accent = function(group, options) {
12808    var accentNode = new mathMLTree.MathNode(
12809        "mo", [makeText(group.value.accent, group.mode)]);
12810
12811    var node = new mathMLTree.MathNode(
12812        "mover",
12813        [buildGroup$1(group.value.base, options),
12814            accentNode]);
12815
12816    node.setAttribute("accent", "true");
12817
12818    return node;
12819};
12820
12821groupTypes$1.spacing = function(group) {
12822    var node;
12823
12824    if (group.value === "\\ " || group.value === "\\space" ||
12825        group.value === " " || group.value === "~") {
12826        node = new mathMLTree.MathNode(
12827            "mtext", [new mathMLTree.TextNode("\u00a0")]);
12828    } else {
12829        node = new mathMLTree.MathNode("mspace");
12830
12831        node.setAttribute(
12832            "width", buildCommon$5.spacingFunctions[group.value].size);
12833    }
12834
12835    return node;
12836};
12837
12838groupTypes$1.op = function(group, options) {
12839    var node;
12840
12841    // TODO(emily): handle big operators using the `largeop` attribute
12842
12843    if (group.value.symbol) {
12844        // This is a symbol. Just add the symbol.
12845        node = new mathMLTree.MathNode(
12846            "mo", [makeText(group.value.body, group.mode)]);
12847    } else if (group.value.value) {
12848        // This is an operator with children. Add them.
12849        node = new mathMLTree.MathNode(
12850            "mo", buildExpression$1(group.value.value, options));
12851    } else {
12852        // This is a text operator. Add all of the characters from the
12853        // operator's name.
12854        // TODO(emily): Add a space in the middle of some of these
12855        // operators, like \limsup.
12856        node = new mathMLTree.MathNode(
12857            "mi", [new mathMLTree.TextNode(group.value.body.slice(1))]);
12858    }
12859
12860    return node;
12861};
12862
12863groupTypes$1.mod = function(group, options) {
12864    var inner = [];
12865
12866    if (group.value.modType === "pod" || group.value.modType === "pmod") {
12867        inner.push(new mathMLTree.MathNode(
12868            "mo", [makeText("(", group.mode)]));
12869    }
12870    if (group.value.modType !== "pod") {
12871        inner.push(new mathMLTree.MathNode(
12872            "mo", [makeText("mod", group.mode)]));
12873    }
12874    if (group.value.value) {
12875        var space = new mathMLTree.MathNode("mspace");
12876        space.setAttribute("width", "0.333333em");
12877        inner.push(space);
12878        inner = inner.concat(buildExpression$1(group.value.value, options));
12879    }
12880    if (group.value.modType === "pod" || group.value.modType === "pmod") {
12881        inner.push(new mathMLTree.MathNode(
12882            "mo", [makeText(")", group.mode)]));
12883    }
12884
12885    return new mathMLTree.MathNode("mo", inner);
12886};
12887
12888groupTypes$1.katex = function(group) {
12889    var node = new mathMLTree.MathNode(
12890        "mtext", [new mathMLTree.TextNode("KaTeX")]);
12891
12892    return node;
12893};
12894
12895groupTypes$1.font = function(group, options) {
12896    var font = group.value.font;
12897    return buildGroup$1(group.value.body, options.withFont(font));
12898};
12899
12900groupTypes$1.delimsizing = function(group) {
12901    var children = [];
12902
12903    if (group.value.value !== ".") {
12904        children.push(makeText(group.value.value, group.mode));
12905    }
12906
12907    var node = new mathMLTree.MathNode("mo", children);
12908
12909    if (group.value.mclass === "mopen" ||
12910        group.value.mclass === "mclose") {
12911        // Only some of the delimsizing functions act as fences, and they
12912        // return "mopen" or "mclose" mclass.
12913        node.setAttribute("fence", "true");
12914    } else {
12915        // Explicitly disable fencing if it's not a fence, to override the
12916        // defaults.
12917        node.setAttribute("fence", "false");
12918    }
12919
12920    return node;
12921};
12922
12923groupTypes$1.styling = function(group, options) {
12924    var inner = buildExpression$1(group.value.value, options);
12925
12926    var node = new mathMLTree.MathNode("mstyle", inner);
12927
12928    var styleAttributes = {
12929        "display": ["0", "true"],
12930        "text": ["0", "false"],
12931        "script": ["1", "false"],
12932        "scriptscript": ["2", "false"]
12933    };
12934
12935    var attr = styleAttributes[group.value.style];
12936
12937    node.setAttribute("scriptlevel", attr[0]);
12938    node.setAttribute("displaystyle", attr[1]);
12939
12940    return node;
12941};
12942
12943groupTypes$1.sizing = function(group, options) {
12944    var inner = buildExpression$1(group.value.value, options);
12945
12946    var node = new mathMLTree.MathNode("mstyle", inner);
12947
12948    // TODO(emily): This doesn't produce the correct size for nested size
12949    // changes, because we don't keep state of what style we're currently
12950    // in, so we can't reset the size to normal before changing it.  Now
12951    // that we're passing an options parameter we should be able to fix
12952    // this.
12953    node.setAttribute(
12954        "mathsize", buildCommon$5.sizingMultiplier[group.value.size] + "em");
12955
12956    return node;
12957};
12958
12959groupTypes$1.overline = function(group, options) {
12960    var operator = new mathMLTree.MathNode(
12961        "mo", [new mathMLTree.TextNode("\u203e")]);
12962    operator.setAttribute("stretchy", "true");
12963
12964    var node = new mathMLTree.MathNode(
12965        "mover",
12966        [buildGroup$1(group.value.body, options),
12967            operator]);
12968    node.setAttribute("accent", "true");
12969
12970    return node;
12971};
12972
12973groupTypes$1.underline = function(group, options) {
12974    var operator = new mathMLTree.MathNode(
12975        "mo", [new mathMLTree.TextNode("\u203e")]);
12976    operator.setAttribute("stretchy", "true");
12977
12978    var node = new mathMLTree.MathNode(
12979        "munder",
12980        [buildGroup$1(group.value.body, options),
12981            operator]);
12982    node.setAttribute("accentunder", "true");
12983
12984    return node;
12985};
12986
12987groupTypes$1.rule = function(group) {
12988    // TODO(emily): Figure out if there's an actual way to draw black boxes
12989    // in MathML.
12990    var node = new mathMLTree.MathNode("mrow");
12991
12992    return node;
12993};
12994
12995groupTypes$1.kern = function(group) {
12996    // TODO(kevin): Figure out if there's a way to add space in MathML
12997    var node = new mathMLTree.MathNode("mrow");
12998
12999    return node;
13000};
13001
13002groupTypes$1.llap = function(group, options) {
13003    var node = new mathMLTree.MathNode(
13004        "mpadded", [buildGroup$1(group.value.body, options)]);
13005
13006    node.setAttribute("lspace", "-1width");
13007    node.setAttribute("width", "0px");
13008
13009    return node;
13010};
13011
13012groupTypes$1.rlap = function(group, options) {
13013    var node = new mathMLTree.MathNode(
13014        "mpadded", [buildGroup$1(group.value.body, options)]);
13015
13016    node.setAttribute("width", "0px");
13017
13018    return node;
13019};
13020
13021groupTypes$1.phantom = function(group, options) {
13022    var inner = buildExpression$1(group.value.value, options);
13023    return new mathMLTree.MathNode("mphantom", inner);
13024};
13025
13026groupTypes$1.mclass = function(group, options) {
13027    var inner = buildExpression$1(group.value.value, options);
13028    return new mathMLTree.MathNode("mstyle", inner);
13029};
13030
13031/**
13032 * Takes a list of nodes, builds them, and returns a list of the generated
13033 * MathML nodes. A little simpler than the HTML version because we don't do any
13034 * previous-node handling.
13035 */
13036var buildExpression$1 = function(expression, options) {
13037    var groups = [];
13038    for (var i = 0; i < expression.length; i++) {
13039        var group = expression[i];
13040        groups.push(buildGroup$1(group, options));
13041    }
13042    return groups;
13043};
13044
13045/**
13046 * Takes a group from the parser and calls the appropriate groupTypes function
13047 * on it to produce a MathML node.
13048 */
13049var buildGroup$1 = function(group, options) {
13050    if (!group) {
13051        return new mathMLTree.MathNode("mrow");
13052    }
13053
13054    if (groupTypes$1[group.type]) {
13055        // Call the groupTypes function
13056        return groupTypes$1[group.type](group, options);
13057    } else {
13058        throw new ParseError$4(
13059            "Got group of unknown type: '" + group.type + "'");
13060    }
13061};
13062
13063/**
13064 * Takes a full parse tree and settings and builds a MathML representation of
13065 * it. In particular, we put the elements from building the parse tree into a
13066 * <semantics> tag so we can also include that TeX source as an annotation.
13067 *
13068 * Note that we actually return a domTree element with a `<math>` inside it so
13069 * we can do appropriate styling.
13070 */
13071var buildMathML$1 = function(tree, texExpression, options) {
13072    var expression = buildExpression$1(tree, options);
13073
13074    // Wrap up the expression in an mrow so it is presented in the semantics
13075    // tag correctly.
13076    var wrapper = new mathMLTree.MathNode("mrow", expression);
13077
13078    // Build a TeX annotation of the source
13079    var annotation = new mathMLTree.MathNode(
13080        "annotation", [new mathMLTree.TextNode(texExpression)]);
13081
13082    annotation.setAttribute("encoding", "application/x-tex");
13083
13084    var semantics = new mathMLTree.MathNode(
13085        "semantics", [wrapper, annotation]);
13086
13087    var math = new mathMLTree.MathNode("math", [semantics]);
13088
13089    // You can't style <math> nodes, so we wrap the node in a span.
13090    return makeSpan$4(["katex-mathml"], [math]);
13091};
13092
13093var buildMathML_1 = buildMathML$1;
13094
13095/**
13096 * This file contains information about the options that the Parser carries
13097 * around with it while parsing. Data is held in an `Options` object, and when
13098 * recursing, a new `Options` object can be created with the `.with*` and
13099 * `.reset` functions.
13100 */
13101
13102/**
13103 * This is the main options class. It contains the style, size, color, and font
13104 * of the current parse level. It also contains the style and size of the parent
13105 * parse level, so size changes can be handled efficiently.
13106 *
13107 * Each of the `.with*` and `.reset` functions passes its current style and size
13108 * as the parentStyle and parentSize of the new options class, so parent
13109 * handling is taken care of automatically.
13110 */
13111function Options$1(data) {
13112    this.style = data.style;
13113    this.color = data.color;
13114    this.size = data.size;
13115    this.phantom = data.phantom;
13116    this.font = data.font;
13117
13118    if (data.parentStyle === undefined) {
13119        this.parentStyle = data.style;
13120    } else {
13121        this.parentStyle = data.parentStyle;
13122    }
13123
13124    if (data.parentSize === undefined) {
13125        this.parentSize = data.size;
13126    } else {
13127        this.parentSize = data.parentSize;
13128    }
13129}
13130
13131/**
13132 * Returns a new options object with the same properties as "this".  Properties
13133 * from "extension" will be copied to the new options object.
13134 */
13135Options$1.prototype.extend = function(extension) {
13136    var data = {
13137        style: this.style,
13138        size: this.size,
13139        color: this.color,
13140        parentStyle: this.style,
13141        parentSize: this.size,
13142        phantom: this.phantom,
13143        font: this.font
13144    };
13145
13146    for (var key in extension) {
13147        if (extension.hasOwnProperty(key)) {
13148            data[key] = extension[key];
13149        }
13150    }
13151
13152    return new Options$1(data);
13153};
13154
13155/**
13156 * Create a new options object with the given style.
13157 */
13158Options$1.prototype.withStyle = function(style) {
13159    return this.extend({
13160        style: style
13161    });
13162};
13163
13164/**
13165 * Create a new options object with the given size.
13166 */
13167Options$1.prototype.withSize = function(size) {
13168    return this.extend({
13169        size: size
13170    });
13171};
13172
13173/**
13174 * Create a new options object with the given color.
13175 */
13176Options$1.prototype.withColor = function(color) {
13177    return this.extend({
13178        color: color
13179    });
13180};
13181
13182/**
13183 * Create a new options object with "phantom" set to true.
13184 */
13185Options$1.prototype.withPhantom = function() {
13186    return this.extend({
13187        phantom: true
13188    });
13189};
13190
13191/**
13192 * Create a new options objects with the give font.
13193 */
13194Options$1.prototype.withFont = function(font) {
13195    return this.extend({
13196        font: font || this.font
13197    });
13198};
13199
13200/**
13201 * Create a new options object with the same style, size, and color. This is
13202 * used so that parent style and size changes are handled correctly.
13203 */
13204Options$1.prototype.reset = function() {
13205    return this.extend({});
13206};
13207
13208/**
13209 * A map of color names to CSS colors.
13210 * TODO(emily): Remove this when we have real macros
13211 */
13212var colorMap = {
13213    "katex-blue": "#6495ed",
13214    "katex-orange": "#ffa500",
13215    "katex-pink": "#ff00af",
13216    "katex-red": "#df0030",
13217    "katex-green": "#28ae7b",
13218    "katex-gray": "gray",
13219    "katex-purple": "#9d38bd",
13220    "katex-blueA": "#ccfaff",
13221    "katex-blueB": "#80f6ff",
13222    "katex-blueC": "#63d9ea",
13223    "katex-blueD": "#11accd",
13224    "katex-blueE": "#0c7f99",
13225    "katex-tealA": "#94fff5",
13226    "katex-tealB": "#26edd5",
13227    "katex-tealC": "#01d1c1",
13228    "katex-tealD": "#01a995",
13229    "katex-tealE": "#208170",
13230    "katex-greenA": "#b6ffb0",
13231    "katex-greenB": "#8af281",
13232    "katex-greenC": "#74cf70",
13233    "katex-greenD": "#1fab54",
13234    "katex-greenE": "#0d923f",
13235    "katex-goldA": "#ffd0a9",
13236    "katex-goldB": "#ffbb71",
13237    "katex-goldC": "#ff9c39",
13238    "katex-goldD": "#e07d10",
13239    "katex-goldE": "#a75a05",
13240    "katex-redA": "#fca9a9",
13241    "katex-redB": "#ff8482",
13242    "katex-redC": "#f9685d",
13243    "katex-redD": "#e84d39",
13244    "katex-redE": "#bc2612",
13245    "katex-maroonA": "#ffbde0",
13246    "katex-maroonB": "#ff92c6",
13247    "katex-maroonC": "#ed5fa6",
13248    "katex-maroonD": "#ca337c",
13249    "katex-maroonE": "#9e034e",
13250    "katex-purpleA": "#ddd7ff",
13251    "katex-purpleB": "#c6b9fc",
13252    "katex-purpleC": "#aa87ff",
13253    "katex-purpleD": "#7854ab",
13254    "katex-purpleE": "#543b78",
13255    "katex-mintA": "#f5f9e8",
13256    "katex-mintB": "#edf2df",
13257    "katex-mintC": "#e0e5cc",
13258    "katex-grayA": "#f6f7f7",
13259    "katex-grayB": "#f0f1f2",
13260    "katex-grayC": "#e3e5e6",
13261    "katex-grayD": "#d6d8da",
13262    "katex-grayE": "#babec2",
13263    "katex-grayF": "#888d93",
13264    "katex-grayG": "#626569",
13265    "katex-grayH": "#3b3e40",
13266    "katex-grayI": "#21242c",
13267    "katex-kaBlue": "#314453",
13268    "katex-kaGreen": "#71B307"
13269};
13270
13271/**
13272 * Gets the CSS color of the current options object, accounting for the
13273 * `colorMap`.
13274 */
13275Options$1.prototype.getColor = function() {
13276    if (this.phantom) {
13277        return "transparent";
13278    } else {
13279        return colorMap[this.color] || this.color;
13280    }
13281};
13282
13283var Options_1 = Options$1;
13284
13285var buildHTML = buildHTML_1;
13286var buildMathML = buildMathML_1;
13287var buildCommon = buildCommon$2;
13288var Options = Options_1;
13289var Settings$2 = Settings_1;
13290var Style = Style_1;
13291
13292var makeSpan = buildCommon.makeSpan;
13293
13294var buildTree$1 = function(tree, expression, settings) {
13295    settings = settings || new Settings$2({});
13296
13297    var startStyle = Style.TEXT;
13298    if (settings.displayMode) {
13299        startStyle = Style.DISPLAY;
13300    }
13301
13302    // Setup the default options
13303    var options = new Options({
13304        style: startStyle,
13305        size: "size5"
13306    });
13307
13308    // `buildHTML` sometimes messes with the parse tree (like turning bins ->
13309    // ords), so we build the MathML version first.
13310    var mathMLNode = buildMathML(tree, expression, options);
13311    var htmlNode = buildHTML(tree, options);
13312
13313    var katexNode = makeSpan(["katex"], [
13314        mathMLNode, htmlNode
13315    ]);
13316
13317    if (settings.displayMode) {
13318        return makeSpan(["katex-display"], [katexNode]);
13319    } else {
13320        return katexNode;
13321    }
13322};
13323
13324var buildTree_1 = buildTree$1;
13325
13326/**
13327 * The resulting parse tree nodes of the parse tree.
13328 *
13329 * It is possible to provide position information, so that a ParseNode can
13330 * fulfil a role similar to a Token in error reporting.
13331 * For details on the corresponding properties see Token constructor.
13332 * Providing such information can lead to better error reporting.
13333 *
13334 * @param {string}  type       type of node, like e.g. "ordgroup"
13335 * @param {?object} value      type-specific representation of the node
13336 * @param {string}  mode       parse mode in action for this node,
13337 *                             "math" or "text"
13338 * @param {Token=} firstToken  first token of the input for this node,
13339 *                             will omit position information if unset
13340 * @param {Token=} lastToken   last token of the input for this node,
13341 *                             will default to firstToken if unset
13342 */
13343function ParseNode$1(type, value, mode, firstToken, lastToken) {
13344    this.type = type;
13345    this.value = value;
13346    this.mode = mode;
13347    if (firstToken && (!lastToken || lastToken.lexer === firstToken.lexer)) {
13348        this.lexer = firstToken.lexer;
13349        this.start = firstToken.start;
13350        this.end = (lastToken || firstToken).end;
13351    }
13352}
13353
13354var parseData$1 = {
13355    ParseNode: ParseNode$1
13356};
13357
13358var functions$1 = createCommonjsModule(function (module) {
13359var utils = utils$4;
13360var ParseError = ParseError_1;
13361var parseData = parseData$1;
13362var ParseNode = parseData.ParseNode;
13363
13364/* This file contains a list of functions that we parse, identified by
13365 * the calls to defineFunction.
13366 *
13367 * The first argument to defineFunction is a single name or a list of names.
13368 * All functions named in such a list will share a single implementation.
13369 *
13370 * Each declared function can have associated properties, which
13371 * include the following:
13372 *
13373 *  - numArgs: The number of arguments the function takes.
13374 *             If this is the only property, it can be passed as a number
13375 *             instead of an element of a properties object.
13376 *  - argTypes: (optional) An array corresponding to each argument of the
13377 *              function, giving the type of argument that should be parsed. Its
13378 *              length should be equal to `numArgs + numOptionalArgs`. Valid
13379 *              types:
13380 *               - "size": A size-like thing, such as "1em" or "5ex"
13381 *               - "color": An html color, like "#abc" or "blue"
13382 *               - "original": The same type as the environment that the
13383 *                             function being parsed is in (e.g. used for the
13384 *                             bodies of functions like \color where the first
13385 *                             argument is special and the second argument is
13386 *                             parsed normally)
13387 *              Other possible types (probably shouldn't be used)
13388 *               - "text": Text-like (e.g. \text)
13389 *               - "math": Normal math
13390 *              If undefined, this will be treated as an appropriate length
13391 *              array of "original" strings
13392 *  - greediness: (optional) The greediness of the function to use ungrouped
13393 *                arguments.
13394 *
13395 *                E.g. if you have an expression
13396 *                  \sqrt \frac 1 2
13397 *                since \frac has greediness=2 vs \sqrt's greediness=1, \frac
13398 *                will use the two arguments '1' and '2' as its two arguments,
13399 *                then that whole function will be used as the argument to
13400 *                \sqrt. On the other hand, the expressions
13401 *                  \frac \frac 1 2 3
13402 *                and
13403 *                  \frac \sqrt 1 2
13404 *                will fail because \frac and \frac have equal greediness
13405 *                and \sqrt has a lower greediness than \frac respectively. To
13406 *                make these parse, we would have to change them to:
13407 *                  \frac {\frac 1 2} 3
13408 *                and
13409 *                  \frac {\sqrt 1} 2
13410 *
13411 *                The default value is `1`
13412 *  - allowedInText: (optional) Whether or not the function is allowed inside
13413 *                   text mode (default false)
13414 *  - numOptionalArgs: (optional) The number of optional arguments the function
13415 *                     should parse. If the optional arguments aren't found,
13416 *                     `null` will be passed to the handler in their place.
13417 *                     (default 0)
13418 *  - infix: (optional) Must be true if the function is an infix operator.
13419 *
13420 * The last argument is that implementation, the handler for the function(s).
13421 * It is called to handle these functions and their arguments.
13422 * It receives two arguments:
13423 *  - context contains information and references provided by the parser
13424 *  - args is an array of arguments obtained from TeX input
13425 * The context contains the following properties:
13426 *  - funcName: the text (i.e. name) of the function, including \
13427 *  - parser: the parser object
13428 *  - lexer: the lexer object
13429 *  - positions: the positions in the overall string of the function
13430 *               and the arguments.
13431 * The latter three should only be used to produce error messages.
13432 *
13433 * The function should return an object with the following keys:
13434 *  - type: The type of element that this is. This is then used in
13435 *          buildHTML/buildMathML to determine which function
13436 *          should be called to build this node into a DOM node
13437 * Any other data can be added to the object, which will be passed
13438 * in to the function in buildHTML/buildMathML as `group.value`.
13439 */
13440
13441function defineFunction(names, props, handler) {
13442    if (typeof names === "string") {
13443        names = [names];
13444    }
13445    if (typeof props === "number") {
13446        props = { numArgs: props };
13447    }
13448    // Set default values of functions
13449    var data = {
13450        numArgs: props.numArgs,
13451        argTypes: props.argTypes,
13452        greediness: (props.greediness === undefined) ? 1 : props.greediness,
13453        allowedInText: !!props.allowedInText,
13454        numOptionalArgs: props.numOptionalArgs || 0,
13455        infix: !!props.infix,
13456        handler: handler
13457    };
13458    for (var i = 0; i < names.length; ++i) {
13459        module.exports[names[i]] = data;
13460    }
13461}
13462
13463// Since the corresponding buildHTML/buildMathML function expects a
13464// list of elements, we normalize for different kinds of arguments
13465var ordargument = function(arg) {
13466    if (arg.type === "ordgroup") {
13467        return arg.value;
13468    } else {
13469        return [arg];
13470    }
13471};
13472
13473// A normal square root
13474defineFunction("\\sqrt", {
13475    numArgs: 1,
13476    numOptionalArgs: 1
13477}
13477, function(context, args) {
13478    var index = args[0];
13479    var body = args[1];
13480    return {
13481        type: "sqrt",
13482        body: body,
13483        index: index
13484    };
13485});
13486
13487// Non-mathy text, possibly in a font
13488var textFunctionStyles = {
13489    "\\text": undefined, "\\textrm": "mathrm", "\\textsf": "mathsf",
13490    "\\texttt": "mathtt", "\\textnormal": "mathrm", "\\textbf": "mathbf",
13491    "\\textit": "textit"
13492};
13493
13494defineFunction([
13495    "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal",
13496    "\\textbf", "\\textit"
13497], {
13498    numArgs: 1,
13499    argTypes: ["text"],
13500    greediness: 2,
13501    allowedInText: true
13502}, function(context, args) {
13503    var body = args[0];
13504    return {
13505        type: "text",
13506        body: ordargument(body),
13507        style: textFunctionStyles[context.funcName]
13508    };
13509});
13510
13511// A two-argument custom color
13512defineFunction("\\color", {
13513    numArgs: 2,
13514    allowedInText: true,
13515    greediness: 3,
13516    argTypes: ["color", "original"]
13517}, function(context, args) {
13518    var color = args[0];
13519    var body = args[1];
13520    return {
13521        type: "color",
13522        color: color.value,
13523        value: ordargument(body)
13524    };
13525});
13526
13527// An overline
13528defineFunction("\\overline", {
13529    numArgs: 1
13530}, function(context, args) {
13531    var body = args[0];
13532    return {
13533        type: "overline",
13534        body: body
13535    };
13536});
13537
13538// An underline
13539defineFunction("\\underline", {
13540    numArgs: 1
13541}, function(context, args) {
13542    var body = args[0];
13543    return {
13544        type: "underline",
13545        body: body
13546    };
13547});
13548
13549// A box of the width and height
13550defineFunction("\\rule", {
13551    numArgs: 2,
13552    numOptionalArgs: 1,
13553    argTypes: ["size", "size", "size"]
13554}, function(context, args) {
13555    var shift = args[0];
13556    var width = args[1];
13557    var height = args[2];
13558    return {
13559        type: "rule",
13560        shift: shift && shift.value,
13561        width: width.value,
13562        height: height.value
13563    };
13564});
13565
13566// TODO: In TeX, \mkern only accepts mu-units, and \kern does not accept
13567// mu-units. In current KaTeX we relax this; both commands accept any unit.
13568defineFunction(["\\kern", "\\mkern"], {
13569    numArgs: 1,
13570    argTypes: ["size"]
13571}, function(context, args) {
13572    return {
13573        type: "kern",
13574        dimension: args[0].value
13575    };
13576});
13577
13578// A KaTeX logo
13579defineFunction("\\KaTeX", {
13580    numArgs: 0
13581}, function(context) {
13582    return {
13583        type: "katex"
13584    };
13585});
13586
13587defineFunction("\\phantom", {
13588    numArgs: 1
13589}, function(context, args) {
13590    var body = args[0];
13591    return {
13592        type: "phantom",
13593        value: ordargument(body)
13594    };
13595});
13596
13597// Math class commands except \mathop
13598defineFunction([
13599    "\\mathord", "\\mathbin", "\\mathrel", "\\mathopen",
13600    "\\mathclose", "\\mathpunct", "\\mathinner"
13601], {
13602    numArgs: 1
13603}, function(context, args) {
13604    var body = args[0];
13605    return {
13606        type: "mclass",
13607        mclass: "m" + context.funcName.substr(5),
13608        value: ordargument(body)
13609    };
13610});
13611
13612// Build a relation by placing one symbol on top of another
13613defineFunction("\\stackrel", {
13614    numArgs: 2
13615}, function(context, args) {
13616    var top = args[0];
13617    var bottom = args[1];
13618
13619    var bottomop = new ParseNode("op", {
13620        type: "op",
13621        limits: true,
13622        alwaysHandleSupSub: true,
13623        symbol: false,
13624        value: ordargument(bottom)
13625    }, bottom.mode);
13626
13627    var supsub = new ParseNode("supsub", {
13628        base: bottomop,
13629        sup: top,
13630        sub: null
13631    }, top.mode);
13632
13633    return {
13634        type: "mclass",
13635        mclass: "mrel",
13636        value: [supsub]
13637    };
13638});
13639
13640// \mod-type functions
13641defineFunction("\\bmod", {
13642    numArgs: 0
13643}, function(context, args) {
13644    return {
13645        type: "mod",
13646        modType: "bmod",
13647        value: null
13648    };
13649});
13650
13651defineFunction(["\\pod", "\\pmod", "\\mod"], {
13652    numArgs: 1
13653}, function(context, args) {
13654    var body = args[0];
13655    return {
13656        type: "mod",
13657        modType: context.funcName.substr(1),
13658        value: ordargument(body)
13659    };
13660});
13661
13662// Extra data needed for the delimiter handler down below
13663var delimiterSizes = {
13664    "\\bigl" : {mclass: "mopen",    size: 1},
13665    "\\Bigl" : {mclass: "mopen",    size: 2},
13666    "\\biggl": {mclass: "mopen",    size: 3},
13667    "\\Biggl": {mclass: "mopen",    size: 4},
13668    "\\bigr" : {mclass: "mclose",   size: 1},
13669    "\\Bigr" : {mclass: "mclose",   size: 2},
13670    "\\biggr": {mclass: "mclose",   size: 3},
13671    "\\Biggr": {mclass: "mclose",   size: 4},
13672    "\\bigm" : {mclass: "mrel",     size: 1},
13673    "\\Bigm" : {mclass: "mrel",     size: 2},
13674    "\\biggm": {mclass: "mrel",     size: 3},
13675    "\\Biggm": {mclass: "mrel",     size: 4},
13676    "\\big"  : {mclass: "mord",     size: 1},
13677    "\\Big"  : {mclass: "mord",     size: 2},
13678    "\\bigg" : {mclass: "mord",     size: 3},
13679    "\\Bigg" : {mclass: "mord",     size: 4}
13680};
13681
13682var delimiters = [
13683    "(", ")", "[", "\\lbrack", "]", "\\rbrack",
13684    "\\{", "\\lbrace", "\\}", "\\rbrace",
13685    "\\lfloor", "\\rfloor", "\\lceil", "\\rceil",
13686    "<", ">", "\\langle", "\\rangle", "\\lt", "\\gt",
13687    "\\lvert", "\\rvert", "\\lVert", "\\rVert",
13688    "\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache",
13689    "/", "\\backslash",
13690    "|", "\\vert", "\\|", "\\Vert",
13691    "\\uparrow", "\\Uparrow",
13692    "\\downarrow", "\\Downarrow",
13693    "\\updownarrow", "\\Updownarrow",
13694    "."
13695];
13696
13697var fontAliases = {
13698    "\\Bbb": "\\mathbb",
13699    "\\bold": "\\mathbf",
13700    "\\frak": "\\mathfrak"
13701};
13702
13703// Single-argument color functions
13704defineFunction([
13705    "\\blue", "\\orange", "\\pink", "\\red",
13706    "\\green", "\\gray", "\\purple",
13707    "\\blueA", "\\blueB", "\\blueC", "\\blueD", "\\blueE",
13708    "\\tealA", "\\tealB", "\\tealC", "\\tealD", "\\tealE",
13709    "\\greenA", "\\greenB", "\\greenC", "\\greenD", "\\greenE",
13710    "\\goldA", "\\goldB", "\\goldC", "\\goldD", "\\goldE",
13711    "\\redA", "\\redB", "\\redC", "\\redD", "\\redE",
13712    "\\maroonA", "\\maroonB", "\\maroonC", "\\maroonD", "\\maroonE",
13713    "\\purpleA", "\\purpleB", "\\purpleC", "\\purpleD", "\\purpleE",
13714    "\\mintA", "\\mintB", "\\mintC",
13715    "\\grayA", "\\grayB", "\\grayC", "\\grayD", "\\grayE",
13716    "\\grayF", "\\grayG", "\\grayH", "\\grayI",
13717    "\\kaBlue", "\\kaGreen"
13718], {
13719    numArgs: 1,
13720    allowedInText: true,
13721    greediness: 3
13722}, function(context, args) {
13723    var body = args[0];
13724    return {
13725        type: "color",
13726        color: "katex-" + context.funcName.slice(1),
13727        value: ordargument(body)
13728    };
13729});
13730
13731// There are 2 flags for operators; whether they produce limits in
13732// displaystyle, and whether they are symbols and should grow in
13733// displaystyle. These four groups cover the four possible choices.
13734
13735// No limits, not symbols
13736defineFunction([
13737    "\\arcsin", "\\arccos", "\\arctan", "\\arg", "\\cos", "\\cosh",
13738    "\\cot", "\\coth", "\\csc", "\\deg", "\\dim", "\\exp", "\\hom",
13739    "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh",
13740    "\\tan", "\\tanh"
13741], {
13742    numArgs: 0
13743}, function(context) {
13744    return {
13745        type: "op",
13746        limits: false,
13747        symbol: false,
13748        body: context.funcName
13749    };
13750});
13751
13752// Limits, not symbols
13753defineFunction([
13754    "\\det", "\\gcd", "\\inf", "\\lim", "\\liminf", "\\limsup", "\\max",
13755    "\\min", "\\Pr", "\\sup"
13756], {
13757    numArgs: 0
13758}, function(context) {
13759    return {
13760        type: "op",
13761        limits: true,
13762        symbol: false,
13763        body: context.funcName
13764    };
13765});
13766
13767// No limits, symbols
13768defineFunction([
13769    "\\int", "\\iint", "\\iiint", "\\oint"
13770], {
13771    numArgs: 0
13772}, function(context) {
13773    return {
13774        type: "op",
13775        limits: false,
13776        symbol: true,
13777        body: context.funcName
13778    };
13779});
13780
13781// Limits, symbols
13782defineFunction([
13783    "\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap",
13784    "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes",
13785    "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint"
13786], {
13787    numArgs: 0
13788}, function(context) {
13789    return {
13790        type: "op",
13791        limits: true,
13792        symbol: true,
13793        body: context.funcName
13794    };
13795});
13796
13797// \mathop class command
13798defineFunction("\\mathop", {
13799    numArgs: 1
13800}
13800, function(context, args) {
13801    var body = args[0];
13802    return {
13803        type: "op",
13804        limits: false,
13805        symbol: false,
13806        value: ordargument(body)
13807    };
13808});
13809
13810// Fractions
13811defineFunction([
13812    "\\dfrac", "\\frac", "\\tfrac",
13813    "\\dbinom", "\\binom", "\\tbinom",
13814    "\\\\atopfrac" // can’t be entered directly
13815], {
13816    numArgs: 2,
13817    greediness: 2
13818}, function(context, args) {
13819    var numer = args[0];
13820    var denom = args[1];
13821    var hasBarLine;
13822    var leftDelim = null;
13823    var rightDelim = null;
13824    var size = "auto";
13825
13826    switch (context.funcName) {
13827        case "\\dfrac":
13828        case "\\frac":
13829        case "\\tfrac":
13830            hasBarLine = true;
13831            break;
13832        case "\\\\atopfrac":
13833            hasBarLine = false;
13834            break;
13835        case "\\dbinom":
13836        case "\\binom":
13837        case "\\tbinom":
13838            hasBarLine = false;
13839            leftDelim = "(";
13840            rightDelim = ")";
13841            break;
13842        default:
13843            throw new Error("Unrecognized genfrac command");
13844    }
13845
13846    switch (context.funcName) {
13847        case "\\dfrac":
13848        case "\\dbinom":
13849            size = "display";
13850            break;
13851        case "\\tfrac":
13852        case "\\tbinom":
13853            size = "text";
13854            break;
13855    }
13856
13857    return {
13858        type: "genfrac",
13859        numer: numer,
13860        denom: denom,
13861        hasBarLine: hasBarLine,
13862        leftDelim: leftDelim,
13863        rightDelim: rightDelim,
13864        size: size
13865    };
13866});
13867
13868// Left and right overlap functions
13869defineFunction(["\\llap", "\\rlap"], {
13870    numArgs: 1,
13871    allowedInText: true
13872}, function(context, args) {
13873    var body = args[0];
13874    return {
13875        type: context.funcName.slice(1),
13876        body: body
13877    };
13878});
13879
13880// Delimiter functions
13881var checkDelimiter = function(delim, context) {
13882    if (utils.contains(delimiters, delim.value)) {
13883        return delim;
13884    } else {
13885        throw new ParseError(
13886            "Invalid delimiter: '" + delim.value + "' after '" +
13887            context.funcName + "'", delim);
13888    }
13889};
13890
13891defineFunction([
13892    "\\bigl", "\\Bigl", "\\biggl", "\\Biggl",
13893    "\\bigr", "\\Bigr", "\\biggr", "\\Biggr",
13894    "\\bigm", "\\Bigm", "\\biggm", "\\Biggm",
13895    "\\big",  "\\Big",  "\\bigg",  "\\Bigg"
13896], {
13897    numArgs: 1
13898}, function(context, args) {
13899    var delim = checkDelimiter(args[0], context);
13900
13901    return {
13902        type: "delimsizing",
13903        size: delimiterSizes[context.funcName].size,
13904        mclass: delimiterSizes[context.funcName].mclass,
13905        value: delim.value
13906    };
13907});
13908
13909defineFunction([
13910    "\\left", "\\right"
13911], {
13912    numArgs: 1
13913}, function(context, args) {
13914    var delim = checkDelimiter(args[0], context);
13915
13916    // \left and \right are caught somewhere in Parser.js, which is
13917    // why this data doesn't match what is in buildHTML.
13918    return {
13919        type: "leftright",
13920        value: delim.value
13921    };
13922});
13923
13924defineFunction("\\middle", {
13925    numArgs: 1
13926}, function(context, args) {
13927    var delim = checkDelimiter(args[0], context);
13928    if (!context.parser.leftrightDepth) {
13929        throw new ParseError("\\middle without preceding \\left", delim);
13930    }
13931
13932    return {
13933        type: "middle",
13934        value: delim.value
13935    };
13936});
13937
13938// Sizing functions (handled in Parser.js explicitly, hence no handler)
13939defineFunction([
13940    "\\tiny", "\\scriptsize", "\\footnotesize", "\\small",
13941    "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"
13942], 0, null);
13943
13944// Style changing functions (handled in Parser.js explicitly, hence no
13945// handler)
13946defineFunction([
13947    "\\displaystyle", "\\textstyle", "\\scriptstyle",
13948    "\\scriptscriptstyle"
13949], 0, null);
13950
13951defineFunction([
13952    // styles
13953    "\\mathrm", "\\mathit", "\\mathbf",
13954
13955    // families
13956    "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf",
13957    "\\mathtt",
13958
13959    // aliases
13960    "\\Bbb", "\\bold", "\\frak"
13961], {
13962    numArgs: 1,
13963    greediness: 2
13964}, function(context, args) {
13965    var body = args[0];
13966    var func = context.funcName;
13967    if (func in fontAliases) {
13968        func = fontAliases[func];
13969    }
13970    return {
13971        type: "font",
13972        font: func.slice(1),
13973        body: body
13974    };
13975});
13976
13977// Accents
13978defineFunction([
13979    "\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve",
13980    "\\check", "\\hat", "\\vec", "\\dot" ], {
13981    numArgs: 1
13982}
13982, function(context, args) {
13983    var base = args[0];
13984    return {
13985        type: "accent",
13986        accent: context.funcName,
13987        base: base
13988    };
13989});
13990
13991// Infix generalized fractions
13992defineFunction(["\\over", "\\choose", "\\atop"], {
13993    numArgs: 0,
13994    infix: true
13995}, function(context) {
13996    var replaceWith;
13997    switch (context.funcName) {
13998        case "\\over":
13999            replaceWith = "\\frac";
14000            break;
14001        case "\\choose":
14002            replaceWith = "\\binom";
14003            break;
14004        case "\\atop":
14005            replaceWith = "\\\\atopfrac";
14006            break;
14007        default:
14008            throw new Error("Unrecognized infix genfrac command");
14009    }
14010    return {
14011        type: "infix",
14012        replaceWith: replaceWith,
14013        token: context.token
14014    };
14015});
14016
14017// Row breaks for aligned data
14018defineFunction(["\\\\", "\\cr"], {
14019    numArgs: 0,
14020    numOptionalArgs: 1,
14021    argTypes: ["size"]
14022}, function(context, args) {
14023    var size = args[0];
14024    return {
14025        type: "cr",
14026        size: size
14027    };
14028});
14029
14030// Environment delimiters
14031defineFunction(["\\begin", "\\end"], {
14032    numArgs: 1,
14033    argTypes: ["text"]
14034}, function(context, args) {
14035    var nameGroup = args[0];
14036    if (nameGroup.type !== "ordgroup") {
14037        throw new ParseError("Invalid environment name", nameGroup);
14038    }
14039    var name = "";
14040    for (var i = 0; i < nameGroup.value.length; ++i) {
14041        name += nameGroup.value[i].value;
14042    }
14043    return {
14044        type: "environment",
14045        name: name,
14046        nameGroup: nameGroup
14047    };
14048});
14049});
14050
14051var environments$1 = createCommonjsModule(function (module) {
14052/* eslint no-constant-condition:0 */
14053var parseData = parseData$1;
14054var ParseError = ParseError_1;
14055var Style = Style_1;
14056
14057var ParseNode = parseData.ParseNode;
14058
14059/**
14060 * Parse the body of the environment, with rows delimited by \\ and
14061 * columns delimited by &, and create a nested list in row-major order
14062 * with one group per cell.
14063 */
14064function parseArray(parser, result) {
14065    var row = [];
14066    var body = [row];
14067    var rowGaps = [];
14068    while (true) {
14069        var cell = parser.parseExpression(false, null);
14070        row.push(new ParseNode("ordgroup", cell, parser.mode));
14071        var next = parser.nextToken.text;
14072        if (next === "&") {
14073            parser.consume();
14074        } else if (next === "\\end") {
14075            break;
14076        } else if (next === "\\\\" || next === "\\cr") {
14077            var cr = parser.parseFunction();
14078            rowGaps.push(cr.value.size);
14079            row = [];
14080            body.push(row);
14081        } else {
14082            throw new ParseError("Expected & or \\\\ or \\end",
14083                                 parser.nextToken);
14084        }
14085    }
14086    result.body = body;
14087    result.rowGaps = rowGaps;
14088    return new ParseNode(result.type, result, parser.mode);
14089}
14090
14091/*
14092 * An environment definition is very similar to a function definition:
14093 * it is declared with a name or a list of names, a set of properties
14094 * and a handler containing the actual implementation.
14095 *
14096 * The properties include:
14097 *  - numArgs: The number of arguments after the \begin{name} function.
14098 *  - argTypes: (optional) Just like for a function
14099 *  - allowedInText: (optional) Whether or not the environment is allowed inside
14100 *                   text mode (default false) (not enforced yet)
14101 *  - numOptionalArgs: (optional) Just like for a function
14102 * A bare number instead of that object indicates the numArgs value.
14103 *
14104 * The handler function will receive two arguments
14105 *  - context: information and references provided by the parser
14106 *  - args: an array of arguments passed to \begin{name}
14107 * The context contains the following properties:
14108 *  - envName: the name of the environment, one of the listed names.
14109 *  - parser: the parser object
14110 *  - lexer: the lexer object
14111 *  - positions: the positions associated with these arguments from args.
14112 * The handler must return a ParseResult.
14113 */
14114
14115function defineEnvironment(names, props, handler) {
14116    if (typeof names === "string") {
14117        names = [names];
14118    }
14119    if (typeof props === "number") {
14120        props = { numArgs: props };
14121    }
14122    // Set default values of environments
14123    var data = {
14124        numArgs: props.numArgs || 0,
14125        argTypes: props.argTypes,
14126        greediness: 1,
14127        allowedInText: !!props.allowedInText,
14128        numOptionalArgs: props.numOptionalArgs || 0,
14129        handler: handler
14130    };
14131    for (var i = 0; i < names.length; ++i) {
14132        module.exports[names[i]] = data;
14133    }
14134}
14135
14136// Arrays are part of LaTeX, defined in lttab.dtx so its documentation
14137// is part of the source2e.pdf file of LaTeX2e source documentation.
14138defineEnvironment("array", {
14139    numArgs: 1
14140}, function(context, args) {
14141    var colalign = args[0];
14142    colalign = colalign.value.map ? colalign.value : [colalign];
14143    var cols = colalign.map(function(node) {
14144        var ca = node.value;
14145        if ("lcr".indexOf(ca) !== -1) {
14146            return {
14147                type: "align",
14148                align: ca
14149            };
14150        } else if (ca === "|") {
14151            return {
14152                type: "separator",
14153                separator: "|"
14154            };
14155        }
14156        throw new ParseError(
14157            "Unknown column alignment: " + node.value,
14158            node);
14159    });
14160    var res = {
14161        type: "array",
14162        cols: cols,
14163        hskipBeforeAndAfter: true // \@preamble in lttab.dtx
14164    };
14165    res = parseArray(context.parser, res);
14166    return res;
14167});
14168
14169// The matrix environments of amsmath builds on the array environment
14170// of LaTeX, which is discussed above.
14171defineEnvironment([
14172    "matrix",
14173    "pmatrix",
14174    "bmatrix",
14175    "Bmatrix",
14176    "vmatrix",
14177    "Vmatrix"
14178], {
14179}, function(context) {
14180    var delimiters = {
14181        "matrix": null,
14182        "pmatrix": ["(", ")"],
14183        "bmatrix": ["[", "]"],
14184        "Bmatrix": ["\\{", "\\}"],
14185        "vmatrix": ["|", "|"],
14186        "Vmatrix": ["\\Vert", "\\Vert"]
14187    }[context.envName];
14188    var res = {
14189        type: "array",
14190        hskipBeforeAndAfter: false // \hskip -\arraycolsep in amsmath
14191    };
14192    res = parseArray(context.parser, res);
14193    if (delimiters) {
14194        res = new ParseNode("leftright", {
14195            body: [res],
14196            left: delimiters[0],
14197            right: delimiters[1]
14198        }, context.mode);
14199    }
14200    return res;
14201});
14202
14203// A cases environment (in amsmath.sty) is almost equivalent to
14204// \def\arraystretch{1.2}%
14205// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
14206defineEnvironment("cases", {
14207}, function(context) {
14208    var res = {
14209        type: "array",
14210        arraystretch: 1.2,
14211        cols: [{
14212            type: "align",
14213            align: "l",
14214            pregap: 0,
14215            // TODO(kevinb) get the current style.
14216            // For now we use the metrics for TEXT style which is what we were
14217            // doing before.  Before attempting to get the current style we
14218            // should look at TeX's behavior especially for \over and matrices.
14219            postgap: Style.TEXT.metrics.quad
14220        }, {
14221            type: "align",
14222            align: "l",
14223            pregap: 0,
14224            postgap: 0
14225        }]
14226    };
14227    res = parseArray(context.parser, res);
14228    res = new ParseNode("leftright", {
14229        body: [res],
14230        left: "\\{",
14231        right: "."
14232    }, context.mode);
14233    return res;
14234});
14235
14236// An aligned environment is like the align* environment
14237// except it operates within math mode.
14238// Note that we assume \nomallineskiplimit to be zero,
14239// so that \strut@ is the same as \strut.
14240defineEnvironment("aligned", {
14241}, function(context) {
14242    var res = {
14243        type: "array",
14244        cols: []
14245    };
14246    res = parseArray(context.parser, res);
14247    var emptyGroup = new ParseNode("ordgroup", [], context.mode);
14248    var numCols = 0;
14249    res.value.body.forEach(function(row) {
14250        var i;
14251        for (i = 1; i < row.length; i += 2) {
14252            row[i].value.unshift(emptyGroup);
14253        }
14254        if (numCols < row.length) {
14255            numCols = row.length;
14256        }
14257    });
14258    for (var i = 0; i < numCols; ++i) {
14259        var align = "r";
14260        var pregap = 0;
14261        if (i % 2 === 1) {
14262            align = "l";
14263        } else if (i > 0) {
14264            pregap = 2; // one \qquad between columns
14265        }
14266        res.value.cols[i] = {
14267            type: "align",
14268            align: align,
14269            pregap: pregap,
14270            postgap: 0
14271        };
14272    }
14273    return res;
14274});
14275});
14276
14277/** @flow */
14278
14279function getRelocatable(re) {
14280  // In the future, this could use a WeakMap instead of an expando.
14281  if (!re.__matchAtRelocatable) {
14282    // Disjunctions are the lowest-precedence operator, so we can make any
14283    // pattern match the empty string by appending `|()` to it:
14284    // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-patterns
14285    var source = re.source + "|()";
14286
14287    // We always make the new regex global.
14288    var flags = "g" + (re.ignoreCase ? "i" : "") + (re.multiline ? "m" : "") + (re.unicode ? "u" : "");
14289
14290    re.__matchAtRelocatable = new RegExp(source, flags);
14291  }
14292  return re.__matchAtRelocatable;
14293}
14294
14295function matchAt$1(re, str, pos) {
14296  if (re.global || re.sticky) {
14297    throw new Error("matchAt(...): Only non-global regexes are supported");
14298  }
14299  var reloc = getRelocatable(re);
14300  reloc.lastIndex = pos;
14301  var match = reloc.exec(str);
14302  // Last capturing group is our sentinel that indicates whether the regex
14303  // matched at the given location.
14304  if (match[match.length - 1] == null) {
14305    // Original regex matched.
14306    match.length = match.length - 1;
14307    return match;
14308  } else {
14309    return null;
14310  }
14311}
14312
14313var matchAt_1 = matchAt$1;
14314
14315/**
14316 * The Lexer class handles tokenizing the input in various ways. Since our
14317 * parser expects us to be able to backtrack, the lexer allows lexing from any
14318 * given starting point.
14319 *
14320 * Its main exposed function is the `lex` function, which takes a position to
14321 * lex from and a type of token to lex. It defers to the appropriate `_innerLex`
14322 * function.
14323 *
14324 * The various `_innerLex` functions perform the actual lexing of different
14325 * kinds.
14326 */
14327
14328var matchAt = matchAt_1;
14329
14330var ParseError$6 = ParseError_1;
14331
14332// The main lexer class
14333function Lexer$1(input) {
14334    this.input = input;
14335    this.pos = 0;
14336}
14337
14338/**
14339 * The resulting token returned from `lex`.
14340 *
14341 * It consists of the token text plus some position information.
14342 * The position information is essentially a range in an input string,
14343 * but instead of referencing the bare input string, we refer to the lexer.
14344 * That way it is possible to attach extra metadata to the input string,
14345 * like for example a file name or similar.
14346 *
14347 * The position information (all three parameters) is optional,
14348 * so it is OK to construct synthetic tokens if appropriate.
14349 * Not providing available position information may lead to
14350 * degraded error reporting, though.
14351 *
14352 * @param {string}  text   the text of this token
14353 * @param {number=} start  the start offset, zero-based inclusive
14354 * @param {number=} end    the end offset, zero-based exclusive
14355 * @param {Lexer=}  lexer  the lexer which in turn holds the input string
14356 */
14357function Token(text, start, end, lexer) {
14358    this.text = text;
14359    this.start = start;
14360    this.end = end;
14361    this.lexer = lexer;
14362}
14363
14364/**
14365 * Given a pair of tokens (this and endToken), compute a “Token” encompassing
14366 * the whole input range enclosed by these two.
14367 *
14368 * @param {Token}  endToken  last token of the range, inclusive
14369 * @param {string} text      the text of the newly constructed token
14370 */
14371Token.prototype.range = function(endToken, text) {
14372    if (endToken.lexer !== this.lexer) {
14373        return new Token(text); // sorry, no position information available
14374    }
14375    return new Token(text, this.start, endToken.end, this.lexer);
14376};
14377
14378/* The following tokenRegex
14379 * - matches typical whitespace (but not NBSP etc.) using its first group
14380 * - does not match any control character \x00-\x1f except whitespace
14381 * - does not match a bare backslash
14382 * - matches any ASCII character except those just mentioned
14383 * - does not match the BMP private use area \uE000-\uF8FF
14384 * - does not match bare surrogate code units
14385 * - matches any BMP character except for those just described
14386 * - matches any valid Unicode surrogate pair
14387 * - matches a backslash followed by one or more letters
14388 * - matches a backslash followed by any BMP character, including newline
14389 * Just because the Lexer matches something doesn't mean it's valid input:
14390 * If there is no matching function or symbol definition, the Parser will
14391 * still reject the input.
14392 */
14393var tokenRegex = new RegExp(
14394    "([ \r\n\t]+)|" +                                 // whitespace
14395    "([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" +  // single codepoint
14396    "|[\uD800-\uDBFF][\uDC00-\uDFFF]" +               // surrogate pair
14397    "|\\\\(?:[a-zA-Z]+|[^\uD800-\uDFFF])" +           // function name
14398    ")"
14399);
14400
14401/**
14402 * This function lexes a single token.
14403 */
14404Lexer$1.prototype.lex = function() {
14405    var input = this.input;
14406    var pos = this.pos;
14407    if (pos === input.length) {
14408        return new Token("EOF", pos, pos, this);
14409    }
14410    var match = matchAt(tokenRegex, input, pos);
14411    if (match === null) {
14412        throw new ParseError$6(
14413            "Unexpected character: '" + input[pos] + "'",
14414            new Token(input[pos], pos, pos + 1, this));
14415    }
14416    var text = match[2] || " ";
14417    var start = this.pos;
14418    this.pos += match[0].length;
14419    var end = this.pos;
14420    return new Token(text, start, end, this);
14421};
14422
14423var Lexer_1 = Lexer$1;
14424
14425/**
14426 * This file contains the “gullet” where macros are expanded
14427 * until only non-macro tokens remain.
14428 */
14429
14430var Lexer = Lexer_1;
14431
14432function MacroExpander$1(input, macros) {
14433    this.lexer = new Lexer(input);
14434    this.macros = macros;
14435    this.stack = []; // contains tokens in REVERSE order
14436    this.discardedWhiteSpace = [];
14437}
14438
14439/**
14440 * Recursively expand first token, then return first non-expandable token.
14441 */
14442MacroExpander$1.prototype.nextToken = function() {
14443    var this$1 = this;
14444
14445    for (;;) {
14446        if (this$1.stack.length === 0) {
14447            this$1.stack.push(this$1.lexer.lex());
14448        }
14449        var topToken = this$1.stack.pop();
14450        var name = topToken.text;
14451        if (!(name.charAt(0) === "\\" && this$1.macros.hasOwnProperty(name))) {
14452            return topToken;
14453        }
14454        var expansion = this$1.macros[name];
14455        if (typeof expansion === "string") {
14456            var bodyLexer = new Lexer(expansion);
14457            expansion = [];
14458            var tok = bodyLexer.lex();
14459            while (tok.text !== "EOF") {
14460                expansion.push(tok);
14461                tok = bodyLexer.lex();
14462            }
14463            expansion.reverse(); // to fit in with stack using push and pop
14464            this$1.macros[name] = expansion;
14465        }
14466        this$1.stack = this$1.stack.concat(expansion);
14467    }
14468};
14469
14470MacroExpander$1.prototype.get = function(ignoreSpace) {
14471    var this$1 = this;
14472
14473    this.discardedWhiteSpace = [];
14474    var token = this.nextToken();
14475    if (ignoreSpace) {
14476        while (token.text === " ") {
14477            this$1.discardedWhiteSpace.push(token);
14478            token = this$1.nextToken();
14479        }
14480    }
14481    return token;
14482};
14483
14484/**
14485 * Undo the effect of the preceding call to the get method.
14486 * A call to this method MUST be immediately preceded and immediately followed
14487 * by a call to get.  Only used during mode switching, i.e. after one token
14488 * was got in the old mode but should get got again in a new mode
14489 * with possibly different whitespace handling.
14490 */
14491MacroExpander$1.prototype.unget = function(token) {
14492    var this$1 = this;
14493
14494    this.stack.push(token);
14495    while (this.discardedWhiteSpace.length !== 0) {
14496        this$1.stack.push(this$1.discardedWhiteSpace.pop());
14497    }
14498};
14499
14500var MacroExpander_1 = MacroExpander$1;
14501
14502/* eslint no-constant-condition:0 */
14503var functions = functions$1;
14504var environments = environments$1;
14505var MacroExpander = MacroExpander_1;
14506var symbols$5 = symbols$1;
14507var utils$9 = utils$4;
14508var cjkRegex$2 = unicodeRegexes.cjkRegex;
14509
14510var parseData = parseData$1;
14511var ParseError$5 = ParseError_1;
14512
14513/**
14514 * This file contains the parser used to parse out a TeX expression from the
14515 * input. Since TeX isn't context-free, standard parsers don't work particularly
14516 * well.
14517 *
14518 * The strategy of this parser is as such:
14519 *
14520 * The main functions (the `.parse...` ones) take a position in the current
14521 * parse string to parse tokens from. The lexer (found in Lexer.js, stored at
14522 * this.lexer) also supports pulling out tokens at arbitrary places. When
14523 * individual tokens are needed at a position, the lexer is called to pull out a
14524 * token, which is then used.
14525 *
14526 * The parser has a property called "mode" indicating the mode that
14527 * the parser is currently in. Currently it has to be one of "math" or
14528 * "text", which denotes whether the current environment is a math-y
14529 * one or a text-y one (e.g. inside \text). Currently, this serves to
14530 * limit the functions which can be used in text mode.
14531 *
14532 * The main functions then return an object which contains the useful data that
14533 * was parsed at its given point, and a new position at the end of the parsed
14534 * data. The main functions can call each other and continue the parsing by
14535 * using the returned position as a new starting point.
14536 *
14537 * There are also extra `.handle...` functions, which pull out some reused
14538 * functionality into self-contained functions.
14539 *
14540 * The earlier functions return ParseNodes.
14541 * The later functions (which are called deeper in the parse) sometimes return
14542 * ParseFuncOrArgument, which contain a ParseNode as well as some data about
14543 * whether the parsed object is a function which is missing some arguments, or a
14544 * standalone object which can be used as an argument to another function.
14545 */
14546
14547/**
14548 * Main Parser class
14549 */
14550function Parser$1(input, settings) {
14551    // Create a new macro expander (gullet) and (indirectly via that) also a
14552    // new lexer (mouth) for this parser (stomach, in the language of TeX)
14553    this.gullet = new MacroExpander(input, settings.macros);
14554    // Store the settings for use in parsing
14555    this.settings = settings;
14556    // Count leftright depth (for \middle errors)
14557    this.leftrightDepth = 0;
14558}
14559
14560var ParseNode = parseData.ParseNode;
14561
14562/**
14563 * An initial function (without its arguments), or an argument to a function.
14564 * The `result` argument should be a ParseNode.
14565 */
14566function ParseFuncOrArgument(result, isFunction, token) {
14567    this.result = result;
14568    // Is this a function (i.e. is it something defined in functions.js)?
14569    this.isFunction = isFunction;
14570    this.token = token;
14571}
14572
14573/**
14574 * Checks a result to make sure it has the right type, and throws an
14575 * appropriate error otherwise.
14576 *
14577 * @param {boolean=} consume whether to consume the expected token,
14578 *                           defaults to true
14579 */
14580Parser$1.prototype.expect = function(text, consume) {
14581    if (this.nextToken.text !== text) {
14582        throw new ParseError$5(
14583            "Expected '" + text + "', got '" + this.nextToken.text + "'",
14584            this.nextToken
14585        );
14586    }
14587    if (consume !== false) {
14588        this.consume();
14589    }
14590};
14591
14592/**
14593 * Considers the current look ahead token as consumed,
14594 * and fetches the one after that as the new look ahead.
14595 */
14596Parser$1.prototype.consume = function() {
14597    this.nextToken = this.gullet.get(this.mode === "math");
14598};
14599
14600Parser$1.prototype.switchMode = function(newMode) {
14601    this.gullet.unget(this.nextToken);
14602    this.mode = newMode;
14603    this.consume();
14604};
14605
14606/**
14607 * Main parsing function, which parses an entire input.
14608 *
14609 * @return {?Array.<ParseNode>}
14610 */
14611Parser$1.prototype.parse = function() {
14612    // Try to parse the input
14613    this.mode = "math";
14614    this.consume();
14615    var parse = this.parseInput();
14616    return parse;
14617};
14618
14619/**
14620 * Parses an entire input tree.
14621 */
14622Parser$1.prototype.parseInput = function() {
14623    // Parse an expression
14624    var expression = this.parseExpression(false);
14625    // If we succeeded, make sure there's an EOF at the end
14626    this.expect("EOF", false);
14627    return expression;
14628};
14629
14630var endOfExpression = ["}", "\\end", "\\right", "&", "\\\\", "\\cr"];
14631
14632/**
14633 * Parses an "expression", which is a list of atoms.
14634 *
14635 * @param {boolean} breakOnInfix  Should the parsing stop when we hit infix
14636 *                  nodes? This happens when functions have higher precendence
14637 *                  than infix nodes in implicit parses.
14638 *
14639 * @param {?string} breakOnTokenText  The text of the token that the expression
14640 *                  should end with, or `null` if something else should end the
14641 *                  expression.
14642 *
14643 * @return {ParseNode}
14644 */
14645Parser$1.prototype.parseExpression = function(breakOnInfix, breakOnTokenText) {
14646    var this$1 = this;
14647
14648    var body = [];
14649    // Keep adding atoms to the body until we can't parse any more atoms (either
14650    // we reached the end, a }, or a \right)
14651    while (true) {
14652        var lex = this$1.nextToken;
14653        if (endOfExpression.indexOf(lex.text) !== -1) {
14654            break;
14655        }
14656        if (breakOnTokenText && lex.text === breakOnTokenText) {
14657            break;
14658        }
14659        if (breakOnInfix && functions[lex.text] && functions[lex.text].infix) {
14660            break;
14661        }
14662        var atom = this$1.parseAtom();
14663        if (!atom) {
14664            if (!this$1.settings.throwOnError && lex.text[0] === "\\") {
14665                var errorNode = this$1.handleUnsupportedCmd();
14666                body.push(errorNode);
14667                continue;
14668            }
14669
14670            break;
14671        }
14672        body.push(atom);
14673    }
14674    return this.handleInfixNodes(body);
14675};
14676
14677/**
14678 * Rewrites infix operators such as \over with corresponding commands such
14679 * as \frac.
14680 *
14681 * There can only be one infix operator per group.  If there's more than one
14682 * then the expression is ambiguous.  This can be resolved by adding {}.
14683 *
14684 * @returns {Array}
14685 */
14686Parser$1.prototype.handleInfixNodes = function(body) {
14687    var overIndex = -1;
14688    var funcName;
14689
14690    for (var i = 0; i < body.length; i++) {
14691        var node = body[i];
14692        if (node.type === "infix") {
14693            if (overIndex !== -1) {
14694                throw new ParseError$5(
14695                    "only one infix operator per group",
14696                    node.value.token);
14697            }
14698            overIndex = i;
14699            funcName = node.value.replaceWith;
14700        }
14701    }
14702
14703    if (overIndex !== -1) {
14704        var numerNode;
14705        var denomNode;
14706
14707        var numerBody = body.slice(0, overIndex);
14708        var denomBody = body.slice(overIndex + 1);
14709
14710        if (numerBody.length === 1 && numerBody[0].type === "ordgroup") {
14711            numerNode = numerBody[0];
14712        } else {
14713            numerNode = new ParseNode("ordgroup", numerBody, this.mode);
14714        }
14715
14716        if (denomBody.length === 1 && denomBody[0].type === "ordgroup") {
14717            denomNode = denomBody[0];
14718        } else {
14719            denomNode = new ParseNode("ordgroup", denomBody, this.mode);
14720        }
14721
14722        var value = this.callFunction(
14723            funcName, [numerNode, denomNode], null);
14724        return [new ParseNode(value.type, value, this.mode)];
14725    } else {
14726        return body;
14727    }
14728};
14729
14730// The greediness of a superscript or subscript
14731var SUPSUB_GREEDINESS = 1;
14732
14733/**
14734 * Handle a subscript or superscript with nice errors.
14735 */
14736Parser$1.prototype.handleSupSubscript = function(name) {
14737    var symbolToken = this.nextToken;
14738    var symbol = symbolToken.text;
14739    this.consume();
14740    var group = this.parseGroup();
14741
14742    if (!group) {
14743        if (!this.settings.throwOnError && this.nextToken.text[0] === "\\") {
14744            return this.handleUnsupportedCmd();
14745        } else {
14746            throw new ParseError$5(
14747                "Expected group after '" + symbol + "'",
14748                symbolToken
14749            );
14750        }
14751    } else if (group.isFunction) {
14752        // ^ and _ have a greediness, so handle interactions with functions'
14753        // greediness
14754        var funcGreediness = functions[group.result].greediness;
14755        if (funcGreediness > SUPSUB_GREEDINESS) {
14756            return this.parseFunction(group);
14757        } else {
14758            throw new ParseError$5(
14759                "Got function '" + group.result + "' with no arguments " +
14760                    "as " + name, symbolToken);
14761        }
14762    } else {
14763        return group.result;
14764    }
14765};
14766
14767/**
14768 * Converts the textual input of an unsupported command into a text node
14769 * contained within a color node whose color is determined by errorColor
14770 */
14771Parser$1.prototype.handleUnsupportedCmd = function() {
14772    var text = this.nextToken.text;
14773    var textordArray = [];
14774
14775    for (var i = 0; i < text.length; i++) {
14776        textordArray.push(new ParseNode("textord", text[i], "text"));
14777    }
14778
14779    var textNode = new ParseNode(
14780        "text",
14781        {
14782            body: textordArray,
14783            type: "text"
14784        },
14785        this.mode);
14786
14787    var colorNode = new ParseNode(
14788        "color",
14789        {
14790            color: this.settings.errorColor,
14791            value: [textNode],
14792            type: "color"
14793        },
14794        this.mode);
14795
14796    this.consume();
14797    return colorNode;
14798};
14799
14800/**
14801 * Parses a group with optional super/subscripts.
14802 *
14803 * @return {?ParseNode}
14804 */
14805Parser$1.prototype.parseAtom = function() {
14806    var this$1 = this;
14807
14808    // The body of an atom is an implicit group, so that things like
14809    // \left(x\right)^2 work correctly.
14810    var base = this.parseImplicitGroup();
14811
14812    // In text mode, we don't have superscripts or subscripts
14813    if (this.mode === "text") {
14814        return base;
14815    }
14816
14817    // Note that base may be empty (i.e. null) at this point.
14818
14819    var superscript;
14820    var subscript;
14821    while (true) {
14822        // Lex the first token
14823        var lex = this$1.nextToken;
14824
14825        if (lex.text === "\\limits" || lex.text === "\\nolimits") {
14826            // We got a limit control
14827            if (!base || base.type !== "op") {
14828                throw new ParseError$5(
14829                    "Limit controls must follow a math operator",
14830                    lex);
14831            } else {
14832                var limits = lex.text === "\\limits";
14833                base.value.limits = limits;
14834                base.value.alwaysHandleSupSub = true;
14835            }
14836            this$1.consume();
14837        } else if (lex.text === "^") {
14838            // We got a superscript start
14839            if (superscript) {
14840                throw new ParseError$5("Double superscript", lex);
14841            }
14842            superscript = this$1.handleSupSubscript("superscript");
14843        } else if (lex.text === "_") {
14844            // We got a subscript start
14845            if (subscript) {
14846                throw new ParseError$5("Double subscript", lex);
14847            }
14848            subscript = this$1.handleSupSubscript("subscript");
14849        } else if (lex.text === "'") {
14850            // We got a prime
14851            var prime = new ParseNode("textord", "\\prime", this$1.mode);
14852
14853            // Many primes can be grouped together, so we handle this here
14854            var primes = [prime];
14855            this$1.consume();
14856            // Keep lexing tokens until we get something that's not a prime
14857            while (this.nextToken.text === "'") {
14858                // For each one, add another prime to the list
14859                primes.push(prime);
14860                this$1.consume();
14861            }
14862            // Put them into an ordgroup as the superscript
14863            superscript = new ParseNode("ordgroup", primes, this$1.mode);
14864        } else {
14865            // If it wasn't ^, _, or ', stop parsing super/subscripts
14866            break;
14867        }
14868    }
14869
14870    if (superscript || subscript) {
14871        // If we got either a superscript or subscript, create a supsub
14872        return new ParseNode("supsub", {
14873            base: base,
14874            sup: superscript,
14875            sub: subscript
14876        }, this.mode);
14877    } else {
14878        // Otherwise return the original body
14879        return base;
14880    }
14881};
14882
14883// A list of the size-changing functions, for use in parseImplicitGroup
14884var sizeFuncs = [
14885    "\\tiny", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize",
14886    "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"
14887];
14888
14889// A list of the style-changing functions, for use in parseImplicitGroup
14890var styleFuncs = [
14891    "\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"
14892];
14893
14894/**
14895 * Parses an implicit group, which is a group that starts at the end of a
14896 * specified, and ends right before a higher explicit group ends, or at EOL. It
14897 * is used for functions that appear to affect the current style, like \Large or
14898 * \textrm, where instead of keeping a style we just pretend that there is an
14899 * implicit grouping after it until the end of the group. E.g.
14900 *   small text {\Large large text} small text again
14901 * It is also used for \left and \right to get the correct grouping.
14902 *
14903 * @return {?ParseNode}
14904 */
14905Parser$1.prototype.parseImplicitGroup = function() {
14906    var start = this.parseSymbol();
14907
14908    if (start == null) {
14909        // If we didn't get anything we handle, fall back to parseFunction
14910        return this.parseFunction();
14911    }
14912
14913    var func = start.result;
14914    var body;
14915
14916    if (func === "\\left") {
14917        // If we see a left:
14918        // Parse the entire left function (including the delimiter)
14919        var left = this.parseFunction(start);
14920        // Parse out the implicit body
14921        ++this.leftrightDepth;
14922        body = this.parseExpression(false);
14923        --this.leftrightDepth;
14924        // Check the next token
14925        this.expect("\\right", false);
14926        var right = this.parseFunction();
14927        return new ParseNode("leftright", {
14928            body: body,
14929            left: left.value.value,
14930            right: right.value.value
14931        }, this.mode);
14932    } else if (func === "\\begin") {
14933        // begin...end is similar to left...right
14934        var begin = this.parseFunction(start);
14935        var envName = begin.value.name;
14936        if (!environments.hasOwnProperty(envName)) {
14937            throw new ParseError$5(
14938                "No such environment: " + envName, begin.value.nameGroup);
14939        }
14940        // Build the environment object. Arguments and other information will
14941        // be made available to the begin and end methods using properties.
14942        var env = environments[envName];
14943        var args = this.parseArguments("\\begin{" + envName + "}", env);
14944        var context = {
14945            mode: this.mode,
14946            envName: envName,
14947            parser: this,
14948            positions: args.pop()
14949        };
14950        var result = env.handler(context, args);
14951        this.expect("\\end", false);
14952        var endNameToken = this.nextToken;
14953        var end = this.parseFunction();
14954        if (end.value.name !== envName) {
14955            throw new ParseError$5(
14956                "Mismatch: \\begin{" + envName + "} matched " +
14957                "by \\end{" + end.value.name + "}",
14958                endNameToken);
14959        }
14960        result.position = end.position;
14961        return result;
14962    } else if (utils$9.contains(sizeFuncs, func)) {
14963        // If we see a sizing function, parse out the implict body
14964        body = this.parseExpression(false);
14965        return new ParseNode("sizing", {
14966            // Figure out what size to use based on the list of functions above
14967            size: "size" + (utils$9.indexOf(sizeFuncs, func) + 1),
14968            value: body
14969        }, this.mode);
14970    } else if (utils$9.contains(styleFuncs, func)) {
14971        // If we see a styling function, parse out the implict body
14972        body = this.parseExpression(true);
14973        return new ParseNode("styling", {
14974            // Figure out what style to use by pulling out the style from
14975            // the function name
14976            style: func.slice(1, func.length - 5),
14977            value: body
14978        }, this.mode);
14979    } else {
14980        // Defer to parseFunction if it's not a function we handle
14981        return this.parseFunction(start);
14982    }
14983};
14984
14985/**
14986 * Parses an entire function, including its base and all of its arguments.
14987 * The base might either have been parsed already, in which case
14988 * it is provided as an argument, or it's the next group in the input.
14989 *
14990 * @param {ParseFuncOrArgument=} baseGroup optional as described above
14991 * @return {?ParseNode}
14992 */
14993Parser$1.prototype.parseFunction = function(baseGroup) {
14994    if (!baseGroup) {
14995        baseGroup = this.parseGroup();
14996    }
14997
14998    if (baseGroup) {
14999        if (baseGroup.isFunction) {
15000            var func = baseGroup.result;
15001            var funcData = functions[func];
15002            if (this.mode === "text" && !funcData.allowedInText) {
15003                throw new ParseError$5(
15004                    "Can't use function '" + func + "' in text mode",
15005                    baseGroup.token);
15006            }
15007
15008            var args = this.parseArguments(func, funcData);
15009            var token = baseGroup.token;
15010            var result = this.callFunction(func, args, args.pop(), token);
15011            return new ParseNode(result.type, result, this.mode);
15012        } else {
15013            return baseGroup.result;
15014        }
15015    } else {
15016        return null;
15017    }
15018};
15019
15020/**
15021 * Call a function handler with a suitable context and arguments.
15022 */
15023Parser$1.prototype.callFunction = function(name, args, positions, token) {
15024    var context = {
15025        funcName: name,
15026        parser: this,
15027        positions: positions,
15028        token: token
15029    };
15030    return functions[name].handler(context, args);
15031};
15032
15033/**
15034 * Parses the arguments of a function or environment
15035 *
15036 * @param {string} func  "\name" or "\begin{name}"
15037 * @param {{numArgs:number,numOptionalArgs:number|undefined}} funcData
15038 * @return the array of arguments, with the list of positions as last element
15039 */
15040Parser$1.prototype.parseArguments = function(func, funcData) {
15041    var this$1 = this;
15042
15043    var totalArgs = funcData.numArgs + funcData.numOptionalArgs;
15044    if (totalArgs === 0) {
15045        return [[this.pos]];
15046    }
15047
15048    var baseGreediness = funcData.greediness;
15049    var positions = [this.pos];
15050    var args = [];
15051
15052    for (var i = 0; i < totalArgs; i++) {
15053        var nextToken = this$1.nextToken;
15054        var argType = funcData.argTypes && funcData.argTypes[i];
15055        var arg;
15056        if (i < funcData.numOptionalArgs) {
15057            if (argType) {
15058                arg = this$1.parseGroupOfType(argType, true);
15059            } else {
15060                arg = this$1.parseGroup(true);
15061            }
15062            if (!arg) {
15063                args.push(null);
15064                positions.push(this$1.pos);
15065                continue;
15066            }
15067        } else {
15068            if (argType) {
15069                arg = this$1.parseGroupOfType(argType);
15070            } else {
15071                arg = this$1.parseGroup();
15072            }
15073            if (!arg) {
15074                if (!this$1.settings.throwOnError &&
15075                    this$1.nextToken.text[0] === "\\") {
15076                    arg = new ParseFuncOrArgument(
15077                        this$1.handleUnsupportedCmd(this$1.nextToken.text),
15078                        false);
15079                } else {
15080                    throw new ParseError$5(
15081                        "Expected group after '" + func + "'", nextToken);
15082                }
15083            }
15084        }
15085        var argNode;
15086        if (arg.isFunction) {
15087            var argGreediness =
15088                functions[arg.result].greediness;
15089            if (argGreediness > baseGreediness) {
15090                argNode = this$1.parseFunction(arg);
15091            } else {
15092                throw new ParseError$5(
15093                    "Got function '" + arg.result + "' as " +
15094                    "argument to '" + func + "'", nextToken);
15095            }
15096        } else {
15097            argNode = arg.result;
15098        }
15099        args.push(argNode);
15100        positions.push(this$1.pos);
15101    }
15102
15103    args.push(positions);
15104
15105    return args;
15106};
15107
15108
15109/**
15110 * Parses a group when the mode is changing.
15111 *
15112 * @return {?ParseFuncOrArgument}
15113 */
15114Parser$1.prototype.parseGroupOfType = function(innerMode, optional) {
15115    var this$1 = this;
15116
15117    var outerMode = this.mode;
15118    // Handle `original` argTypes
15119    if (innerMode === "original") {
15120        innerMode = outerMode;
15121    }
15122
15123    if (innerMode === "color") {
15124        return this.parseColorGroup(optional);
15125    }
15126    if (innerMode === "size") {
15127        return this.parseSizeGroup(optional);
15128    }
15129
15130    this.switchMode(innerMode);
15131    if (innerMode === "text") {
15132        // text mode is special because it should ignore the whitespace before
15133        // it
15134        while (this.nextToken.text === " ") {
15135            this$1.consume();
15136        }
15137    }
15138    // By the time we get here, innerMode is one of "text" or "math".
15139    // We switch the mode of the parser, recurse, then restore the old mode.
15140    var res = this.parseGroup(optional);
15141    this.switchMode(outerMode);
15142    return res;
15143};
15144
15145/**
15146 * Parses a group, essentially returning the string formed by the
15147 * brace-enclosed tokens plus some position information.
15148 *
15149 * @param {string} modeName  Used to describe the mode in error messages
15150 * @param {boolean=} optional  Whether the group is optional or required
15151 */
15152Parser$1.prototype.parseStringGroup = function(modeName, optional) {
15153    var this$1 = this;
15154
15155    if (optional && this.nextToken.text !== "[") {
15156        return null;
15157    }
15158    var outerMode = this.mode;
15159    this.mode = "text";
15160    this.expect(optional ? "[" : "{");
15161    var str = "";
15162    var firstToken = this.nextToken;
15163    var lastToken = firstToken;
15164    while (this.nextToken.text !== (optional ? "]" : "}")) {
15165        if (this$1.nextToken.text === "EOF") {
15166            throw new ParseError$5(
15167                "Unexpected end of input in " + modeName,
15168                firstToken.range(this$1.nextToken, str));
15169        }
15170        lastToken = this$1.nextToken;
15171        str += lastToken.text;
15172        this$1.consume();
15173    }
15174    this.mode = outerMode;
15175    this.expect(optional ? "]" : "}");
15176    return firstToken.range(lastToken, str);
15177};
15178
15179/**
15180 * Parses a regex-delimited group: the largest sequence of tokens
15181 * whose concatenated strings match `regex`. Returns the string
15182 * formed by the tokens plus some position information.
15183 *
15184 * @param {RegExp} regex
15185 * @param {string} modeName  Used to describe the mode in error messages
15186 */
15187Parser$1.prototype.parseRegexGroup = function(regex, modeName) {
15188    var this$1 = this;
15189
15190    var outerMode = this.mode;
15191    this.mode = "text";
15192    var firstToken = this.nextToken;
15193    var lastToken = firstToken;
15194    var str = "";
15195    while (this.nextToken.text !== "EOF"
15196           && regex.test(str + this.nextToken.text)) {
15197        lastToken = this$1.nextToken;
15198        str += lastToken.text;
15199        this$1.consume();
15200    }
15201    if (str === "") {
15202        throw new ParseError$5(
15203            "Invalid " + modeName + ": '" + firstToken.text + "'",
15204            firstToken);
15205    }
15206    this.mode = outerMode;
15207    return firstToken.range(lastToken, str);
15208};
15209
15210/**
15211 * Parses a color description.
15212 */
15213Parser$1.prototype.parseColorGroup = function(optional) {
15214    var res = this.parseStringGroup("color", optional);
15215    if (!res) {
15216        return null;
15217    }
15218    var match = (/^(#[a-z0-9]+|[a-z]+)$/i).exec(res.text);
15219    if (!match) {
15220        throw new ParseError$5("Invalid color: '" + res.text + "'", res);
15221    }
15222    return new ParseFuncOrArgument(
15223        new ParseNode("color", match[0], this.mode),
15224        false);
15225};
15226
15227/**
15228 * Parses a size specification, consisting of magnitude and unit.
15229 */
15230Parser$1.prototype.parseSizeGroup = function(optional) {
15231    var res;
15232    if (!optional && this.nextToken.text !== "{") {
15233        res = this.parseRegexGroup(
15234            /^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2}$/, "size");
15235    } else {
15236        res = this.parseStringGroup("size", optional);
15237    }
15238    if (!res) {
15239        return null;
15240    }
15241    var match = (/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/).exec(res.text);
15242    if (!match) {
15243        throw new ParseError$5("Invalid size: '" + res.text + "'", res);
15244    }
15245    var data = {
15246        number: +(match[1] + match[2]), // sign + magnitude, cast to number
15247        unit: match[3]
15248    };
15249    if (data.unit !== "em" && data.unit !== "ex" && data.unit !== "mu") {
15250        throw new ParseError$5("Invalid unit: '" + data.unit + "'", res);
15251    }
15252    return new ParseFuncOrArgument(
15253        new ParseNode("color", data, this.mode),
15254        false);
15255};
15256
15257/**
15258 * If the argument is false or absent, this parses an ordinary group,
15259 * which is either a single nucleus (like "x") or an expression
15260 * in braces (like "{x+y}").
15261 * If the argument is true, it parses either a bracket-delimited expression
15262 * (like "[x+y]") or returns null to indicate the absence of a
15263 * bracket-enclosed group.
15264 *
15265 * @param {boolean=} optional  Whether the group is optional or required
15266 * @return {?ParseFuncOrArgument}
15267 */
15268Parser$1.prototype.parseGroup = function(optional) {
15269    var firstToken = this.nextToken;
15270    // Try to parse an open brace
15271    if (this.nextToken.text === (optional ? "[" : "{")) {
15272        // If we get a brace, parse an expression
15273        this.consume();
15274        var expression = this.parseExpression(false, optional ? "]" : null);
15275        var lastToken = this.nextToken;
15276        // Make sure we get a close brace
15277        this.expect(optional ? "]" : "}");
15278        if (this.mode === "text") {
15279            this.formLigatures(expression);
15280        }
15281        return new ParseFuncOrArgument(
15282            new ParseNode("ordgroup", expression, this.mode,
15283                          firstToken, lastToken),
15284            false);
15285    } else {
15286        // Otherwise, just return a nucleus, or nothing for an optional group
15287        return optional ? null : this.parseSymbol();
15288    }
15289};
15290
15291/**
15292 * Form ligature-like combinations of characters for text mode.
15293 * This includes inputs like "--", "---", "``" and "''".
15294 * The result will simply replace multiple textord nodes with a single
15295 * character in each value by a single textord node having multiple
15296 * characters in its value.  The representation is still ASCII source.
15297 *
15298 * @param {Array.<ParseNode>} group  the nodes of this group,
15299 *                                   list will be moified in place
15300 */
15301Parser$1.prototype.formLigatures = function(group) {
15302    var i;
15303    var n = group.length - 1;
15304    for (i = 0; i < n; ++i) {
15305        var a = group[i];
15306        var v = a.value;
15307        if (v === "-" && group[i + 1].value === "-") {
15308            if (i + 1 < n && group[i + 2].value === "-") {
15309                group.splice(i, 3, new ParseNode(
15310                    "textord", "---", "text", a, group[i + 2]));
15311                n -= 2;
15312            } else {
15313                group.splice(i, 2, new ParseNode(
15314                    "textord", "--", "text", a, group[i + 1]));
15315                n -= 1;
15316            }
15317        }
15318        if ((v === "'" || v === "`") && group[i + 1].value === v) {
15319            group.splice(i, 2, new ParseNode(
15320                "textord", v + v, "text", a, group[i + 1]));
15321            n -= 1;
15322        }
15323    }
15324};
15325
15326/**
15327 * Parse a single symbol out of the string. Here, we handle both the functions
15328 * we have defined, as well as the single character symbols
15329 *
15330 * @return {?ParseFuncOrArgument}
15331 */
15332Parser$1.prototype.parseSymbol = function() {
15333    var nucleus = this.nextToken;
15334
15335    if (functions[nucleus.text]) {
15336        this.consume();
15337        // If there exists a function with this name, we return the function and
15338        // say that it is a function.
15339        return new ParseFuncOrArgument(
15340            nucleus.text,
15341            true, nucleus);
15342    } else if (symbols$5[this.mode][nucleus.text]) {
15343        this.consume();
15344        // Otherwise if this is a no-argument function, find the type it
15345        // corresponds to in the symbols map
15346        return new ParseFuncOrArgument(
15347            new ParseNode(symbols$5[this.mode][nucleus.text].group,
15348                          nucleus.text, this.mode, nucleus),
15349            false, nucleus);
15350    } else if (this.mode === "text" && cjkRegex$2.test(nucleus.text)) {
15351        this.consume();
15352        return new ParseFuncOrArgument(
15353            new ParseNode("textord", nucleus.text, this.mode, nucleus),
15354            false, nucleus);
15355    } else {
15356        return null;
15357    }
15358};
15359
15360Parser$1.prototype.ParseNode = ParseNode;
15361
15362var Parser_1 = Parser$1;
15363
15364/**
15365 * Provides a single function for parsing an expression using a Parser
15366 * TODO(emily): Remove this
15367 */
15368
15369var Parser = Parser_1;
15370
15371/**
15372 * Parses an expression using a Parser, then returns the parsed result.
15373 */
15374var parseTree$1 = function(toParse, settings) {
15375    if (!(typeof toParse === 'string' || toParse instanceof String)) {
15376        throw new TypeError('KaTeX can only parse string typed expression');
15377    }
15378    var parser = new Parser(toParse, settings);
15379
15380    return parser.parse();
15381};
15382
15383var parseTree_1 = parseTree$1;
15384
15385/* eslint no-console:0 */
15386/**
15387 * This is the main entry point for KaTeX. Here, we expose functions for
15388 * rendering expressions either to DOM nodes or to markup strings.
15389 *
15390 * We also expose the ParseError class to check if errors thrown from KaTeX are
15391 * errors in the expression, or errors in javascript handling.
15392 */
15393
15394var ParseError = ParseError_1;
15395var Settings = Settings_1;
15396
15397var buildTree = buildTree_1;
15398var parseTree = parseTree_1;
15399var utils = utils$4;
15400
15401/**
15402 * Parse and build an expression, and place that expression in the DOM node
15403 * given.
15404 */
15405var render$2 = function(expression, baseNode, options) {
15406    utils.clearNode(baseNode);
15407
15408    var settings = new Settings(options);
15409
15410    var tree = parseTree(expression, settings);
15411    var node = buildTree(tree, expression, settings).toNode();
15412
15413    baseNode.appendChild(node);
15414};
15415
15416// KaTeX's styles don't work properly in quirks mode. Print out an error, and
15417// disable rendering.
15418if (typeof document !== "undefined") {
15419    if (document.compatMode !== "CSS1Compat") {
15420        typeof console !== "undefined" && console.warn(
15421            "Warning: KaTeX doesn't work in quirks mode. Make sure your " +
15422                "website has a suitable doctype.");
15423
15424        render$2 = function() {
15425            throw new ParseError("KaTeX doesn't work in quirks mode.");
15426        };
15427    }
15428}
15429
15430/**
15431 * Parse and build an expression, and return the markup for that.
15432 */
15433var renderToString = function(expression, options) {
15434    var settings = new Settings(options);
15435
15436    var tree = parseTree(expression, settings);
15437    return buildTree(tree, expression, settings).toMarkup();
15438};
15439
15440/**
15441 * Parse an expression and return the parse tree.
15442 */
15443var generateParseTree = function(expression, options) {
15444    var settings = new Settings(options);
15445    return parseTree(expression, settings);
15446};
15447
15448var katex = {
15449    render: render$2,
15450    renderToString: renderToString,
15451    /**
15452     * NOTE: This method is not currently recommended for public use.
15453     * The internal tree representation is unstable and is very likely
15454     * to change. Use at your own risk.
15455     */
15456    __parse: generateParseTree,
15457    ParseError: ParseError
15458};
15459
15460var html$3 = "\n<style>\ndt-math[block] {\n  display: block;\n}\n</style>\n";
15461
15462var DTMath = function(dom, data) {
15463  var equationElements = [].slice.call(dom.querySelectorAll("dt-math"));
15464  equationElements.forEach(function (el) {
15465    var content = el.textContent;
15466    var displayMode = el.hasAttribute("block") ? true : false;
15467    el.innerHTML = html$3 + katex.renderToString(content, {displayMode: displayMode});
15468  });
15469};
15470
15471var marked = createCommonjsModule(function (module, exports) {
15472/**
15473 * marked - a markdown parser
15474 * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
15475 * https://github.com/chjj/marked
15476 */
15477
15478(function() {
15479
15480/**
15481 * Block-Level Grammar
15482 */
15483
15484var block = {
15485  newline: /^\n+/,
15486  code: /^( {4}[^\n]+\n*)+/,
15487  fences: noop,
15488  hr: /^( *[-*_]){3,} *(?:\n+|$)/,
15489  heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
15490  nptable: noop,
15491  lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
15492  blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
15493  list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
15494  html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
15495  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
15496  table: noop,
15497  paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
15498  text: /^[^\n]+/
15499};
15500
15501block.bullet = /(?:[*+-]|\d+\.)/;
15502block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
15503block.item = replace(block.item, 'gm')
15504  (/bull/g, block.bullet)
15505  ();
15506
15507block.list = replace(block.list)
15508  (/bull/g, block.bullet)
15509  ('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
15510  ('def', '\\n+(?=' + block.def.source + ')')
15511  ();
15512
15513block.blockquote = replace(block.blockquote)
15514  ('def', block.def)
15515  ();
15516
15517block._tag = '(?!(?:'
15518  + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
15519  + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
15520  + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
15521
15522block.html = replace(block.html)
15523  ('comment', /<!--[\s\S]*?-->/)
15524  ('closed', /<(tag)[\s\S]+?<\/\1>/)
15525  ('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
15526  (/tag/g, block._tag)
15527  ();
15528
15529block.paragraph = replace(block.paragraph)
15530  ('hr', block.hr)
15531  ('heading', block.heading)
15532  ('lheading', block.lheading)
15533  ('blockquote', block.blockquote)
15534  ('tag', '<' + block._tag)
15535  ('def', block.def)
15536  ();
15537
15538/**
15539 * Normal Block Grammar
15540 */
15541
15542block.normal = merge({}, block);
15543
15544/**
15545 * GFM Block Grammar
15546 */
15547
15548block.gfm = merge({}, block.normal, {
15549  fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
15550  paragraph: /^/,
15551  heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
15552});
15553
15554block.gfm.paragraph = replace(block.paragraph)
15555  ('(?!', '(?!'
15556    + block.gfm.fences.source.replace('\\1', '\\2') + '|'
15557    + block.list.source.replace('\\1', '\\3') + '|')
15558  ();
15559
15560/**
15561 * GFM + Tables Block Grammar
15562 */
15563
15564block.tables = merge({}, block.gfm, {
15565  nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
15566  table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
15567});
15568
15569/**
15570 * Block Lexer
15571 */
15572
15573function Lexer(options) {
15574  this.tokens = [];
15575  this.tokens.links = {};
15576  this.options = options || marked.defaults;
15577  this.rules = block.normal;
15578
15579  if (this.options.gfm) {
15580    if (this.options.tables) {
15581      this.rules = block.tables;
15582    } else {
15583      this.rules = block.gfm;
15584    }
15585  }
15586}
15587
15588/**
15589 * Expose Block Rules
15590 */
15591
15592Lexer.rules = block;
15593
15594/**
15595 * Static Lex Method
15596 */
15597
15598Lexer.lex = function(src, options) {
15599  var lexer = new Lexer(options);
15600  return lexer.lex(src);
15601};
15602
15603/**
15604 * Preprocessing
15605 */
15606
15607Lexer.prototype.lex = function(src) {
15608  src = src
15609    .replace(/\r\n|\r/g, '\n')
15610    .replace(/\t/g, '    ')
15611    .replace(/\u00a0/g, ' ')
15612    .replace(/\u2424/g, '\n');
15613
15614  return this.token(src, true);
15615};
15616
15617/**
15618 * Lexing
15619 */
15620
15621Lexer.prototype.token = function(src, top, bq) {
15622  var this$1 = this;
15623
15624  var src = src.replace(/^ +$/gm, '')
15625    , next
15626    , loose
15627    , cap
15628    , bull
15629    , b
15630    , item
15631    , space
15632    , i
15633    , l;
15634
15635  while (src) {
15636    // newline
15637    if (cap = this$1.rules.newline.exec(src)) {
15638      src = src.substring(cap[0].length);
15639      if (cap[0].length > 1) {
15640        this$1.tokens.push({
15641          type: 'space'
15642        });
15643      }
15644    }
15645
15646    // code
15647    if (cap = this$1.rules.code.exec(src)) {
15648      src = src.substring(cap[0].length);
15649      cap = cap[0].replace(/^ {4}/gm, '');
15650      this$1.tokens.push({
15651        type: 'code',
15652        text: !this$1.options.pedantic
15653          ? cap.replace(/\n+$/, '')
15654          : cap
15655      });
15656      continue;
15657    }
15658
15659    // fences (gfm)
15660    if (cap = this$1.rules.fences.exec(src)) {
15661      src = src.substring(cap[0].length);
15662      this$1.tokens.push({
15663        type: 'code',
15664        lang: cap[2],
15665        text: cap[3] || ''
15666      });
15667      continue;
15668    }
15669
15670    // heading
15671    if (cap = this$1.rules.heading.exec(src)) {
15672      src = src.substring(cap[0].length);
15673      this$1.tokens.push({
15674        type: 'heading',
15675        depth: cap[1].length,
15676        text: cap[2]
15677      });
15678      continue;
15679    }
15680
15681    // table no leading pipe (gfm)
15682    if (top && (cap = this$1.rules.nptable.exec(src))) {
15683      src = src.substring(cap[0].length);
15684
15685      item = {
15686        type: 'table',
15687        header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
15688        align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
15689        cells: cap[3].replace(/\n$/, '').split('\n')
15690      };
15691
15692      for (i = 0; i < item.align.length; i++) {
15693        if (/^ *-+: *$/.test(item.align[i])) {
15694          item.align[i] = 'right';
15695        } else if (/^ *:-+: *$/.test(item.align[i])) {
15696          item.align[i] = 'center';
15697        } else if (/^ *:-+ *$/.test(item.align[i])) {
15698          item.align[i] = 'left';
15699        } else {
15700          item.align[i] = null;
15701        }
15702      }
15703
15704      for (i = 0; i < item.cells.length; i++) {
15705        item.cells[i] = item.cells[i].split(/ *\| */);
15706      }
15707
15708      this$1.tokens.push(item);
15709
15710      continue;
15711    }
15712
15713    // lheading
15714    if (cap = this$1.rules.lheading.exec(src)) {
15715      src = src.substring(cap[0].length);
15716      this$1.tokens.push({
15717        type: 'heading',
15718        depth: cap[2] === '=' ? 1 : 2,
15719        text: cap[1]
15720      });
15721      continue;
15722    }
15723
15724    // hr
15725    if (cap = this$1.rules.hr.exec(src)) {
15726      src = src.substring(cap[0].length);
15727      this$1.tokens.push({
15728        type: 'hr'
15729      });
15730      continue;
15731    }
15732
15733    // blockquote
15734    if (cap = this$1.rules.blockquote.exec(src)) {
15735      src = src.substring(cap[0].length);
15736
15737      this$1.tokens.push({
15738        type: 'blockquote_start'
15739      });
15740
15741      cap = cap[0].replace(/^ *> ?/gm, '');
15742
15743      // Pass `top` to keep the current
15744      // "toplevel" state. This is exactly
15745      // how markdown.pl works.
15746      this$1.token(cap, top, true);
15747
15748      this$1.tokens.push({
15749        type: 'blockquote_end'
15750      });
15751
15752      continue;
15753    }
15754
15755    // list
15756    if (cap = this$1.rules.list.exec(src)) {
15757      src = src.substring(cap[0].length);
15758      bull = cap[2];
15759
15760      this$1.tokens.push({
15761        type: 'list_start',
15762        ordered: bull.length > 1
15763      });
15764
15765      // Get each top-level item.
15766      cap = cap[0].match(this$1.rules.item);
15767
15768      next = false;
15769      l = cap.length;
15770      i = 0;
15771
15772      for (; i < l; i++) {
15773        item = cap[i];
15774
15775        // Remove the list item's bullet
15776        // so it is seen as the next token.
15777        space = item.length;
15778        item = item.replace(/^ *([*+-]|\d+\.) +/, '');
15779
15780        // Outdent whatever the
15781        // list item contains. Hacky.
15782        if (~item.indexOf('\n ')) {
15783          space -= item.length;
15784          item = !this$1.options.pedantic
15785            ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
15786            : item.replace(/^ {1,4}/gm, '');
15787        }
15788
15789        // Determine whether the next list item belongs here.
15790        // Backpedal if it does not belong in this list.
15791        if (this$1.options.smartLists && i !== l - 1) {
15792          b = block.bullet.exec(cap[i + 1])[0];
15793          if (bull !== b && !(bull.length > 1 && b.length > 1)) {
15794            src = cap.slice(i + 1).join('\n') + src;
15795            i = l - 1;
15796          }
15797        }
15798
15799        // Determine whether item is loose or not.
15800        // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
15801        // for discount behavior.
15802        loose = next || /\n\n(?!\s*$)/.test(item);
15803        if (i !== l - 1) {
15804          next = item.charAt(item.length - 1) === '\n';
15805          if (!loose) { loose = next; }
15806        }
15807
15808        this$1.tokens.push({
15809          type: loose
15810            ? 'loose_item_start'
15811            : 'list_item_start'
15812        });
15813
15814        // Recurse.
15815        this$1.token(item, false, bq);
15816
15817        this$1.tokens.push({
15818          type: 'list_item_end'
15819        });
15820      }
15821
15822      this$1.tokens.push({
15823        type: 'list_end'
15824      });
15825
15826      continue;
15827    }
15828
15829    // html
15830    if (cap = this$1.rules.html.exec(src)) {
15831      src = src.substring(cap[0].length);
15832      this$1.tokens.push({
15833        type: this$1.options.sanitize
15834          ? 'paragraph'
15835          : 'html',
15836        pre: !this$1.options.sanitizer
15837          && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
15838        text: cap[0]
15839      });
15840      continue;
15841    }
15842
15843    // def
15844    if ((!bq && top) && (cap = this$1.rules.def.exec(src))) {
15845      src = src.substring(cap[0].length);
15846      this$1.tokens.links[cap[1].toLowerCase()] = {
15847        href: cap[2],
15848        title: cap[3]
15849      };
15850      continue;
15851    }
15852
15853    // table (gfm)
15854    if (top && (cap = this$1.rules.table.exec(src))) {
15855      src = src.substring(cap[0].length);
15856
15857      item = {
15858        type: 'table',
15859        header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
15860        align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
15861        cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
15862      };
15863
15864      for (i = 0; i < item.align.length; i++) {
15865        if (/^ *-+: *$/.test(item.align[i])) {
15866          item.align[i] = 'right';
15867        } else if (/^ *:-+: *$/.test(item.align[i])) {
15868          item.align[i] = 'center';
15869        } else if (/^ *:-+ *$/.test(item.align[i])) {
15870          item.align[i] = 'left';
15871        } else {
15872          item.align[i] = null;
15873        }
15874      }
15875
15876      for (i = 0; i < item.cells.length; i++) {
15877        item.cells[i] = item.cells[i]
15878          .replace(/^ *\| *| *\| *$/g, '')
15879          .split(/ *\| */);
15880      }
15881
15882      this$1.tokens.push(item);
15883
15884      continue;
15885    }
15886
15887    // top-level paragraph
15888    if (top && (cap = this$1.rules.paragraph.exec(src))) {
15889      src = src.substring(cap[0].length);
15890      this$1.tokens.push({
15891        type: 'paragraph',
15892        text: cap[1].charAt(cap[1].length - 1) === '\n'
15893          ? cap[1].slice(0, -1)
15894          : cap[1]
15895      });
15896      continue;
15897    }
15898
15899    // text
15900    if (cap = this$1.rules.text.exec(src)) {
15901      // Top-level should never reach here.
15902      src = src.substring(cap[0].length);
15903      this$1.tokens.push({
15904        type: 'text',
15905        text: cap[0]
15906      });
15907      continue;
15908    }
15909
15910    if (src) {
15911      throw new
15912        Error('Infinite loop on byte: ' + src.charCodeAt(0));
15913    }
15914  }
15915
15916  return this.tokens;
15917};
15918
15919/**
15920 * Inline-Level Grammar
15921 */
15922
15923var inline = {
15924  escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
15925  autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
15926  url: noop,
15927  tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
15928  link: /^!?\[(inside)\]\(href\)/,
15929  reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
15930  nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
15931  strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
15932  em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
15933  code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
15934  br: /^ {2,}\n(?!\s*$)/,
15935  del: noop,
15936  text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
15937};
15938
15939inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
15940inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
15941
15942inline.link = replace(inline.link)
15943  ('inside', inline._inside)
15944  ('href', inline._href)
15945  ();
15946
15947inline.reflink = replace(inline.reflink)
15948  ('inside', inline._inside)
15949  ();
15950
15951/**
15952 * Normal Inline Grammar
15953 */
15954
15955inline.normal = merge({}, inline);
15956
15957/**
15958 * Pedantic Inline Grammar
15959 */
15960
15961inline.pedantic = merge({}, inline.normal, {
15962  strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
15963  em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
15964});
15965
15966/**
15967 * GFM Inline Grammar
15968 */
15969
15970inline.gfm = merge({}, inline.normal, {
15971  escape: replace(inline.escape)('])', '~|])')(),
15972  url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
15973  del: /^~~(?=\S)([\s\S]*?\S)~~/,
15974  text: replace(inline.text)
15975    (']|', '~]|')
15976    ('|', '|https?://|')
15977    ()
15978});
15979
15980/**
15981 * GFM + Line Breaks Inline Grammar
15982 */
15983
15984inline.breaks = merge({}, inline.gfm, {
15985  br: replace(inline.br)('{2,}', '*')(),
15986  text: replace(inline.gfm.text)('{2,}', '*')()
15987});
15988
15989/**
15990 * Inline Lexer & Compiler
15991 */
15992
15993function InlineLexer(links, options) {
15994  this.options = options || marked.defaults;
15995  this.links = links;
15996  this.rules = inline.normal;
15997  this.renderer = this.options.renderer || new Renderer;
15998  this.renderer.options = this.options;
15999
16000  if (!this.links) {
16001    throw new
16002      Error('Tokens array requires a `links` property.');
16003  }
16004
16005  if (this.options.gfm) {
16006    if (this.options.breaks) {
16007      this.rules = inline.breaks;
16008    } else {
16009      this.rules = inline.gfm;
16010    }
16011  } else if (this.options.pedantic) {
16012    this.rules = inline.pedantic;
16013  }
16014}
16015
16016/**
16017 * Expose Inline Rules
16018 */
16019
16020InlineLexer.rules = inline;
16021
16022/**
16023 * Static Lexing/Compiling Method
16024 */
16025
16026InlineLexer.output = function(src, links, options) {
16027  var inline = new InlineLexer(links, options);
16028  return inline.output(src);
16029};
16030
16031/**
16032 * Lexing/Compiling
16033 */
16034
16035InlineLexer.prototype.output = function(src) {
16036  var this$1 = this;
16037
16038  var out = ''
16039    , link
16040    , text
16041    , href
16042    , cap;
16043
16044  while (src) {
16045    // escape
16046    if (cap = this$1.rules.escape.exec(src)) {
16047      src = src.substring(cap[0].length);
16048      out += cap[1];
16049      continue;
16050    }
16051
16052    // autolink
16053    if (cap = this$1.rules.autolink.exec(src)) {
16054      src = src.substring(cap[0].length);
16055      if (cap[2] === '@') {
16056        text = cap[1].charAt(6) === ':'
16057          ? this$1.mangle(cap[1].substring(7))
16058          : this$1.mangle(cap[1]);
16059        href = this$1.mangle('mailto:') + text;
16060      } else {
16061        text = escape(cap[1]);
16062        href = text;
16063      }
16064      out += this$1.renderer.link(href, null, text);
16065      continue;
16066    }
16067
16068    // url (gfm)
16069    if (!this$1.inLink && (cap = this$1.rules.url.exec(src))) {
16070      src = src.substring(cap[0].length);
16071      text = escape(cap[1]);
16072      href = text;
16073      out += this$1.renderer.link(href, null, text);
16074      continue;
16075    }
16076
16077    // tag
16078    if (cap = this$1.rules.tag.exec(src)) {
16079      if (!this$1.inLink && /^<a /i.test(cap[0])) {
16080        this$1.inLink = true;
16081      } else if (this$1.inLink && /^<\/a>/i.test(cap[0])) {
16082        this$1.inLink = false;
16083      }
16084      src = src.substring(cap[0].length);
16085      out += this$1.options.sanitize
16086        ? this$1.options.sanitizer
16087          ? this$1.options.sanitizer(cap[0])
16088          : escape(cap[0])
16089        : cap[0];
16090      continue;
16091    }
16092
16093    // link
16094    if (cap = this$1.rules.link.exec(src)) {
16095      src = src.substring(cap[0].length);
16096      this$1.inLink = true;
16097      out += this$1.outputLink(cap, {
16098        href: cap[2],
16099        title: cap[3]
16100      });
16101      this$1.inLink = false;
16102      continue;
16103    }
16104
16105    // reflink, nolink
16106    if ((cap = this$1.rules.reflink.exec(src))
16107        || (cap = this$1.rules.nolink.exec(src))) {
16108      src = src.substring(cap[0].length);
16109      link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
16110      link = this$1.links[link.toLowerCase()];
16111      if (!link || !link.href) {
16112        out += cap[0].charAt(0);
16113        src = cap[0].substring(1) + src;
16114        continue;
16115      }
16116      this$1.inLink = true;
16117      out += this$1.outputLink(cap, link);
16118      this$1.inLink = false;
16119      continue;
16120    }
16121
16122    // strong
16123    if (cap = this$1.rules.strong.exec(src)) {
16124      src = src.substring(cap[0].length);
16125      out += this$1.renderer.strong(this$1.output(cap[2] || cap[1]));
16126      continue;
16127    }
16128
16129    // em
16130    if (cap = this$1.rules.em.exec(src)) {
16131      src = src.substring(cap[0].length);
16132      out += this$1.renderer.em(this$1.output(cap[2] || cap[1]));
16133      continue;
16134    }
16135
16136    // code
16137    if (cap = this$1.rules.code.exec(src)) {
16138      src = src.substring(cap[0].length);
16139      out += this$1.renderer.codespan(escape(cap[2], true));
16140      continue;
16141    }
16142
16143    // br
16144    if (cap = this$1.rules.br.exec(src)) {
16145      src = src.substring(cap[0].length);
16146      out += this$1.renderer.br();
16147      continue;
16148    }
16149
16150    // del (gfm)
16151    if (cap = this$1.rules.del.exec(src)) {
16152      src = src.substring(cap[0].length);
16153      out += this$1.renderer.del(this$1.output(cap[1]));
16154      continue;
16155    }
16156
16157    // text
16158    if (cap = this$1.rules.text.exec(src)) {
16159      src = src.substring(cap[0].length);
16160      out += this$1.renderer.text(escape(this$1.smartypants(cap[0])));
16161      continue;
16162    }
16163
16164    if (src) {
16165      throw new
16166        Error('Infinite loop on byte: ' + src.charCodeAt(0));
16167    }
16168  }
16169
16170  return out;
16171};
16172
16173/**
16174 * Compile Link
16175 */
16176
16177InlineLexer.prototype.outputLink = function(cap, link) {
16178  var href = escape(link.href)
16179    , title = link.title ? escape(link.title) : null;
16180
16181  return cap[0].charAt(0) !== '!'
16182    ? this.renderer.link(href, title, this.output(cap[1]))
16183    : this.renderer.image(href, title, escape(cap[1]));
16184};
16185
16186/**
16187 * Smartypants Transformations
16188 */
16189
16190InlineLexer.prototype.smartypants = function(text) {
16191  if (!this.options.smartypants) { return text; }
16192  return text
16193    // em-dashes
16194    .replace(/---/g, '\u2014')
16195    // en-dashes
16196    .replace(/--/g, '\u2013')
16197    // opening singles
16198    .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
16199    // closing singles & apostrophes
16200    .replace(/'/g, '\u2019')
16201    // opening doubles
16202    .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
16203    // closing doubles
16204    .replace(/"/g, '\u201d')
16205    // ellipses
16206    .replace(/\.{3}/g, '\u2026');
16207};
16208
16209/**
16210 * Mangle Links
16211 */
16212
16213InlineLexer.prototype.mangle = function(text) {
16214  if (!this.options.mangle) { return text; }
16215  var out = ''
16216    , l = text.length
16217    , i = 0
16218    , ch;
16219
16220  for (; i < l; i++) {
16221    ch = text.charCodeAt(i);
16222    if (Math.random() > 0.5) {
16223      ch = 'x' + ch.toString(16);
16224    }
16225    out += '&#' + ch + ';';
16226  }
16227
16228  return out;
16229};
16230
16231/**
16232 * Renderer
16233 */
16234
16235function Renderer(options) {
16236  this.options = options || {};
16237}
16238
16239Renderer.prototype.code = function(code, lang, escaped) {
16240  if (this.options.highlight) {
16241    var out = this.options.highlight(code, lang);
16242    if (out != null && out !== code) {
16243      escaped = true;
16244      code = out;
16245    }
16246  }
16247
16248  if (!lang) {
16249    return '<pre><code>'
16250      + (escaped ? code : escape(code, true))
16251      + '\n</code></pre>';
16252  }
16253
16254  return '<pre><code class="'
16255    + this.options.langPrefix
16256    + escape(lang, true)
16257    + '">'
16258    + (escaped ? code : escape(code, true))
16259    + '\n</code></pre>\n';
16260};
16261
16262Renderer.prototype.blockquote = function(quote) {
16263  return '<blockquote>\n' + quote + '</blockquote>\n';
16264};
16265
16266Renderer.prototype.html = function(html) {
16267  return html;
16268};
16269
16270Renderer.prototype.heading = function(text, level, raw) {
16271  return '<h'
16272    + level
16273    + ' id="'
16274    + this.options.headerPrefix
16275    + raw.toLowerCase().replace(/[^\w]+/g, '-')
16276    + '">'
16277    + text
16278    + '</h'
16279    + level
16280    + '>\n';
16281};
16282
16283Renderer.prototype.hr = function() {
16284  return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
16285};
16286
16287Renderer.prototype.list = function(body, ordered) {
16288  var type = ordered ? 'ol' : 'ul';
16289  return '<' + type + '>\n' + body + '</' + type + '>\n';
16290};
16291
16292Renderer.prototype.listitem = function(text) {
16293  return '<li>
16293' + text + '</li>\n';
16294};
16295
16296Renderer.prototype.paragraph = function(text) {
16297  return '<p>' + text + '</p>\n';
16298};
16299
16300Renderer.prototype.table = function(header, body) {
16301  return '<table>\n'
16302    + '<thead>\n'
16303    + header
16304    + '</thead>\n'
16305    + '<tbody>\n'
16306    + body
16307    + '</tbody>\n'
16308    + '</table>\n';
16309};
16310
16311Renderer.prototype.tablerow = function(content) {
16312  return '<tr>\n' + content + '</tr>\n';
16313};
16314
16315Renderer.prototype.tablecell = function(content, flags) {
16316  var type = flags.header ? 'th' : 'td';
16317  var tag = flags.align
16318    ? '<' + type + ' style="text-align:' + flags.align + '">'
16319    : '<' + type + '>';
16320  return tag + content + '</' + type + '>\n';
16321};
16322
16323// span level renderer
16324Renderer.prototype.strong = function(text) {
16325  return '<strong>' + text + '</strong>';
16326};
16327
16328Renderer.prototype.em = function(text) {
16329  return '<em>' + text + '</em>';
16330};
16331
16332Renderer.prototype.codespan = function(text) {
16333  return '<code>' + text + '</code>';
16334};
16335
16336Renderer.prototype.br = function() {
16337  return this.options.xhtml ? '<br/>' : '<br>';
16338};
16339
16340Renderer.prototype.del = function(text) {
16341  return '<del>' + text + '</del>';
16342};
16343
16344Renderer.prototype.link = function(href, title, text) {
16345  if (this.options.sanitize) {
16346    try {
16347      var prot = decodeURIComponent(unescape(href))
16348        .replace(/[^\w:]/g, '')
16349        .toLowerCase();
16350    } catch (e) {
16351      return '';
16352    }
16353    if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) {
16354      return '';
16355    }
16356  }
16357  var out = '<a href="' + href + '"';
16358  if (title) {
16359    out += ' title="' + title + '"';
16360  }
16361  out += '>
16361' + text + '</a>';
16362  return out;
16363};
16364
16365Renderer.prototype.image = function(href, title, text) {
16366  var out = '<img src="' + href + '" alt="' + text + '"';
16367  if (title) {
16368    out += ' title="' + title + '"';
16369  }
16370  out += this.options.xhtml ? '/>' : '>';
16371  return out;
16372};
16373
16374Renderer.prototype.text = function(text) {
16375  return text;
16376};
16377
16378/**
16379 * Parsing & Compiling
16380 */
16381
16382function Parser(options) {
16383  this.tokens = [];
16384  this.token = null;
16385  this.options = options || marked.defaults;
16386  this.options.renderer = this.options.renderer || new Renderer;
16387  this.renderer = this.options.renderer;
16388  this.renderer.options = this.options;
16389}
16390
16391/**
16392 * Static Parse Method
16393 */
16394
16395Parser.parse = function(src, options, renderer) {
16396  var parser = new Parser(options, renderer);
16397  return parser.parse(src);
16398};
16399
16400/**
16401 * Parse Loop
16402 */
16403
16404Parser.prototype.parse = function(src) {
16405  var this$1 = this;
16406
16407  this.inline = new InlineLexer(src.links, this.options, this.renderer);
16408  this.tokens = src.reverse();
16409
16410  var out = '';
16411  while (this.next()) {
16412    out += this$1.tok();
16413  }
16414
16415  return out;
16416};
16417
16418/**
16419 * Next Token
16420 */
16421
16422Parser.prototype.next = function() {
16423  return this.token = this.tokens.pop();
16424};
16425
16426/**
16427 * Preview Next Token
16428 */
16429
16430Parser.prototype.peek = function() {
16431  return this.tokens[this.tokens.length - 1] || 0;
16432};
16433
16434/**
16435 * Parse Text Tokens
16436 */
16437
16438Parser.prototype.parseText = function() {
16439  var this$1 = this;
16440
16441  var body = this.token.text;
16442
16443  while (this.peek().type === 'text') {
16444    body += '\n' + this$1.next().text;
16445  }
16446
16447  return this.inline.output(body);
16448};
16449
16450/**
16451 * Parse Current Token
16452 */
16453
16454Parser.prototype.tok = function() {
16455  var this$1 = this;
16456
16457  switch (this.token.type) {
16458    case 'space': {
16459      return '';
16460    }
16461    case 'hr': {
16462      return this.renderer.hr();
16463    }
16464    case 'heading': {
16465      return this.renderer.heading(
16466        this.inline.output(this.token.text),
16467        this.token.depth,
16468        this.token.text);
16469    }
16470    case 'code': {
16471      return this.renderer.code(this.token.text,
16472        this.token.lang,
16473        this.token.escaped);
16474    }
16475    case 'table': {
16476      var header = ''
16477        , body = ''
16478        , i
16479        , row
16480        , cell
16481        , flags
16482        , j;
16483
16484      // header
16485      cell = '';
16486      for (i = 0; i < this.token.header.length; i++) {
16487        flags = { header: true, align: this$1.token.align[i] };
16488        cell += this$1.renderer.tablecell(
16489          this$1.inline.output(this$1.token.header[i]),
16490          { header: true, align: this$1.token.align[i] }
16491        );
16492      }
16493      header += this.renderer.tablerow(cell);
16494
16495      for (i = 0; i < this.token.cells.length; i++) {
16496        row = this$1.token.cells[i];
16497
16498        cell = '';
16499        for (j = 0; j < row.length; j++) {
16500          cell += this$1.renderer.tablecell(
16501            this$1.inline.output(row[j]),
16502            { header: false, align: this$1.token.align[j] }
16503          );
16504        }
16505
16506        body += this$1.renderer.tablerow(cell);
16507      }
16508      return this.renderer.table(header, body);
16509    }
16510    case 'blockquote_start': {
16511      var body = '';
16512
16513      while (this.next().type !== 'blockquote_end') {
16514        body += this$1.tok();
16515      }
16516
16517      return this.renderer.blockquote(body);
16518    }
16519    case 'list_start': {
16520      var body = ''
16521        , ordered = this.token.ordered;
16522
16523      while (this.next().type !== 'list_end') {
16524        body += this$1.tok();
16525      }
16526
16527      return this.renderer.list(body, ordered);
16528    }
16529    case 'list_item_start': {
16530      var body = '';
16531
16532      while (this.next().type !== 'list_item_end') {
16533        body += this$1.token.type === 'text'
16534          ? this$1.parseText()
16535          : this$1.tok();
16536      }
16537
16538      return this.renderer.listitem(body);
16539    }
16540    case 'loose_item_start': {
16541      var body = '';
16542
16543      while (this.next().type !== 'list_item_end') {
16544        body += this$1.tok();
16545      }
16546
16547      return this.renderer.listitem(body);
16548    }
16549    case 'html': {
16550      var html = !this.token.pre && !this.options.pedantic
16551        ? this.inline.output(this.token.text)
16552        : this.token.text;
16553      return this.renderer.html(html);
16554    }
16555    case 'paragraph': {
16556      return this.renderer.paragraph(this.inline.output(this.token.text));
16557    }
16558    case 'text': {
16559      return this.renderer.paragraph(this.parseText());
16560    }
16561  }
16562};
16563
16564/**
16565 * Helpers
16566 */
16567
16568function escape(html, encode) {
16569  return html
16570    .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
16571    .replace(/</g, '&lt;')
16572    .replace(/>/g, '&gt;')
16573    .replace(/"/g, '&quot;')
16574    .replace(/'/g, '&#39;');
16575}
16576
16577function unescape(html) {
16578	// explicitly match decimal, hex, and named HTML entities 
16579  return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
16580    n = n.toLowerCase();
16581    if (n === 'colon') { return ':'; }
16582    if (n.charAt(0) === '#') {
16583      return n.charAt(1) === 'x'
16584        ? String.fromCharCode(parseInt(n.substring(2), 16))
16585        : String.fromCharCode(+n.substring(1));
16586    }
16587    return '';
16588  });
16589}
16590
16591function replace(regex, opt) {
16592  regex = regex.source;
16593  opt = opt || '';
16594  return function self(name, val) {
16595    if (!name) { return new RegExp(regex, opt); }
16596    val = val.source || val;
16597    val = val.replace(/(^|[^\[])\^/g, '$1');
16598    regex = regex.replace(name, val);
16599    return self;
16600  };
16601}
16602
16603function noop() {}
16604noop.exec = noop;
16605
16606function merge(obj) {
16607  var arguments$1 = arguments;
16608
16609  var i = 1
16610    , target
16611    , key;
16612
16613  for (; i < arguments.length; i++) {
16614    target = arguments$1[i];
16615    for (key in target) {
16616      if (Object.prototype.hasOwnProperty.call(target, key)) {
16617        obj[key] = target[key];
16618      }
16619    }
16620  }
16621
16622  return obj;
16623}
16624
16625
16626/**
16627 * Marked
16628 */
16629
16630function marked(src, opt, callback) {
16631  if (callback || typeof opt === 'function') {
16632    if (!callback) {
16633      callback = opt;
16634      opt = null;
16635    }
16636
16637    opt = merge({}, marked.defaults, opt || {});
16638
16639    var highlight = opt.highlight
16640      , tokens
16641      , pending
16642      , i = 0;
16643
16644    try {
16645      tokens = Lexer.lex(src, opt);
16646    } catch (e) {
16647      return callback(e);
16648    }
16649
16650    pending = tokens.length;
16651
16652    var done = function(err) {
16653      if (err) {
16654        opt.highlight = highlight;
16655        return callback(err);
16656      }
16657
16658      var out;
16659
16660      try {
16661        out = Parser.parse(tokens, opt);
16662      } catch (e) {
16663        err = e;
16664      }
16665
16666      opt.highlight = highlight;
16667
16668      return err
16669        ? callback(err)
16670        : callback(null, out);
16671    };
16672
16673    if (!highlight || highlight.length < 3) {
16674      return done();
16675    }
16676
16677    delete opt.highlight;
16678
16679    if (!pending) { return done(); }
16680
16681    for (; i < tokens.length; i++) {
16682      (function(token) {
16683        if (token.type !== 'code') {
16684          return --pending || done();
16685        }
16686        return highlight(token.text, token.lang, function(err, code) {
16687          if (err) { return done(err); }
16688          if (code == null || code === token.text) {
16689            return --pending || done();
16690          }
16691          token.text = code;
16692          token.escaped = true;
16693          --pending || done();
16694        });
16695      })(tokens[i]);
16696    }
16697
16698    return;
16699  }
16700  try {
16701    if (opt) { opt = merge({}, marked.defaults, opt); }
16702    return Parser.parse(Lexer.lex(src, opt), opt);
16703  } catch (e) {
16704    e.message += '\nPlease report this to https://github.com/chjj/marked.';
16705    if ((opt || marked.defaults).silent) {
16706      return '<p>An error occured:</p><pre>'
16707        + escape(e.message + '', true)
16708        + '</pre>';
16709    }
16710    throw e;
16711  }
16712}
16713
16714/**
16715 * Options
16716 */
16717
16718marked.options =
16719marked.setOptions = function(opt) {
16720  merge(marked.defaults, opt);
16721  return marked;
16722};
16723
16724marked.defaults = {
16725  gfm: true,
16726  tables: true,
16727  breaks: false,
16728  pedantic: false,
16729  sanitize: false,
16730  sanitizer: null,
16731  mangle: true,
16732  smartLists: false,
16733  silent: false,
16734  highlight: null,
16735  langPrefix: 'lang-',
16736  smartypants: false,
16737  headerPrefix: '',
16738  renderer: new Renderer,
16739  xhtml: false
16740};
16741
16742/**
16743 * Expose
16744 */
16745
16746marked.Parser = Parser;
16747marked.parser = Parser.parse;
16748
16749marked.Renderer = Renderer;
16750
16751marked.Lexer = Lexer;
16752marked.lexer = Lexer.lex;
16753
16754marked.InlineLexer = InlineLexer;
16755marked.inlineLexer = InlineLexer.output;
16756
16757marked.parse = marked;
16758
16759if ('object' !== 'undefined' && 'object' === 'object') {
16760  module.exports = marked;
16761} else if (typeof undefined === 'function' && undefined.amd) {
16762  undefined(function() { return marked; });
16763} else {
16764  this.marked = marked;
16765}
16766
16767}
16767).call(function() {
16768  return this || (typeof window !== 'undefined' ? window : commonjsGlobal);
16769}());
16770});
16771
16772marked.setOptions({
16773  gfm: true,
16774  smartypants: true
16775});
16776
16777var markdown = function(dom, data) {
16778  var markdownElements = [].slice.call(dom.querySelectorAll('[markdown]'));
16779  markdownElements.forEach(function (el) {
16780    var content = el.innerHTML;
16781    // Set default indents
16782    content = content.replace(/\n/, "");
16783    var tabs = content.match(/\s*/);
16784    content = content.replace(new RegExp("\n" + tabs, "g"), "\n");
16785    content = content.trim();
16786
16787    el.innerHTML = marked(content);
16788  });
16789};
16790
16791var prism = createCommonjsModule(function (module) {
16792/* **********************************************
16793     Begin prism-core.js
16794********************************************** */
16795
16796var _self = (typeof window !== 'undefined')
16797	? window   // if in browser
16798	: (
16799		(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
16800		? self // if in worker
16801		: {}   // if in node js
16802	);
16803
16804/**
16805 * Prism: Lightweight, robust, elegant syntax highlighting
16806 * MIT license http://www.opensource.org/licenses/mit-license.php/
16807 * @author Lea Verou http://lea.verou.me
16808 */
16809
16810var Prism = (function(){
16811
16812// Private helper vars
16813var lang = /\blang(?:uage)?-(\w+)\b/i;
16814var uniqueId = 0;
16815
16816var _ = _self.Prism = {
16817	util: {
16818		encode: function (tokens) {
16819			if (tokens instanceof Token) {
16820				return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
16821			} else if (_.util.type(tokens) === 'Array') {
16822				return tokens.map(_.util.encode);
16823			} else {
16824				return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
16825			}
16826		},
16827
16828		type: function (o) {
16829			return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
16830		},
16831
16832		objId: function (obj) {
16833			if (!obj['__id']) {
16834				Object.defineProperty(obj, '__id', { value: ++uniqueId });
16835			}
16836			return obj['__id'];
16837		},
16838
16839		// Deep clone a language definition (e.g. to extend it)
16840		clone: function (o) {
16841			var type = _.util.type(o);
16842
16843			switch (type) {
16844				case 'Object':
16845					var clone = {};
16846
16847					for (var key in o) {
16848						if (o.hasOwnProperty(key)) {
16849							clone[key] = _.util.clone(o[key]);
16850						}
16851					}
16852
16853					return clone;
16854
16855				case 'Array':
16856					// Check for existence for IE8
16857					return o.map && o.map(function(v) { return _.util.clone(v); });
16858			}
16859
16860			return o;
16861		}
16862	},
16863
16864	languages: {
16865		extend: function (id, redef) {
16866			var lang = _.util.clone(_.languages[id]);
16867
16868			for (var key in redef) {
16869				lang[key] = redef[key];
16870			}
16871
16872			return lang;
16873		},
16874
16875		/**
16876		 * Insert a token before another token in a language literal
16877		 * As this needs to recreate the object (we cannot actually insert before keys in object literals),
16878		 * we cannot just provide an object, we need anobject and a key.
16879		 * @param inside The key (or language id) of the parent
16880		 * @param before The key to insert before. If not provided, the function appends instead.
16881		 * @param insert Object with the key/value pairs to insert
16882		 * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
16883		 */
16884		insertBefore: function (inside, before, insert, root) {
16885			root = root || _.languages;
16886			var grammar = root[inside];
16887
16888			if (arguments.length == 2) {
16889				insert = arguments[1];
16890
16891				for (var newToken in insert) {
16892					if (insert.hasOwnProperty(newToken)) {
16893						grammar[newToken] = insert[newToken];
16894					}
16895				}
16896
16897				return grammar;
16898			}
16899
16900			var ret = {};
16901
16902			for (var token in grammar) {
16903
16904				if (grammar.hasOwnProperty(token)) {
16905
16906					if (token == before) {
16907
16908						for (var newToken in insert) {
16909
16910							if (insert.hasOwnProperty(newToken)) {
16911								ret[newToken] = insert[newToken];
16912							}
16913						}
16914					}
16915
16916					ret[token] = grammar[token];
16917				}
16918			}
16919
16920			// Update references in other language definitions
16921			_.languages.DFS(_.languages, function(key, value) {
16922				if (value === root[inside] && key != inside) {
16923					this[key] = ret;
16924				}
16925			});
16926
16927			return root[inside] = ret;
16928		},
16929
16930		// Traverse a language definition with Depth First Search
16931		DFS: function(o, callback, type, visited) {
16932			visited = visited || {};
16933			for (var i in o) {
16934				if (o.hasOwnProperty(i)) {
16935					callback.call(o, i, o[i], type || i);
16936
16937					if (_.util.type(o[i]) === 'Object' && !visited[_.util.objId(o[i])]) {
16938						visited[_.util.objId(o[i])] = true;
16939						_.languages.DFS(o[i], callback, null, visited);
16940					}
16941					else if (_.util.type(o[i]) === 'Array' && !visited[_.util.objId(o[i])]) {
16942						visited[_.util.objId(o[i])] = true;
16943						_.languages.DFS(o[i], callback, i, visited);
16944					}
16945				}
16946			}
16947		}
16948	},
16949	plugins: {},
16950
16951	highlightAll: function(async, callback) {
16952		var env = {
16953			callback: callback,
16954			selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
16955		};
16956
16957		_.hooks.run("before-highlightall", env);
16958
16959		var elements = env.elements || document.querySelectorAll(env.selector);
16960
16961		for (var i=0, element; element = elements[i++];) {
16962			_.highlightElement(element, async === true, env.callback);
16963		}
16964	},
16965
16966	highlightElement: function(element, async, callback) {
16967		// Find language
16968		var language, grammar, parent = element;
16969
16970		while (parent && !lang.test(parent.className)) {
16971			parent = parent.parentNode;
16972		}
16973
16974		if (parent) {
16975			language = (parent.className.match(lang) || [,''])[1].toLowerCase();
16976			grammar = _.languages[language];
16977		}
16978
16979		// Set language on the element, if not present
16980		element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
16981
16982		// Set language on the parent, for styling
16983		parent = element.parentNode;
16984
16985		if (/pre/i.test(parent.nodeName)) {
16986			parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
16987		}
16988
16989		var code = element.textContent;
16990
16991		var env = {
16992			element: element,
16993			language: language,
16994			grammar: grammar,
16995			code: code
16996		};
16997
16998		_.hooks.run('before-sanity-check', env);
16999
17000		if (!env.code || !env.grammar) {
17001			if (env.code) {
17002				env.element.textContent = env.code;
17003			}
17004			_.hooks.run('complete', env);
17005			return;
17006		}
17007
17008		_.hooks.run('before-highlight', env);
17009
17010		if (async && _self.Worker) {
17011			var worker = new Worker(_.filename);
17012
17013			worker.onmessage = function(evt) {
17014				env.highlightedCode = evt.data;
17015
17016				_.hooks.run('before-insert', env);
17017
17018				env.element.innerHTML = env.highlightedCode;
17019
17020				callback && callback.call(env.element);
17021				_.hooks.run('after-highlight', env);
17022				_.hooks.run('complete', env);
17023			};
17024
17025			worker.postMessage(JSON.stringify({
17026				language: env.language,
17027				code: env.code,
17028				immediateClose: true
17029			}));
17030		}
17031		else {
17032			env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
17033
17034			_.hooks.run('before-insert', env);
17035
17036			env.element.innerHTML = env.highlightedCode;
17037
17038			callback && callback.call(element);
17039
17040			_.hooks.run('after-highlight', env);
17041			_.hooks.run('complete', env);
17042		}
17043	},
17044
17045	highlight: function (text, grammar, language) {
17046		var tokens = _.tokenize(text, grammar);
17047		return Token.stringify(_.util.encode(tokens), language);
17048	},
17049
17050	tokenize: function(text, grammar, language) {
17051		var Token = _.Token;
17052
17053		var strarr = [text];
17054
17055		var rest = grammar.rest;
17056
17057		if (rest) {
17058			for (var token in rest) {
17059				grammar[token] = rest[token];
17060			}
17061
17062			delete grammar.rest;
17063		}
17064
17065		tokenloop: for (var token in grammar) {
17066			if(!grammar.hasOwnProperty(token) || !grammar[token]) {
17067				continue;
17068			}
17069
17070			var patterns = grammar[token];
17071			patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
17072
17073			for (var j = 0; j < patterns.length; ++j) {
17074				var pattern = patterns[j],
17075					inside = pattern.inside,
17076					lookbehind = !!pattern.lookbehind,
17077					greedy = !!pattern.greedy,
17078					lookbehindLength = 0,
17079					alias = pattern.alias;
17080
17081				if (greedy && !pattern.pattern.global) {
17082					// Without the global flag, lastIndex won't work
17083					var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
17084					pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
17085				}
17086
17087				pattern = pattern.pattern || pattern;
17088
17089				// Don’t cache length as it changes during the loop
17090				for (var i=0, pos = 0; i<strarr.length; pos += strarr[i].length, ++i) {
17091
17092					var str = strarr[i];
17093
17094					if (strarr.length > text.length) {
17095						// Something went terribly wrong, ABORT, ABORT!
17096						break tokenloop;
17097					}
17098
17099					if (str instanceof Token) {
17100						continue;
17101					}
17102
17103					pattern.lastIndex = 0;
17104
17105					var match = pattern.exec(str),
17106					    delNum = 1;
17107
17108					// Greedy patterns can override/remove up to two previously matched tokens
17109					if (!match && greedy && i != strarr.length - 1) {
17110						pattern.lastIndex = pos;
17111						match = pattern.exec(text);
17112						if (!match) {
17113							break;
17114						}
17115
17116						var from = match.index + (lookbehind ? match[1].length : 0),
17117						    to = match.index + match[0].length,
17118						    k = i,
17119						    p = pos;
17120
17121						for (var len = strarr.length; k < len && p < to; ++k) {
17122							p += strarr[k].length;
17123							// Move the index i to the element in strarr that is closest to from
17124							if (from >= p) {
17125								++i;
17126								pos = p;
17127							}
17128						}
17129
17130						/*
17131						 * If strarr[i] is a Token, then the match starts inside another Token, which is invalid
17132						 * If strarr[k - 1] is greedy we are in conflict with another greedy pattern
17133						 */
17134						if (strarr[i] instanceof Token || strarr[k - 1].greedy) {
17135							continue;
17136						}
17137
17138						// Number of tokens to delete and replace with the new match
17139						delNum = k - i;
17140						str = text.slice(pos, p);
17141						match.index -= pos;
17142					}
17143
17144					if (!match) {
17145						continue;
17146					}
17147
17148					if(lookbehind) {
17149						lookbehindLength = match[1].length;
17150					}
17151
17152					var from = match.index + lookbehindLength,
17153					    match = match[0].slice(lookbehindLength),
17154					    to = from + match.length,
17155					    before = str.slice(0, from),
17156					    after = str.slice(to);
17157
17158					var args = [i, delNum];
17159
17160					if (before) {
17161						args.push(before);
17162					}
17163
17164					var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
17165
17166					args.push(wrapped);
17167
17168					if (after) {
17169						args.push(after);
17170					}
17171
17172					Array.prototype.splice.apply(strarr, args);
17173				}
17174			}
17175		}
17176
17177		return strarr;
17178	},
17179
17180	hooks: {
17181		all: {},
17182
17183		add: function (name, callback) {
17184			var hooks = _.hooks.all;
17185
17186			hooks[name] = hooks[name] || [];
17187
17188			hooks[name].push(callback);
17189		},
17190
17191		run: function (name, env) {
17192			var callbacks = _.hooks.all[name];
17193
17194			if (!callbacks || !callbacks.length) {
17195				return;
17196			}
17197
17198			for (var i=0, callback; callback = callbacks[i++];) {
17199				callback(env);
17200			}
17201		}
17202	}
17203};
17204
17205var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
17206	this.type = type;
17207	this.content = content;
17208	this.alias = alias;
17209	// Copy of the full string this token was created from
17210	this.length = (matchedStr || "").length|0;
17211	this.greedy = !!greedy;
17212};
17213
17214Token.stringify = function(o, language, parent) {
17215	if (typeof o == 'string') {
17216		return o;
17217	}
17218
17219	if (_.util.type(o) === 'Array') {
17220		return o.map(function(element) {
17221			return Token.stringify(element, language, o);
17222		}).join('');
17223	}
17224
17225	var env = {
17226		type: o.type,
17227		content: Token.stringify(o.content, language, parent),
17228		tag: 'span',
17229		classes: ['token', o.type],
17230		attributes: {},
17231		language: language,
17232		parent: parent
17233	};
17234
17235	if (env.type == 'comment') {
17236		env.attributes['spellcheck'] = 'true';
17237	}
17238
17239	if (o.alias) {
17240		var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
17241		Array.prototype.push.apply(env.classes, aliases);
17242	}
17243
17244	_.hooks.run('wrap', env);
17245
17246	var attributes = Object.keys(env.attributes).map(function(name) {
17247		return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
17248	}).join(' ');
17249
17250	return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
17251
17252};
17253
17254if (!_self.document) {
17255	if (!_self.addEventListener) {
17256		// in Node.js
17257		return _self.Prism;
17258	}
17259 	// In worker
17260	_self.addEventListener('message', function(evt) {
17261		var message = JSON.parse(evt.data),
17262		    lang = message.language,
17263		    code = message.code,
17264		    immediateClose = message.immediateClose;
17265
17266		_self.postMessage(_.highlight(code, _.languages[lang], lang));
17267		if (immediateClose) {
17268			_self.close();
17269		}
17270	}, false);
17271
17272	return _self.Prism;
17273}
17274
17275//Get current script and highlight
17276var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
17277
17278if (script) {
17279	_.filename = script.src;
17280
17281	if (document.addEventListener && !script.hasAttribute('data-manual')) {
17282		if(document.readyState !== "loading") {
17283			if (window.requestAnimationFrame) {
17284				window.requestAnimationFrame(_.highlightAll);
17285			} else {
17286				window.setTimeout(_.highlightAll, 16);
17287			}
17288		}
17289		else {
17290			document.addEventListener('DOMContentLoaded', _.highlightAll);
17291		}
17292	}
17293}
17294
17295return _self.Prism;
17296
17297})();
17298
17299if ('object' !== 'undefined' && module.exports) {
17300	module.exports = Prism;
17301}
17302
17303// hack for components to work correctly in node.js
17304if (typeof commonjsGlobal !== 'undefined') {
17305	commonjsGlobal.Prism = Prism;
17306}
17307
17308
17309/* **********************************************
17310     Begin prism-markup.js
17311********************************************** */
17312
17313Prism.languages.markup = {
17314	'comment': /<!--[\w\W]*?-->/,
17315	'prolog': /<\?[\w\W]+?\?>/,
17316	'doctype': /<!DOCTYPE[\w\W]+?>/i,
17317	'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
17318	'tag': {
17319		pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
17320		inside: {
17321			'tag': {
17322				pattern: /^<\/?[^\s>\/]+/i,
17323				inside: {
17324					'punctuation': /^<\/?/,
17325					'namespace': /^[^\s>\/:]+:/
17326				}
17327			},
17328			'attr-value': {
17329				pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,
17330				inside: {
17331					'punctuation': /[=>"']/
17332				}
17333			},
17334			'punctuation': /\/?>/,
17335			'attr-name': {
17336				pattern: /[^\s>\/]+/,
17337				inside: {
17338					'namespace': /^[^\s>\/:]+:/
17339				}
17340			}
17341
17342		}
17343	},
17344	'entity': /&#?[\da-z]{1,8};/i
17345};
17346
17347// Plugin to make entity title show the real entity, idea by Roman Komarov
17348Prism.hooks.add('wrap', function(env) {
17349
17350	if (env.type === 'entity') {
17351		env.attributes['title'] = env.content.replace(/&amp;/, '&');
17352	}
17353});
17354
17355Prism.languages.xml = Prism.languages.markup;
17356Prism.languages.html = Prism.languages.markup;
17357Prism.languages.mathml = Prism.languages.markup;
17358Prism.languages.svg = Prism.languages.markup;
17359
17360
17361/* **********************************************
17362     Begin prism-css.js
17363********************************************** */
17364
17365Prism.languages.css = {
17366	'comment': /\/\*[\w\W]*?\*\//,
17367	'atrule': {
17368		pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
17369		inside: {
17370			'rule': /@[\w-]+/
17371			// See rest below
17372		}
17373	},
17374	'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
17375	'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
17376	'string': {
17377		pattern: /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
17378		greedy: true
17379	},
17380	'property': /(\b|\B)[\w-]+(?=\s*:)/i,
17381	'important': /\B!important\b/i,
17382	'function': /[-a-z0-9]+(?=\()/i,
17383	'punctuation': /[(){};:]/
17384};
17385
17386Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
17387
17388if (Prism.languages.markup) {
17389	Prism.languages.insertBefore('markup', 'tag', {
17390		'style': {
17391			pattern: /(<style[\w\W]*?>)[\w\W]*?(?=<\/style>)/i,
17392			lookbehind: true,
17393			inside: Prism.languages.css,
17394			alias: 'language-css'
17395		}
17396	});
17397	
17398	Prism.languages.insertBefore('inside', 'attr-value', {
17399		'style-attr': {
17400			pattern: /\s*style=("|').*?\1/i,
17401			inside: {
17402				'attr-name': {
17403					pattern: /^\s*style/i,
17404					inside: Prism.languages.markup.tag.inside
17405				},
17406				'punctuation': /^\s*=\s*['"]|['"]\s*$/,
17407				'attr-value': {
17408					pattern: /.+/i,
17409					inside: Prism.languages.css
17410				}
17411			},
17412			alias: 'language-css'
17413		}
17414	}, Prism.languages.markup.tag);
17415}
17416
17417/* **********************************************
17418     Begin prism-clike.js
17419********************************************** */
17420
17421Prism.languages.clike = {
17422	'comment': [
17423		{
17424			pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
17425			lookbehind: true
17426		},
17427		{
17428			pattern: /(^|[^\\:])\/\/.*/,
17429			lookbehind: true
17430		}
17431	],
17432	'string': {
17433		pattern: /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
17434		greedy: true
17435	},
17436	'class-name': {
17437		pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
17438		lookbehind: true,
17439		inside: {
17440			punctuation: /(\.|\\)/
17441		}
17442	},
17443	'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
17444	'boolean': /\b(true|false)\b/,
17445	'function': /[a-z0-9_]+(?=\()/i,
17446	'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
17447	'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
17448	'punctuation': /[{}[\];(),.:]/
17449};
17450
17451
17452/* **********************************************
17453     Begin prism-javascript.js
17454********************************************** */
17455
17456Prism.languages.javascript = Prism.languages.extend('clike', {
17457	'keyword': /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,
17458	'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
17459	// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
17460	'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,
17461	'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/
17462});
17463
17464Prism.languages.insertBefore('javascript', 'keyword', {
17465	'regex': {
17466		pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
17467		lookbehind: true,
17468		greedy: true
17469	}
17470});
17471
17472Prism.languages.insertBefore('javascript', 'string', {
17473	'template-string': {
17474		pattern: /`(?:\\\\|\\?[^\\])*?`/,
17475		greedy: true,
17476		inside: {
17477			'interpolation': {
17478				pattern: /\$\{[^}]+\}/,
17479				inside: {
17480					'interpolation-punctuation': {
17481						pattern: /^\$\{|\}$/,
17482						alias: 'punctuation'
17483					},
17484					rest: Prism.languages.javascript
17485				}
17486			},
17487			'string': /[\s\S]+/
17488		}
17489	}
17490});
17491
17492if (Prism.languages.markup) {
17493	Prism.languages.insertBefore('markup', 'tag', {
17494		'script': {
17495			pattern: /(<script[\w\W]*?>)[\w\W]*?(?=<\/script>)/i,
17496			lookbehind: true,
17497			inside: Prism.languages.javascript,
17498			alias: 'language-javascript'
17499		}
17500	});
17501}
17502
17503Prism.languages.js = Prism.languages.javascript;
17504
17505/* **********************************************
17506     Begin prism-file-highlight.js
17507********************************************** */
17508
17509(function () {
17510	if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
17511		return;
17512	}
17513
17514	self.Prism.fileHighlight = function() {
17515
17516		var Extensions = {
17517			'js': 'javascript',
17518			'py': 'python',
17519			'rb': 'ruby',
17520			'ps1': 'powershell',
17521			'psm1': 'powershell',
17522			'sh': 'bash',
17523			'bat': 'batch',
17524			'h': 'c',
17525			'tex': 'latex'
17526		};
17527
17528		if(Array.prototype.forEach) { // Check to prevent error in IE8
17529			Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {
17530				var src = pre.getAttribute('data-src');
17531
17532				var language, parent = pre;
17533				var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
17534				while (parent && !lang.test(parent.className)) {
17535					parent = parent.parentNode;
17536				}
17537
17538				if (parent) {
17539					language = (pre.className.match(lang) || [, ''])[1];
17540				}
17541
17542				if (!language) {
17543					var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
17544					language = Extensions[extension] || extension;
17545				}
17546
17547				var code = document.createElement('code');
17548				code.className = 'language-' + language;
17549
17550				pre.textContent = '';
17551
17552				code.textContent = 'Loading…';
17553
17554				pre.appendChild(code);
17555
17556				var xhr = new XMLHttpRequest();
17557
17558				xhr.open('GET', src, true);
17559
17560				xhr.onreadystatechange = function () {
17561					if (xhr.readyState == 4) {
17562
17563						if (xhr.status < 400 && xhr.responseText) {
17564							code.textContent = xhr.responseText;
17565
17566							Prism.highlightElement(code);
17567						}
17568						else if (xhr.status >= 400) {
17569							code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
17570						}
17571						else {
17572							code.textContent = '✖ Error: File does not exist or is empty';
17573						}
17574					}
17575				};
17576
17577				xhr.send(null);
17578			});
17579		}
17580
17581	};
17582
17583	document.addEventListener('DOMContentLoaded', self.Prism.fileHighlight);
17584
17585})();
17586});
17587
17588Prism.languages.python= {
17589	'triple-quoted-string': {
17590		pattern: /"""[\s\S]+?"""|'''[\s\S]+?'''/,
17591		alias: 'string'
17592	},
17593	'comment': {
17594		pattern: /(^|[^\\])#.*/,
17595		lookbehind: true
17596	},
17597	'string': {
17598		pattern: /("|')(?:\\\\|\\?[^\\\r\n])*?\1/,
17599		greedy: true
17600	},
17601	'function' : {
17602		pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\()/g,
17603		lookbehind: true
17604	},
17605	'class-name': {
17606		pattern: /(\bclass\s+)[a-z0-9_]+/i,
17607		lookbehind: true
17608	},
17609	'keyword' : /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,
17610	'boolean' : /\b(?:True|False)\b/,
17611	'number' : /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
17612	'operator' : /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
17613	'punctuation' : /[{}[\];(),.:]/
17614};
17615
17616Prism.languages.clike = {
17617	'comment': [
17618		{
17619			pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
17620			lookbehind: true
17621		},
17622		{
17623			pattern: /(^|[^\\:])\/\/.*/,
17624			lookbehind: true
17625		}
17626	],
17627	'string': {
17628		pattern: /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
17629		greedy: true
17630	},
17631	'class-name': {
17632		pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
17633		lookbehind: true,
17634		inside: {
17635			punctuation: /(\.|\\)/
17636		}
17637	},
17638	'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
17639	'boolean': /\b(true|false)\b/,
17640	'function': /[a-z0-9_]+(?=\()/i,
17641	'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
17642	'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
17643	'punctuation': /[{}[\];(),.:]/
17644};
17645
17646Prism.languages.lua = {
17647	'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
17648	// \z may be used to skip the following space
17649	'string': {
17650		pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[\s\S]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
17651		greedy: true
17652	},
17653	'number': /\b0x[a-f\d]+\.?[a-f\d]*(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|\.?\d*(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,
17654	'keyword': /\b(?:and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,
17655	'function': /(?!\d)\w+(?=\s*(?:[({]))/,
17656	'operator': [
17657		/[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
17658		{
17659			// Match ".." but don't break "..."
17660			pattern: /(^|[^.])\.\.(?!\.)/,
17661			lookbehind: true
17662		}
17663	],
17664	'punctuation': /[\[\](){},;]|\.+|:+/
17665};
17666
17667(function(Prism) {
17668	var insideString = {
17669		variable: [
17670			// Arithmetic Environment
17671			{
17672				pattern: /\$?\(\([\w\W]+?\)\)/,
17673				inside: {
17674					// If there is a $ sign at the beginning highlight $(( and )) as variable
17675					variable: [{
17676							pattern: /(^\$\(\([\w\W]+)\)\)/,
17677							lookbehind: true
17678						},
17679						/^\$\(\(/ ],
17680					number: /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee]-?\d+)?)\b/,
17681					// Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
17682					operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
17683					// If there is no $ sign at the beginning highlight (( and )) as punctuation
17684					punctuation: /\(\(?|\)\)?|,|;/
17685				}
17686			},
17687			// Command Substitution
17688			{
17689				pattern: /\$\([^)]+\)|`[^`]+`/,
17690				inside: {
17691					variable: /^\$\(|^`|\)$|`$/
17692				}
17693			},
17694			/\$(?:[a-z0-9_#\?\*!@]+|\{[^}]+\})/i
17695		],
17696	};
17697
17698	Prism.languages.bash = {
17699		'shebang': {
17700			pattern: /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/,
17701			alias: 'important'
17702		},
17703		'comment': {
17704			pattern: /(^|[^"{\\])#.*/,
17705			lookbehind: true
17706		},
17707		'string': [
17708			//Support for Here-Documents https://en.wikipedia.org/wiki/Here_document
17709			{
17710				pattern: /((?:^|[^<])<<\s*)(?:"|')?(\w+?)(?:"|')?\s*\r?\n(?:[\s\S])*?\r?\n\2/g,
17711				lookbehind: true,
17712				greedy: true,
17713				inside: insideString
17714			},
17715			{
17716				pattern: /(["'])(?:\\\\|\\?[^\\])*?\1/g,
17717				greedy: true,
17718				inside: insideString
17719			}
17720		],
17721		'variable': insideString.variable,
17722		// Originally based on http://ss64.com/bash/
17723		'function': {
17724			pattern: /(^|\s|;|\||&)(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|
17724ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|\s|;|\||&)/,
17725			lookbehind: true
17726		},
17727		'keyword': {
17728			pattern: /(^|\s|;|\||&)(?:let|:|\.|if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)(?=$|\s|;|\||&)/,
17729			lookbehind: true
17730		},
17731		'boolean': {
17732			pattern: /(^|\s|;|\||&)(?:true|false)(?=$|\s|;|\||&)/,
17733			lookbehind: true
17734		},
17735		'operator': /&&?|\|\|?|==?|!=?|<<<?|>>|<=?|>=?|=~/,
17736		'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];]/
17737	};
17738
17739	var inside = insideString.variable[1].inside;
17740	inside['function'] = Prism.languages.bash['function'];
17741	inside.keyword = Prism.languages.bash.keyword;
17742	inside.boolean = Prism.languages.bash.boolean;
17743	inside.operator = Prism.languages.bash.operator;
17744	inside.punctuation = Prism.languages.bash.punctuation;
17745})(Prism);
17746
17747Prism.languages.go = Prism.languages.extend('clike', {
17748	'keyword': /\b(break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
17749	'builtin': /\b(bool|byte|complex(64|128)|error|float(32|64)|rune|string|u?int(8|16|32|64|)|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(ln)?|real|recover)\b/,
17750	'boolean': /\b(_|iota|nil|true|false)\b/,
17751	'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
17752	'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,
17753	'string': /("|'|`)(\\?.|\r|\n)*?\1/
17754});
17755delete Prism.languages.go['class-name'];
17756
17757Prism.languages.markdown = Prism.languages.extend('markup', {});
17758Prism.languages.insertBefore('markdown', 'prolog', {
17759	'blockquote': {
17760		// > ...
17761		pattern: /^>(?:[\t ]*>)*/m,
17762		alias: 'punctuation'
17763	},
17764	'code': [
17765		{
17766			// Prefixed by 4 spaces or 1 tab
17767			pattern: /^(?: {4}|\t).+/m,
17768			alias: 'keyword'
17769		},
17770		{
17771			// `code`
17772			// ``code``
17773			pattern: /``.+?``|`[^`\n]+`/,
17774			alias: 'keyword'
17775		}
17776	],
17777	'title': [
17778		{
17779			// title 1
17780			// =======
17781
17782			// title 2
17783			// -------
17784			pattern: /\w+.*(?:\r?\n|\r)(?:==+|--+)/,
17785			alias: 'important',
17786			inside: {
17787				punctuation: /==+$|--+$/
17788			}
17789		},
17790		{
17791			// # title 1
17792			// ###### title 6
17793			pattern: /(^\s*)#+.+/m,
17794			lookbehind: true,
17795			alias: 'important',
17796			inside: {
17797				punctuation: /^#+|#+$/
17798			}
17799		}
17800	],
17801	'hr': {
17802		// ***
17803		// ---
17804		// * * *
17805		// -----------
17806		pattern: /(^\s*)([*-])([\t ]*\2){2,}(?=\s*$)/m,
17807		lookbehind: true,
17808		alias: 'punctuation'
17809	},
17810	'list': {
17811		// * item
17812		// + item
17813		// - item
17814		// 1. item
17815		pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,
17816		lookbehind: true,
17817		alias: 'punctuation'
17818	},
17819	'url-reference': {
17820		// [id]: http://example.com "Optional title"
17821		// [id]: http://example.com 'Optional title'
17822		// [id]: http://example.com (Optional title)
17823		// [id]: <http://example.com> "Optional title"
17824		pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,
17825		inside: {
17826			'variable': {
17827				pattern: /^(!?\[)[^\]]+/,
17828				lookbehind: true
17829			},
17830			'string': /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,
17831			'punctuation': /^[\[\]!:]|[<>]/
17832		},
17833		alias: 'url'
17834	},
17835	'bold': {
17836		// **strong**
17837		// __strong__
17838
17839		// Allow only one line break
17840		pattern: /(^|[^\\])(\*\*|__)(?:(?:\r?\n|\r)(?!\r?\n|\r)|.)+?\2/,
17841		lookbehind: true,
17842		inside: {
17843			'punctuation': /^\*\*|^__|\*\*$|__$/
17844		}
17845	},
17846	'italic': {
17847		// *em*
17848		// _em_
17849
17850		// Allow only one line break
17851		pattern: /(^|[^\\])([*_])(?:(?:\r?\n|\r)(?!\r?\n|\r)|.)+?\2/,
17852		lookbehind: true,
17853		inside: {
17854			'punctuation': /^[*_]|[*_]$/
17855		}
17856	},
17857	'url': {
17858		// [example](http://example.com "Optional title")
17859		// [example] [id]
17860		pattern: /!?\[[^\]]+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)| ?\[[^\]\n]*\])/,
17861		inside: {
17862			'variable': {
17863				pattern: /(!?\[)[^\]]+(?=\]$)/,
17864				lookbehind: true
17865			},
17866			'string': {
17867				pattern: /"(?:\\.|[^"\\])*"(?=\)$)/
17868			}
17869		}
17870	}
17871});
17872
17873Prism.languages.markdown['bold'].inside['url'] = Prism.util.clone(Prism.languages.markdown['url']);
17874Prism.languages.markdown['italic'].inside['url'] = Prism.util.clone(Prism.languages.markdown['url']);
17875Prism.languages.markdown['bold'].inside['italic'] = Prism.util.clone(Prism.languages.markdown['italic']);
17876Prism.languages.markdown['italic'].inside['bold'] = Prism.util.clone(Prism.languages.markdown['bold']);
17877
17878Prism.languages.julia= {
17879	'comment': {
17880		pattern: /(^|[^\\])#.*/,
17881		lookbehind: true
17882	},
17883	'string': /"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/,
17884	'keyword' : /\b(abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|let|local|macro|module|print|println|quote|return|try|type|typealias|using|while)\b/,
17885	'boolean' : /\b(true|false)\b/,
17886	'number' : /\b-?(0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:[efp][+-]?\d+)?j?\b/i,
17887	'operator': /\+=?|-=?|\*=?|\/[\/=]?|\\=?|\^=?|%=?|÷=?|!=?=?|&=?|\|[=>]?|\$=?|<(?:<=?|[=:])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥]/,
17888	'punctuation' : /[{}[\];(),.:]/
17889};
17890
17891var code$1 = function(dom, data) {
17892  var codeElements = [].slice.call(dom.querySelectorAll("dt-code"));
17893  codeElements.forEach(function (el) {
17894    var content = el.textContent;
17895    el.innerHTML = "";
17896    var language = el.getAttribute("language");
17897    var c = dom.createElement("code");
17898    if (el.getAttribute("block") === "") {
17899      // Let's normalize the tab indents
17900      content = content.replace(/\n/, "");
17901      var tabs = content.match(/\s*/);
17902      content = content.replace(new RegExp("\n" + tabs, "g"), "\n");
17903      content = content.trim();
17904      var p = dom.createElement("pre");
17905      p.appendChild(c);
17906      el.appendChild(p);
17907    } else {
17908      el.appendChild(c);
17909    }
17910    var highlighted = content;
17911    if (prism.languages[language]) {
17912      c.setAttribute("class", "language-" + language);
17913      highlighted = prism.highlight(content, prism.languages[language]);
17914    }
17915    c.innerHTML = highlighted;
17916  });
17917};
17918
17919var typeset = function(dom, data) {
17920
17921  var textNodes = dom.createTreeWalker(
17922    dom.body,
17923    dom.defaultView.NodeFilter.SHOW_TEXT
17924  );
17925  while (textNodes.nextNode()) {
17926    var n = textNodes.currentNode,
17927        text = n.nodeValue;
17928    if (text && acceptNode(n)) {
17929      text = quotes(text);
17930      text = punctuation(text);
17931      n.nodeValue = text;
17932    }
17933  }
17934};
17935
17936function acceptNode(node) {
17937  var parent = node.parentElement;
17938  var isMath = (parent && parent.getAttribute && parent.getAttribute("class")) ? parent.getAttribute("class").includes("katex") || parent.getAttribute("class").includes("MathJax") : false;
17939  return parent &&
17940         parent.nodeName !== "SCRIPT" &&
17941         parent.nodeName !== "STYLE" &&
17942         parent.nodeName !== "CODE" &&
17943         parent.nodeName !== "PRE" &&
17944         parent.nodeName !== "SPAN" &&
17945         parent.nodeName !== "DT-HEADER" &&
17946         parent.nodeName !== "DT-BYLINE" &&
17947         parent.nodeName !== "DT-MATH" &&
17948         parent.nodeName !== "DT-CODE" &&
17949         parent.nodeName !== "DT-BIBLIOGRAPHY" &&
17950         parent.nodeName !== "DT-FOOTER" &&
17951         parent.nodeType !== 8 && //comment nodes
17952         !isMath;
17953}
17954
17955
17956/*!
17957 * typeset - Typesetting for the web
17958 * @version v0.1.6
17959 * @link https://github.com/davidmerfield/Typeset.js
17960 * @author David Merfield
17961 */
17962 // which has a CC0 license
17963 // http://creativecommons.org/publicdomain/zero/1.0/
17964
17965
17966function punctuation(text){
17967
17968  // Dashes
17969  text = text.replace(/--/g, '\u2014');
17970  text = text.replace(/ \u2014 /g,"\u2009\u2014\u2009"); //this has thin spaces
17971
17972  // The following are temporary commented out because incompatibility
17973  // with katex
17974
17975  // Elipses
17976  // text = text.replace(/\.\.\./g,'…');
17977
17978  // Nbsp for punc with spaces
17979  // var NBSP = "\u00a0";
17980  // var NBSP_PUNCTUATION_START = /([«¿¡]) /g;
17981  // var NBSP_PUNCTUATION_END = / ([\!\?:;\.,‽»])/g;
17982
17983  // text = text.replace(NBSP_PUNCTUATION_START, '$1' + NBSP);
17984  // text = text.replace(NBSP_PUNCTUATION_END, NBSP + '$1');
17985
17986  return text;
17987}
17988
17989function quotes(text) {
17990
17991  text = text
17992    .replace(/(\W|^)"([^\s\!\?:;\.,‽»])/g, '$1\u201c$2') // beginning "
17993    .replace(/(\u201c[^"]*)"([^"]*$|[^\u201c"]*\u201c)/g, '$1\u201d$2') // ending "
17994    .replace(/([^0-9])"/g,'$1\u201d') // remaining " at end of word
17995    .replace(/(\W|^)'(\S)/g, '$1\u2018$2') // beginning '
17996    .replace(/([a-z])'([a-z])/ig, '$1\u2019$2') // conjunction's possession
17997    .replace(/((\u2018[^']*)|[a-z])'([^0-9]|$)/ig, '$1\u2019$3') // ending '
17998    .replace(/(\u2018)([0-9]{2}[^\u2019]*)(\u2018([^0-9]|$)|$|\u2019[a-z])/ig, '\u2019$2$3') // abbrev. years like '93
17999    .replace(/(\B|^)\u2018(?=([^\u2019]*\u2019\b)*([^\u2019\u2018]*\W[\u2019\u2018]\b|[^\u2019\u2018]*$))/ig, '$1\u2019') // backwards apostrophe
18000    .replace(/'''/g, '\u2034') // triple prime
18001    .replace(/("|'')/g, '\u2033') // double prime
18002    .replace(/'/g, '\u2032');
18003
18004  // Allow escaped quotes
18005  text = text.replace(/\\“/, '\"');
18006  text = text.replace(/\\”/, '\"');
18007  text = text.replace(/\\’/, '\'');
18008  text = text.replace(/\\‘/, '\'');
18009
18010  return text;
18011}
18012
18013var code$2 = "\n\nfunction nodeFromString(str) {\n  var div = document.createElement(\"div\");\n  div.innerHTML = str;\n  return div.firstChild;\n}
18013\n\nfunction make_hover_css(pos) {\n  var pretty = window.innerWidth > 600;\n  var padding = pretty? 18 : 12;\n  var outer_padding = pretty ? 18 : 0;\n  var bbox = document.querySelector(\"body\").getBoundingClientRect();\n  var left = pos[0] - bbox.left, top = pos[1] - bbox.top;\n  var width = Math.min(window.innerWidth-2*outer_padding, 648);\n  left = Math.min(left, window.innerWidth-width-outer_padding);\n  width = width - 2*padding;\n  return (`position: absolute;\n     background-color: #FFF;\n     opacity: 0.95;\n     max-width: ${width}px;\n     top: ${top}px;\n     left: ${left}px;\n     border: 1px solid rgba(0, 0, 0, 0.25);\n     padding: ${padding}px;\n     border-radius: ${pretty? 3 : 0}px;\n     box-shadow: 0px 2px 10px 2px rgba(0, 0, 0, 0.2);\n     z-index: ${1e6};`);\n}\n\n\nfunction DtHoverBox(div_id) {\n  this.div = document.querySelector(\"#\"+div_id);\n  this.visible = false;\n  this.bindDivEvents();\n  DtHoverBox.box_map[div_id] = this;\n}\n\nDtHoverBox.box_map = {};\n\nDtHoverBox.get_box = function get_box(div_id) {\n  if (div_id in DtHoverBox.box_map) {\n    return DtHoverBox.box_map[div_id];\n  } else {\n    return new DtHoverBox(div_id);\n  }\n}\n\nDtHoverBox.prototype.show = function show(pos){\n  this.visible = true;\n  this.div.setAttribute(\"style\", make_hover_css(pos) );\n  for (var box_id in DtHoverBox.box_map) {\n    var box = DtHoverBox.box_map[box_id];\n    if (box != this) box.hide();\n  }\n}\n\nDtHoverBox.prototype.showAtNode = function showAtNode(node){\n    var bbox = node.getBoundingClientRect();\n    this.show([bbox.right, bbox.bottom]);\n}\n\nDtHoverBox.prototype.hide = function hide(){\n  this.visible = false;\n  if (this.div) this.div.setAttribute(\"style\", \"display:none\");\n  if (this.timeout) clearTimeout(this.timeout);\n}\n\nDtHoverBox.prototype.stopTimeout = function stopTimeout() {\n  if (this.timeout) clearTimeout(this.timeout);\n}\n\nDtHoverBox.prototype.extendTimeout = function extendTimeout(T) {\n  //console.log(\"extend\", T)\n  var this_ = this;\n  this.stopTimeout();\n  this.timeout = setTimeout(function(){this_.hide();}.bind(this), T);\n}\n\n// Bind events to a link to open this box\nDtHoverBox.prototype.bind = function bind(node) {\n  if (typeof node == \"string\"){\n    node = document.querySelector(node);\n  }\n\n  node.addEventListener(\"mouseover\", function(){\n    if (!this.visible) this.showAtNode(node);\n    this.stopTimeout();\n  }.bind(this));\n\n  node.addEventListener(\"mouseout\", function(){this.extendTimeout(250);}.bind(this));\n\n  node.addEventListener(\"touchstart\", function(e) {\n    if (this.visible) {\n      this.hide();\n    } else {\n      this.showAtNode(node);\n    }\n    // Don't trigger body touchstart event when touching link\n    e.stopPropagation();\n  }.bind(this));\n}\n\nDtHoverBox.prototype.bindDivEvents = function bindDivEvents(){\n  // For mice, same behavior as hovering on links\n  this.div.addEventListener(\"mouseover\", function(){\n    if (!this.visible) this.showAtNode(node);\n    this.stopTimeout();\n  }.bind(this));\n  this.div.addEventListener(\"mouseout\", function(){this.extendTimeout(250);}.bind(this));\n\n  // Don't trigger body touchstart event when touching within box\n  this.div.addEventListener(\"touchstart\", function(e){e.stopPropagation();});\n  // Close box when touching outside box\n  document.body.addEventListener(\"touchstart\", function(){this.hide();}.bind(this));\n}\n\nvar hover_es = document.querySelectorAll(\"span[data-hover-ref]\");\nhover_es = [].slice.apply(hover_es);\nhover_es.forEach(function(e,n){\n  var ref_id = e.getAttribute(\"data-hover-ref\");\n  DtHoverBox.get_box(ref_id).bind(e);\n})\n";
18014
18015var hoverBox = function(dom) {
18016  var s = dom.createElement("script");
18017  s.textContent = code$2;
18018  dom.querySelector("body").appendChild(s);
18019};
18020
18021//import xml from "xml";
18022
18023var generateCrossref = function(data) {
18024
18025
18026  var date = data.publishedDate;
18027
18028  var batch_timestamp = Math.floor(Date.now() / 1000);
18029  var batch_id = data.authors.length ? data.authors[0].lastName.toLowerCase().slice(0,20) : "Anonymous";
18030      batch_id += "_" + date.getFullYear();
18031      batch_id += "_" + data.title.split(" ")[0].toLowerCase().slice(0,20) + "_" +  batch_timestamp;
18032  // generate XML
18033  var crf_data =
18034    {doi_batch : [
18035
18036      { _attr: {
18037        version: "4.3.7",
18038        xmlns: "http://www.crossref.org/schema/4.3.7",
18039        "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
18040        "xsi:schemaLocation": "http://www.crossref.org/schema/4.3.7 http://www.crossref.org/schemas/crossref4.3.7.xsd",
18041      }},
18042
18043      { head: [
18044        {doi_batch_id: batch_id},
18045        {timestamp: batch_timestamp},
18046        {depositor: [
18047          {depositor_name: data.journal.publisherName},
18048          {email_address: data.journal.publisherEmail} ]},
18049        {registrant: data.journal.publisherName} ]},
18050
18051      {body: [
18052        {journal: [
18053
18054          {journal_metadata: [
18055            {full_title: data.journal.full_title || data.journal.title},
18056            {abbrev_title: data.journal.abbrev_title || data.journal.title || data.journal.full_title},
18057            {issn: data.journal.issn},
18058            {doi_data: [
18059              {doi: data.journal.doi},
18060              {resource: data.journal.url} ]} ]},
18061
18062          {journal_issue: [
18063            {publication_date: [
18064              {month: date.getMonth()+1},
18065              {year: date.getFullYear()} ]},
18066            {journal_volume: [
18067              {volume: data.volume} ]},
18068            {issue: data.issue} ]},
18069
18070          {journal_article: [
18071            {titles: [
18072              {title: data.title} ]},
18073            { contributors:
18074              data.authors.map(function (author, ind) { return (
18075                {person_name: [
18076                  { _attr: {
18077                    contributor_role: "author",
18078                    sequence: (ind == 0)? "first" : "additional"
18079                  }},
18080                  {given_name: author.firstName},
18081                  {surname: author.lastName},
18082                  {affiliation: author.affiliation}
18083                  // TODO: ORCID?
18084                ]}
18085              ); })
18086            },
18087            {publication_date: [
18088                {month: date.getMonth()+1},
18089                {day: date.getDate()},
18090                {year: date.getFullYear()}
18091            ]},
18092            { publisher_item: [
18093              {item_number: data.doi}
18094            ]},
18095            {doi_data: [
18096              {doi: data.doi},
18097              //{timestamp: ""},
18098              {resource: data.url} ]},
18099            {citation_list:
18100              data.citations.map(function (key) { return citation_xml(key, data.bibliography[key]); })
18101            }
18102
18103          ]} ]} ]} ]};
18104
18105  return xml(crf_data);
18106};
18107
18108function citation_xml(key, ent){
18109  if (ent == undefined) { return {}; }
18110  var info = [];
18111  info.push({_attr: {key: key}});
18112  if ("title" in ent)
18113    { info.push({article_title: ent.title}); }
18114  if ("author" in ent)
18115    { info.push({author: ent.author.split(" and ")[0].split(",")[0].trim()}); }
18116  if ("journal" in ent)
18117    { info.push({journal_title: ent.journal}); }
18118  if ("booktitle" in ent)
18119    { info.push({volume_title: ent.booktitle}); }
18120  if ("volume" in ent)
18121    { info.push({volume: ent.volume}); }
18122  if ("issue" in ent)
18123    { info.push({issue: ent.issue}); }
18124  if ("doi" in ent)
18125    { info.push({doi: ent.doi}); }
18126  return {citation: info}
18127}
18128
18129function xml(obj) {
18130  //console.log(typeof(obj), obj)
18131  if (typeof obj === 'string') { return obj; }
18132  if (typeof obj === 'number') { return ""+obj; }
18133  var keys = Object.keys(obj);
18134  if (keys.length != 1) { console.error("can't interpret ", obj, "as xml"); }
18135  var name = keys[0];
18136  var full_content = obj[name];
18137  var attr = {};
18138  if (Array.isArray(full_content)){
18139    var content = [];
18140    for (var i in  full_content) {
18141      var obj = full_content[i];
18142      var obj_name = Object.keys(obj)[0];
18143      if ("_attr" == obj_name) {
18144        attr = obj["_attr"];
18145      } else {
18146        //console.log(Object.keys(obj)[0])
18147        content.push(obj);
18148      }
18149    }
18150  } else {
18151    content = full_content;
18152  }
18153  if (content == undefined){
18154    content = "undefined";
18155  }
18156
18157  var attr_string = "";
18158  for (var k in attr) {
18159    attr_string += " " + k + "=\"" + (attr[k]) + "\"";
18160  }
18161
18162  //console.log(typeof content, Array.isArray(content), content instanceof String, content)
18163  if (Array.isArray(content)){
18164    content = content.map(xml);
18165    content = content.join("\n").split("\n");
18166    content = content.map(function (s) { return "  " + s; }).join("\n");
18167    var result = "<" + name + attr_string + ">\n" + content + "\n</" + name + ">";
18168  } else {
18169    content = xml(content);
18170    var result = "<" + name + attr_string + ">" + content + "</" + name + ">";
18171  }
18172  return result;
18173}
18174
18175var logo = "<svg viewBox=\"-607 419 64 64\">\n  <path d=\"M-573.4,478.9c-8,0-14.6-6.4-14.6-14.5s14.6-25.9,14.6-40.8c0,14.9,14.6,32.8,14.6,40.8S-565.4,478.9-573.4,478.9z\"/>\n</svg>\n";
18176
18177var html$4 = "\n<style>\ndt-header {\n  display: block;\n  position: relative;\n  height: 60px;\n  background-color: hsl(200, 60%, 15%);\n  width: 100%;\n  box-sizing: border-box;\n  z-index: 2;\n  color: rgba(0, 0, 0, 0.8);\n  border-bottom: 1px solid rgba(0, 0, 0, 0.08);\n  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);\n}\ndt-header .content {\n  height: 70px;\n}\ndt-header a {\n  font-size: 16px;\n  height: 60px;\n  line-height: 60px;\n  text-decoration: none;\n  color: rgba(255, 255, 255, 0.8);\n  padding: 22px 0;\n}
18177\ndt-header a:hover {\n  color: rgba(255, 255, 255, 1);\n}\ndt-header svg {\n  width: 24px;\n  position: relative;\n  top: 4px;\n  margin-right: 2px;\n}\n@media(min-width: 1080px) {\n  dt-header {\n    height: 70px;\n  }\n  dt-header a {\n    height: 70px;\n    line-height: 70px;\n    padding: 28px 0;\n  }\n  dt-header .logo {\n  }\n}\ndt-header svg path {\n  fill: none;\n  stroke: rgba(255, 255, 255, 0.8);\n  stroke-width: 3px;\n}\ndt-header .logo {\n  font-size: 17px;\n  font-weight: 200;\n}\ndt-header .nav {\n  float: right;\n  font-weight: 300;\n}\ndt-header .nav a {\n  font-size: 12px;\n  margin-left: 24px;\n  text-transform: uppercase;\n}\n</style>\n\n<div class=\"content l-page\">\n  <a href=\"/\" class=\"logo\">\n    " + logo + "\n    Distill\n  </a>\n  <div class=\"nav\">\n    <a href=\"/about/\">About</a>\n    <a href=\"/prize/\">Prize</a>\n    <a href=\"/journal/\">Submit</a>\n  </div>\n</div>\n";
18178
18179var header = function(dom, data) {
18180  var el = dom.querySelector("dt-header");
18181  if(el) {
18182    el.innerHTML = html$4;
18183  } else {
18184    var header = dom.createElement("dt-header");
18185    header.innerHTML = html$4;
18186    var b = dom.querySelector("body");
18187    b.insertBefore(header, b.firstChild);
18188  }
18189};
18190
18191var html$5 = "\n<style>\ndt-footer {\n  display: block;\n  color: rgba(255, 255, 255, 0.4);\n  font-weight: 300;\n  padding: 40px 0;\n  border-top: 1px solid rgba(0, 0, 0, 0.1);\n  background-color: hsl(200, 60%, 15%);\n  text-align: center;\n}\ndt-footer .logo svg {\n  width: 24px;\n  position: relative;\n  top: 4px;\n  margin-right: 2px;\n}\ndt-footer .logo svg path {\n  fill: none;\n  stroke: rgba(255, 255, 255, 0.8);\n  stroke-width: 3px;\n}\ndt-footer .logo {\n  font-size: 17px;\n  font-weight: 200;\n  color: rgba(255, 255, 255, 0.8);\n  text-decoration: none;\n  margin-right: 6px;\n}\ndt-footer .nav {\n  margin-top: 12px;\n}\ndt-footer .nav a {\n  color: rgba(255, 255, 255, 0.8);\n  margin-right: 6px;\n}\n</style>\n\n<div class=\"l-page\">\n  <div class=\"description\">\n  <a href=\"/\" class=\"logo\">\n    " + logo + "\n    Distill\n  </a>\n  is dedicated to clear explanations of machine learning\n  </div>\n  <div class=\"nav\">\n    <a href=\"http://distill.pub/about/\">About</a>\n    <a href=\"http://distill.pub/journal/\">Submit</a>\n    <a href=\"http://distill.pub/prize/\">Prize</a>\n    <a href=\"http://distill.pub/archive/\">Archive</a>\n    <a href=\"http://distill.pub/rss.xml\">RSS</a>\n    <a href=\"https://github.com/distillpub\">GitHub</a>\n    <a href=\"https://twitter.com/distillpub\">Twitter</a>\n    &nbsp;&nbsp;&nbsp;&nbsp; ISSN 2476-0757\n  </div>\n</div>\n";
18192
18193var footer = function(dom, data) {
18194  var el = dom.querySelector("dt-footer");
18195  if(el) {
18196    el.innerHTML = html$5;
18197  } else {
18198    var footer = dom.createElement("dt-footer");
18199    footer.innerHTML = html$5;
18200    var b = dom.querySelector("body");
18201    b.appendChild(footer);
18202  }
18203};
18204
18205function renderImmediately(dom) {
18206  html(dom);
18207  styles(dom);
18208}
18209
18210function renderOnLoad(dom, data) {
18211  frontMatter(dom, data);
18212  bibliography(dom, data);
18213  expandData(dom, data);
18214  meta(dom, data);
18215  byline(dom, data);
18216  appendix(dom, data);
18217  markdown(dom, data);
18218  DTMath(dom, data);
18219  code$1(dom, data);
18220  citation(dom, data);
18221  footnote(dom, data);
18222  typeset(dom, data);
18223  hoverBox(dom, data);
18224}
18225
18226// If we are in a browser, render automatically...
18227var browser = new Function("try { return this === window; }catch(e){ return false; }");
18228if (browser) {
18229  try {
18230    var data = {};
18231    renderImmediately(window.document);
18232    window.document.addEventListener("DOMContentLoaded", function (event) {
18233      renderOnLoad(window.document, data);
18234      // Add a banner if we're not on localhost.
18235      if (window.location.hostname !== "localhost" && window.location.origin !== "file://") {
18236        banner(window.document, data);
18237      }
18238      generateCrossref(data);
18239      // console.log(data);
18240    });
18241  } catch (error) {
18242    console.error("Window not defined");
18243  }
18244}
18245
18246// If we are in node...
18247function render$1(dom, data) {
18248  renderImmediately(dom);
18249  renderOnLoad(dom, data);
18250  // Remove script tag so it doesn't run again in the client
18251  var s = dom.querySelector('script[src*="distill.pub/template"]');
18252  if (s) { s.parentElement.removeChild(s); }
18253}
18254
18255// Distill specific rendering
18256function distillify(dom, data) {
18257  header(dom, data);
18258  appendixDistill(dom, data);
18259  footer(dom, data);
18260}
18261
18262exports.render = render$1;
18263exports.distillify = distillify;
18264exports.generateCrossref = generateCrossref;
18265
18266Object.defineProperty(exports, '__esModule', { value: true });
18267
18268})));
18269//# sourceMappingURL=template.v1.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.