1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
3 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
4 | (factory((global.dl = global.dl || {})));
|
5 | }(this, (function (exports) { 'use strict';
|
6 |
|
7 | var html = function(dom) {
|
8 | if (!dom.querySelector("html").getAttribute("lang")) {
|
9 | dom.querySelector("html").setAttribute("lang", "en");
|
10 | }
|
11 |
|
12 | var head = dom.querySelector("head");
|
13 |
|
14 | if (!dom.querySelector("meta[charset]")) {
|
15 | var meta = dom.createElement("meta");
|
16 | meta.setAttribute("charset", "utf-8");
|
17 | head.appendChild(meta);
|
18 | }
|
19 | if (!dom.querySelector("meta[name=viewport]")) {
|
20 | var meta$1 = dom.createElement("meta");
|
21 | meta$1.setAttribute("name", "viewport");
|
22 | meta$1.setAttribute("content", "width=device-width, initial-scale=1");
|
23 | head.appendChild(meta$1);
|
24 | }
|
25 | };
|
26 |
|
27 | var 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";
|
28 |
|
29 | var 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 > ul,\ndt-article > dt-byline,\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 > 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-middle,\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 > ul,\n dt-article > dt-byline,\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 > 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 > ul,\n dt-article > dt-byline,\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 > 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 > 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 > 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 > 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 }\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";
|
30 |
|
31 | var 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 overflow: hidden;\n background: white;\n min-height: calc(100vh - 70px - 182px);\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\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\n/*dt-article figure figcaption::before {\n position: relative;\n display: block;\n top: -20px;\n content: \"\";\n width: 25px;\n border-top: 1px solid rgba(0, 0, 0, 0.3);\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";
|
32 |
|
33 | var 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;\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-\"],\npre[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";
|
34 |
|
35 | var 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";
|
36 |
|
37 | var styles = function(dom) {
|
38 | var s = dom.createElement("style");
|
39 | s.textContent = base + layout + article + code + print;
|
40 | dom.querySelector("head").appendChild(s);
|
41 | };
|
42 |
|
43 | function isNothing(subject) {
|
44 | return (typeof subject === 'undefined') || (subject === null);
|
45 | }
|
46 |
|
47 |
|
48 | function isObject(subject) {
|
49 | return (typeof subject === 'object') && (subject !== null);
|
50 | }
|
51 |
|
52 |
|
53 | function toArray(sequence) {
|
54 | if (Array.isArray(sequence)) { return sequence; }
|
55 | else if (isNothing(sequence)) { return []; }
|
56 |
|
57 | return [ sequence ];
|
58 | }
|
59 |
|
60 |
|
61 | function extend(target, source) {
|
62 | var index, length, key, sourceKeys;
|
63 |
|
64 | if (source) {
|
65 | sourceKeys = Object.keys(source);
|
66 |
|
67 | for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
68 | key = sourceKeys[index];
|
69 | target[key] = source[key];
|
70 | }
|
71 | }
|
72 |
|
73 | return target;
|
74 | }
|
75 |
|
76 |
|
77 | function repeat(string, count) {
|
78 | var result = '', cycle;
|
79 |
|
80 | for (cycle = 0; cycle < count; cycle += 1) {
|
81 | result += string;
|
82 | }
|
83 |
|
84 | return result;
|
85 | }
|
86 |
|
87 |
|
88 | function isNegativeZero(number) {
|
89 | return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
|
90 | }
|
91 |
|
92 |
|
93 | var isNothing_1 = isNothing;
|
94 | var isObject_1 = isObject;
|
95 | var toArray_1 = toArray;
|
96 | var repeat_1 = repeat;
|
97 | var isNegativeZero_1 = isNegativeZero;
|
98 | var extend_1 = extend;
|
99 |
|
100 | var common$1 = {
|
101 | isNothing: isNothing_1,
|
102 | isObject: isObject_1,
|
103 | toArray: toArray_1,
|
104 | repeat: repeat_1,
|
105 | isNegativeZero: isNegativeZero_1,
|
106 | extend: extend_1
|
107 | };
|
108 |
|
109 |
|
110 |
|
111 | function YAMLException$2(reason, mark) {
|
112 |
|
113 | Error.call(this);
|
114 |
|
115 |
|
116 | if (Error.captureStackTrace) {
|
117 |
|
118 | Error.captureStackTrace(this, this.constructor);
|
119 | } else {
|
120 |
|
121 | this.stack = (new Error()).stack || '';
|
122 | }
|
123 |
|
124 | this.name = 'YAMLException';
|
125 | this.reason = reason;
|
126 | this.mark = mark;
|
127 | this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
|
128 | }
|
129 |
|
130 |
|
131 |
|
132 | YAMLException$2.prototype = Object.create(Error.prototype);
|
133 | YAMLException$2.prototype.constructor = YAMLException$2;
|
134 |
|
135 |
|
136 | YAMLException$2.prototype.toString = function toString(compact) {
|
137 | var result = this.name + ': ';
|
138 |
|
139 | result += this.reason || '(unknown reason)';
|
140 |
|
141 | if (!compact && this.mark) {
|
142 | result += ' ' + this.mark.toString();
|
143 | }
|
144 |
|
145 | return result;
|
146 | };
|
147 |
|
148 |
|
149 | var exception = YAMLException$2;
|
150 |
|
151 | var common$3 = common$1;
|
152 |
|
153 |
|
154 | function Mark$1(name, buffer, position, line, column) {
|
155 | this.name = name;
|
156 | this.buffer = buffer;
|
157 | this.position = position;
|
158 | this.line = line;
|
159 | this.column = column;
|
160 | }
|
161 |
|
162 |
|
163 | Mark$1.prototype.getSnippet = function getSnippet(indent, maxLength) {
|
164 | var this$1 = this;
|
165 |
|
166 | var head, start, tail, end, snippet;
|
167 |
|
168 | if (!this.buffer) { return null; }
|
169 |
|
170 | indent = indent || 4;
|
171 | maxLength = maxLength || 75;
|
172 |
|
173 | head = '';
|
174 | start = this.position;
|
175 |
|
176 | while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
|
177 | start -= 1;
|
178 | if (this$1.position - start > (maxLength / 2 - 1)) {
|
179 | head = ' ... ';
|
180 | start += 5;
|
181 | break;
|
182 | }
|
183 | }
|
184 |
|
185 | tail = '';
|
186 | end = this.position;
|
187 |
|
188 | while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
|
189 | end += 1;
|
190 | if (end - this$1.position > (maxLength / 2 - 1)) {
|
191 | tail = ' ... ';
|
192 | end -= 5;
|
193 | break;
|
194 | }
|
195 | }
|
196 |
|
197 | snippet = this.buffer.slice(start, end);
|
198 |
|
199 | return common$3.repeat(' ', indent) + head + snippet + tail + '\n' +
|
200 | common$3.repeat(' ', indent + this.position - start + head.length) + '^';
|
201 | };
|
202 |
|
203 |
|
204 | Mark$1.prototype.toString = function toString(compact) {
|
205 | var snippet, where = '';
|
206 |
|
207 | if (this.name) {
|
208 | where += 'in "' + this.name + '" ';
|
209 | }
|
210 |
|
211 | where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
|
212 |
|
213 | if (!compact) {
|
214 | snippet = this.getSnippet();
|
215 |
|
216 | if (snippet) {
|
217 | where += ':\n' + snippet;
|
218 | }
|
219 | }
|
220 |
|
221 | return where;
|
222 | };
|
223 |
|
224 |
|
225 | var mark = Mark$1;
|
226 |
|
227 | var YAMLException$4 = exception;
|
228 |
|
229 | var TYPE_CONSTRUCTOR_OPTIONS = [
|
230 | 'kind',
|
231 | 'resolve',
|
232 | 'construct',
|
233 | 'instanceOf',
|
234 | 'predicate',
|
235 | 'represent',
|
236 | 'defaultStyle',
|
237 | 'styleAliases'
|
238 | ];
|
239 |
|
240 | var YAML_NODE_KINDS = [
|
241 | 'scalar',
|
242 | 'sequence',
|
243 | 'mapping'
|
244 | ];
|
245 |
|
246 | function compileStyleAliases(map) {
|
247 | var result = {};
|
248 |
|
249 | if (map !== null) {
|
250 | Object.keys(map).forEach(function (style) {
|
251 | map[style].forEach(function (alias) {
|
252 | result[String(alias)] = style;
|
253 | });
|
254 | });
|
255 | }
|
256 |
|
257 | return result;
|
258 | }
|
259 |
|
260 | function Type$2(tag, options) {
|
261 | options = options || {};
|
262 |
|
263 | Object.keys(options).forEach(function (name) {
|
264 | if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
265 | throw new YAMLException$4('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
266 | }
|
267 | });
|
268 |
|
269 |
|
270 | this.tag = tag;
|
271 | this.kind = options['kind'] || null;
|
272 | this.resolve = options['resolve'] || function () { return true; };
|
273 | this.construct = options['construct'] || function (data) { return data; };
|
274 | this.instanceOf = options['instanceOf'] || null;
|
275 | this.predicate = options['predicate'] || null;
|
276 | this.represent = options['represent'] || null;
|
277 | this.defaultStyle = options['defaultStyle'] || null;
|
278 | this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
|
279 |
|
280 | if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
281 | throw new YAMLException$4('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
282 | }
|
283 | }
|
284 |
|
285 | var type = Type$2;
|
286 |
|
287 |
|
288 |
|
289 | var common$4 = common$1;
|
290 | var YAMLException$3 = exception;
|
291 | var Type$1 = type;
|
292 |
|
293 |
|
294 | function compileList(schema, name, result) {
|
295 | var exclude = [];
|
296 |
|
297 | schema.include.forEach(function (includedSchema) {
|
298 | result = compileList(includedSchema, name, result);
|
299 | });
|
300 |
|
301 | schema[name].forEach(function (currentType) {
|
302 | result.forEach(function (previousType, previousIndex) {
|
303 | if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
|
304 | exclude.push(previousIndex);
|
305 | }
|
306 | });
|
307 |
|
308 | result.push(currentType);
|
309 | });
|
310 |
|
311 | return result.filter(function (type$$1, index) {
|
312 | return exclude.indexOf(index) === -1;
|
313 | });
|
314 | }
|
315 |
|
316 |
|
317 | function compileMap(/* lists... */) {
|
318 | var arguments$1 = arguments;
|
319 |
|
320 | var result = {
|
321 | scalar: {},
|
322 | sequence: {},
|
323 | mapping: {},
|
324 | fallback: {}
|
325 | }, index, length;
|
326 |
|
327 | function collectType(type$$1) {
|
328 | result[type$$1.kind][type$$1.tag] = result['fallback'][type$$1.tag] = type$$1;
|
329 | }
|
330 |
|
331 | for (index = 0, length = arguments.length; index < length; index += 1) {
|
332 | arguments$1[index].forEach(collectType);
|
333 | }
|
334 | return result;
|
335 | }
|
336 |
|
337 |
|
338 | function Schema$2(definition) {
|
339 | this.include = definition.include || [];
|
340 | this.implicit = definition.implicit || [];
|
341 | this.explicit = definition.explicit || [];
|
342 |
|
343 | this.implicit.forEach(function (type$$1) {
|
344 | if (type$$1.loadKind && type$$1.loadKind !== 'scalar') {
|
345 | 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.');
|
346 | }
|
347 | });
|
348 |
|
349 | this.compiledImplicit = compileList(this, 'implicit', []);
|
350 | this.compiledExplicit = compileList(this, 'explicit', []);
|
351 | this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
|
352 | }
|
353 |
|
354 |
|
355 | Schema$2.DEFAULT = null;
|
356 |
|
357 |
|
358 | Schema$2.create = function createSchema() {
|
359 | var schemas, types;
|
360 |
|
361 | switch (arguments.length) {
|
362 | case 1:
|
363 | schemas = Schema$2.DEFAULT;
|
364 | types = arguments[0];
|
365 | break;
|
366 |
|
367 | case 2:
|
368 | schemas = arguments[0];
|
369 | types = arguments[1];
|
370 | break;
|
371 |
|
372 | default:
|
373 | throw new YAMLException$3('Wrong number of arguments for Schema.create function');
|
374 | }
|
375 |
|
376 | schemas = common$4.toArray(schemas);
|
377 | types = common$4.toArray(types);
|
378 |
|
379 | if (!schemas.every(function (schema) { return schema instanceof Schema$2; })) {
|
380 | throw new YAMLException$3('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
|
381 | }
|
382 |
|
383 | if (!types.every(function (type$$1) { return type$$1 instanceof Type$1; })) {
|
384 | throw new YAMLException$3('Specified list of YAML types (or a single Type object) contains a non-Type object.');
|
385 | }
|
386 |
|
387 | return new Schema$2({
|
388 | include: schemas,
|
389 | explicit: types
|
390 | });
|
391 | };
|
392 |
|
393 |
|
394 | var schema = Schema$2;
|
395 |
|
396 | var Type$3 = type;
|
397 |
|
398 | var str = new Type$3('tag:yaml.org,2002:str', {
|
399 | kind: 'scalar',
|
400 | construct: function (data) { return data !== null ? data : ''; }
|
401 | });
|
402 |
|
403 | var Type$4 = type;
|
404 |
|
405 | var seq = new Type$4('tag:yaml.org,2002:seq', {
|
406 | kind: 'sequence',
|
407 | construct: function (data) { return data !== null ? data : []; }
|
408 | });
|
409 |
|
410 | var Type$5 = type;
|
411 |
|
412 | var map = new Type$5('tag:yaml.org,2002:map', {
|
413 | kind: 'mapping',
|
414 | construct: function (data) { return data !== null ? data : {}; }
|
415 | });
|
416 |
|
417 | var Schema$5 = schema;
|
418 |
|
419 |
|
420 | var failsafe = new Schema$5({
|
421 | explicit: [
|
422 | str,
|
423 | seq,
|
424 | map
|
425 | ]
|
426 | });
|
427 |
|
428 | var Type$6 = type;
|
429 |
|
430 | function resolveYamlNull(data) {
|
431 | if (data === null) { return true; }
|
432 |
|
433 | var max = data.length;
|
434 |
|
435 | return (max === 1 && data === '~') ||
|
436 | (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
|
437 | }
|
438 |
|
439 | function constructYamlNull() {
|
440 | return null;
|
441 | }
|
442 |
|
443 | function isNull(object) {
|
444 | return object === null;
|
445 | }
|
446 |
|
447 | var _null = new Type$6('tag:yaml.org,2002:null', {
|
448 | kind: 'scalar',
|
449 | resolve: resolveYamlNull,
|
450 | construct: constructYamlNull,
|
451 | predicate: isNull,
|
452 | represent: {
|
453 | canonical: function () { return '~'; },
|
454 | lowercase: function () { return 'null'; },
|
455 | uppercase: function () { return 'NULL'; },
|
456 | camelcase: function () { return 'Null'; }
|
457 | },
|
458 | defaultStyle: 'lowercase'
|
459 | });
|
460 |
|
461 | var Type$7 = type;
|
462 |
|
463 | function resolveYamlBoolean(data) {
|
464 | if (data === null) { return false; }
|
465 |
|
466 | var max = data.length;
|
467 |
|
468 | return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
|
469 | (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
|
470 | }
|
471 |
|
472 | function constructYamlBoolean(data) {
|
473 | return data === 'true' ||
|
474 | data === 'True' ||
|
475 | data === 'TRUE';
|
476 | }
|
477 |
|
478 | function isBoolean(object) {
|
479 | return Object.prototype.toString.call(object) === '[object Boolean]';
|
480 | }
|
481 |
|
482 | var bool = new Type$7('tag:yaml.org,2002:bool', {
|
483 | kind: 'scalar',
|
484 | resolve: resolveYamlBoolean,
|
485 | construct: constructYamlBoolean,
|
486 | predicate: isBoolean,
|
487 | represent: {
|
488 | lowercase: function (object) { return object ? 'true' : 'false'; },
|
489 | uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
|
490 | camelcase: function (object) { return object ? 'True' : 'False'; }
|
491 | },
|
492 | defaultStyle: 'lowercase'
|
493 | });
|
494 |
|
495 | var common$5 = common$1;
|
496 | var Type$8 = type;
|
497 |
|
498 | function isHexCode(c) {
|
499 | return ((0x30 <= c) && (c <= 0x39)) ||
|
500 | ((0x41 <= c) && (c <= 0x46)) ||
|
501 | ((0x61 <= c) && (c <= 0x66));
|
502 | }
|
503 |
|
504 | function isOctCode(c) {
|
505 | return ((0x30 <= c) && (c <= 0x37));
|
506 | }
|
507 |
|
508 | function isDecCode(c) {
|
509 | return ((0x30 <= c) && (c <= 0x39));
|
510 | }
|
511 |
|
512 | function resolveYamlInteger(data) {
|
513 | if (data === null) { return false; }
|
514 |
|
515 | var max = data.length,
|
516 | index = 0,
|
517 | hasDigits = false,
|
518 | ch;
|
519 |
|
520 | if (!max) { return false; }
|
521 |
|
522 | ch = data[index];
|
523 |
|
524 |
|
525 | if (ch === '-' || ch === '+') {
|
526 | ch = data[++index];
|
527 | }
|
528 |
|
529 | if (ch === '0') {
|
530 |
|
531 | if (index + 1 === max) { return true; }
|
532 | ch = data[++index];
|
533 |
|
534 |
|
535 |
|
536 | if (ch === 'b') {
|
537 |
|
538 | index++;
|
539 |
|
540 | for (; index < max; index++) {
|
541 | ch = data[index];
|
542 | if (ch === '_') { continue; }
|
543 | if (ch !== '0' && ch !== '1') { return false; }
|
544 | hasDigits = true;
|
545 | }
|
546 | return hasDigits;
|
547 | }
|
548 |
|
549 |
|
550 | if (ch === 'x') {
|
551 |
|
552 | index++;
|
553 |
|
554 | for (; index < max; index++) {
|
555 | ch = data[index];
|
556 | if (ch === '_') { continue; }
|
557 | if (!isHexCode(data.charCodeAt(index))) { return false; }
|
558 | hasDigits = true;
|
559 | }
|
560 | return hasDigits;
|
561 | }
|
562 |
|
563 |
|
564 | for (; index < max; index++) {
|
565 | ch = data[index];
|
566 | if (ch === '_') { continue; }
|
567 | if (!isOctCode(data.charCodeAt(index))) { return false; }
|
568 | hasDigits = true;
|
569 | }
|
570 | return hasDigits;
|
571 | }
|
572 |
|
573 |
|
574 |
|
575 | for (; index < max; index++) {
|
576 | ch = data[index];
|
577 | if (ch === '_') { continue; }
|
578 | if (ch === ':') { break; }
|
579 | if (!isDecCode(data.charCodeAt(index))) {
|
580 | return false;
|
581 | }
|
582 | hasDigits = true;
|
583 | }
|
584 |
|
585 | if (!hasDigits) { return false; }
|
586 |
|
587 |
|
588 | if (ch !== ':') { return true; }
|
589 |
|
590 |
|
591 | return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
592 | }
|
593 |
|
594 | function constructYamlInteger(data) {
|
595 | var value = data, sign = 1, ch, base, digits = [];
|
596 |
|
597 | if (value.indexOf('_') !== -1) {
|
598 | value = value.replace(/_/g, '');
|
599 | }
|
600 |
|
601 | ch = value[0];
|
602 |
|
603 | if (ch === '-' || ch === '+') {
|
604 | if (ch === '-') { sign = -1; }
|
605 | value = value.slice(1);
|
606 | ch = value[0];
|
607 | }
|
608 |
|
609 | if (value === '0') { return 0; }
|
610 |
|
611 | if (ch === '0') {
|
612 | if (value[1] === 'b') { return sign * parseInt(value.slice(2), 2); }
|
613 | if (value[1] === 'x') { return sign * parseInt(value, 16); }
|
614 | return sign * parseInt(value, 8);
|
615 | }
|
616 |
|
617 | if (value.indexOf(':') !== -1) {
|
618 | value.split(':').forEach(function (v) {
|
619 | digits.unshift(parseInt(v, 10));
|
620 | });
|
621 |
|
622 | value = 0;
|
623 | base = 1;
|
624 |
|
625 | digits.forEach(function (d) {
|
626 | value += (d * base);
|
627 | base *= 60;
|
628 | });
|
629 |
|
630 | return sign * value;
|
631 |
|
632 | }
|
633 |
|
634 | return sign * parseInt(value, 10);
|
635 | }
|
636 |
|
637 | function isInteger(object) {
|
638 | return (Object.prototype.toString.call(object)) === '[object Number]' &&
|
639 | (object % 1 === 0 && !common$5.isNegativeZero(object));
|
640 | }
|
641 |
|
642 | var int_1 = new Type$8('tag:yaml.org,2002:int', {
|
643 | kind: 'scalar',
|
644 | resolve: resolveYamlInteger,
|
645 | construct: constructYamlInteger,
|
646 | predicate: isInteger,
|
647 | represent: {
|
648 | binary: function (object) { return '0b' + object.toString(2); },
|
649 | octal: function (object) { return '0' + object.toString(8); },
|
650 | decimal: function (object) { return object.toString(10); },
|
651 | hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); }
|
652 | },
|
653 | defaultStyle: 'decimal',
|
654 | styleAliases: {
|
655 | binary: [ 2, 'bin' ],
|
656 | octal: [ 8, 'oct' ],
|
657 | decimal: [ 10, 'dec' ],
|
658 | hexadecimal: [ 16, 'hex' ]
|
659 | }
|
660 | });
|
661 |
|
662 | var common$6 = common$1;
|
663 | var Type$9 = type;
|
664 |
|
665 | var YAML_FLOAT_PATTERN = new RegExp(
|
666 | '^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' +
|
667 | '|\\.[0-9_]+(?:[eE][-+][0-9]+)?' +
|
668 | '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
|
669 | '|[-+]?\\.(?:inf|Inf|INF)' +
|
670 | '|\\.(?:nan|NaN|NAN))$');
|
671 |
|
672 | function resolveYamlFloat(data) {
|
673 | if (data === null) { return false; }
|
674 |
|
675 | if (!YAML_FLOAT_PATTERN.test(data)) { return false; }
|
676 |
|
677 | return true;
|
678 | }
|
679 |
|
680 | function constructYamlFloat(data) {
|
681 | var value, sign, base, digits;
|
682 |
|
683 | value = data.replace(/_/g, '').toLowerCase();
|
684 | sign = value[0] === '-' ? -1 : 1;
|
685 | digits = [];
|
686 |
|
687 | if ('+-'.indexOf(value[0]) >= 0) {
|
688 | value = value.slice(1);
|
689 | }
|
690 |
|
691 | if (value === '.inf') {
|
692 | return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
693 |
|
694 | } else if (value === '.nan') {
|
695 | return NaN;
|
696 |
|
697 | } else if (value.indexOf(':') >= 0) {
|
698 | value.split(':').forEach(function (v) {
|
699 | digits.unshift(parseFloat(v, 10));
|
700 | });
|
701 |
|
702 | value = 0.0;
|
703 | base = 1;
|
704 |
|
705 | digits.forEach(function (d) {
|
706 | value += d * base;
|
707 | base *= 60;
|
708 | });
|
709 |
|
710 | return sign * value;
|
711 |
|
712 | }
|
713 | return sign * parseFloat(value, 10);
|
714 | }
|
715 |
|
716 |
|
717 | var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
718 |
|
719 | function representYamlFloat(object, style) {
|
720 | var res;
|
721 |
|
722 | if (isNaN(object)) {
|
723 | switch (style) {
|
724 | case 'lowercase': return '.nan';
|
725 | case 'uppercase': return '.NAN';
|
726 | case 'camelcase': return '.NaN';
|
727 | }
|
728 | } else if (Number.POSITIVE_INFINITY === object) {
|
729 | switch (style) {
|
730 | case 'lowercase': return '.inf';
|
731 | case 'uppercase': return '.INF';
|
732 | case 'camelcase': return '.Inf';
|
733 | }
|
734 | } else if (Number.NEGATIVE_INFINITY === object) {
|
735 | switch (style) {
|
736 | case 'lowercase': return '-.inf';
|
737 | case 'uppercase': return '-.INF';
|
738 | case 'camelcase': return '-.Inf';
|
739 | }
|
740 | } else if (common$6.isNegativeZero(object)) {
|
741 | return '-0.0';
|
742 | }
|
743 |
|
744 | res = object.toString(10);
|
745 |
|
746 |
|
747 |
|
748 |
|
749 | return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
|
750 | }
|
751 |
|
752 | function isFloat(object) {
|
753 | return (Object.prototype.toString.call(object) === '[object Number]') &&
|
754 | (object % 1 !== 0 || common$6.isNegativeZero(object));
|
755 | }
|
756 |
|
757 | var float_1 = new Type$9('tag:yaml.org,2002:float', {
|
758 | kind: 'scalar',
|
759 | resolve: resolveYamlFloat,
|
760 | construct: constructYamlFloat,
|
761 | predicate: isFloat,
|
762 | represent: representYamlFloat,
|
763 | defaultStyle: 'lowercase'
|
764 | });
|
765 |
|
766 | var Schema$4 = schema;
|
767 |
|
768 |
|
769 | var json = new Schema$4({
|
770 | include: [
|
771 | failsafe
|
772 | ],
|
773 | implicit: [
|
774 | _null,
|
775 | bool,
|
776 | int_1,
|
777 | float_1
|
778 | ]
|
779 | });
|
780 |
|
781 | var Schema$3 = schema;
|
782 |
|
783 |
|
784 | var core = new Schema$3({
|
785 | include: [
|
786 | json
|
787 | ]
|
788 | });
|
789 |
|
790 | var Type$10 = type;
|
791 |
|
792 | var YAML_DATE_REGEXP = new RegExp(
|
793 | '^([0-9][0-9][0-9][0-9])' +
|
794 | '-([0-9][0-9])' +
|
795 | '-([0-9][0-9])$');
|
796 |
|
797 | var YAML_TIMESTAMP_REGEXP = new RegExp(
|
798 | '^([0-9][0-9][0-9][0-9])' +
|
799 | '-([0-9][0-9]?)' +
|
800 | '-([0-9][0-9]?)' +
|
801 | '(?:[Tt]|[ \\t]+)' +
|
802 | '([0-9][0-9]?)' +
|
803 | ':([0-9][0-9])' +
|
804 | ':([0-9][0-9])' +
|
805 | '(?:\\.([0-9]*))?' +
|
806 | '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' +
|
807 | '(?::([0-9][0-9]))?))?$');
|
808 |
|
809 | function resolveYamlTimestamp(data) {
|
810 | if (data === null) { return false; }
|
811 | if (YAML_DATE_REGEXP.exec(data) !== null) { return true; }
|
812 | if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) { return true; }
|
813 | return false;
|
814 | }
|
815 |
|
816 | function constructYamlTimestamp(data) {
|
817 | var match, year, month, day, hour, minute, second, fraction = 0,
|
818 | delta = null, tz_hour, tz_minute, date;
|
819 |
|
820 | match = YAML_DATE_REGEXP.exec(data);
|
821 | if (match === null) { match = YAML_TIMESTAMP_REGEXP.exec(data); }
|
822 |
|
823 | if (match === null) { throw new Error('Date resolve error'); }
|
824 |
|
825 |
|
826 |
|
827 | year = +(match[1]);
|
828 | month = +(match[2]) - 1;
|
829 | day = +(match[3]);
|
830 |
|
831 | if (!match[4]) {
|
832 | return new Date(Date.UTC(year, month, day));
|
833 | }
|
834 |
|
835 |
|
836 |
|
837 | hour = +(match[4]);
|
838 | minute = +(match[5]);
|
839 | second = +(match[6]);
|
840 |
|
841 | if (match[7]) {
|
842 | fraction = match[7].slice(0, 3);
|
843 | while (fraction.length < 3) {
|
844 | fraction += '0';
|
845 | }
|
846 | fraction = +fraction;
|
847 | }
|
848 |
|
849 |
|
850 |
|
851 | if (match[9]) {
|
852 | tz_hour = +(match[10]);
|
853 | tz_minute = +(match[11] || 0);
|
854 | delta = (tz_hour * 60 + tz_minute) * 60000;
|
855 | if (match[9] === '-') { delta = -delta; }
|
856 | }
|
857 |
|
858 | date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
859 |
|
860 | if (delta) { date.setTime(date.getTime() - delta); }
|
861 |
|
862 | return date;
|
863 | }
|
864 |
|
865 | function representYamlTimestamp(object /*, style*/) {
|
866 | return object.toISOString();
|
867 | }
|
868 |
|
869 | var timestamp = new Type$10('tag:yaml.org,2002:timestamp', {
|
870 | kind: 'scalar',
|
871 | resolve: resolveYamlTimestamp,
|
872 | construct: constructYamlTimestamp,
|
873 | instanceOf: Date,
|
874 | represent: representYamlTimestamp
|
875 | });
|
876 |
|
877 | var Type$11 = type;
|
878 |
|
879 | function resolveYamlMerge(data) {
|
880 | return data === '<<' || data === null;
|
881 | }
|
882 |
|
883 | var merge = new Type$11('tag:yaml.org,2002:merge', {
|
884 | kind: 'scalar',
|
885 | resolve: resolveYamlMerge
|
886 | });
|
887 |
|
888 | var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
889 |
|
890 | function commonjsRequire () {
|
891 | throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
|
892 | }
|
893 |
|
894 |
|
895 |
|
896 | function createCommonjsModule(fn, module) {
|
897 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
898 | }
|
899 |
|
900 |
|
901 |
|
902 | var NodeBuffer;
|
903 |
|
904 | try {
|
905 |
|
906 | var _require = commonjsRequire;
|
907 | NodeBuffer = _require('buffer').Buffer;
|
908 | } catch (__) {}
|
909 |
|
910 | var Type$12 = type;
|
911 |
|
912 |
|
913 |
|
914 | var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
|
915 |
|
916 |
|
917 | function resolveYamlBinary(data) {
|
918 | if (data === null) { return false; }
|
919 |
|
920 | var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
|
921 |
|
922 |
|
923 | for (idx = 0; idx < max; idx++) {
|
924 | code = map.indexOf(data.charAt(idx));
|
925 |
|
926 |
|
927 | if (code > 64) { continue; }
|
928 |
|
929 |
|
930 | if (code < 0) { return false; }
|
931 |
|
932 | bitlen += 6;
|
933 | }
|
934 |
|
935 |
|
936 | return (bitlen % 8) === 0;
|
937 | }
|
938 |
|
939 | function constructYamlBinary(data) {
|
940 | var idx, tailbits,
|
941 | input = data.replace(/[\r\n=]/g, ''),
|
942 | max = input.length,
|
943 | map = BASE64_MAP,
|
944 | bits = 0,
|
945 | result = [];
|
946 |
|
947 |
|
948 |
|
949 | for (idx = 0; idx < max; idx++) {
|
950 | if ((idx % 4 === 0) && idx) {
|
951 | result.push((bits >> 16) & 0xFF);
|
952 | result.push((bits >> 8) & 0xFF);
|
953 | result.push(bits & 0xFF);
|
954 | }
|
955 |
|
956 | bits = (bits << 6) | map.indexOf(input.charAt(idx));
|
957 | }
|
958 |
|
959 |
|
960 |
|
961 | tailbits = (max % 4) * 6;
|
962 |
|
963 | if (tailbits === 0) {
|
964 | result.push((bits >> 16) & 0xFF);
|
965 | result.push((bits >> 8) & 0xFF);
|
966 | result.push(bits & 0xFF);
|
967 | } else if (tailbits === 18) {
|
968 | result.push((bits >> 10) & 0xFF);
|
969 | result.push((bits >> 2) & 0xFF);
|
970 | } else if (tailbits === 12) {
|
971 | result.push((bits >> 4) & 0xFF);
|
972 | }
|
973 |
|
974 |
|
975 | if (NodeBuffer) { return new NodeBuffer(result); }
|
976 |
|
977 | return result;
|
978 | }
|
979 |
|
980 | function representYamlBinary(object /*, style*/) {
|
981 | var result = '', bits = 0, idx, tail,
|
982 | max = object.length,
|
983 | map = BASE64_MAP;
|
984 |
|
985 |
|
986 |
|
987 | for (idx = 0; idx < max; idx++) {
|
988 | if ((idx % 3 === 0) && idx) {
|
989 | result += map[(bits >> 18) & 0x3F];
|
990 | result += map[(bits >> 12) & 0x3F];
|
991 | result += map[(bits >> 6) & 0x3F];
|
992 | result += map[bits & 0x3F];
|
993 | }
|
994 |
|
995 | bits = (bits << 8) + object[idx];
|
996 | }
|
997 |
|
998 |
|
999 |
|
1000 | tail = max % 3;
|
1001 |
|
1002 | if (tail === 0) {
|
1003 | result += map[(bits >> 18) & 0x3F];
|
1004 | result += map[(bits >> 12) & 0x3F];
|
1005 | result += map[(bits >> 6) & 0x3F];
|
1006 | result += map[bits & 0x3F];
|
1007 | } else if (tail === 2) {
|
1008 | result += map[(bits >> 10) & 0x3F];
|
1009 | result += map[(bits >> 4) & 0x3F];
|
1010 | result += map[(bits << 2) & 0x3F];
|
1011 | result += map[64];
|
1012 | } else if (tail === 1) {
|
1013 | result += map[(bits >> 2) & 0x3F];
|
1014 | result += map[(bits << 4) & 0x3F];
|
1015 | result += map[64];
|
1016 | result += map[64];
|
1017 | }
|
1018 |
|
1019 | return result;
|
1020 | }
|
1021 |
|
1022 | function isBinary(object) {
|
1023 | return NodeBuffer && NodeBuffer.isBuffer(object);
|
1024 | }
|
1025 |
|
1026 | var binary = new Type$12('tag:yaml.org,2002:binary', {
|
1027 | kind: 'scalar',
|
1028 | resolve: resolveYamlBinary,
|
1029 | construct: constructYamlBinary,
|
1030 | predicate: isBinary,
|
1031 | represent: representYamlBinary
|
1032 | });
|
1033 |
|
1034 | var Type$13 = type;
|
1035 |
|
1036 | var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
1037 | var _toString = Object.prototype.toString;
|
1038 |
|
1039 | function resolveYamlOmap(data) {
|
1040 | if (data === null) { return true; }
|
1041 |
|
1042 | var objectKeys = [], index, length, pair, pairKey, pairHasKey,
|
1043 | object = data;
|
1044 |
|
1045 | for (index = 0, length = object.length; index < length; index += 1) {
|
1046 | pair = object[index];
|
1047 | pairHasKey = false;
|
1048 |
|
1049 | if (_toString.call(pair) !== '[object Object]') { return false; }
|
1050 |
|
1051 | for (pairKey in pair) {
|
1052 | if (_hasOwnProperty$1.call(pair, pairKey)) {
|
1053 | if (!pairHasKey) { pairHasKey = true; }
|
1054 | else { return false; }
|
1055 | }
|
1056 | }
|
1057 |
|
1058 | if (!pairHasKey) { return false; }
|
1059 |
|
1060 | if (objectKeys.indexOf(pairKey) === -1) { objectKeys.push(pairKey); }
|
1061 | else { return false; }
|
1062 | }
|
1063 |
|
1064 | return true;
|
1065 | }
|
1066 |
|
1067 | function constructYamlOmap(data) {
|
1068 | return data !== null ? data : [];
|
1069 | }
|
1070 |
|
1071 | var omap = new Type$13('tag:yaml.org,2002:omap', {
|
1072 | kind: 'sequence',
|
1073 | resolve: resolveYamlOmap,
|
1074 | construct: constructYamlOmap
|
1075 | });
|
1076 |
|
1077 | var Type$14 = type;
|
1078 |
|
1079 | var _toString$1 = Object.prototype.toString;
|
1080 |
|
1081 | function resolveYamlPairs(data) {
|
1082 | if (data === null) { return true; }
|
1083 |
|
1084 | var index, length, pair, keys, result,
|
1085 | object = data;
|
1086 |
|
1087 | result = new Array(object.length);
|
1088 |
|
1089 | for (index = 0, length = object.length; index < length; index += 1) {
|
1090 | pair = object[index];
|
1091 |
|
1092 | if (_toString$1.call(pair) !== '[object Object]') { return false; }
|
1093 |
|
1094 | keys = Object.keys(pair);
|
1095 |
|
1096 | if (keys.length !== 1) { return false; }
|
1097 |
|
1098 | result[index] = [ keys[0], pair[keys[0]] ];
|
1099 | }
|
1100 |
|
1101 | return true;
|
1102 | }
|
1103 |
|
1104 | function constructYamlPairs(data) {
|
1105 | if (data === null) { return []; }
|
1106 |
|
1107 | var index, length, pair, keys, result,
|
1108 | object = data;
|
1109 |
|
1110 | result = new Array(object.length);
|
1111 |
|
1112 | for (index = 0, length = object.length; index < length; index += 1) {
|
1113 | pair = object[index];
|
1114 |
|
1115 | keys = Object.keys(pair);
|
1116 |
|
1117 | result[index] = [ keys[0], pair[keys[0]] ];
|
1118 | }
|
1119 |
|
1120 | return result;
|
1121 | }
|
1122 |
|
1123 | var pairs = new Type$14('tag:yaml.org,2002:pairs', {
|
1124 | kind: 'sequence',
|
1125 | resolve: resolveYamlPairs,
|
1126 | construct: constructYamlPairs
|
1127 | });
|
1128 |
|
1129 | var Type$15 = type;
|
1130 |
|
1131 | var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
1132 |
|
1133 | function resolveYamlSet(data) {
|
1134 | if (data === null) { return true; }
|
1135 |
|
1136 | var key, object = data;
|
1137 |
|
1138 | for (key in object) {
|
1139 | if (_hasOwnProperty$2.call(object, key)) {
|
1140 | if (object[key] !== null) { return false; }
|
1141 | }
|
1142 | }
|
1143 |
|
1144 | return true;
|
1145 | }
|
1146 |
|
1147 | function constructYamlSet(data) {
|
1148 | return data !== null ? data : {};
|
1149 | }
|
1150 |
|
1151 | var set = new Type$15('tag:yaml.org,2002:set', {
|
1152 | kind: 'mapping',
|
1153 | resolve: resolveYamlSet,
|
1154 | construct: constructYamlSet
|
1155 | });
|
1156 |
|
1157 | var Schema$1 = schema;
|
1158 |
|
1159 |
|
1160 | var default_safe = new Schema$1({
|
1161 | include: [
|
1162 | core
|
1163 | ],
|
1164 | implicit: [
|
1165 | timestamp,
|
1166 | merge
|
1167 | ],
|
1168 | explicit: [
|
1169 | binary,
|
1170 | omap,
|
1171 | pairs,
|
1172 | set
|
1173 | ]
|
1174 | });
|
1175 |
|
1176 | var Type$16 = type;
|
1177 |
|
1178 | function resolveJavascriptUndefined() {
|
1179 | return true;
|
1180 | }
|
1181 |
|
1182 | function constructJavascriptUndefined() {
|
1183 |
|
1184 | return undefined;
|
1185 | }
|
1186 |
|
1187 | function representJavascriptUndefined() {
|
1188 | return '';
|
1189 | }
|
1190 |
|
1191 | function isUndefined(object) {
|
1192 | return typeof object === 'undefined';
|
1193 | }
|
1194 |
|
1195 | var _undefined = new Type$16('tag:yaml.org,2002:js/undefined', {
|
1196 | kind: 'scalar',
|
1197 | resolve: resolveJavascriptUndefined,
|
1198 | construct: constructJavascriptUndefined,
|
1199 | predicate: isUndefined,
|
1200 | represent: representJavascriptUndefined
|
1201 | });
|
1202 |
|
1203 | var Type$17 = type;
|
1204 |
|
1205 | function resolveJavascriptRegExp(data) {
|
1206 | if (data === null) { return false; }
|
1207 | if (data.length === 0) { return false; }
|
1208 |
|
1209 | var regexp = data,
|
1210 | tail = /\/([gim]*)$/.exec(data),
|
1211 | modifiers = '';
|
1212 |
|
1213 |
|
1214 |
|
1215 | if (regexp[0] === '/') {
|
1216 | if (tail) { modifiers = tail[1]; }
|
1217 |
|
1218 | if (modifiers.length > 3) { return false; }
|
1219 |
|
1220 | if (regexp[regexp.length - modifiers.length - 1] !== '/') { return false; }
|
1221 | }
|
1222 |
|
1223 | return true;
|
1224 | }
|
1225 |
|
1226 | function constructJavascriptRegExp(data) {
|
1227 | var regexp = data,
|
1228 | tail = /\/([gim]*)$/.exec(data),
|
1229 | modifiers = '';
|
1230 |
|
1231 |
|
1232 | if (regexp[0] === '/') {
|
1233 | if (tail) { modifiers = tail[1]; }
|
1234 | regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
1235 | }
|
1236 |
|
1237 | return new RegExp(regexp, modifiers);
|
1238 | }
|
1239 |
|
1240 | function representJavascriptRegExp(object /*, style*/) {
|
1241 | var result = '/' + object.source + '/';
|
1242 |
|
1243 | if (object.global) { result += 'g'; }
|
1244 | if (object.multiline) { result += 'm'; }
|
1245 | if (object.ignoreCase) { result += 'i'; }
|
1246 |
|
1247 | return result;
|
1248 | }
|
1249 |
|
1250 | function isRegExp(object) {
|
1251 | return Object.prototype.toString.call(object) === '[object RegExp]';
|
1252 | }
|
1253 |
|
1254 | var regexp = new Type$17('tag:yaml.org,2002:js/regexp', {
|
1255 | kind: 'scalar',
|
1256 | resolve: resolveJavascriptRegExp,
|
1257 | construct: constructJavascriptRegExp,
|
1258 | predicate: isRegExp,
|
1259 | represent: representJavascriptRegExp
|
1260 | });
|
1261 |
|
1262 | var esprima;
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 | try {
|
1272 |
|
1273 | var _require$1 = commonjsRequire;
|
1274 | esprima = _require$1('esprima');
|
1275 | } catch (_) {
|
1276 |
|
1277 | if (typeof window !== 'undefined') { esprima = window.esprima; }
|
1278 | }
|
1279 |
|
1280 | var Type$18 = type;
|
1281 |
|
1282 | function resolveJavascriptFunction(data) {
|
1283 | if (data === null) { return false; }
|
1284 |
|
1285 | try {
|
1286 | var source = '(' + data + ')',
|
1287 | ast = esprima.parse(source, { range: true });
|
1288 |
|
1289 | if (ast.type !== 'Program' ||
|
1290 | ast.body.length !== 1 ||
|
1291 | ast.body[0].type !== 'ExpressionStatement' ||
|
1292 | ast.body[0].expression.type !== 'FunctionExpression') {
|
1293 | return false;
|
1294 | }
|
1295 |
|
1296 | return true;
|
1297 | } catch (err) {
|
1298 | return false;
|
1299 | }
|
1300 | }
|
1301 |
|
1302 | function constructJavascriptFunction(data) {
|
1303 |
|
1304 |
|
1305 | var source = '(' + data + ')',
|
1306 | ast = esprima.parse(source, { range: true }),
|
1307 | params = [],
|
1308 | body;
|
1309 |
|
1310 | if (ast.type !== 'Program' ||
|
1311 | ast.body.length !== 1 ||
|
1312 | ast.body[0].type !== 'ExpressionStatement' ||
|
1313 | ast.body[0].expression.type !== 'FunctionExpression') {
|
1314 | throw new Error('Failed to resolve function');
|
1315 | }
|
1316 |
|
1317 | ast.body[0].expression.params.forEach(function (param) {
|
1318 | params.push(param.name);
|
1319 | });
|
1320 |
|
1321 | body = ast.body[0].expression.body.range;
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 | return new Function(params, source.slice(body[0] + 1, body[1] - 1));
|
1327 | }
|
1328 |
|
1329 | function representJavascriptFunction(object /*, style*/) {
|
1330 | return object.toString();
|
1331 | }
|
1332 |
|
1333 | function isFunction(object) {
|
1334 | return Object.prototype.toString.call(object) === '[object Function]';
|
1335 | }
|
1336 |
|
1337 | var _function = new Type$18('tag:yaml.org,2002:js/function', {
|
1338 | kind: 'scalar',
|
1339 | resolve: resolveJavascriptFunction,
|
1340 | construct: constructJavascriptFunction,
|
1341 | predicate: isFunction,
|
1342 | represent: representJavascriptFunction
|
1343 | });
|
1344 |
|
1345 | var Schema$6 = schema;
|
1346 |
|
1347 |
|
1348 | var default_full = Schema$6.DEFAULT = new Schema$6({
|
1349 | include: [
|
1350 | default_safe
|
1351 | ],
|
1352 | explicit: [
|
1353 | _undefined,
|
1354 | regexp,
|
1355 | _function
|
1356 | ]
|
1357 | });
|
1358 |
|
1359 |
|
1360 |
|
1361 | var common = common$1;
|
1362 | var YAMLException$1 = exception;
|
1363 | var Mark = mark;
|
1364 | var DEFAULT_SAFE_SCHEMA$1 = default_safe;
|
1365 | var DEFAULT_FULL_SCHEMA$1 = default_full;
|
1366 |
|
1367 |
|
1368 | var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
1369 |
|
1370 |
|
1371 | var CONTEXT_FLOW_IN = 1;
|
1372 | var CONTEXT_FLOW_OUT = 2;
|
1373 | var CONTEXT_BLOCK_IN = 3;
|
1374 | var CONTEXT_BLOCK_OUT = 4;
|
1375 |
|
1376 |
|
1377 | var CHOMPING_CLIP = 1;
|
1378 | var CHOMPING_STRIP = 2;
|
1379 | var CHOMPING_KEEP = 3;
|
1380 |
|
1381 |
|
1382 | var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
1383 | var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
1384 | var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
1385 | var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
1386 | var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
1387 |
|
1388 |
|
1389 | function is_EOL(c) {
|
1390 | return (c === 0x0A) || (c === 0x0D);
|
1391 | }
|
1392 |
|
1393 | function is_WHITE_SPACE(c) {
|
1394 | return (c === 0x09) || (c === 0x20);
|
1395 | }
|
1396 |
|
1397 | function is_WS_OR_EOL(c) {
|
1398 | return (c === 0x09) ||
|
1399 | (c === 0x20) ||
|
1400 | (c === 0x0A) ||
|
1401 | (c === 0x0D);
|
1402 | }
|
1403 |
|
1404 | function is_FLOW_INDICATOR(c) {
|
1405 | return c === 0x2C ||
|
1406 | c === 0x5B ||
|
1407 | c === 0x5D ||
|
1408 | c === 0x7B ||
|
1409 | c === 0x7D;
|
1410 | }
|
1411 |
|
1412 | function fromHexCode(c) {
|
1413 | var lc;
|
1414 |
|
1415 | if ((0x30 <= c) && (c <= 0x39)) {
|
1416 | return c - 0x30;
|
1417 | }
|
1418 |
|
1419 |
|
1420 | lc = c | 0x20;
|
1421 |
|
1422 | if ((0x61 <= lc) && (lc <= 0x66)) {
|
1423 | return lc - 0x61 + 10;
|
1424 | }
|
1425 |
|
1426 | return -1;
|
1427 | }
|
1428 |
|
1429 | function escapedHexLen(c) {
|
1430 | if (c === 0x78) { return 2; }
|
1431 | if (c === 0x75) { return 4; }
|
1432 | if (c === 0x55) { return 8; }
|
1433 | return 0;
|
1434 | }
|
1435 |
|
1436 | function fromDecimalCode(c) {
|
1437 | if ((0x30 <= c) && (c <= 0x39)) {
|
1438 | return c - 0x30;
|
1439 | }
|
1440 |
|
1441 | return -1;
|
1442 | }
|
1443 |
|
1444 | function simpleEscapeSequence(c) {
|
1445 | return (c === 0x30) ? '\x00' :
|
1446 | (c === 0x61) ? '\x07' :
|
1447 | (c === 0x62) ? '\x08' :
|
1448 | (c === 0x74) ? '\x09' :
|
1449 | (c === 0x09) ? '\x09' :
|
1450 | (c === 0x6E) ? '\x0A' :
|
1451 | (c === 0x76) ? '\x0B' :
|
1452 | (c === 0x66) ? '\x0C' :
|
1453 | (c === 0x72) ? '\x0D' :
|
1454 | (c === 0x65) ? '\x1B' :
|
1455 | (c === 0x20) ? ' ' :
|
1456 | (c === 0x22) ? '\x22' :
|
1457 | (c === 0x2F) ? '/' :
|
1458 | (c === 0x5C) ? '\x5C' :
|
1459 | (c === 0x4E) ? '\x85' :
|
1460 | (c === 0x5F) ? '\xA0' :
|
1461 | (c === 0x4C) ? '\u2028' :
|
1462 | (c === 0x50) ? '\u2029' : '';
|
1463 | }
|
1464 |
|
1465 | function charFromCodepoint(c) {
|
1466 | if (c <= 0xFFFF) {
|
1467 | return String.fromCharCode(c);
|
1468 | }
|
1469 |
|
1470 |
|
1471 | return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
|
1472 | ((c - 0x010000) & 0x03FF) + 0xDC00);
|
1473 | }
|
1474 |
|
1475 | var simpleEscapeCheck = new Array(256);
|
1476 | var simpleEscapeMap = new Array(256);
|
1477 | for (var i = 0; i < 256; i++) {
|
1478 | simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
1479 | simpleEscapeMap[i] = simpleEscapeSequence(i);
|
1480 | }
|
1481 |
|
1482 |
|
1483 | function State(input, options) {
|
1484 | this.input = input;
|
1485 |
|
1486 | this.filename = options['filename'] || null;
|
1487 | this.schema = options['schema'] || DEFAULT_FULL_SCHEMA$1;
|
1488 | this.onWarning = options['onWarning'] || null;
|
1489 | this.legacy = options['legacy'] || false;
|
1490 | this.json = options['json'] || false;
|
1491 | this.listener = options['listener'] || null;
|
1492 |
|
1493 | this.implicitTypes = this.schema.compiledImplicit;
|
1494 | this.typeMap = this.schema.compiledTypeMap;
|
1495 |
|
1496 | this.length = input.length;
|
1497 | this.position = 0;
|
1498 | this.line = 0;
|
1499 | this.lineStart = 0;
|
1500 | this.lineIndent = 0;
|
1501 |
|
1502 | this.documents = [];
|
1503 |
|
1504 | |
1505 |
|
1506 |
|
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 | }
|
1515 |
|
1516 |
|
1517 | function generateError(state, message) {
|
1518 | return new YAMLException$1(
|
1519 | message,
|
1520 | new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
|
1521 | }
|
1522 |
|
1523 | function throwError(state, message) {
|
1524 | throw generateError(state, message);
|
1525 | }
|
1526 |
|
1527 | function throwWarning(state, message) {
|
1528 | if (state.onWarning) {
|
1529 | state.onWarning.call(null, generateError(state, message));
|
1530 | }
|
1531 | }
|
1532 |
|
1533 |
|
1534 | var directiveHandlers = {
|
1535 |
|
1536 | YAML: function handleYamlDirective(state, name, args) {
|
1537 |
|
1538 | var match, major, minor;
|
1539 |
|
1540 | if (state.version !== null) {
|
1541 | throwError(state, 'duplication of %YAML directive');
|
1542 | }
|
1543 |
|
1544 | if (args.length !== 1) {
|
1545 | throwError(state, 'YAML directive accepts exactly one argument');
|
1546 | }
|
1547 |
|
1548 | match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
1549 |
|
1550 | if (match === null) {
|
1551 | throwError(state, 'ill-formed argument of the YAML directive');
|
1552 | }
|
1553 |
|
1554 | major = parseInt(match[1], 10);
|
1555 | minor = parseInt(match[2], 10);
|
1556 |
|
1557 | if (major !== 1) {
|
1558 | throwError(state, 'unacceptable YAML version of the document');
|
1559 | }
|
1560 |
|
1561 | state.version = args[0];
|
1562 | state.checkLineBreaks = (minor < 2);
|
1563 |
|
1564 | if (minor !== 1 && minor !== 2) {
|
1565 | throwWarning(state, 'unsupported YAML version of the document');
|
1566 | }
|
1567 | },
|
1568 |
|
1569 | TAG: function handleTagDirective(state, name, args) {
|
1570 |
|
1571 | var handle, prefix;
|
1572 |
|
1573 | if (args.length !== 2) {
|
1574 | throwError(state, 'TAG directive accepts exactly two arguments');
|
1575 | }
|
1576 |
|
1577 | handle = args[0];
|
1578 | prefix = args[1];
|
1579 |
|
1580 | if (!PATTERN_TAG_HANDLE.test(handle)) {
|
1581 | throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
|
1582 | }
|
1583 |
|
1584 | if (_hasOwnProperty.call(state.tagMap, handle)) {
|
1585 | throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
1586 | }
|
1587 |
|
1588 | if (!PATTERN_TAG_URI.test(prefix)) {
|
1589 | throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
|
1590 | }
|
1591 |
|
1592 | state.tagMap[handle] = prefix;
|
1593 | }
|
1594 | };
|
1595 |
|
1596 |
|
1597 | function captureSegment(state, start, end, checkJson) {
|
1598 | var _position, _length, _character, _result;
|
1599 |
|
1600 | if (start < end) {
|
1601 | _result = state.input.slice(start, end);
|
1602 |
|
1603 | if (checkJson) {
|
1604 | for (_position = 0, _length = _result.length;
|
1605 | _position < _length;
|
1606 | _position += 1) {
|
1607 | _character = _result.charCodeAt(_position);
|
1608 | if (!(_character === 0x09 ||
|
1609 | (0x20 <= _character && _character <= 0x10FFFF))) {
|
1610 | throwError(state, 'expected valid JSON character');
|
1611 | }
|
1612 | }
|
1613 | } else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
1614 | throwError(state, 'the stream contains non-printable characters');
|
1615 | }
|
1616 |
|
1617 | state.result += _result;
|
1618 | }
|
1619 | }
|
1620 |
|
1621 | function mergeMappings(state, destination, source, overridableKeys) {
|
1622 | var sourceKeys, key, index, quantity;
|
1623 |
|
1624 | if (!common.isObject(source)) {
|
1625 | throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
|
1626 | }
|
1627 |
|
1628 | sourceKeys = Object.keys(source);
|
1629 |
|
1630 | for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
1631 | key = sourceKeys[index];
|
1632 |
|
1633 | if (!_hasOwnProperty.call(destination, key)) {
|
1634 | destination[key] = source[key];
|
1635 | overridableKeys[key] = true;
|
1636 | }
|
1637 | }
|
1638 | }
|
1639 |
|
1640 | function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode) {
|
1641 | var index, quantity;
|
1642 |
|
1643 | keyNode = String(keyNode);
|
1644 |
|
1645 | if (_result === null) {
|
1646 | _result = {};
|
1647 | }
|
1648 |
|
1649 | if (keyTag === 'tag:yaml.org,2002:merge') {
|
1650 | if (Array.isArray(valueNode)) {
|
1651 | for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
1652 | mergeMappings(state, _result, valueNode[index], overridableKeys);
|
1653 | }
|
1654 | } else {
|
1655 | mergeMappings(state, _result, valueNode, overridableKeys);
|
1656 | }
|
1657 | } else {
|
1658 | if (!state.json &&
|
1659 | !_hasOwnProperty.call(overridableKeys, keyNode) &&
|
1660 | _hasOwnProperty.call(_result, keyNode)) {
|
1661 | throwError(state, 'duplicated mapping key');
|
1662 | }
|
1663 | _result[keyNode] = valueNode;
|
1664 | delete overridableKeys[keyNode];
|
1665 | }
|
1666 |
|
1667 | return _result;
|
1668 | }
|
1669 |
|
1670 | function readLineBreak(state) {
|
1671 | var ch;
|
1672 |
|
1673 | ch = state.input.charCodeAt(state.position);
|
1674 |
|
1675 | if (ch === 0x0A) {
|
1676 | state.position++;
|
1677 | } else if (ch === 0x0D) {
|
1678 | state.position++;
|
1679 | if (state.input.charCodeAt(state.position) === 0x0A) {
|
1680 | state.position++;
|
1681 | }
|
1682 | } else {
|
1683 | throwError(state, 'a line break is expected');
|
1684 | }
|
1685 |
|
1686 | state.line += 1;
|
1687 | state.lineStart = state.position;
|
1688 | }
|
1689 |
|
1690 | function skipSeparationSpace(state, allowComments, checkIndent) {
|
1691 | var lineBreaks = 0,
|
1692 | ch = state.input.charCodeAt(state.position);
|
1693 |
|
1694 | while (ch !== 0) {
|
1695 | while (is_WHITE_SPACE(ch)) {
|
1696 | ch = state.input.charCodeAt(++state.position);
|
1697 | }
|
1698 |
|
1699 | if (allowComments && ch === 0x23) {
|
1700 | do {
|
1701 | ch = state.input.charCodeAt(++state.position);
|
1702 | } while (ch !== 0x0A && ch !== 0x0D && ch !== 0);
|
1703 | }
|
1704 |
|
1705 | if (is_EOL(ch)) {
|
1706 | readLineBreak(state);
|
1707 |
|
1708 | ch = state.input.charCodeAt(state.position);
|
1709 | lineBreaks++;
|
1710 | state.lineIndent = 0;
|
1711 |
|
1712 | while (ch === 0x20) {
|
1713 | state.lineIndent++;
|
1714 | ch = state.input.charCodeAt(++state.position);
|
1715 | }
|
1716 | } else {
|
1717 | break;
|
1718 | }
|
1719 | }
|
1720 |
|
1721 | if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
1722 | throwWarning(state, 'deficient indentation');
|
1723 | }
|
1724 |
|
1725 | return lineBreaks;
|
1726 | }
|
1727 |
|
1728 | function testDocumentSeparator(state) {
|
1729 | var _position = state.position,
|
1730 | ch;
|
1731 |
|
1732 | ch = state.input.charCodeAt(_position);
|
1733 |
|
1734 |
|
1735 |
|
1736 | if ((ch === 0x2D || ch === 0x2E) &&
|
1737 | ch === state.input.charCodeAt(_position + 1) &&
|
1738 | ch === state.input.charCodeAt(_position + 2)) {
|
1739 |
|
1740 | _position += 3;
|
1741 |
|
1742 | ch = state.input.charCodeAt(_position);
|
1743 |
|
1744 | if (ch === 0 || is_WS_OR_EOL(ch)) {
|
1745 | return true;
|
1746 | }
|
1747 | }
|
1748 |
|
1749 | return false;
|
1750 | }
|
1751 |
|
1752 | function writeFoldedLines(state, count) {
|
1753 | if (count === 1) {
|
1754 | state.result += ' ';
|
1755 | } else if (count > 1) {
|
1756 | state.result += common.repeat('\n', count - 1);
|
1757 | }
|
1758 | }
|
1759 |
|
1760 |
|
1761 | function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
1762 | var preceding,
|
1763 | following,
|
1764 | captureStart,
|
1765 | captureEnd,
|
1766 | hasPendingContent,
|
1767 | _line,
|
1768 | _lineStart,
|
1769 | _lineIndent,
|
1770 | _kind = state.kind,
|
1771 | _result = state.result,
|
1772 | ch;
|
1773 |
|
1774 | ch = state.input.charCodeAt(state.position);
|
1775 |
|
1776 | if (is_WS_OR_EOL(ch) ||
|
1777 | is_FLOW_INDICATOR(ch) ||
|
1778 | ch === 0x23 ||
|
1779 | ch === 0x26 ||
|
1780 | ch === 0x2A ||
|
1781 | ch === 0x21 ||
|
1782 | ch === 0x7C ||
|
1783 | ch === 0x3E ||
|
1784 | ch === 0x27 ||
|
1785 | ch === 0x22 ||
|
1786 | ch === 0x25 ||
|
1787 | ch === 0x40 ||
|
1788 | ch === 0x60) {
|
1789 | return false;
|
1790 | }
|
1791 |
|
1792 | if (ch === 0x3F || ch === 0x2D) {
|
1793 | following = state.input.charCodeAt(state.position + 1);
|
1794 |
|
1795 | if (is_WS_OR_EOL(following) ||
|
1796 | withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
1797 | return false;
|
1798 | }
|
1799 | }
|
1800 |
|
1801 | state.kind = 'scalar';
|
1802 | state.result = '';
|
1803 | captureStart = captureEnd = state.position;
|
1804 | hasPendingContent = false;
|
1805 |
|
1806 | while (ch !== 0) {
|
1807 | if (ch === 0x3A) {
|
1808 | following = state.input.charCodeAt(state.position + 1);
|
1809 |
|
1810 | if (is_WS_OR_EOL(following) ||
|
1811 | withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
1812 | break;
|
1813 | }
|
1814 |
|
1815 | } else if (ch === 0x23) {
|
1816 | preceding = state.input.charCodeAt(state.position - 1);
|
1817 |
|
1818 | if (is_WS_OR_EOL(preceding)) {
|
1819 | break;
|
1820 | }
|
1821 |
|
1822 | } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
|
1823 | withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
1824 | break;
|
1825 |
|
1826 | } else if (is_EOL(ch)) {
|
1827 | _line = state.line;
|
1828 | _lineStart = state.lineStart;
|
1829 | _lineIndent = state.lineIndent;
|
1830 | skipSeparationSpace(state, false, -1);
|
1831 |
|
1832 | if (state.lineIndent >= nodeIndent) {
|
1833 | hasPendingContent = true;
|
1834 | ch = state.input.charCodeAt(state.position);
|
1835 | continue;
|
1836 | } else {
|
1837 | state.position = captureEnd;
|
1838 | state.line = _line;
|
1839 | state.lineStart = _lineStart;
|
1840 | state.lineIndent = _lineIndent;
|
1841 | break;
|
1842 | }
|
1843 | }
|
1844 |
|
1845 | if (hasPendingContent) {
|
1846 | captureSegment(state, captureStart, captureEnd, false);
|
1847 | writeFoldedLines(state, state.line - _line);
|
1848 | captureStart = captureEnd = state.position;
|
1849 | hasPendingContent = false;
|
1850 | }
|
1851 |
|
1852 | if (!is_WHITE_SPACE(ch)) {
|
1853 | captureEnd = state.position + 1;
|
1854 | }
|
1855 |
|
1856 | ch = state.input.charCodeAt(++state.position);
|
1857 | }
|
1858 |
|
1859 | captureSegment(state, captureStart, captureEnd, false);
|
1860 |
|
1861 | if (state.result) {
|
1862 | return true;
|
1863 | }
|
1864 |
|
1865 | state.kind = _kind;
|
1866 | state.result = _result;
|
1867 | return false;
|
1868 | }
|
1869 |
|
1870 | function readSingleQuotedScalar(state, nodeIndent) {
|
1871 | var ch,
|
1872 | captureStart, captureEnd;
|
1873 |
|
1874 | ch = state.input.charCodeAt(state.position);
|
1875 |
|
1876 | if (ch !== 0x27) {
|
1877 | return false;
|
1878 | }
|
1879 |
|
1880 | state.kind = 'scalar';
|
1881 | state.result = '';
|
1882 | state.position++;
|
1883 | captureStart = captureEnd = state.position;
|
1884 |
|
1885 | while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
1886 | if (ch === 0x27) {
|
1887 | captureSegment(state, captureStart, state.position, true);
|
1888 | ch = state.input.charCodeAt(++state.position);
|
1889 |
|
1890 | if (ch === 0x27) {
|
1891 | captureStart = state.position;
|
1892 | state.position++;
|
1893 | captureEnd = state.position;
|
1894 | } else {
|
1895 | return true;
|
1896 | }
|
1897 |
|
1898 | } else if (is_EOL(ch)) {
|
1899 | captureSegment(state, captureStart, captureEnd, true);
|
1900 | writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
1901 | captureStart = captureEnd = state.position;
|
1902 |
|
1903 | } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
1904 | throwError(state, 'unexpected end of the document within a single quoted scalar');
|
1905 |
|
1906 | } else {
|
1907 | state.position++;
|
1908 | captureEnd = state.position;
|
1909 | }
|
1910 | }
|
1911 |
|
1912 | throwError(state, 'unexpected end of the stream within a single quoted scalar');
|
1913 | }
|
1914 |
|
1915 | function readDoubleQuotedScalar(state, nodeIndent) {
|
1916 | var captureStart,
|
1917 | captureEnd,
|
1918 | hexLength,
|
1919 | hexResult,
|
1920 | tmp,
|
1921 | ch;
|
1922 |
|
1923 | ch = state.input.charCodeAt(state.position);
|
1924 |
|
1925 | if (ch !== 0x22) {
|
1926 | return false;
|
1927 | }
|
1928 |
|
1929 | state.kind = 'scalar';
|
1930 | state.result = '';
|
1931 | state.position++;
|
1932 | captureStart = captureEnd = state.position;
|
1933 |
|
1934 | while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
1935 | if (ch === 0x22) {
|
1936 | captureSegment(state, captureStart, state.position, true);
|
1937 | state.position++;
|
1938 | return true;
|
1939 |
|
1940 | } else if (ch === 0x5C) {
|
1941 | captureSegment(state, captureStart, state.position, true);
|
1942 | ch = state.input.charCodeAt(++state.position);
|
1943 |
|
1944 | if (is_EOL(ch)) {
|
1945 | skipSeparationSpace(state, false, nodeIndent);
|
1946 |
|
1947 |
|
1948 | } else if (ch < 256 && simpleEscapeCheck[ch]) {
|
1949 | state.result += simpleEscapeMap[ch];
|
1950 | state.position++;
|
1951 |
|
1952 | } else if ((tmp = escapedHexLen(ch)) > 0) {
|
1953 | hexLength = tmp;
|
1954 | hexResult = 0;
|
1955 |
|
1956 | for (; hexLength > 0; hexLength--) {
|
1957 | ch = state.input.charCodeAt(++state.position);
|
1958 |
|
1959 | if ((tmp = fromHexCode(ch)) >= 0) {
|
1960 | hexResult = (hexResult << 4) + tmp;
|
1961 |
|
1962 | } else {
|
1963 | throwError(state, 'expected hexadecimal character');
|
1964 | }
|
1965 | }
|
1966 |
|
1967 | state.result += charFromCodepoint(hexResult);
|
1968 |
|
1969 | state.position++;
|
1970 |
|
1971 | } else {
|
1972 | throwError(state, 'unknown escape sequence');
|
1973 | }
|
1974 |
|
1975 | captureStart = captureEnd = state.position;
|
1976 |
|
1977 | } else if (is_EOL(ch)) {
|
1978 | captureSegment(state, captureStart, captureEnd, true);
|
1979 | writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
1980 | captureStart = captureEnd = state.position;
|
1981 |
|
1982 | } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
1983 | throwError(state, 'unexpected end of the document within a double quoted scalar');
|
1984 |
|
1985 | } else {
|
1986 | state.position++;
|
1987 | captureEnd = state.position;
|
1988 | }
|
1989 | }
|
1990 |
|
1991 | throwError(state, 'unexpected end of the stream within a double quoted scalar');
|
1992 | }
|
1993 |
|
1994 | function readFlowCollection(state, nodeIndent) {
|
1995 | var readNext = true,
|
1996 | _line,
|
1997 | _tag = state.tag,
|
1998 | _result,
|
1999 | _anchor = state.anchor,
|
2000 | following,
|
2001 | terminator,
|
2002 | isPair,
|
2003 | isExplicitPair,
|
2004 | isMapping,
|
2005 | overridableKeys = {},
|
2006 | keyNode,
|
2007 | keyTag,
|
2008 | valueNode,
|
2009 | ch;
|
2010 |
|
2011 | ch = state.input.charCodeAt(state.position);
|
2012 |
|
2013 | if (ch === 0x5B) {
|
2014 | terminator = 0x5D;
|
2015 | isMapping = false;
|
2016 | _result = [];
|
2017 | } else if (ch === 0x7B) {
|
2018 | terminator = 0x7D;
|
2019 | isMapping = true;
|
2020 | _result = {};
|
2021 | } else {
|
2022 | return false;
|
2023 | }
|
2024 |
|
2025 | if (state.anchor !== null) {
|
2026 | state.anchorMap[state.anchor] = _result;
|
2027 | }
|
2028 |
|
2029 | ch = state.input.charCodeAt(++state.position);
|
2030 |
|
2031 | while (ch !== 0) {
|
2032 | skipSeparationSpace(state, true, nodeIndent);
|
2033 |
|
2034 | ch = state.input.charCodeAt(state.position);
|
2035 |
|
2036 | if (ch === terminator) {
|
2037 | state.position++;
|
2038 | state.tag = _tag;
|
2039 | state.anchor = _anchor;
|
2040 | state.kind = isMapping ? 'mapping' : 'sequence';
|
2041 | state.result = _result;
|
2042 | return true;
|
2043 | } else if (!readNext) {
|
2044 | throwError(state, 'missed comma between flow collection entries');
|
2045 | }
|
2046 |
|
2047 | keyTag = keyNode = valueNode = null;
|
2048 | isPair = isExplicitPair = false;
|
2049 |
|
2050 | if (ch === 0x3F) {
|
2051 | following = state.input.charCodeAt(state.position + 1);
|
2052 |
|
2053 | if (is_WS_OR_EOL(following)) {
|
2054 | isPair = isExplicitPair = true;
|
2055 | state.position++;
|
2056 | skipSeparationSpace(state, true, nodeIndent);
|
2057 | }
|
2058 | }
|
2059 |
|
2060 | _line = state.line;
|
2061 | composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
2062 | keyTag = state.tag;
|
2063 | keyNode = state.result;
|
2064 | skipSeparationSpace(state, true, nodeIndent);
|
2065 |
|
2066 | ch = state.input.charCodeAt(state.position);
|
2067 |
|
2068 | if ((isExplicitPair || state.line === _line) && ch === 0x3A) {
|
2069 | isPair = true;
|
2070 | ch = state.input.charCodeAt(++state.position);
|
2071 | skipSeparationSpace(state, true, nodeIndent);
|
2072 | composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
2073 | valueNode = state.result;
|
2074 | }
|
2075 |
|
2076 | if (isMapping) {
|
2077 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
|
2078 | } else if (isPair) {
|
2079 | _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
|
2080 | } else {
|
2081 | _result.push(keyNode);
|
2082 | }
|
2083 |
|
2084 | skipSeparationSpace(state, true, nodeIndent);
|
2085 |
|
2086 | ch = state.input.charCodeAt(state.position);
|
2087 |
|
2088 | if (ch === 0x2C) {
|
2089 | readNext = true;
|
2090 | ch = state.input.charCodeAt(++state.position);
|
2091 | } else {
|
2092 | readNext = false;
|
2093 | }
|
2094 | }
|
2095 |
|
2096 | throwError(state, 'unexpected end of the stream within a flow collection');
|
2097 | }
|
2098 |
|
2099 | function readBlockScalar(state, nodeIndent) {
|
2100 | var captureStart,
|
2101 | folding,
|
2102 | chomping = CHOMPING_CLIP,
|
2103 | didReadContent = false,
|
2104 | detectedIndent = false,
|
2105 | textIndent = nodeIndent,
|
2106 | emptyLines = 0,
|
2107 | atMoreIndented = false,
|
2108 | tmp,
|
2109 | ch;
|
2110 |
|
2111 | ch = state.input.charCodeAt(state.position);
|
2112 |
|
2113 | if (ch === 0x7C) {
|
2114 | folding = false;
|
2115 | } else if (ch === 0x3E) {
|
2116 | folding = true;
|
2117 | } else {
|
2118 | return false;
|
2119 | }
|
2120 |
|
2121 | state.kind = 'scalar';
|
2122 | state.result = '';
|
2123 |
|
2124 | while (ch !== 0) {
|
2125 | ch = state.input.charCodeAt(++state.position);
|
2126 |
|
2127 | if (ch === 0x2B || ch === 0x2D) {
|
2128 | if (CHOMPING_CLIP === chomping) {
|
2129 | chomping = (ch === 0x2B) ? CHOMPING_KEEP : CHOMPING_STRIP;
|
2130 | } else {
|
2131 | throwError(state, 'repeat of a chomping mode identifier');
|
2132 | }
|
2133 |
|
2134 | } else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
2135 | if (tmp === 0) {
|
2136 | throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
|
2137 | } else if (!detectedIndent) {
|
2138 | textIndent = nodeIndent + tmp - 1;
|
2139 | detectedIndent = true;
|
2140 | } else {
|
2141 | throwError(state, 'repeat of an indentation width identifier');
|
2142 | }
|
2143 |
|
2144 | } else {
|
2145 | break;
|
2146 | }
|
2147 | }
|
2148 |
|
2149 | if (is_WHITE_SPACE(ch)) {
|
2150 | do { ch = state.input.charCodeAt(++state.position); }
|
2151 | while (is_WHITE_SPACE(ch));
|
2152 |
|
2153 | if (ch === 0x23) {
|
2154 | do { ch = state.input.charCodeAt(++state.position); }
|
2155 | while (!is_EOL(ch) && (ch !== 0));
|
2156 | }
|
2157 | }
|
2158 |
|
2159 | while (ch !== 0) {
|
2160 | readLineBreak(state);
|
2161 | state.lineIndent = 0;
|
2162 |
|
2163 | ch = state.input.charCodeAt(state.position);
|
2164 |
|
2165 | while ((!detectedIndent || state.lineIndent < textIndent) &&
|
2166 | (ch === 0x20)) {
|
2167 | state.lineIndent++;
|
2168 | ch = state.input.charCodeAt(++state.position);
|
2169 | }
|
2170 |
|
2171 | if (!detectedIndent && state.lineIndent > textIndent) {
|
2172 | textIndent = state.lineIndent;
|
2173 | }
|
2174 |
|
2175 | if (is_EOL(ch)) {
|
2176 | emptyLines++;
|
2177 | continue;
|
2178 | }
|
2179 |
|
2180 |
|
2181 | if (state.lineIndent < textIndent) {
|
2182 |
|
2183 |
|
2184 | if (chomping === CHOMPING_KEEP) {
|
2185 | state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
2186 | } else if (chomping === CHOMPING_CLIP) {
|
2187 | if (didReadContent) {
|
2188 | state.result += '\n';
|
2189 | }
|
2190 | }
|
2191 |
|
2192 |
|
2193 | break;
|
2194 | }
|
2195 |
|
2196 |
|
2197 | if (folding) {
|
2198 |
|
2199 |
|
2200 | if (is_WHITE_SPACE(ch)) {
|
2201 | atMoreIndented = true;
|
2202 |
|
2203 | state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
2204 |
|
2205 |
|
2206 | } else if (atMoreIndented) {
|
2207 | atMoreIndented = false;
|
2208 | state.result += common.repeat('\n', emptyLines + 1);
|
2209 |
|
2210 |
|
2211 | } else if (emptyLines === 0) {
|
2212 | if (didReadContent) {
|
2213 | state.result += ' ';
|
2214 | }
|
2215 |
|
2216 |
|
2217 | } else {
|
2218 | state.result += common.repeat('\n', emptyLines);
|
2219 | }
|
2220 |
|
2221 |
|
2222 | } else {
|
2223 |
|
2224 | state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
|
2225 | }
|
2226 |
|
2227 | didReadContent = true;
|
2228 | detectedIndent = true;
|
2229 | emptyLines = 0;
|
2230 | captureStart = state.position;
|
2231 |
|
2232 | while (!is_EOL(ch) && (ch !== 0)) {
|
2233 | ch = state.input.charCodeAt(++state.position);
|
2234 | }
|
2235 |
|
2236 | captureSegment(state, captureStart, state.position, false);
|
2237 | }
|
2238 |
|
2239 | return true;
|
2240 | }
|
2241 |
|
2242 | function readBlockSequence(state, nodeIndent) {
|
2243 | var _line,
|
2244 | _tag = state.tag,
|
2245 | _anchor = state.anchor,
|
2246 | _result = [],
|
2247 | following,
|
2248 | detected = false,
|
2249 | ch;
|
2250 |
|
2251 | if (state.anchor !== null) {
|
2252 | state.anchorMap[state.anchor] = _result;
|
2253 | }
|
2254 |
|
2255 | ch = state.input.charCodeAt(state.position);
|
2256 |
|
2257 | while (ch !== 0) {
|
2258 |
|
2259 | if (ch !== 0x2D) {
|
2260 | break;
|
2261 | }
|
2262 |
|
2263 | following = state.input.charCodeAt(state.position + 1);
|
2264 |
|
2265 | if (!is_WS_OR_EOL(following)) {
|
2266 | break;
|
2267 | }
|
2268 |
|
2269 | detected = true;
|
2270 | state.position++;
|
2271 |
|
2272 | if (skipSeparationSpace(state, true, -1)) {
|
2273 | if (state.lineIndent <= nodeIndent) {
|
2274 | _result.push(null);
|
2275 | ch = state.input.charCodeAt(state.position);
|
2276 | continue;
|
2277 | }
|
2278 | }
|
2279 |
|
2280 | _line = state.line;
|
2281 | composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
2282 | _result.push(state.result);
|
2283 | skipSeparationSpace(state, true, -1);
|
2284 |
|
2285 | ch = state.input.charCodeAt(state.position);
|
2286 |
|
2287 | if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
|
2288 | throwError(state, 'bad indentation of a sequence entry');
|
2289 | } else if (state.lineIndent < nodeIndent) {
|
2290 | break;
|
2291 | }
|
2292 | }
|
2293 |
|
2294 | if (detected) {
|
2295 | state.tag = _tag;
|
2296 | state.anchor = _anchor;
|
2297 | state.kind = 'sequence';
|
2298 | state.result = _result;
|
2299 | return true;
|
2300 | }
|
2301 | return false;
|
2302 | }
|
2303 |
|
2304 | function readBlockMapping(state, nodeIndent, flowIndent) {
|
2305 | var following,
|
2306 | allowCompact,
|
2307 | _line,
|
2308 | _tag = state.tag,
|
2309 | _anchor = state.anchor,
|
2310 | _result = {},
|
2311 | overridableKeys = {},
|
2312 | keyTag = null,
|
2313 | keyNode = null,
|
2314 | valueNode = null,
|
2315 | atExplicitKey = false,
|
2316 | detected = false,
|
2317 | ch;
|
2318 |
|
2319 | if (state.anchor !== null) {
|
2320 | state.anchorMap[state.anchor] = _result;
|
2321 | }
|
2322 |
|
2323 | ch = state.input.charCodeAt(state.position);
|
2324 |
|
2325 | while (ch !== 0) {
|
2326 | following = state.input.charCodeAt(state.position + 1);
|
2327 | _line = state.line;
|
2328 |
|
2329 |
|
2330 |
|
2331 |
|
2332 |
|
2333 | if ((ch === 0x3F || ch === 0x3A) && is_WS_OR_EOL(following)) {
|
2334 |
|
2335 | if (ch === 0x3F) {
|
2336 | if (atExplicitKey) {
|
2337 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
2338 | keyTag = keyNode = valueNode = null;
|
2339 | }
|
2340 |
|
2341 | detected = true;
|
2342 | atExplicitKey = true;
|
2343 | allowCompact = true;
|
2344 |
|
2345 | } else if (atExplicitKey) {
|
2346 |
|
2347 | atExplicitKey = false;
|
2348 | allowCompact = true;
|
2349 |
|
2350 | } else {
|
2351 | throwError(state, 'incomplete explicit mapping pair; a key node is missed');
|
2352 | }
|
2353 |
|
2354 | state.position += 1;
|
2355 | ch = following;
|
2356 |
|
2357 |
|
2358 |
|
2359 |
|
2360 | } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
2361 |
|
2362 | if (state.line === _line) {
|
2363 | ch = state.input.charCodeAt(state.position);
|
2364 |
|
2365 | while (is_WHITE_SPACE(ch)) {
|
2366 | ch = state.input.charCodeAt(++state.position);
|
2367 | }
|
2368 |
|
2369 | if (ch === 0x3A) {
|
2370 | ch = state.input.charCodeAt(++state.position);
|
2371 |
|
2372 | if (!is_WS_OR_EOL(ch)) {
|
2373 | throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
|
2374 | }
|
2375 |
|
2376 | if (atExplicitKey) {
|
2377 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
2378 | keyTag = keyNode = valueNode = null;
|
2379 | }
|
2380 |
|
2381 | detected = true;
|
2382 | atExplicitKey = false;
|
2383 | allowCompact = false;
|
2384 | keyTag = state.tag;
|
2385 | keyNode = state.result;
|
2386 |
|
2387 | } else if (detected) {
|
2388 | throwError(state, 'can not read an implicit mapping pair; a colon is missed');
|
2389 |
|
2390 | } else {
|
2391 | state.tag = _tag;
|
2392 | state.anchor = _anchor;
|
2393 | return true;
|
2394 | }
|
2395 |
|
2396 | } else if (detected) {
|
2397 | throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
|
2398 |
|
2399 | } else {
|
2400 | state.tag = _tag;
|
2401 | state.anchor = _anchor;
|
2402 | return true;
|
2403 | }
|
2404 |
|
2405 | } else {
|
2406 | break;
|
2407 | }
|
2408 |
|
2409 |
|
2410 |
|
2411 |
|
2412 | if (state.line === _line || state.lineIndent > nodeIndent) {
|
2413 | if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
2414 | if (atExplicitKey) {
|
2415 | keyNode = state.result;
|
2416 | } else {
|
2417 | valueNode = state.result;
|
2418 | }
|
2419 | }
|
2420 |
|
2421 | if (!atExplicitKey) {
|
2422 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
|
2423 | keyTag = keyNode = valueNode = null;
|
2424 | }
|
2425 |
|
2426 | skipSeparationSpace(state, true, -1);
|
2427 | ch = state.input.charCodeAt(state.position);
|
2428 | }
|
2429 |
|
2430 | if (state.lineIndent > nodeIndent && (ch !== 0)) {
|
2431 | throwError(state, 'bad indentation of a mapping entry');
|
2432 | } else if (state.lineIndent < nodeIndent) {
|
2433 | break;
|
2434 | }
|
2435 | }
|
2436 |
|
2437 |
|
2438 |
|
2439 |
|
2440 |
|
2441 |
|
2442 | if (atExplicitKey) {
|
2443 | storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
2444 | }
|
2445 |
|
2446 |
|
2447 | if (detected) {
|
2448 | state.tag = _tag;
|
2449 | state.anchor = _anchor;
|
2450 | state.kind = 'mapping';
|
2451 | state.result = _result;
|
2452 | }
|
2453 |
|
2454 | return detected;
|
2455 | }
|
2456 |
|
2457 | function readTagProperty(state) {
|
2458 | var _position,
|
2459 | isVerbatim = false,
|
2460 | isNamed = false,
|
2461 | tagHandle,
|
2462 | tagName,
|
2463 | ch;
|
2464 |
|
2465 | ch = state.input.charCodeAt(state.position);
|
2466 |
|
2467 | if (ch !== 0x21) { return false; }
|
2468 |
|
2469 | if (state.tag !== null) {
|
2470 | throwError(state, 'duplication of a tag property');
|
2471 | }
|
2472 |
|
2473 | ch = state.input.charCodeAt(++state.position);
|
2474 |
|
2475 | if (ch === 0x3C) {
|
2476 | isVerbatim = true;
|
2477 | ch = state.input.charCodeAt(++state.position);
|
2478 |
|
2479 | } else if (ch === 0x21) {
|
2480 | isNamed = true;
|
2481 | tagHandle = '!!';
|
2482 | ch = state.input.charCodeAt(++state.position);
|
2483 |
|
2484 | } else {
|
2485 | tagHandle = '!';
|
2486 | }
|
2487 |
|
2488 | _position = state.position;
|
2489 |
|
2490 | if (isVerbatim) {
|
2491 | do { ch = state.input.charCodeAt(++state.position); }
|
2492 | while (ch !== 0 && ch !== 0x3E);
|
2493 |
|
2494 | if (state.position < state.length) {
|
2495 | tagName = state.input.slice(_position, state.position);
|
2496 | ch = state.input.charCodeAt(++state.position);
|
2497 | } else {
|
2498 | throwError(state, 'unexpected end of the stream within a verbatim tag');
|
2499 | }
|
2500 | } else {
|
2501 | while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
2502 |
|
2503 | if (ch === 0x21) {
|
2504 | if (!isNamed) {
|
2505 | tagHandle = state.input.slice(_position - 1, state.position + 1);
|
2506 |
|
2507 | if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
2508 | throwError(state, 'named tag handle cannot contain such characters');
|
2509 | }
|
2510 |
|
2511 | isNamed = true;
|
2512 | _position = state.position + 1;
|
2513 | } else {
|
2514 | throwError(state, 'tag suffix cannot contain exclamation marks');
|
2515 | }
|
2516 | }
|
2517 |
|
2518 | ch = state.input.charCodeAt(++state.position);
|
2519 | }
|
2520 |
|
2521 | tagName = state.input.slice(_position, state.position);
|
2522 |
|
2523 | if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
2524 | throwError(state, 'tag suffix cannot contain flow indicator characters');
|
2525 | }
|
2526 | }
|
2527 |
|
2528 | if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
2529 | throwError(state, 'tag name cannot contain such characters: ' + tagName);
|
2530 | }
|
2531 |
|
2532 | if (isVerbatim) {
|
2533 | state.tag = tagName;
|
2534 |
|
2535 | } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
|
2536 | state.tag = state.tagMap[tagHandle] + tagName;
|
2537 |
|
2538 | } else if (tagHandle === '!') {
|
2539 | state.tag = '!' + tagName;
|
2540 |
|
2541 | } else if (tagHandle === '!!') {
|
2542 | state.tag = 'tag:yaml.org,2002:' + tagName;
|
2543 |
|
2544 | } else {
|
2545 | throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
2546 | }
|
2547 |
|
2548 | return true;
|
2549 | }
|
2550 |
|
2551 | function readAnchorProperty(state) {
|
2552 | var _position,
|
2553 | ch;
|
2554 |
|
2555 | ch = state.input.charCodeAt(state.position);
|
2556 |
|
2557 | if (ch !== 0x26) { return false; }
|
2558 |
|
2559 | if (state.anchor !== null) {
|
2560 | throwError(state, 'duplication of an anchor property');
|
2561 | }
|
2562 |
|
2563 | ch = state.input.charCodeAt(++state.position);
|
2564 | _position = state.position;
|
2565 |
|
2566 | while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
2567 | ch = state.input.charCodeAt(++state.position);
|
2568 | }
|
2569 |
|
2570 | if (state.position === _position) {
|
2571 | throwError(state, 'name of an anchor node must contain at least one character');
|
2572 | }
|
2573 |
|
2574 | state.anchor = state.input.slice(_position, state.position);
|
2575 | return true;
|
2576 | }
|
2577 |
|
2578 | function readAlias(state) {
|
2579 | var _position, alias,
|
2580 | ch;
|
2581 |
|
2582 | ch = state.input.charCodeAt(state.position);
|
2583 |
|
2584 | if (ch !== 0x2A) { return false; }
|
2585 |
|
2586 | ch = state.input.charCodeAt(++state.position);
|
2587 | _position = state.position;
|
2588 |
|
2589 | while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
2590 | ch = state.input.charCodeAt(++state.position);
|
2591 | }
|
2592 |
|
2593 | if (state.position === _position) {
|
2594 | throwError(state, 'name of an alias node must contain at least one character');
|
2595 | }
|
2596 |
|
2597 | alias = state.input.slice(_position, state.position);
|
2598 |
|
2599 | if (!state.anchorMap.hasOwnProperty(alias)) {
|
2600 | throwError(state, 'unidentified alias "' + alias + '"');
|
2601 | }
|
2602 |
|
2603 | state.result = state.anchorMap[alias];
|
2604 | skipSeparationSpace(state, true, -1);
|
2605 | return true;
|
2606 | }
|
2607 |
|
2608 | function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
2609 | var allowBlockStyles,
|
2610 | allowBlockScalars,
|
2611 | allowBlockCollections,
|
2612 | indentStatus = 1,
|
2613 | atNewLine = false,
|
2614 | hasContent = false,
|
2615 | typeIndex,
|
2616 | typeQuantity,
|
2617 | type,
|
2618 | flowIndent,
|
2619 | blockIndent;
|
2620 |
|
2621 | if (state.listener !== null) {
|
2622 | state.listener('open', state);
|
2623 | }
|
2624 |
|
2625 | state.tag = null;
|
2626 | state.anchor = null;
|
2627 | state.kind = null;
|
2628 | state.result = null;
|
2629 |
|
2630 | allowBlockStyles = allowBlockScalars = allowBlockCollections =
|
2631 | CONTEXT_BLOCK_OUT === nodeContext ||
|
2632 | CONTEXT_BLOCK_IN === nodeContext;
|
2633 |
|
2634 | if (allowToSeek) {
|
2635 | if (skipSeparationSpace(state, true, -1)) {
|
2636 | atNewLine = true;
|
2637 |
|
2638 | if (state.lineIndent > parentIndent) {
|
2639 | indentStatus = 1;
|
2640 | } else if (state.lineIndent === parentIndent) {
|
2641 | indentStatus = 0;
|
2642 | } else if (state.lineIndent < parentIndent) {
|
2643 | indentStatus = -1;
|
2644 | }
|
2645 | }
|
2646 | }
|
2647 |
|
2648 | if (indentStatus === 1) {
|
2649 | while (readTagProperty(state) || readAnchorProperty(state)) {
|
2650 | if (skipSeparationSpace(state, true, -1)) {
|
2651 | atNewLine = true;
|
2652 | allowBlockCollections = allowBlockStyles;
|
2653 |
|
2654 | if (state.lineIndent > parentIndent) {
|
2655 | indentStatus = 1;
|
2656 | } else if (state.lineIndent === parentIndent) {
|
2657 | indentStatus = 0;
|
2658 | } else if (state.lineIndent < parentIndent) {
|
2659 | indentStatus = -1;
|
2660 | }
|
2661 | } else {
|
2662 | allowBlockCollections = false;
|
2663 | }
|
2664 | }
|
2665 | }
|
2666 |
|
2667 | if (allowBlockCollections) {
|
2668 | allowBlockCollections = atNewLine || allowCompact;
|
2669 | }
|
2670 |
|
2671 | if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
2672 | if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
2673 | flowIndent = parentIndent;
|
2674 | } else {
|
2675 | flowIndent = parentIndent + 1;
|
2676 | }
|
2677 |
|
2678 | blockIndent = state.position - state.lineStart;
|
2679 |
|
2680 | if (indentStatus === 1) {
|
2681 | if (allowBlockCollections &&
|
2682 | (readBlockSequence(state, blockIndent) ||
|
2683 | readBlockMapping(state, blockIndent, flowIndent)) ||
|
2684 | readFlowCollection(state, flowIndent)) {
|
2685 | hasContent = true;
|
2686 | } else {
|
2687 | if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
|
2688 | readSingleQuotedScalar(state, flowIndent) ||
|
2689 | readDoubleQuotedScalar(state, flowIndent)) {
|
2690 | hasContent = true;
|
2691 |
|
2692 | } else if (readAlias(state)) {
|
2693 | hasContent = true;
|
2694 |
|
2695 | if (state.tag !== null || state.anchor !== null) {
|
2696 | throwError(state, 'alias node should not have any properties');
|
2697 | }
|
2698 |
|
2699 | } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
2700 | hasContent = true;
|
2701 |
|
2702 | if (state.tag === null) {
|
2703 | state.tag = '?';
|
2704 | }
|
2705 | }
|
2706 |
|
2707 | if (state.anchor !== null) {
|
2708 | state.anchorMap[state.anchor] = state.result;
|
2709 | }
|
2710 | }
|
2711 | } else if (indentStatus === 0) {
|
2712 |
|
2713 |
|
2714 | hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
2715 | }
|
2716 | }
|
2717 |
|
2718 | if (state.tag !== null && state.tag !== '!') {
|
2719 | if (state.tag === '?') {
|
2720 | for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
|
2721 | typeIndex < typeQuantity;
|
2722 | typeIndex += 1) {
|
2723 | type = state.implicitTypes[typeIndex];
|
2724 |
|
2725 |
|
2726 |
|
2727 |
|
2728 |
|
2729 | if (type.resolve(state.result)) {
|
2730 | state.result = type.construct(state.result);
|
2731 | state.tag = type.tag;
|
2732 | if (state.anchor !== null) {
|
2733 | state.anchorMap[state.anchor] = state.result;
|
2734 | }
|
2735 | break;
|
2736 | }
|
2737 | }
|
2738 | } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
|
2739 | type = state.typeMap[state.kind || 'fallback'][state.tag];
|
2740 |
|
2741 | if (state.result !== null && type.kind !== state.kind) {
|
2742 | throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
|
2743 | }
|
2744 |
|
2745 | if (!type.resolve(state.result)) {
|
2746 | throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
|
2747 | } else {
|
2748 | state.result = type.construct(state.result);
|
2749 | if (state.anchor !== null) {
|
2750 | state.anchorMap[state.anchor] = state.result;
|
2751 | }
|
2752 | }
|
2753 | } else {
|
2754 | throwError(state, 'unknown tag !<' + state.tag + '>');
|
2755 | }
|
2756 | }
|
2757 |
|
2758 | if (state.listener !== null) {
|
2759 | state.listener('close', state);
|
2760 | }
|
2761 | return state.tag !== null || state.anchor !== null || hasContent;
|
2762 | }
|
2763 |
|
2764 | function readDocument(state) {
|
2765 | var documentStart = state.position,
|
2766 | _position,
|
2767 | directiveName,
|
2768 | directiveArgs,
|
2769 | hasDirectives = false,
|
2770 | ch;
|
2771 |
|
2772 | state.version = null;
|
2773 | state.checkLineBreaks = state.legacy;
|
2774 | state.tagMap = {};
|
2775 | state.anchorMap = {};
|
2776 |
|
2777 | while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
2778 | skipSeparationSpace(state, true, -1);
|
2779 |
|
2780 | ch = state.input.charCodeAt(state.position);
|
2781 |
|
2782 | if (state.lineIndent > 0 || ch !== 0x25) {
|
2783 | break;
|
2784 | }
|
2785 |
|
2786 | hasDirectives = true;
|
2787 | ch = state.input.charCodeAt(++state.position);
|
2788 | _position = state.position;
|
2789 |
|
2790 | while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
2791 | ch = state.input.charCodeAt(++state.position);
|
2792 | }
|
2793 |
|
2794 | directiveName = state.input.slice(_position, state.position);
|
2795 | directiveArgs = [];
|
2796 |
|
2797 | if (directiveName.length < 1) {
|
2798 | throwError(state, 'directive name must not be less than one character in length');
|
2799 | }
|
2800 |
|
2801 | while (ch !== 0) {
|
2802 | while (is_WHITE_SPACE(ch)) {
|
2803 | ch = state.input.charCodeAt(++state.position);
|
2804 | }
|
2805 |
|
2806 | if (ch === 0x23) {
|
2807 | do { ch = state.input.charCodeAt(++state.position); }
|
2808 | while (ch !== 0 && !is_EOL(ch));
|
2809 | break;
|
2810 | }
|
2811 |
|
2812 | if (is_EOL(ch)) { break; }
|
2813 |
|
2814 | _position = state.position;
|
2815 |
|
2816 | while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
2817 | ch = state.input.charCodeAt(++state.position);
|
2818 | }
|
2819 |
|
2820 | directiveArgs.push(state.input.slice(_position, state.position));
|
2821 | }
|
2822 |
|
2823 | if (ch !== 0) { readLineBreak(state); }
|
2824 |
|
2825 | if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
|
2826 | directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
2827 | } else {
|
2828 | throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
2829 | }
|
2830 | }
|
2831 |
|
2832 | skipSeparationSpace(state, true, -1);
|
2833 |
|
2834 | if (state.lineIndent === 0 &&
|
2835 | state.input.charCodeAt(state.position) === 0x2D &&
|
2836 | state.input.charCodeAt(state.position + 1) === 0x2D &&
|
2837 | state.input.charCodeAt(state.position + 2) === 0x2D) {
|
2838 | state.position += 3;
|
2839 | skipSeparationSpace(state, true, -1);
|
2840 |
|
2841 | } else if (hasDirectives) {
|
2842 | throwError(state, 'directives end mark is expected');
|
2843 | }
|
2844 |
|
2845 | composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
2846 | skipSeparationSpace(state, true, -1);
|
2847 |
|
2848 | if (state.checkLineBreaks &&
|
2849 | PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
2850 | throwWarning(state, 'non-ASCII line breaks are interpreted as content');
|
2851 | }
|
2852 |
|
2853 | state.documents.push(state.result);
|
2854 |
|
2855 | if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
2856 |
|
2857 | if (state.input.charCodeAt(state.position) === 0x2E) {
|
2858 | state.position += 3;
|
2859 | skipSeparationSpace(state, true, -1);
|
2860 | }
|
2861 | return;
|
2862 | }
|
2863 |
|
2864 | if (state.position < (state.length - 1)) {
|
2865 | throwError(state, 'end of the stream or a document separator is expected');
|
2866 | } else {
|
2867 | return;
|
2868 | }
|
2869 | }
|
2870 |
|
2871 |
|
2872 | function loadDocuments(input, options) {
|
2873 | input = String(input);
|
2874 | options = options || {};
|
2875 |
|
2876 | if (input.length !== 0) {
|
2877 |
|
2878 |
|
2879 | if (input.charCodeAt(input.length - 1) !== 0x0A &&
|
2880 | input.charCodeAt(input.length - 1) !== 0x0D) {
|
2881 | input += '\n';
|
2882 | }
|
2883 |
|
2884 |
|
2885 | if (input.charCodeAt(0) === 0xFEFF) {
|
2886 | input = input.slice(1);
|
2887 | }
|
2888 | }
|
2889 |
|
2890 | var state = new State(input, options);
|
2891 |
|
2892 |
|
2893 | state.input += '\0';
|
2894 |
|
2895 | while (state.input.charCodeAt(state.position) === 0x20) {
|
2896 | state.lineIndent += 1;
|
2897 | state.position += 1;
|
2898 | }
|
2899 |
|
2900 | while (state.position < (state.length - 1)) {
|
2901 | readDocument(state);
|
2902 | }
|
2903 |
|
2904 | return state.documents;
|
2905 | }
|
2906 |
|
2907 |
|
2908 | function loadAll$1(input, iterator, options) {
|
2909 | var documents = loadDocuments(input, options), index, length;
|
2910 |
|
2911 | for (index = 0, length = documents.length; index < length; index += 1) {
|
2912 | iterator(documents[index]);
|
2913 | }
|
2914 | }
|
2915 |
|
2916 |
|
2917 | function load$1(input, options) {
|
2918 | var documents = loadDocuments(input, options);
|
2919 |
|
2920 | if (documents.length === 0) {
|
2921 |
|
2922 | return undefined;
|
2923 | } else if (documents.length === 1) {
|
2924 | return documents[0];
|
2925 | }
|
2926 | throw new YAMLException$1('expected a single document in the stream, but found more');
|
2927 | }
|
2928 |
|
2929 |
|
2930 | function safeLoadAll$1(input, output, options) {
|
2931 | loadAll$1(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options));
|
2932 | }
|
2933 |
|
2934 |
|
2935 | function safeLoad$1(input, options) {
|
2936 | return load$1(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options));
|
2937 | }
|
2938 |
|
2939 |
|
2940 | var loadAll_1 = loadAll$1;
|
2941 | var load_1 = load$1;
|
2942 | var safeLoadAll_1 = safeLoadAll$1;
|
2943 | var safeLoad_1 = safeLoad$1;
|
2944 |
|
2945 | var loader$1 = {
|
2946 | loadAll: loadAll_1,
|
2947 | load: load_1,
|
2948 | safeLoadAll: safeLoadAll_1,
|
2949 | safeLoad: safeLoad_1
|
2950 | };
|
2951 |
|
2952 |
|
2953 |
|
2954 | var common$7 = common$1;
|
2955 | var YAMLException$5 = exception;
|
2956 | var DEFAULT_FULL_SCHEMA$2 = default_full;
|
2957 | var DEFAULT_SAFE_SCHEMA$2 = default_safe;
|
2958 |
|
2959 | var _toString$2 = Object.prototype.toString;
|
2960 | var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
2961 |
|
2962 | var CHAR_TAB = 0x09;
|
2963 | var CHAR_LINE_FEED = 0x0A;
|
2964 | var CHAR_SPACE = 0x20;
|
2965 | var CHAR_EXCLAMATION = 0x21;
|
2966 | var CHAR_DOUBLE_QUOTE = 0x22;
|
2967 | var CHAR_SHARP = 0x23;
|
2968 | var CHAR_PERCENT = 0x25;
|
2969 | var CHAR_AMPERSAND = 0x26;
|
2970 | var CHAR_SINGLE_QUOTE = 0x27;
|
2971 | var CHAR_ASTERISK = 0x2A;
|
2972 | var CHAR_COMMA = 0x2C;
|
2973 | var CHAR_MINUS = 0x2D;
|
2974 | var CHAR_COLON = 0x3A;
|
2975 | var CHAR_GREATER_THAN = 0x3E;
|
2976 | var CHAR_QUESTION = 0x3F;
|
2977 | var CHAR_COMMERCIAL_AT = 0x40;
|
2978 | var CHAR_LEFT_SQUARE_BRACKET = 0x5B;
|
2979 | var CHAR_RIGHT_SQUARE_BRACKET = 0x5D;
|
2980 | var CHAR_GRAVE_ACCENT = 0x60;
|
2981 | var CHAR_LEFT_CURLY_BRACKET = 0x7B;
|
2982 | var CHAR_VERTICAL_LINE = 0x7C;
|
2983 | var CHAR_RIGHT_CURLY_BRACKET = 0x7D;
|
2984 |
|
2985 | var ESCAPE_SEQUENCES = {};
|
2986 |
|
2987 | ESCAPE_SEQUENCES[0x00] = '\\0';
|
2988 | ESCAPE_SEQUENCES[0x07] = '\\a';
|
2989 | ESCAPE_SEQUENCES[0x08] = '\\b';
|
2990 | ESCAPE_SEQUENCES[0x09] = '\\t';
|
2991 | ESCAPE_SEQUENCES[0x0A] = '\\n';
|
2992 | ESCAPE_SEQUENCES[0x0B] = '\\v';
|
2993 | ESCAPE_SEQUENCES[0x0C] = '\\f';
|
2994 | ESCAPE_SEQUENCES[0x0D] = '\\r';
|
2995 | ESCAPE_SEQUENCES[0x1B] = '\\e';
|
2996 | ESCAPE_SEQUENCES[0x22] = '\\"';
|
2997 | ESCAPE_SEQUENCES[0x5C] = '\\\\';
|
2998 | ESCAPE_SEQUENCES[0x85] = '\\N';
|
2999 | ESCAPE_SEQUENCES[0xA0] = '\\_';
|
3000 | ESCAPE_SEQUENCES[0x2028] = '\\L';
|
3001 | ESCAPE_SEQUENCES[0x2029] = '\\P';
|
3002 |
|
3003 | var DEPRECATED_BOOLEANS_SYNTAX = [
|
3004 | 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
3005 | 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
3006 | ];
|
3007 |
|
3008 | function compileStyleMap(schema, map) {
|
3009 | var result, keys, index, length, tag, style, type;
|
3010 |
|
3011 | if (map === null) { return {}; }
|
3012 |
|
3013 | result = {};
|
3014 | keys = Object.keys(map);
|
3015 |
|
3016 | for (index = 0, length = keys.length; index < length; index += 1) {
|
3017 | tag = keys[index];
|
3018 | style = String(map[tag]);
|
3019 |
|
3020 | if (tag.slice(0, 2) === '!!') {
|
3021 | tag = 'tag:yaml.org,2002:' + tag.slice(2);
|
3022 | }
|
3023 | type = schema.compiledTypeMap['fallback'][tag];
|
3024 |
|
3025 | if (type && _hasOwnProperty$3.call(type.styleAliases, style)) {
|
3026 | style = type.styleAliases[style];
|
3027 | }
|
3028 |
|
3029 | result[tag] = style;
|
3030 | }
|
3031 |
|
3032 | return result;
|
3033 | }
|
3034 |
|
3035 | function encodeHex(character) {
|
3036 | var string, handle, length;
|
3037 |
|
3038 | string = character.toString(16).toUpperCase();
|
3039 |
|
3040 | if (character <= 0xFF) {
|
3041 | handle = 'x';
|
3042 | length = 2;
|
3043 | } else if (character <= 0xFFFF) {
|
3044 | handle = 'u';
|
3045 | length = 4;
|
3046 | } else if (character <= 0xFFFFFFFF) {
|
3047 | handle = 'U';
|
3048 | length = 8;
|
3049 | } else {
|
3050 | throw new YAMLException$5('code point within a string may not be greater than 0xFFFFFFFF');
|
3051 | }
|
3052 |
|
3053 | return '\\' + handle + common$7.repeat('0', length - string.length) + string;
|
3054 | }
|
3055 |
|
3056 | function State$1(options) {
|
3057 | this.schema = options['schema'] || DEFAULT_FULL_SCHEMA$2;
|
3058 | this.indent = Math.max(1, (options['indent'] || 2));
|
3059 | this.skipInvalid = options['skipInvalid'] || false;
|
3060 | this.flowLevel = (common$7.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
3061 | this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
3062 | this.sortKeys = options['sortKeys'] || false;
|
3063 | this.lineWidth = options['lineWidth'] || 80;
|
3064 | this.noRefs = options['noRefs'] || false;
|
3065 | this.noCompatMode = options['noCompatMode'] || false;
|
3066 |
|
3067 | this.implicitTypes = this.schema.compiledImplicit;
|
3068 | this.explicitTypes = this.schema.compiledExplicit;
|
3069 |
|
3070 | this.tag = null;
|
3071 | this.result = '';
|
3072 |
|
3073 | this.duplicates = [];
|
3074 | this.usedDuplicates = null;
|
3075 | }
|
3076 |
|
3077 |
|
3078 | function indentString(string, spaces) {
|
3079 | var ind = common$7.repeat(' ', spaces),
|
3080 | position = 0,
|
3081 | next = -1,
|
3082 | result = '',
|
3083 | line,
|
3084 | length = string.length;
|
3085 |
|
3086 | while (position < length) {
|
3087 | next = string.indexOf('\n', position);
|
3088 | if (next === -1) {
|
3089 | line = string.slice(position);
|
3090 | position = length;
|
3091 | } else {
|
3092 | line = string.slice(position, next + 1);
|
3093 | position = next + 1;
|
3094 | }
|
3095 |
|
3096 | if (line.length && line !== '\n') { result += ind; }
|
3097 |
|
3098 | result += line;
|
3099 | }
|
3100 |
|
3101 | return result;
|
3102 | }
|
3103 |
|
3104 | function generateNextLine(state, level) {
|
3105 | return '\n' + common$7.repeat(' ', state.indent * level);
|
3106 | }
|
3107 |
|
3108 | function testImplicitResolving(state, str) {
|
3109 | var index, length, type;
|
3110 |
|
3111 | for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
3112 | type = state.implicitTypes[index];
|
3113 |
|
3114 | if (type.resolve(str)) {
|
3115 | return true;
|
3116 | }
|
3117 | }
|
3118 |
|
3119 | return false;
|
3120 | }
|
3121 |
|
3122 |
|
3123 | function isWhitespace(c) {
|
3124 | return c === CHAR_SPACE || c === CHAR_TAB;
|
3125 | }
|
3126 |
|
3127 |
|
3128 |
|
3129 |
|
3130 |
|
3131 | function isPrintable(c) {
|
3132 | return (0x00020 <= c && c <= 0x00007E)
|
3133 | || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
|
3134 | || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF )
|
3135 | || (0x10000 <= c && c <= 0x10FFFF);
|
3136 | }
|
3137 |
|
3138 |
|
3139 | function isPlainSafe(c) {
|
3140 |
|
3141 |
|
3142 | return isPrintable(c) && c !== 0xFEFF
|
3143 |
|
3144 | && c !== CHAR_COMMA
|
3145 | && c !== CHAR_LEFT_SQUARE_BRACKET
|
3146 | && c !== CHAR_RIGHT_SQUARE_BRACKET
|
3147 | && c !== CHAR_LEFT_CURLY_BRACKET
|
3148 | && c !== CHAR_RIGHT_CURLY_BRACKET
|
3149 |
|
3150 | && c !== CHAR_COLON
|
3151 | && c !== CHAR_SHARP;
|
3152 | }
|
3153 |
|
3154 |
|
3155 | function isPlainSafeFirst(c) {
|
3156 |
|
3157 |
|
3158 | return isPrintable(c) && c !== 0xFEFF
|
3159 | && !isWhitespace(c)
|
3160 |
|
3161 |
|
3162 | && c !== CHAR_MINUS
|
3163 | && c !== CHAR_QUESTION
|
3164 | && c !== CHAR_COLON
|
3165 | && c !== CHAR_COMMA
|
3166 | && c !== CHAR_LEFT_SQUARE_BRACKET
|
3167 | && c !== CHAR_RIGHT_SQUARE_BRACKET
|
3168 | && c !== CHAR_LEFT_CURLY_BRACKET
|
3169 | && c !== CHAR_RIGHT_CURLY_BRACKET
|
3170 |
|
3171 | && c !== CHAR_SHARP
|
3172 | && c !== CHAR_AMPERSAND
|
3173 | && c !== CHAR_ASTERISK
|
3174 | && c !== CHAR_EXCLAMATION
|
3175 | && c !== CHAR_VERTICAL_LINE
|
3176 | && c !== CHAR_GREATER_THAN
|
3177 | && c !== CHAR_SINGLE_QUOTE
|
3178 | && c !== CHAR_DOUBLE_QUOTE
|
3179 |
|
3180 | && c !== CHAR_PERCENT
|
3181 | && c !== CHAR_COMMERCIAL_AT
|
3182 | && c !== CHAR_GRAVE_ACCENT;
|
3183 | }
|
3184 |
|
3185 | var STYLE_PLAIN = 1;
|
3186 | var STYLE_SINGLE = 2;
|
3187 | var STYLE_LITERAL = 3;
|
3188 | var STYLE_FOLDED = 4;
|
3189 | var STYLE_DOUBLE = 5;
|
3190 |
|
3191 |
|
3192 |
|
3193 |
|
3194 |
|
3195 |
|
3196 |
|
3197 |
|
3198 | function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
|
3199 | var i;
|
3200 | var char;
|
3201 | var hasLineBreak = false;
|
3202 | var hasFoldableLine = false;
|
3203 | var shouldTrackWidth = lineWidth !== -1;
|
3204 | var previousLineBreak = -1;
|
3205 | var plain = isPlainSafeFirst(string.charCodeAt(0))
|
3206 | && !isWhitespace(string.charCodeAt(string.length - 1));
|
3207 |
|
3208 | if (singleLineOnly) {
|
3209 |
|
3210 |
|
3211 | for (i = 0; i < string.length; i++) {
|
3212 | char = string.charCodeAt(i);
|
3213 | if (!isPrintable(char)) {
|
3214 | return STYLE_DOUBLE;
|
3215 | }
|
3216 | plain = plain && isPlainSafe(char);
|
3217 | }
|
3218 | } else {
|
3219 |
|
3220 | for (i = 0; i < string.length; i++) {
|
3221 | char = string.charCodeAt(i);
|
3222 | if (char === CHAR_LINE_FEED) {
|
3223 | hasLineBreak = true;
|
3224 |
|
3225 | if (shouldTrackWidth) {
|
3226 | hasFoldableLine = hasFoldableLine ||
|
3227 |
|
3228 | (i - previousLineBreak - 1 > lineWidth &&
|
3229 | string[previousLineBreak + 1] !== ' ');
|
3230 | previousLineBreak = i;
|
3231 | }
|
3232 | } else if (!isPrintable(char)) {
|
3233 | return STYLE_DOUBLE;
|
3234 | }
|
3235 | plain = plain && isPlainSafe(char);
|
3236 | }
|
3237 |
|
3238 | hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
|
3239 | (i - previousLineBreak - 1 > lineWidth &&
|
3240 | string[previousLineBreak + 1] !== ' '));
|
3241 | }
|
3242 |
|
3243 |
|
3244 |
|
3245 | if (!hasLineBreak && !hasFoldableLine) {
|
3246 |
|
3247 |
|
3248 | return plain && !testAmbiguousType(string)
|
3249 | ? STYLE_PLAIN : STYLE_SINGLE;
|
3250 | }
|
3251 |
|
3252 | if (string[0] === ' ' && indentPerLevel > 9) {
|
3253 | return STYLE_DOUBLE;
|
3254 | }
|
3255 |
|
3256 |
|
3257 | return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
3258 | }
|
3259 |
|
3260 |
|
3261 |
|
3262 |
|
3263 |
|
3264 |
|
3265 |
|
3266 | function writeScalar(state, string, level, iskey) {
|
3267 | state.dump = (function () {
|
3268 | if (string.length === 0) {
|
3269 | return "''";
|
3270 | }
|
3271 | if (!state.noCompatMode &&
|
3272 | DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
|
3273 | return "'" + string + "'";
|
3274 | }
|
3275 |
|
3276 | var indent = state.indent * Math.max(1, level);
|
3277 |
|
3278 |
|
3279 |
|
3280 |
|
3281 |
|
3282 |
|
3283 |
|
3284 | var lineWidth = state.lineWidth === -1
|
3285 | ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
3286 |
|
3287 |
|
3288 | var singleLineOnly = iskey
|
3289 |
|
3290 | || (state.flowLevel > -1 && level >= state.flowLevel);
|
3291 | function testAmbiguity(string) {
|
3292 | return testImplicitResolving(state, string);
|
3293 | }
|
3294 |
|
3295 | switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
|
3296 | case STYLE_PLAIN:
|
3297 | return string;
|
3298 | case STYLE_SINGLE:
|
3299 | return "'" + string.replace(/'/g, "''") + "'";
|
3300 | case STYLE_LITERAL:
|
3301 | return '|' + blockHeader(string, state.indent)
|
3302 | + dropEndingNewline(indentString(string, indent));
|
3303 | case STYLE_FOLDED:
|
3304 | return '>' + blockHeader(string, state.indent)
|
3305 | + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
3306 | case STYLE_DOUBLE:
|
3307 | return '"' + escapeString(string, lineWidth) + '"';
|
3308 | default:
|
3309 | throw new YAMLException$5('impossible error: invalid scalar style');
|
3310 | }
|
3311 | }());
|
3312 | }
|
3313 |
|
3314 |
|
3315 | function blockHeader(string, indentPerLevel) {
|
3316 | var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : '';
|
3317 |
|
3318 |
|
3319 | var clip = string[string.length - 1] === '\n';
|
3320 | var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
|
3321 | var chomp = keep ? '+' : (clip ? '' : '-');
|
3322 |
|
3323 | return indentIndicator + chomp + '\n';
|
3324 | }
|
3325 |
|
3326 |
|
3327 | function dropEndingNewline(string) {
|
3328 | return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
|
3329 | }
|
3330 |
|
3331 |
|
3332 |
|
3333 | function foldString(string, width) {
|
3334 |
|
3335 |
|
3336 |
|
3337 |
|
3338 | var lineRe = /(\n+)([^\n]*)/g;
|
3339 |
|
3340 |
|
3341 | var result = (function () {
|
3342 | var nextLF = string.indexOf('\n');
|
3343 | nextLF = nextLF !== -1 ? nextLF : string.length;
|
3344 | lineRe.lastIndex = nextLF;
|
3345 | return foldLine(string.slice(0, nextLF), width);
|
3346 | }());
|
3347 |
|
3348 | var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
|
3349 | var moreIndented;
|
3350 |
|
3351 |
|
3352 | var match;
|
3353 | while ((match = lineRe.exec(string))) {
|
3354 | var prefix = match[1], line = match[2];
|
3355 | moreIndented = (line[0] === ' ');
|
3356 | result += prefix
|
3357 | + (!prevMoreIndented && !moreIndented && line !== ''
|
3358 | ? '\n' : '')
|
3359 | + foldLine(line, width);
|
3360 | prevMoreIndented = moreIndented;
|
3361 | }
|
3362 |
|
3363 | return result;
|
3364 | }
|
3365 |
|
3366 |
|
3367 |
|
3368 |
|
3369 |
|
3370 | function foldLine(line, width) {
|
3371 | if (line === '' || line[0] === ' ') { return line; }
|
3372 |
|
3373 |
|
3374 | var breakRe = / [^ ]/g;
|
3375 | var match;
|
3376 |
|
3377 | var start = 0, end, curr = 0, next = 0;
|
3378 | var result = '';
|
3379 |
|
3380 |
|
3381 |
|
3382 |
|
3383 |
|
3384 | while ((match = breakRe.exec(line))) {
|
3385 | next = match.index;
|
3386 |
|
3387 | if (next - start > width) {
|
3388 | end = (curr > start) ? curr : next;
|
3389 | result += '\n' + line.slice(start, end);
|
3390 |
|
3391 | start = end + 1;
|
3392 | }
|
3393 | curr = next;
|
3394 | }
|
3395 |
|
3396 |
|
3397 |
|
3398 | result += '\n';
|
3399 |
|
3400 | if (line.length - start > width && curr > start) {
|
3401 | result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
|
3402 | } else {
|
3403 | result += line.slice(start);
|
3404 | }
|
3405 |
|
3406 | return result.slice(1);
|
3407 | }
|
3408 |
|
3409 |
|
3410 | function escapeString(string) {
|
3411 | var result = '';
|
3412 | var char;
|
3413 | var escapeSeq;
|
3414 |
|
3415 | for (var i = 0; i < string.length; i++) {
|
3416 | char = string.charCodeAt(i);
|
3417 | escapeSeq = ESCAPE_SEQUENCES[char];
|
3418 | result += !escapeSeq && isPrintable(char)
|
3419 | ? string[i]
|
3420 | : escapeSeq || encodeHex(char);
|
3421 | }
|
3422 |
|
3423 | return result;
|
3424 | }
|
3425 |
|
3426 | function writeFlowSequence(state, level, object) {
|
3427 | var _result = '',
|
3428 | _tag = state.tag,
|
3429 | index,
|
3430 | length;
|
3431 |
|
3432 | for (index = 0, length = object.length; index < length; index += 1) {
|
3433 |
|
3434 | if (writeNode(state, level, object[index], false, false)) {
|
3435 | if (index !== 0) { _result += ', '; }
|
3436 | _result += state.dump;
|
3437 | }
|
3438 | }
|
3439 |
|
3440 | state.tag = _tag;
|
3441 | state.dump = '[' + _result + ']';
|
3442 | }
|
3443 |
|
3444 | function writeBlockSequence(state, level, object, compact) {
|
3445 | var _result = '',
|
3446 | _tag = state.tag,
|
3447 | index,
|
3448 | length;
|
3449 |
|
3450 | for (index = 0, length = object.length; index < length; index += 1) {
|
3451 |
|
3452 | if (writeNode(state, level + 1, object[index], true, true)) {
|
3453 | if (!compact || index !== 0) {
|
3454 | _result += generateNextLine(state, level);
|
3455 | }
|
3456 | _result += '- ' + state.dump;
|
3457 | }
|
3458 | }
|
3459 |
|
3460 | state.tag = _tag;
|
3461 | state.dump = _result || '[]';
|
3462 | }
|
3463 |
|
3464 | function writeFlowMapping(state, level, object) {
|
3465 | var _result = '',
|
3466 | _tag = state.tag,
|
3467 | objectKeyList = Object.keys(object),
|
3468 | index,
|
3469 | length,
|
3470 | objectKey,
|
3471 | objectValue,
|
3472 | pairBuffer;
|
3473 |
|
3474 | for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
3475 | pairBuffer = '';
|
3476 |
|
3477 | if (index !== 0) { pairBuffer += ', '; }
|
3478 |
|
3479 | objectKey = objectKeyList[index];
|
3480 | objectValue = object[objectKey];
|
3481 |
|
3482 | if (!writeNode(state, level, objectKey, false, false)) {
|
3483 | continue;
|
3484 | }
|
3485 |
|
3486 | if (state.dump.length > 1024) { pairBuffer += '? '; }
|
3487 |
|
3488 | pairBuffer += state.dump + ': ';
|
3489 |
|
3490 | if (!writeNode(state, level, objectValue, false, false)) {
|
3491 | continue;
|
3492 | }
|
3493 |
|
3494 | pairBuffer += state.dump;
|
3495 |
|
3496 |
|
3497 | _result += pairBuffer;
|
3498 | }
|
3499 |
|
3500 | state.tag = _tag;
|
3501 | state.dump = '{' + _result + '}';
|
3502 | }
|
3503 |
|
3504 | function writeBlockMapping(state, level, object, compact) {
|
3505 | var _result = '',
|
3506 | _tag = state.tag,
|
3507 | objectKeyList = Object.keys(object),
|
3508 | index,
|
3509 | length,
|
3510 | objectKey,
|
3511 | objectValue,
|
3512 | explicitPair,
|
3513 | pairBuffer;
|
3514 |
|
3515 |
|
3516 | if (state.sortKeys === true) {
|
3517 |
|
3518 | objectKeyList.sort();
|
3519 | } else if (typeof state.sortKeys === 'function') {
|
3520 |
|
3521 | objectKeyList.sort(state.sortKeys);
|
3522 | } else if (state.sortKeys) {
|
3523 |
|
3524 | throw new YAMLException$5('sortKeys must be a boolean or a function');
|
3525 | }
|
3526 |
|
3527 | for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
3528 | pairBuffer = '';
|
3529 |
|
3530 | if (!compact || index !== 0) {
|
3531 | pairBuffer += generateNextLine(state, level);
|
3532 | }
|
3533 |
|
3534 | objectKey = objectKeyList[index];
|
3535 | objectValue = object[objectKey];
|
3536 |
|
3537 | if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
3538 | continue;
|
3539 | }
|
3540 |
|
3541 | explicitPair = (state.tag !== null && state.tag !== '?') ||
|
3542 | (state.dump && state.dump.length > 1024);
|
3543 |
|
3544 | if (explicitPair) {
|
3545 | if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
3546 | pairBuffer += '?';
|
3547 | } else {
|
3548 | pairBuffer += '? ';
|
3549 | }
|
3550 | }
|
3551 |
|
3552 | pairBuffer += state.dump;
|
3553 |
|
3554 | if (explicitPair) {
|
3555 | pairBuffer += generateNextLine(state, level);
|
3556 | }
|
3557 |
|
3558 | if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
3559 | continue;
|
3560 | }
|
3561 |
|
3562 | if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
3563 | pairBuffer += ':';
|
3564 | } else {
|
3565 | pairBuffer += ': ';
|
3566 | }
|
3567 |
|
3568 | pairBuffer += state.dump;
|
3569 |
|
3570 |
|
3571 | _result += pairBuffer;
|
3572 | }
|
3573 |
|
3574 | state.tag = _tag;
|
3575 | state.dump = _result || '{}';
|
3576 | }
|
3577 |
|
3578 | function detectType(state, object, explicit) {
|
3579 | var _result, typeList, index, length, type, style;
|
3580 |
|
3581 | typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
3582 |
|
3583 | for (index = 0, length = typeList.length; index < length; index += 1) {
|
3584 | type = typeList[index];
|
3585 |
|
3586 | if ((type.instanceOf || type.predicate) &&
|
3587 | (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
|
3588 | (!type.predicate || type.predicate(object))) {
|
3589 |
|
3590 | state.tag = explicit ? type.tag : '?';
|
3591 |
|
3592 | if (type.represent) {
|
3593 | style = state.styleMap[type.tag] || type.defaultStyle;
|
3594 |
|
3595 | if (_toString$2.call(type.represent) === '[object Function]') {
|
3596 | _result = type.represent(object, style);
|
3597 | } else if (_hasOwnProperty$3.call(type.represent, style)) {
|
3598 | _result = type.represent[style](object, style);
|
3599 | } else {
|
3600 | throw new YAMLException$5('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
|
3601 | }
|
3602 |
|
3603 | state.dump = _result;
|
3604 | }
|
3605 |
|
3606 | return true;
|
3607 | }
|
3608 | }
|
3609 |
|
3610 | return false;
|
3611 | }
|
3612 |
|
3613 |
|
3614 |
|
3615 |
|
3616 | function writeNode(state, level, object, block, compact, iskey) {
|
3617 | state.tag = null;
|
3618 | state.dump = object;
|
3619 |
|
3620 | if (!detectType(state, object, false)) {
|
3621 | detectType(state, object, true);
|
3622 | }
|
3623 |
|
3624 | var type = _toString$2.call(state.dump);
|
3625 |
|
3626 | if (block) {
|
3627 | block = (state.flowLevel < 0 || state.flowLevel > level);
|
3628 | }
|
3629 |
|
3630 | var objectOrArray = type === '[object Object]' || type === '[object Array]',
|
3631 | duplicateIndex,
|
3632 | duplicate;
|
3633 |
|
3634 | if (objectOrArray) {
|
3635 | duplicateIndex = state.duplicates.indexOf(object);
|
3636 | duplicate = duplicateIndex !== -1;
|
3637 | }
|
3638 |
|
3639 | if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
|
3640 | compact = false;
|
3641 | }
|
3642 |
|
3643 | if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
3644 | state.dump = '*ref_' + duplicateIndex;
|
3645 | } else {
|
3646 | if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
3647 | state.usedDuplicates[duplicateIndex] = true;
|
3648 | }
|
3649 | if (type === '[object Object]') {
|
3650 | if (block && (Object.keys(state.dump).length !== 0)) {
|
3651 | writeBlockMapping(state, level, state.dump, compact);
|
3652 | if (duplicate) {
|
3653 | state.dump = '&ref_' + duplicateIndex + state.dump;
|
3654 | }
|
3655 | } else {
|
3656 | writeFlowMapping(state, level, state.dump);
|
3657 | if (duplicate) {
|
3658 | state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
3659 | }
|
3660 | }
|
3661 | } else if (type === '[object Array]') {
|
3662 | if (block && (state.dump.length !== 0)) {
|
3663 | writeBlockSequence(state, level, state.dump, compact);
|
3664 | if (duplicate) {
|
3665 | state.dump = '&ref_' + duplicateIndex + state.dump;
|
3666 | }
|
3667 | } else {
|
3668 | writeFlowSequence(state, level, state.dump);
|
3669 | if (duplicate) {
|
3670 | state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
3671 | }
|
3672 | }
|
3673 | } else if (type === '[object String]') {
|
3674 | if (state.tag !== '?') {
|
3675 | writeScalar(state, state.dump, level, iskey);
|
3676 | }
|
3677 | } else {
|
3678 | if (state.skipInvalid) { return false; }
|
3679 | throw new YAMLException$5('unacceptable kind of an object to dump ' + type);
|
3680 | }
|
3681 |
|
3682 | if (state.tag !== null && state.tag !== '?') {
|
3683 | state.dump = '!<' + state.tag + '> ' + state.dump;
|
3684 | }
|
3685 | }
|
3686 |
|
3687 | return true;
|
3688 | }
|
3689 |
|
3690 | function getDuplicateReferences(object, state) {
|
3691 | var objects = [],
|
3692 | duplicatesIndexes = [],
|
3693 | index,
|
3694 | length;
|
3695 |
|
3696 | inspectNode(object, objects, duplicatesIndexes);
|
3697 |
|
3698 | for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
3699 | state.duplicates.push(objects[duplicatesIndexes[index]]);
|
3700 | }
|
3701 | state.usedDuplicates = new Array(length);
|
3702 | }
|
3703 |
|
3704 | function inspectNode(object, objects, duplicatesIndexes) {
|
3705 | var objectKeyList,
|
3706 | index,
|
3707 | length;
|
3708 |
|
3709 | if (object !== null && typeof object === 'object') {
|
3710 | index = objects.indexOf(object);
|
3711 | if (index !== -1) {
|
3712 | if (duplicatesIndexes.indexOf(index) === -1) {
|
3713 | duplicatesIndexes.push(index);
|
3714 | }
|
3715 | } else {
|
3716 | objects.push(object);
|
3717 |
|
3718 | if (Array.isArray(object)) {
|
3719 | for (index = 0, length = object.length; index < length; index += 1) {
|
3720 | inspectNode(object[index], objects, duplicatesIndexes);
|
3721 | }
|
3722 | } else {
|
3723 | objectKeyList = Object.keys(object);
|
3724 |
|
3725 | for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
3726 | inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
3727 | }
|
3728 | }
|
3729 | }
|
3730 | }
|
3731 | }
|
3732 |
|
3733 | function dump$1(input, options) {
|
3734 | options = options || {};
|
3735 |
|
3736 | var state = new State$1(options);
|
3737 |
|
3738 | if (!state.noRefs) { getDuplicateReferences(input, state); }
|
3739 |
|
3740 | if (writeNode(state, 0, input, true, true)) { return state.dump + '\n'; }
|
3741 |
|
3742 | return '';
|
3743 | }
|
3744 |
|
3745 | function safeDump$1(input, options) {
|
3746 | return dump$1(input, common$7.extend({ schema: DEFAULT_SAFE_SCHEMA$2 }, options));
|
3747 | }
|
3748 |
|
3749 | var dump_1 = dump$1;
|
3750 | var safeDump_1 = safeDump$1;
|
3751 |
|
3752 | var dumper$1 = {
|
3753 | dump: dump_1,
|
3754 | safeDump: safeDump_1
|
3755 | };
|
3756 |
|
3757 | var loader = loader$1;
|
3758 | var dumper = dumper$1;
|
3759 |
|
3760 |
|
3761 | function deprecated(name) {
|
3762 | return function () {
|
3763 | throw new Error('Function ' + name + ' is deprecated and cannot be used.');
|
3764 | };
|
3765 | }
|
3766 |
|
3767 |
|
3768 | var Type = type;
|
3769 | var Schema = schema;
|
3770 | var FAILSAFE_SCHEMA = failsafe;
|
3771 | var JSON_SCHEMA = json;
|
3772 | var CORE_SCHEMA = core;
|
3773 | var DEFAULT_SAFE_SCHEMA = default_safe;
|
3774 | var DEFAULT_FULL_SCHEMA = default_full;
|
3775 | var load = loader.load;
|
3776 | var loadAll = loader.loadAll;
|
3777 | var safeLoad = loader.safeLoad;
|
3778 | var safeLoadAll = loader.safeLoadAll;
|
3779 | var dump = dumper.dump;
|
3780 | var safeDump = dumper.safeDump;
|
3781 | var YAMLException = exception;
|
3782 |
|
3783 |
|
3784 | var MINIMAL_SCHEMA = failsafe;
|
3785 | var SAFE_SCHEMA = default_safe;
|
3786 | var DEFAULT_SCHEMA = default_full;
|
3787 |
|
3788 |
|
3789 | var scan$1 = deprecated('scan');
|
3790 | var parse$1 = deprecated('parse');
|
3791 | var compose = deprecated('compose');
|
3792 | var addConstructor = deprecated('addConstructor');
|
3793 |
|
3794 | var jsYaml = {
|
3795 | Type: Type,
|
3796 | Schema: Schema,
|
3797 | FAILSAFE_SCHEMA: FAILSAFE_SCHEMA,
|
3798 | JSON_SCHEMA: JSON_SCHEMA,
|
3799 | CORE_SCHEMA: CORE_SCHEMA,
|
3800 | DEFAULT_SAFE_SCHEMA: DEFAULT_SAFE_SCHEMA,
|
3801 | DEFAULT_FULL_SCHEMA: DEFAULT_FULL_SCHEMA,
|
3802 | load: load,
|
3803 | loadAll: loadAll,
|
3804 | safeLoad: safeLoad,
|
3805 | safeLoadAll: safeLoadAll,
|
3806 | dump: dump,
|
3807 | safeDump: safeDump,
|
3808 | YAMLException: YAMLException,
|
3809 | MINIMAL_SCHEMA: MINIMAL_SCHEMA,
|
3810 | SAFE_SCHEMA: SAFE_SCHEMA,
|
3811 | DEFAULT_SCHEMA: DEFAULT_SCHEMA,
|
3812 | scan: scan$1,
|
3813 | parse: parse$1,
|
3814 | compose: compose,
|
3815 | addConstructor: addConstructor
|
3816 | };
|
3817 |
|
3818 | var yaml = jsYaml;
|
3819 |
|
3820 |
|
3821 | var index = yaml;
|
3822 |
|
3823 | var frontMatter = function(dom, data) {
|
3824 | var localData = {};
|
3825 | var el = dom.querySelector('script[type="text/front-matter"]');
|
3826 | if (el) {
|
3827 | var text = el.textContent;
|
3828 | localData = index.safeLoad(text);
|
3829 | }
|
3830 |
|
3831 | data.title = localData.title ? localData.title : "Untitled";
|
3832 | data.description = localData.description ? localData.description : "No description.";
|
3833 |
|
3834 | data.authors = localData.authors ? localData.authors : [];
|
3835 |
|
3836 | data.authors = data.authors.map(function (author, i) {
|
3837 | var a = {};
|
3838 | var name = Object.keys(author)[0];
|
3839 | if ((typeof author) === "string") {
|
3840 | name = author;
|
3841 | } else {
|
3842 | a.personalURL = author[name];
|
3843 | }
|
3844 | var names = name.split(" ");
|
3845 | a.name = name;
|
3846 | a.firstName = names.slice(0, names.length - 1).join(" ");
|
3847 | a.lastName = names[names.length -1];
|
3848 | if(localData.affiliations[i]) {
|
3849 | var affiliation = Object.keys(localData.affiliations[i])[0];
|
3850 | if ((typeof localData.affiliations[i]) === "string") {
|
3851 | affiliation = localData.affiliations[i];
|
3852 | } else {
|
3853 | a.affiliationURL = localData.affiliations[i][affiliation];
|
3854 | }
|
3855 | a.affiliation = affiliation;
|
3856 | }
|
3857 | return a;
|
3858 | });
|
3859 |
|
3860 |
|
3861 | };
|
3862 |
|
3863 | var bibtexParse = createCommonjsModule(function (module, exports) {
|
3864 |
|
3865 |
|
3866 |
|
3867 |
|
3868 |
|
3869 |
|
3870 |
|
3871 |
|
3872 |
|
3873 |
|
3874 |
|
3875 |
|
3876 |
|
3877 |
|
3878 |
|
3879 |
|
3880 |
|
3881 |
|
3882 |
|
3883 |
|
3884 |
|
3885 |
|
3886 |
|
3887 | (function(exports) {
|
3888 |
|
3889 | function BibtexParser() {
|
3890 |
|
3891 | this.months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
3892 | this.notKey = [',','{','}',' ','='];
|
3893 | this.pos = 0;
|
3894 | this.input = "";
|
3895 | this.entries = new Array();
|
3896 |
|
3897 | this.currentEntry = "";
|
3898 |
|
3899 | this.setInput = function(t) {
|
3900 | this.input = t;
|
3901 | };
|
3902 |
|
3903 | this.getEntries = function() {
|
3904 | return this.entries;
|
3905 | };
|
3906 |
|
3907 | this.isWhitespace = function(s) {
|
3908 | return (s == ' ' || s == '\r' || s == '\t' || s == '\n');
|
3909 | };
|
3910 |
|
3911 | this.match = function(s, canCommentOut) {
|
3912 | if (canCommentOut == undefined || canCommentOut == null)
|
3913 | { canCommentOut = true; }
|
3914 | this.skipWhitespace(canCommentOut);
|
3915 | if (this.input.substring(this.pos, this.pos + s.length) == s) {
|
3916 | this.pos += s.length;
|
3917 | } else {
|
3918 | throw "Token mismatch, expected " + s + ", found "
|
3919 | + this.input.substring(this.pos);
|
3920 | }
|
3921 | this.skipWhitespace(canCommentOut);
|
3922 | };
|
3923 |
|
3924 | this.tryMatch = function(s, canCommentOut) {
|
3925 | if (canCommentOut == undefined || canCommentOut == null)
|
3926 | { canCommentOut = true; }
|
3927 | this.skipWhitespace(canCommentOut);
|
3928 | if (this.input.substring(this.pos, this.pos + s.length) == s) {
|
3929 | return true;
|
3930 | } else {
|
3931 | return false;
|
3932 | }
|
3933 | this.skipWhitespace(canCommentOut);
|
3934 | };
|
3935 |
|
3936 |
|
3937 | this.matchAt = function() {
|
3938 | var this$1 = this;
|
3939 |
|
3940 | while (this.input.length > this.pos && this.input[this.pos] != '@') {
|
3941 | this$1.pos++;
|
3942 | }
|
3943 |
|
3944 | if (this.input[this.pos] == '@') {
|
3945 | return true;
|
3946 | }
|
3947 | return false;
|
3948 | };
|
3949 |
|
3950 | this.skipWhitespace = function(canCommentOut) {
|
3951 | var this$1 = this;
|
3952 |
|
3953 | while (this.isWhitespace(this.input[this.pos])) {
|
3954 | this$1.pos++;
|
3955 | }
|
3956 | if (this.input[this.pos] == "%" && canCommentOut == true) {
|
3957 | while (this.input[this.pos] != "\n") {
|
3958 | this$1.pos++;
|
3959 | }
|
3960 | this.skipWhitespace(canCommentOut);
|
3961 | }
|
3962 | };
|
3963 |
|
3964 | this.value_braces = function() {
|
3965 | var this$1 = this;
|
3966 |
|
3967 | var bracecount = 0;
|
3968 | this.match("{", false);
|
3969 | var start = this.pos;
|
3970 | var escaped = false;
|
3971 | while (true) {
|
3972 | if (!escaped) {
|
3973 | if (this$1.input[this$1.pos] == '}') {
|
3974 | if (bracecount > 0) {
|
3975 | bracecount--;
|
3976 | } else {
|
3977 | var end = this$1.pos;
|
3978 | this$1.match("}", false);
|
3979 | return this$1.input.substring(start, end);
|
3980 | }
|
3981 | } else if (this$1.input[this$1.pos] == '{') {
|
3982 | bracecount++;
|
3983 | } else if (this$1.pos >= this$1.input.length - 1) {
|
3984 | throw "Unterminated value";
|
3985 | }
|
3986 | }
|
3987 | if (this$1.input[this$1.pos] == '\\' && escaped == false)
|
3988 | { escaped = true; }
|
3989 | else
|
3990 | { escaped = false; }
|
3991 | this$1.pos++;
|
3992 | }
|
3993 | };
|
3994 |
|
3995 | this.value_comment = function() {
|
3996 | var this$1 = this;
|
3997 |
|
3998 | var str = '';
|
3999 | var brcktCnt = 0;
|
4000 | while (!(this.tryMatch("}", false) && brcktCnt == 0)) {
|
4001 | str = str + this$1.input[this$1.pos];
|
4002 | if (this$1.input[this$1.pos] == '{')
|
4003 | { brcktCnt++; }
|
4004 | if (this$1.input[this$1.pos] == '}')
|
4005 | { brcktCnt--; }
|
4006 | if (this$1.pos >= this$1.input.length - 1) {
|
4007 | throw "Unterminated value:" + this$1.input.substring(start);
|
4008 | }
|
4009 | this$1.pos++;
|
4010 | }
|
4011 | return str;
|
4012 | };
|
4013 |
|
4014 | this.value_quotes = function() {
|
4015 | var this$1 = this;
|
4016 |
|
4017 | this.match('"', false);
|
4018 | var start = this.pos;
|
4019 | var escaped = false;
|
4020 | while (true) {
|
4021 | if (!escaped) {
|
4022 | if (this$1.input[this$1.pos] == '"') {
|
4023 | var end = this$1.pos;
|
4024 | this$1.match('"', false);
|
4025 | return this$1.input.substring(start, end);
|
4026 | } else if (this$1.pos >= this$1.input.length - 1) {
|
4027 | throw "Unterminated value:" + this$1.input.substring(start);
|
4028 | }
|
4029 | }
|
4030 | if (this$1.input[this$1.pos] == '\\' && escaped == false)
|
4031 | { escaped = true; }
|
4032 | else
|
4033 | { escaped = false; }
|
4034 | this$1.pos++;
|
4035 | }
|
4036 | };
|
4037 |
|
4038 | this.single_value = function() {
|
4039 | var start = this.pos;
|
4040 | if (this.tryMatch("{")) {
|
4041 | return this.value_braces();
|
4042 | } else if (this.tryMatch('"')) {
|
4043 | return this.value_quotes();
|
4044 | } else {
|
4045 | var k = this.key();
|
4046 | if (k.match("^[0-9]+$"))
|
4047 | { return k; }
|
4048 | else if (this.months.indexOf(k.toLowerCase()) >= 0)
|
4049 | { return k.toLowerCase(); }
|
4050 | else
|
4051 | { throw "Value expected:" + this.input.substring(start) + ' for key: ' + k; }
|
4052 |
|
4053 | }
|
4054 | };
|
4055 |
|
4056 | this.value = function() {
|
4057 | var this$1 = this;
|
4058 |
|
4059 | var values = [];
|
4060 | values.push(this.single_value());
|
4061 | while (this.tryMatch("#")) {
|
4062 | this$1.match("#");
|
4063 | values.push(this$1.single_value());
|
4064 | }
|
4065 | return values.join("");
|
4066 | };
|
4067 |
|
4068 | this.key = function() {
|
4069 | var this$1 = this;
|
4070 |
|
4071 | var start = this.pos;
|
4072 | while (true) {
|
4073 | if (this$1.pos >= this$1.input.length) {
|
4074 | throw "Runaway key";
|
4075 | }
|
4076 |
|
4077 |
|
4078 | if (this$1.notKey.indexOf(this$1.input[this$1.pos]) >= 0) {
|
4079 | return this$1.input.substring(start, this$1.pos);
|
4080 | } else {
|
4081 | this$1.pos++;
|
4082 |
|
4083 | }
|
4084 | }
|
4085 | };
|
4086 |
|
4087 | this.key_equals_value = function() {
|
4088 | var key = this.key();
|
4089 | if (this.tryMatch("=")) {
|
4090 | this.match("=");
|
4091 | var val = this.value();
|
4092 | return [ key, val ];
|
4093 | } else {
|
4094 | throw "... = value expected, equals sign missing:"
|
4095 | + this.input.substring(this.pos);
|
4096 | }
|
4097 | };
|
4098 |
|
4099 | this.key_value_list = function() {
|
4100 | var this$1 = this;
|
4101 |
|
4102 | var kv = this.key_equals_value();
|
4103 | this.currentEntry['entryTags'] = {};
|
4104 | this.currentEntry['entryTags'][kv[0]] = kv[1];
|
4105 | while (this.tryMatch(",")) {
|
4106 | this$1.match(",");
|
4107 |
|
4108 | if (this$1.tryMatch("}")) {
|
4109 | break;
|
4110 | }
|
4111 |
|
4112 | kv = this$1.key_equals_value();
|
4113 | this$1.currentEntry['entryTags'][kv[0]] = kv[1];
|
4114 | }
|
4115 | };
|
4116 |
|
4117 | this.entry_body = function(d) {
|
4118 | this.currentEntry = {};
|
4119 | this.currentEntry['citationKey'] = this.key();
|
4120 | this.currentEntry['entryType'] = d.substring(1);
|
4121 | this.match(",");
|
4122 | this.key_value_list();
|
4123 | this.entries.push(this.currentEntry);
|
4124 | };
|
4125 |
|
4126 | this.directive = function() {
|
4127 | this.match("@");
|
4128 | return "@" + this.key();
|
4129 | };
|
4130 |
|
4131 | this.preamble = function() {
|
4132 | this.currentEntry = {};
|
4133 | this.currentEntry['entryType'] = 'PREAMBLE';
|
4134 | this.currentEntry['entry'] = this.value_comment();
|
4135 | this.entries.push(this.currentEntry);
|
4136 | };
|
4137 |
|
4138 | this.comment = function() {
|
4139 | this.currentEntry = {};
|
4140 | this.currentEntry['entryType'] = 'COMMENT';
|
4141 | this.currentEntry['entry'] = this.value_comment();
|
4142 | this.entries.push(this.currentEntry);
|
4143 | };
|
4144 |
|
4145 | this.entry = function(d) {
|
4146 | this.entry_body(d);
|
4147 | };
|
4148 |
|
4149 | this.bibtex = function() {
|
4150 | var this$1 = this;
|
4151 |
|
4152 | while (this.matchAt()) {
|
4153 | var d = this$1.directive();
|
4154 | this$1.match("{");
|
4155 | if (d == "@STRING") {
|
4156 | this$1.string();
|
4157 | } else if (d == "@PREAMBLE") {
|
4158 | this$1.preamble();
|
4159 | } else if (d == "@COMMENT") {
|
4160 | this$1.comment();
|
4161 | } else {
|
4162 | this$1.entry(d);
|
4163 | }
|
4164 | this$1.match("}");
|
4165 | }
|
4166 | };
|
4167 | }
|
4168 |
|
4169 | exports.toJSON = function(bibtex) {
|
4170 | var b = new BibtexParser();
|
4171 | b.setInput(bibtex);
|
4172 | b.bibtex();
|
4173 | return b.entries;
|
4174 | };
|
4175 |
|
4176 |
|
4177 | exports.toBibtex = function(json) {
|
4178 | var out = '';
|
4179 | for ( var i in json) {
|
4180 | out += "@" + json[i].entryType;
|
4181 | out += '{';
|
4182 | if (json[i].citationKey)
|
4183 | { out += json[i].citationKey + ', '; }
|
4184 | if (json[i].entry)
|
4185 | { out += json[i].entry ; }
|
4186 | if (json[i].entryTags) {
|
4187 | var tags = '';
|
4188 | for (var jdx in json[i].entryTags) {
|
4189 | if (tags.length != 0)
|
4190 | { tags += ', '; }
|
4191 | tags += jdx + '= {' + json[i].entryTags[jdx] + '}';
|
4192 | }
|
4193 | out += tags;
|
4194 | }
|
4195 | out += '}\n\n';
|
4196 | }
|
4197 | return out;
|
4198 |
|
4199 | };
|
4200 |
|
4201 | })(exports);
|
4202 |
|
4203 |
|
4204 | });
|
4205 |
|
4206 | var bibliography = function(dom, data) {
|
4207 | var el = dom.querySelector('script[type="text/bibliography"]');
|
4208 | var citations = [];
|
4209 | var bibliography = {};
|
4210 |
|
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] = val;
|
4224 | }
|
4225 | bibliography[e.citationKey] = e.entryTags;
|
4226 | bibliography[e.citationKey].type = e.entryType;
|
4227 | });
|
4228 | }
|
4229 |
|
4230 |
|
4231 | var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
|
4232 | citeTags.forEach(function (el) {
|
4233 | var key = el.getAttribute("key");
|
4234 | if (key) {
|
4235 | var citationKeys = key.split(",");
|
4236 | citationKeys.forEach(function (key) {
|
4237 | if (citations.indexOf(key) == -1){
|
4238 | citations.push(key);
|
4239 | if (!(key in bibliography)){
|
4240 | console.warn("No bibliography entry found for: " + key);
|
4241 | }
|
4242 | }
|
4243 | });
|
4244 | }
|
4245 | });
|
4246 | }
|
4247 | data.bibliography = bibliography;
|
4248 | data.citations = citations;
|
4249 | };
|
4250 |
|
4251 | var t0 = new Date;
|
4252 | var t1 = new Date;
|
4253 |
|
4254 | function newInterval(floori, offseti, count, field) {
|
4255 |
|
4256 | function interval(date) {
|
4257 | return floori(date = new Date(+date)), date;
|
4258 | }
|
4259 |
|
4260 | interval.floor = interval;
|
4261 |
|
4262 | interval.ceil = function(date) {
|
4263 | return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date;
|
4264 | };
|
4265 |
|
4266 | interval.round = function(date) {
|
4267 | var d0 = interval(date),
|
4268 | d1 = interval.ceil(date);
|
4269 | return date - d0 < d1 - date ? d0 : d1;
|
4270 | };
|
4271 |
|
4272 | interval.offset = function(date, step) {
|
4273 | return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date;
|
4274 | };
|
4275 |
|
4276 | interval.range = function(start, stop, step) {
|
4277 | var range = [];
|
4278 | start = interval.ceil(start);
|
4279 | step = step == null ? 1 : Math.floor(step);
|
4280 | if (!(start < stop) || !(step > 0)) { return range; }
|
4281 | do { range.push(new Date(+start)); } while (offseti(start, step), floori(start), start < stop)
|
4282 | return range;
|
4283 | };
|
4284 |
|
4285 | interval.filter = function(test) {
|
4286 | return newInterval(function(date) {
|
4287 | if (date >= date) { while (floori(date), !test(date)) { date.setTime(date - 1); } }
|
4288 | }, function(date, step) {
|
4289 | if (date >= date) { while (--step >= 0) { while (offseti(date, 1), !test(date)) {} } }
|
4290 | });
|
4291 | };
|
4292 |
|
4293 | if (count) {
|
4294 | interval.count = function(start, end) {
|
4295 | t0.setTime(+start), t1.setTime(+end);
|
4296 | floori(t0), floori(t1);
|
4297 | return Math.floor(count(t0, t1));
|
4298 | };
|
4299 |
|
4300 | interval.every = function(step) {
|
4301 | step = Math.floor(step);
|
4302 | return !isFinite(step) || !(step > 0) ? null
|
4303 | : !(step > 1) ? interval
|
4304 | : interval.filter(field
|
4305 | ? function(d) { return field(d) % step === 0; }
|
4306 | : function(d) { return interval.count(0, d) % step === 0; });
|
4307 | };
|
4308 | }
|
4309 |
|
4310 | return interval;
|
4311 | }
|
4312 |
|
4313 | var millisecond = newInterval(function() {
|
4314 |
|
4315 | }, function(date, step) {
|
4316 | date.setTime(+date + step);
|
4317 | }, function(start, end) {
|
4318 | return end - start;
|
4319 | });
|
4320 |
|
4321 |
|
4322 | millisecond.every = function(k) {
|
4323 | k = Math.floor(k);
|
4324 | if (!isFinite(k) || !(k > 0)) { return null; }
|
4325 | if (!(k > 1)) { return millisecond; }
|
4326 | return newInterval(function(date) {
|
4327 | date.setTime(Math.floor(date / k) * k);
|
4328 | }, function(date, step) {
|
4329 | date.setTime(+date + step * k);
|
4330 | }, function(start, end) {
|
4331 | return (end - start) / k;
|
4332 | });
|
4333 | };
|
4334 |
|
4335 | var durationSecond = 1e3;
|
4336 | var durationMinute = 6e4;
|
4337 | var durationHour = 36e5;
|
4338 | var durationDay = 864e5;
|
4339 | var durationWeek = 6048e5;
|
4340 |
|
4341 | var second = newInterval(function(date) {
|
4342 | date.setTime(Math.floor(date / durationSecond) * durationSecond);
|
4343 | }, function(date, step) {
|
4344 | date.setTime(+date + step * durationSecond);
|
4345 | }, function(start, end) {
|
4346 | return (end - start) / durationSecond;
|
4347 | }, function(date) {
|
4348 | return date.getUTCSeconds();
|
4349 | });
|
4350 |
|
4351 | var minute = newInterval(function(date) {
|
4352 | date.setTime(Math.floor(date / durationMinute) * durationMinute);
|
4353 | }, function(date, step) {
|
4354 | date.setTime(+date + step * durationMinute);
|
4355 | }, function(start, end) {
|
4356 | return (end - start) / durationMinute;
|
4357 | }, function(date) {
|
4358 | return date.getMinutes();
|
4359 | });
|
4360 |
|
4361 | var hour = newInterval(function(date) {
|
4362 | var offset = date.getTimezoneOffset() * durationMinute % durationHour;
|
4363 | if (offset < 0) { offset += durationHour; }
|
4364 | date.setTime(Math.floor((+date - offset) / durationHour) * durationHour + offset);
|
4365 | }, function(date, step) {
|
4366 | date.setTime(+date + step * durationHour);
|
4367 | }, function(start, end) {
|
4368 | return (end - start) / durationHour;
|
4369 | }, function(date) {
|
4370 | return date.getHours();
|
4371 | });
|
4372 |
|
4373 | var day = newInterval(function(date) {
|
4374 | date.setHours(0, 0, 0, 0);
|
4375 | }, function(date, step) {
|
4376 | date.setDate(date.getDate() + step);
|
4377 | }, function(start, end) {
|
4378 | return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay;
|
4379 | }, function(date) {
|
4380 | return date.getDate() - 1;
|
4381 | });
|
4382 |
|
4383 | function weekday(i) {
|
4384 | return newInterval(function(date) {
|
4385 | date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7);
|
4386 | date.setHours(0, 0, 0, 0);
|
4387 | }, function(date, step) {
|
4388 | date.setDate(date.getDate() + step * 7);
|
4389 | }, function(start, end) {
|
4390 | return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek;
|
4391 | });
|
4392 | }
|
4393 |
|
4394 | var sunday = weekday(0);
|
4395 | var monday = weekday(1);
|
4396 | var tuesday = weekday(2);
|
4397 | var wednesday = weekday(3);
|
4398 | var thursday = weekday(4);
|
4399 | var friday = weekday(5);
|
4400 | var saturday = weekday(6);
|
4401 |
|
4402 | var month = newInterval(function(date) {
|
4403 | date.setDate(1);
|
4404 | date.setHours(0, 0, 0, 0);
|
4405 | }, function(date, step) {
|
4406 | date.setMonth(date.getMonth() + step);
|
4407 | }, function(start, end) {
|
4408 | return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12;
|
4409 | }, function(date) {
|
4410 | return date.getMonth();
|
4411 | });
|
4412 |
|
4413 | var year = newInterval(function(date) {
|
4414 | date.setMonth(0, 1);
|
4415 | date.setHours(0, 0, 0, 0);
|
4416 | }, function(date, step) {
|
4417 | date.setFullYear(date.getFullYear() + step);
|
4418 | }, function(start, end) {
|
4419 | return end.getFullYear() - start.getFullYear();
|
4420 | }, function(date) {
|
4421 | return date.getFullYear();
|
4422 | });
|
4423 |
|
4424 |
|
4425 | year.every = function(k) {
|
4426 | return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) {
|
4427 | date.setFullYear(Math.floor(date.getFullYear() / k) * k);
|
4428 | date.setMonth(0, 1);
|
4429 | date.setHours(0, 0, 0, 0);
|
4430 | }, function(date, step) {
|
4431 | date.setFullYear(date.getFullYear() + step * k);
|
4432 | });
|
4433 | };
|
4434 |
|
4435 | var utcMinute = newInterval(function(date) {
|
4436 | date.setUTCSeconds(0, 0);
|
4437 | }, function(date, step) {
|
4438 | date.setTime(+date + step * durationMinute);
|
4439 | }, function(start, end) {
|
4440 | return (end - start) / durationMinute;
|
4441 | }, function(date) {
|
4442 | return date.getUTCMinutes();
|
4443 | });
|
4444 |
|
4445 | var utcHour = newInterval(function(date) {
|
4446 | date.setUTCMinutes(0, 0, 0);
|
4447 | }, function(date, step) {
|
4448 | date.setTime(+date + step * durationHour);
|
4449 | }, function(start, end) {
|
4450 | return (end - start) / durationHour;
|
4451 | }, function(date) {
|
4452 | return date.getUTCHours();
|
4453 | });
|
4454 |
|
4455 | var utcDay = newInterval(function(date) {
|
4456 | date.setUTCHours(0, 0, 0, 0);
|
4457 | }, function(date, step) {
|
4458 | date.setUTCDate(date.getUTCDate() + step);
|
4459 | }, function(start, end) {
|
4460 | return (end - start) / durationDay;
|
4461 | }, function(date) {
|
4462 | return date.getUTCDate() - 1;
|
4463 | });
|
4464 |
|
4465 | function utcWeekday(i) {
|
4466 | return newInterval(function(date) {
|
4467 | date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7);
|
4468 | date.setUTCHours(0, 0, 0, 0);
|
4469 | }, function(date, step) {
|
4470 | date.setUTCDate(date.getUTCDate() + step * 7);
|
4471 | }, function(start, end) {
|
4472 | return (end - start) / durationWeek;
|
4473 | });
|
4474 | }
|
4475 |
|
4476 | var utcSunday = utcWeekday(0);
|
4477 | var utcMonday = utcWeekday(1);
|
4478 | var utcTuesday = utcWeekday(2);
|
4479 | var utcWednesday = utcWeekday(3);
|
4480 | var utcThursday = utcWeekday(4);
|
4481 | var utcFriday = utcWeekday(5);
|
4482 | var utcSaturday = utcWeekday(6);
|
4483 |
|
4484 | var utcMonth = newInterval(function(date) {
|
4485 | date.setUTCDate(1);
|
4486 | date.setUTCHours(0, 0, 0, 0);
|
4487 | }, function(date, step) {
|
4488 | date.setUTCMonth(date.getUTCMonth() + step);
|
4489 | }, function(start, end) {
|
4490 | return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12;
|
4491 | }, function(date) {
|
4492 | return date.getUTCMonth();
|
4493 | });
|
4494 |
|
4495 | var utcYear = newInterval(function(date) {
|
4496 | date.setUTCMonth(0, 1);
|
4497 | date.setUTCHours(0, 0, 0, 0);
|
4498 | }, function(date, step) {
|
4499 | date.setUTCFullYear(date.getUTCFullYear() + step);
|
4500 | }, function(start, end) {
|
4501 | return end.getUTCFullYear() - start.getUTCFullYear();
|
4502 | }, function(date) {
|
4503 | return date.getUTCFullYear();
|
4504 | });
|
4505 |
|
4506 |
|
4507 | utcYear.every = function(k) {
|
4508 | return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) {
|
4509 | date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k);
|
4510 | date.setUTCMonth(0, 1);
|
4511 | date.setUTCHours(0, 0, 0, 0);
|
4512 | }, function(date, step) {
|
4513 | date.setUTCFullYear(date.getUTCFullYear() + step * k);
|
4514 | });
|
4515 | };
|
4516 |
|
4517 | function localDate(d) {
|
4518 | if (0 <= d.y && d.y < 100) {
|
4519 | var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L);
|
4520 | date.setFullYear(d.y);
|
4521 | return date;
|
4522 | }
|
4523 | return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L);
|
4524 | }
|
4525 |
|
4526 | function utcDate(d) {
|
4527 | if (0 <= d.y && d.y < 100) {
|
4528 | var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L));
|
4529 | date.setUTCFullYear(d.y);
|
4530 | return date;
|
4531 | }
|
4532 | return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L));
|
4533 | }
|
4534 |
|
4535 | function newYear(y) {
|
4536 | return {y: y, m: 0, d: 1, H: 0, M: 0, S: 0, L: 0};
|
4537 | }
|
4538 |
|
4539 | function formatLocale(locale) {
|
4540 | var locale_dateTime = locale.dateTime,
|
4541 | locale_date = locale.date,
|
4542 | locale_time = locale.time,
|
4543 | locale_periods = locale.periods,
|
4544 | locale_weekdays = locale.days,
|
4545 | locale_shortWeekdays = locale.shortDays,
|
4546 | locale_months = locale.months,
|
4547 | locale_shortMonths = locale.shortMonths;
|
4548 |
|
4549 | var periodRe = formatRe(locale_periods),
|
4550 | periodLookup = formatLookup(locale_periods),
|
4551 | weekdayRe = formatRe(locale_weekdays),
|
4552 | weekdayLookup = formatLookup(locale_weekdays),
|
4553 | shortWeekdayRe = formatRe(locale_shortWeekdays),
|
4554 | shortWeekdayLookup = formatLookup(locale_shortWeekdays),
|
4555 | monthRe = formatRe(locale_months),
|
4556 | monthLookup = formatLookup(locale_months),
|
4557 | shortMonthRe = formatRe(locale_shortMonths),
|
4558 | shortMonthLookup = formatLookup(locale_shortMonths);
|
4559 |
|
4560 | var formats = {
|
4561 | "a": formatShortWeekday,
|
4562 | "A": formatWeekday,
|
4563 | "b": formatShortMonth,
|
4564 | "B": formatMonth,
|
4565 | "c": null,
|
4566 | "d": formatDayOfMonth,
|
4567 | "e": formatDayOfMonth,
|
4568 | "H": formatHour24,
|
4569 | "I": formatHour12,
|
4570 | "j": formatDayOfYear,
|
4571 | "L": formatMilliseconds,
|
4572 | "m": formatMonthNumber,
|
4573 | "M": formatMinutes,
|
4574 | "p": formatPeriod,
|
4575 | "S": formatSeconds,
|
4576 | "U": formatWeekNumberSunday,
|
4577 | "w": formatWeekdayNumber,
|
4578 | "W": formatWeekNumberMonday,
|
4579 | "x": null,
|
4580 | "X": null,
|
4581 | "y": formatYear,
|
4582 | "Y": formatFullYear,
|
4583 | "Z": formatZone,
|
4584 | "%": formatLiteralPercent
|
4585 | };
|
4586 |
|
4587 | var utcFormats = {
|
4588 | "a": formatUTCShortWeekday,
|
4589 | "A": formatUTCWeekday,
|
4590 | "b": formatUTCShortMonth,
|
4591 | "B": formatUTCMonth,
|
4592 | "c": null,
|
4593 | "d": formatUTCDayOfMonth,
|
4594 | "e": formatUTCDayOfMonth,
|
4595 | "H": formatUTCHour24,
|
4596 | "I": formatUTCHour12,
|
4597 | "j": formatUTCDayOfYear,
|
4598 | "L": formatUTCMilliseconds,
|
4599 | "m": formatUTCMonthNumber,
|
4600 | "M": formatUTCMinutes,
|
4601 | "p": formatUTCPeriod,
|
4602 | "S": formatUTCSeconds,
|
4603 | "U": formatUTCWeekNumberSunday,
|
4604 | "w": formatUTCWeekdayNumber,
|
4605 | "W": formatUTCWeekNumberMonday,
|
4606 | "x": null,
|
4607 | "X": null,
|
4608 | "y": formatUTCYear,
|
4609 | "Y": formatUTCFullYear,
|
4610 | "Z": formatUTCZone,
|
4611 | "%": formatLiteralPercent
|
4612 | };
|
4613 |
|
4614 | var parses = {
|
4615 | "a": parseShortWeekday,
|
4616 | "A": parseWeekday,
|
4617 | "b": parseShortMonth,
|
4618 | "B": parseMonth,
|
4619 | "c": parseLocaleDateTime,
|
4620 | "d": parseDayOfMonth,
|
4621 | "e": parseDayOfMonth,
|
4622 | "H": parseHour24,
|
4623 | "I": parseHour24,
|
4624 | "j": parseDayOfYear,
|
4625 | "L": parseMilliseconds,
|
4626 | "m": parseMonthNumber,
|
4627 | "M": parseMinutes,
|
4628 | "p": parsePeriod,
|
4629 | "S": parseSeconds,
|
4630 | "U": parseWeekNumberSunday,
|
4631 | "w": parseWeekdayNumber,
|
4632 | "W": parseWeekNumberMonday,
|
4633 | "x": parseLocaleDate,
|
4634 | "X": parseLocaleTime,
|
4635 | "y": parseYear,
|
4636 | "Y": parseFullYear,
|
4637 | "Z": parseZone,
|
4638 | "%": parseLiteralPercent
|
4639 | };
|
4640 |
|
4641 |
|
4642 | formats.x = newFormat(locale_date, formats);
|
4643 | formats.X = newFormat(locale_time, formats);
|
4644 | formats.c = newFormat(locale_dateTime, formats);
|
4645 | utcFormats.x = newFormat(locale_date, utcFormats);
|
4646 | utcFormats.X = newFormat(locale_time, utcFormats);
|
4647 | utcFormats.c = newFormat(locale_dateTime, utcFormats);
|
4648 |
|
4649 | function newFormat(specifier, formats) {
|
4650 | return function(date) {
|
4651 | var string = [],
|
4652 | i = -1,
|
4653 | j = 0,
|
4654 | n = specifier.length,
|
4655 | c,
|
4656 | pad,
|
4657 | format;
|
4658 |
|
4659 | if (!(date instanceof Date)) { date = new Date(+date); }
|
4660 |
|
4661 | while (++i < n) {
|
4662 | if (specifier.charCodeAt(i) === 37) {
|
4663 | string.push(specifier.slice(j, i));
|
4664 | if ((pad = pads[c = specifier.charAt(++i)]) != null) { c = specifier.charAt(++i); }
|
4665 | else { pad = c === "e" ? " " : "0"; }
|
4666 | if (format = formats[c]) { c = format(date, pad); }
|
4667 | string.push(c);
|
4668 | j = i + 1;
|
4669 | }
|
4670 | }
|
4671 |
|
4672 | string.push(specifier.slice(j, i));
|
4673 | return string.join("");
|
4674 | };
|
4675 | }
|
4676 |
|
4677 | function newParse(specifier, newDate) {
|
4678 | return function(string) {
|
4679 | var d = newYear(1900),
|
4680 | i = parseSpecifier(d, specifier, string += "", 0);
|
4681 | if (i != string.length) { return null; }
|
4682 |
|
4683 |
|
4684 | if ("p" in d) { d.H = d.H % 12 + d.p * 12; }
|
4685 |
|
4686 |
|
4687 | if ("W" in d || "U" in d) {
|
4688 | if (!("w" in d)) { d.w = "W" in d ? 1 : 0; }
|
4689 | var day$$1 = "Z" in d ? utcDate(newYear(d.y)).getUTCDay() : newDate(newYear(d.y)).getDay();
|
4690 | d.m = 0;
|
4691 | 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;
|
4692 | }
|
4693 |
|
4694 |
|
4695 |
|
4696 | if ("Z" in d) {
|
4697 | d.H += d.Z / 100 | 0;
|
4698 | d.M += d.Z % 100;
|
4699 | return utcDate(d);
|
4700 | }
|
4701 |
|
4702 |
|
4703 | return newDate(d);
|
4704 | };
|
4705 | }
|
4706 |
|
4707 | function parseSpecifier(d, specifier, string, j) {
|
4708 | var i = 0,
|
4709 | n = specifier.length,
|
4710 | m = string.length,
|
4711 | c,
|
4712 | parse;
|
4713 |
|
4714 | while (i < n) {
|
4715 | if (j >= m) { return -1; }
|
4716 | c = specifier.charCodeAt(i++);
|
4717 | if (c === 37) {
|
4718 | c = specifier.charAt(i++);
|
4719 | parse = parses[c in pads ? specifier.charAt(i++) : c];
|
4720 | if (!parse || ((j = parse(d, string, j)) < 0)) { return -1; }
|
4721 | } else if (c != string.charCodeAt(j++)) {
|
4722 | return -1;
|
4723 | }
|
4724 | }
|
4725 |
|
4726 | return j;
|
4727 | }
|
4728 |
|
4729 | function parsePeriod(d, string, i) {
|
4730 | var n = periodRe.exec(string.slice(i));
|
4731 | return n ? (d.p = periodLookup[n[0].toLowerCase()], i + n[0].length) : -1;
|
4732 | }
|
4733 |
|
4734 | function parseShortWeekday(d, string, i) {
|
4735 | var n = shortWeekdayRe.exec(string.slice(i));
|
4736 | return n ? (d.w = shortWeekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
|
4737 | }
|
4738 |
|
4739 | function parseWeekday(d, string, i) {
|
4740 | var n = weekdayRe.exec(string.slice(i));
|
4741 | return n ? (d.w = weekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
|
4742 | }
|
4743 |
|
4744 | function parseShortMonth(d, string, i) {
|
4745 | var n = shortMonthRe.exec(string.slice(i));
|
4746 | return n ? (d.m = shortMonthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
|
4747 | }
|
4748 |
|
4749 | function parseMonth(d, string, i) {
|
4750 | var n = monthRe.exec(string.slice(i));
|
4751 | return n ? (d.m = monthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
|
4752 | }
|
4753 |
|
4754 | function parseLocaleDateTime(d, string, i) {
|
4755 | return parseSpecifier(d, locale_dateTime, string, i);
|
4756 | }
|
4757 |
|
4758 | function parseLocaleDate(d, string, i) {
|
4759 | return parseSpecifier(d, locale_date, string, i);
|
4760 | }
|
4761 |
|
4762 | function parseLocaleTime(d, string, i) {
|
4763 | return parseSpecifier(d, locale_time, string, i);
|
4764 | }
|
4765 |
|
4766 | function formatShortWeekday(d) {
|
4767 | return locale_shortWeekdays[d.getDay()];
|
4768 | }
|
4769 |
|
4770 | function formatWeekday(d) {
|
4771 | return locale_weekdays[d.getDay()];
|
4772 | }
|
4773 |
|
4774 | function formatShortMonth(d) {
|
4775 | return locale_shortMonths[d.getMonth()];
|
4776 | }
|
4777 |
|
4778 | function formatMonth(d) {
|
4779 | return locale_months[d.getMonth()];
|
4780 | }
|
4781 |
|
4782 | function formatPeriod(d) {
|
4783 | return locale_periods[+(d.getHours() >= 12)];
|
4784 | }
|
4785 |
|
4786 | function formatUTCShortWeekday(d) {
|
4787 | return locale_shortWeekdays[d.getUTCDay()];
|
4788 | }
|
4789 |
|
4790 | function formatUTCWeekday(d) {
|
4791 | return locale_weekdays[d.getUTCDay()];
|
4792 | }
|
4793 |
|
4794 | function formatUTCShortMonth(d) {
|
4795 | return locale_shortMonths[d.getUTCMonth()];
|
4796 | }
|
4797 |
|
4798 | function formatUTCMonth(d) {
|
4799 | return locale_months[d.getUTCMonth()];
|
4800 | }
|
4801 |
|
4802 | function formatUTCPeriod(d) {
|
4803 | return locale_periods[+(d.getUTCHours() >= 12)];
|
4804 | }
|
4805 |
|
4806 | return {
|
4807 | format: function(specifier) {
|
4808 | var f = newFormat(specifier += "", formats);
|
4809 | f.toString = function() { return specifier; };
|
4810 | return f;
|
4811 | },
|
4812 | parse: function(specifier) {
|
4813 | var p = newParse(specifier += "", localDate);
|
4814 | p.toString = function() { return specifier; };
|
4815 | return p;
|
4816 | },
|
4817 | utcFormat: function(specifier) {
|
4818 | var f = newFormat(specifier += "", utcFormats);
|
4819 | f.toString = function() { return specifier; };
|
4820 | return f;
|
4821 | },
|
4822 | utcParse: function(specifier) {
|
4823 | var p = newParse(specifier, utcDate);
|
4824 | p.toString = function() { return specifier; };
|
4825 | return p;
|
4826 | }
|
4827 | };
|
4828 | }
|
4829 |
|
4830 | var pads = {"-": "", "_": " ", "0": "0"};
|
4831 | var numberRe = /^\s*\d+/;
|
4832 | var percentRe = /^%/;
|
4833 | var requoteRe = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
|
4834 |
|
4835 | function pad(value, fill, width) {
|
4836 | var sign = value < 0 ? "-" : "",
|
4837 | string = (sign ? -value : value) + "",
|
4838 | length = string.length;
|
4839 | return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);
|
4840 | }
|
4841 |
|
4842 | function requote(s) {
|
4843 | return s.replace(requoteRe, "\\$&");
|
4844 | }
|
4845 |
|
4846 | function formatRe(names) {
|
4847 | return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i");
|
4848 | }
|
4849 |
|
4850 | function formatLookup(names) {
|
4851 | var map = {}, i = -1, n = names.length;
|
4852 | while (++i < n) { map[names[i].toLowerCase()] = i; }
|
4853 | return map;
|
4854 | }
|
4855 |
|
4856 | function parseWeekdayNumber(d, string, i) {
|
4857 | var n = numberRe.exec(string.slice(i, i + 1));
|
4858 | return n ? (d.w = +n[0], i + n[0].length) : -1;
|
4859 | }
|
4860 |
|
4861 | function parseWeekNumberSunday(d, string, i) {
|
4862 | var n = numberRe.exec(string.slice(i));
|
4863 | return n ? (d.U = +n[0], i + n[0].length) : -1;
|
4864 | }
|
4865 |
|
4866 | function parseWeekNumberMonday(d, string, i) {
|
4867 | var n = numberRe.exec(string.slice(i));
|
4868 | return n ? (d.W = +n[0], i + n[0].length) : -1;
|
4869 | }
|
4870 |
|
4871 | function parseFullYear(d, string, i) {
|
4872 | var n = numberRe.exec(string.slice(i, i + 4));
|
4873 | return n ? (d.y = +n[0], i + n[0].length) : -1;
|
4874 | }
|
4875 |
|
4876 | function parseYear(d, string, i) {
|
4877 | var n = numberRe.exec(string.slice(i, i + 2));
|
4878 | return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1;
|
4879 | }
|
4880 |
|
4881 | function parseZone(d, string, i) {
|
4882 | var n = /^(Z)|([+-]\d\d)(?:\:?(\d\d))?/.exec(string.slice(i, i + 6));
|
4883 | return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1;
|
4884 | }
|
4885 |
|
4886 | function parseMonthNumber(d, string, i) {
|
4887 | var n = numberRe.exec(string.slice(i, i + 2));
|
4888 | return n ? (d.m = n[0] - 1, i + n[0].length) : -1;
|
4889 | }
|
4890 |
|
4891 | function parseDayOfMonth(d, string, i) {
|
4892 | var n = numberRe.exec(string.slice(i, i + 2));
|
4893 | return n ? (d.d = +n[0], i + n[0].length) : -1;
|
4894 | }
|
4895 |
|
4896 | function parseDayOfYear(d, string, i) {
|
4897 | var n = numberRe.exec(string.slice(i, i + 3));
|
4898 | return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1;
|
4899 | }
|
4900 |
|
4901 | function parseHour24(d, string, i) {
|
4902 | var n = numberRe.exec(string.slice(i, i + 2));
|
4903 | return n ? (d.H = +n[0], i + n[0].length) : -1;
|
4904 | }
|
4905 |
|
4906 | function parseMinutes(d, string, i) {
|
4907 | var n = numberRe.exec(string.slice(i, i + 2));
|
4908 | return n ? (d.M = +n[0], i + n[0].length) : -1;
|
4909 | }
|
4910 |
|
4911 | function parseSeconds(d, string, i) {
|
4912 | var n = numberRe.exec(string.slice(i, i + 2));
|
4913 | return n ? (d.S = +n[0], i + n[0].length) : -1;
|
4914 | }
|
4915 |
|
4916 | function parseMilliseconds(d, string, i) {
|
4917 | var n = numberRe.exec(string.slice(i, i + 3));
|
4918 | return n ? (d.L = +n[0], i + n[0].length) : -1;
|
4919 | }
|
4920 |
|
4921 | function parseLiteralPercent(d, string, i) {
|
4922 | var n = percentRe.exec(string.slice(i, i + 1));
|
4923 | return n ? i + n[0].length : -1;
|
4924 | }
|
4925 |
|
4926 | function formatDayOfMonth(d, p) {
|
4927 | return pad(d.getDate(), p, 2);
|
4928 | }
|
4929 |
|
4930 | function formatHour24(d, p) {
|
4931 | return pad(d.getHours(), p, 2);
|
4932 | }
|
4933 |
|
4934 | function formatHour12(d, p) {
|
4935 | return pad(d.getHours() % 12 || 12, p, 2);
|
4936 | }
|
4937 |
|
4938 | function formatDayOfYear(d, p) {
|
4939 | return pad(1 + day.count(year(d), d), p, 3);
|
4940 | }
|
4941 |
|
4942 | function formatMilliseconds(d, p) {
|
4943 | return pad(d.getMilliseconds(), p, 3);
|
4944 | }
|
4945 |
|
4946 | function formatMonthNumber(d, p) {
|
4947 | return pad(d.getMonth() + 1, p, 2);
|
4948 | }
|
4949 |
|
4950 | function formatMinutes(d, p) {
|
4951 | return pad(d.getMinutes(), p, 2);
|
4952 | }
|
4953 |
|
4954 | function formatSeconds(d, p) {
|
4955 | return pad(d.getSeconds(), p, 2);
|
4956 | }
|
4957 |
|
4958 | function formatWeekNumberSunday(d, p) {
|
4959 | return pad(sunday.count(year(d), d), p, 2);
|
4960 | }
|
4961 |
|
4962 | function formatWeekdayNumber(d) {
|
4963 | return d.getDay();
|
4964 | }
|
4965 |
|
4966 | function formatWeekNumberMonday(d, p) {
|
4967 | return pad(monday.count(year(d), d), p, 2);
|
4968 | }
|
4969 |
|
4970 | function formatYear(d, p) {
|
4971 | return pad(d.getFullYear() % 100, p, 2);
|
4972 | }
|
4973 |
|
4974 | function formatFullYear(d, p) {
|
4975 | return pad(d.getFullYear() % 10000, p, 4);
|
4976 | }
|
4977 |
|
4978 | function formatZone(d) {
|
4979 | var z = d.getTimezoneOffset();
|
4980 | return (z > 0 ? "-" : (z *= -1, "+"))
|
4981 | + pad(z / 60 | 0, "0", 2)
|
4982 | + pad(z % 60, "0", 2);
|
4983 | }
|
4984 |
|
4985 | function formatUTCDayOfMonth(d, p) {
|
4986 | return pad(d.getUTCDate(), p, 2);
|
4987 | }
|
4988 |
|
4989 | function formatUTCHour24(d, p) {
|
4990 | return pad(d.getUTCHours(), p, 2);
|
4991 | }
|
4992 |
|
4993 | function formatUTCHour12(d, p) {
|
4994 | return pad(d.getUTCHours() % 12 || 12, p, 2);
|
4995 | }
|
4996 |
|
4997 | function formatUTCDayOfYear(d, p) {
|
4998 | return pad(1 + utcDay.count(utcYear(d), d), p, 3);
|
4999 | }
|
5000 |
|
5001 | function formatUTCMilliseconds(d, p) {
|
5002 | return pad(d.getUTCMilliseconds(), p, 3);
|
5003 | }
|
5004 |
|
5005 | function formatUTCMonthNumber(d, p) {
|
5006 | return pad(d.getUTCMonth() + 1, p, 2);
|
5007 | }
|
5008 |
|
5009 | function formatUTCMinutes(d, p) {
|
5010 | return pad(d.getUTCMinutes(), p, 2);
|
5011 | }
|
5012 |
|
5013 | function formatUTCSeconds(d, p) {
|
5014 | return pad(d.getUTCSeconds(), p, 2);
|
5015 | }
|
5016 |
|
5017 | function formatUTCWeekNumberSunday(d, p) {
|
5018 | return pad(utcSunday.count(utcYear(d), d), p, 2);
|
5019 | }
|
5020 |
|
5021 | function formatUTCWeekdayNumber(d) {
|
5022 | return d.getUTCDay();
|
5023 | }
|
5024 |
|
5025 | function formatUTCWeekNumberMonday(d, p) {
|
5026 | return pad(utcMonday.count(utcYear(d), d), p, 2);
|
5027 | }
|
5028 |
|
5029 | function formatUTCYear(d, p) {
|
5030 | return pad(d.getUTCFullYear() % 100, p, 2);
|
5031 | }
|
5032 |
|
5033 | function formatUTCFullYear(d, p) {
|
5034 | return pad(d.getUTCFullYear() % 10000, p, 4);
|
5035 | }
|
5036 |
|
5037 | function formatUTCZone() {
|
5038 | return "+0000";
|
5039 | }
|
5040 |
|
5041 | function formatLiteralPercent() {
|
5042 | return "%";
|
5043 | }
|
5044 |
|
5045 | var locale$1;
|
5046 | var timeFormat;
|
5047 | var timeParse;
|
5048 | var utcFormat;
|
5049 | var utcParse;
|
5050 |
|
5051 | defaultLocale({
|
5052 | dateTime: "%x, %X",
|
5053 | date: "%-m/%-d/%Y",
|
5054 | time: "%-I:%M:%S %p",
|
5055 | periods: ["AM", "PM"],
|
5056 | days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
5057 | shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
5058 | months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
5059 | shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
5060 | });
|
5061 |
|
5062 | function defaultLocale(definition) {
|
5063 | locale$1 = formatLocale(definition);
|
5064 | timeFormat = locale$1.format;
|
5065 | timeParse = locale$1.parse;
|
5066 | utcFormat = locale$1.utcFormat;
|
5067 | utcParse = locale$1.utcParse;
|
5068 | return locale$1;
|
5069 | }
|
5070 |
|
5071 | var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ";
|
5072 |
|
5073 | function formatIsoNative(date) {
|
5074 | return date.toISOString();
|
5075 | }
|
5076 |
|
5077 | var formatIso = Date.prototype.toISOString
|
5078 | ? formatIsoNative
|
5079 | : utcFormat(isoSpecifier);
|
5080 |
|
5081 | function parseIsoNative(string) {
|
5082 | var date = new Date(string);
|
5083 | return isNaN(date) ? null : date;
|
5084 | }
|
5085 |
|
5086 | var parseIso = +new Date("2000-01-01T00:00:00.000Z")
|
5087 | ? parseIsoNative
|
5088 | : utcParse(isoSpecifier);
|
5089 |
|
5090 | var expandData = function(dom, data) {
|
5091 |
|
5092 | data.authors = data.authors || [];
|
5093 |
|
5094 |
|
5095 | data.url = "http://distill.pub/" + data.distillPath;
|
5096 | data.githubUrl = "https://github.com/" + data.githubPath;
|
5097 |
|
5098 |
|
5099 |
|
5100 | data.journal = data.journal || {};
|
5101 |
|
5102 |
|
5103 | if (data.publishedDate){
|
5104 | data.volume = data.publishedDate.getFullYear() - 2015;
|
5105 | data.issue = data.publishedDate.getMonth() + 1;
|
5106 | }
|
5107 |
|
5108 | data.publishedDate = data.publishedDate ? data.publishedDate : new Date("Invalid");
|
5109 | data.updatedDate = data.updatedDate ? data.updatedDate : new Date("Invalid");
|
5110 |
|
5111 | data.publishedDateRFC;
|
5112 | var RFC = timeFormat("%a, %d %b %Y %H:%M:%S %Z");
|
5113 | var months = ["Jan", "Feb", "March", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
|
5114 | var zeroPad = function (n) { return n < 10 ? "0" + n : n; };
|
5115 | data.publishedDateRFC = RFC(data.publishedDate);
|
5116 | data.publishedYear = data.publishedDate.getFullYear();
|
5117 | data.publishedMonth = months[data.publishedDate.getMonth()];
|
5118 | data.publishedDay = data.publishedDate.getDate();
|
5119 | data.publishedMonthPadded = zeroPad(data.publishedDate.getMonth() + 1);
|
5120 | data.publishedDayPadded = zeroPad(data.publishedDate.getDate());
|
5121 | data.updatedDateRFC = RFC(data.updatedDate);
|
5122 |
|
5123 | if (data.authors.length > 2) {
|
5124 | data.concatenatedAuthors = data.authors[0].lastName + ", et al.";
|
5125 | } else if (data.authors.length === 2) {
|
5126 | data.concatenatedAuthors = data.authors[0].lastName + " & " + data.authors[1].lastName;
|
5127 | } else if (data.authors.length === 1) {
|
5128 | data.concatenatedAuthors = data.authors[0].lastName;
|
5129 | }
|
5130 |
|
5131 | data.bibtexAuthors = data.authors.map(function(author){
|
5132 | return author.lastName + ", " + author.firstName;
|
5133 | }).join(" and ");
|
5134 |
|
5135 | data.slug = data.authors.length ? data.authors[0].lastName.toLowerCase() + data.publishedYear + data.title.split(" ")[0].toLowerCase() : "Untitled";
|
5136 |
|
5137 | };
|
5138 |
|
5139 | var favicon = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA99JREFUeNrsG4t1ozDMzQSM4A2ODUonKBucN2hugtIJ6E1AboLcBiQTkJsANiAb9OCd/OpzMWBJBl5TvaeXPiiyJetry0J8wW3D3QpjRh3GjneXDq+fSQA9s2mH9x3KDhN4foJfCb8N/Jrv+2fnDn8vLRQOplWHVYdvHZYdZsBcZP1vBmh/n8DzEmhUQDPaOuP9pFuY+JwJHwHnCLQE2tnWBGEyXozY9xCUgHMhhjE2I4heVWtgIkZ83wL6Qgxj1obfWBxymPwe+b00BCCRNPbwfb60yleAkkBHGT5AEehIYz7eJrFDMF9CvH4wwhcGHiHMneFvLDQwlwvMLQq58trRcYBWfYn0A0OgHWQUSu25mE+BnoYKnnEJoeIWAifzOv7vLWd2ZKRfWAIme3tOiUaQ3UnLkb0xj1FxRIeEGKaGIHOs9nEgLaaA9i0JRYo1Ic67wJW86KSKE/ZAM8KuVMk8ITVhmxUxJ3Cl2xlm9Vtkeju1+mpCQNxaEGNCY8bs9X2YqwNoQeGjBWut/ma0QAWy/TqAsHx9wSya3I5IRxOfTC+leG+kA/4vSeEcGBtNUN6byhu3+keEZCQJUNh8MAO7HL6H8pQLnsW/Hd4T4lv93TPjfM7A46iEEqbB5EDOvwYNW6tGNZzT/o+CZ6sqZ6wUtR/wf7mi/VL8iNciT6rHih48Y55b4nKCHJCCzb4y0nwFmin3ZEMIoLfZF8F7nncFmvnWBaBj7CGAYA/WGJsUwHdYqVDwAmNsUgAx4CGgAA7GOOxADYOFWOaIKifuVYzmOpREqA21Mo7aPsgiY1PhOMAmxtR+AUbYH3Id2wc0SAFIQTsn9IUGWR8k9jx3vtXSiAacFxTAGakBk9UudkNECd6jLe+6HrshshvIuC6IlLMRy7er+JpcKma24SlE4cFZSZJDGVVrsNvitQhQrDhW0jfiOLfFd47C42eHT56D/BK0To+58Ahj+cAT8HT1UWlfLZCCd/uKawzU0Rh2EyIX/Icqth3niG8ybNroezwe6khdCNxRN+l4XGdOLVLlOOt2hTRJlr1ETIuMAltVTMz70mJrkdGAaZLSmnBEqmAE32JCMmuTlCnRgsBENtOUpHhvvsYIL0ibnBkaC6QvKcR7738GKp0AKnim7xgUSNv1bpS8QwhBt8r+EP47v/oyRK/S34yJ9nT+AN0Tkm4OdB9E4BsmXM3SnMlRFUrtp6IDpV2eKzdYvF3etm3KhQksbOLChGkSmcBdmcEwvqkrMy5BzL00NZeu3qPYJOOuCc+5NjcWKXQxFvTa3NoXJ4d8in7fiAUuTt781dkvuHX4K8AA2Usy7yNKLy0AAAAASUVORK5CYII=\n";
|
5140 |
|
5141 | var meta = function(dom, data) {
|
5142 | var head = dom.querySelector("head");
|
5143 | var appendHead = function (html) { return appendHtml(head, html); };
|
5144 |
|
5145 | function meta(name, content) {
|
5146 | if (content)
|
5147 | { appendHead((" <meta name=\"" + name + "\" content=\"" + content + "\" >\n")); }
|
5148 | }
|
5149 |
|
5150 | 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 "));
|
5151 |
|
5152 | appendHead(("\n <!-- https://schema.org/Article -->\n <meta property=\"article:published\" itemprop=\"datePublished\" content=\"" + (data.publishedYear) + "-" + (data.publishedMonthPadded) + "-" + (data.publishedDayPadded) + "\" />\n <meta property=\"article:modified\" itemprop=\"dateModified\" content=\"" + (data.updatedDate) + "\" />\n "));
|
5153 | data.authors.forEach(function (a) {
|
5154 | appendHtml(head, ("\n <meta property=\"article:author\" content=\"" + (a.firstName) + " " + (a.lastName) + "\" />"));
|
5155 | });
|
5156 |
|
5157 | 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.url) + "/thumbnail.jpg\"/>\n <meta property=\"og:locale\" content=\"en_US\" />\n <meta property=\"og:site_name\" content=\"Distill\" />\n "));
|
5158 |
|
5159 | 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.url) + "/thumbnail.jpg\">\n <meta name=\"twitter:image:width\" content=\"560\">\n <meta name=\"twitter:image:height\" content=\"295\">\n "));
|
5160 |
|
5161 |
|
5162 | if (data.doiSuffix){
|
5163 | appendHead("\n <!-- https://scholar.google.com/intl/en/scholar/inclusion.html#indexing -->\n");
|
5164 |
|
5165 | meta("citation_title", data.title);
|
5166 | meta("citation_fulltext_html_url", data.url);
|
5167 | meta("citation_volume", data.volume);
|
5168 | meta("citation_issue", data.issue);
|
5169 | meta("citation_firstpage", data.doiSuffix? ("e" + (data.doiSuffix)) : undefined);
|
5170 | meta("citation_doi", data.doi);
|
5171 |
|
5172 | var journal = data.journal || {};
|
5173 | meta("citation_journal_title", journal.name);
|
5174 | meta("citation_journal_abbrev", journal.nameAbbrev);
|
5175 | meta("citation_issn", journal.issn);
|
5176 | meta("citation_publisher", journal.publisher);
|
5177 |
|
5178 | if (data.publishedDate){
|
5179 | var zeroPad = function (n) { return n < 10 ? "0" + n : n; };
|
5180 | meta("citation_publication_date", ((data.publishedYear) + "/" + (data.publishedMonthPadded) + "/" + (data.publishedDayPadded)));
|
5181 | }
|
5182 |
|
5183 | (data.authors || []).forEach(function (a) {
|
5184 | meta("citation_author", ((a.lastName) + ", " + (a.firstName)));
|
5185 | meta("citation_author_institution", a.affiliation);
|
5186 | });
|
5187 |
|
5188 | if (data.citations) {
|
5189 | data.citations.forEach(function (key) {
|
5190 | var d = data.bibliography[key];
|
5191 | if(!d) {
|
5192 | console.warn("No bibliography data fround for " + key);
|
5193 | } else {
|
5194 | meta("citation_reference", citation_meta_content(data.bibliography[key]) );
|
5195 | }
|
5196 | });
|
5197 | }
|
5198 | }
|
5199 | };
|
5200 |
|
5201 | function appendHtml(el, html) {
|
5202 | el.innerHTML += html;
|
5203 | }
|
5204 |
|
5205 | function citation_meta_content(ref){
|
5206 | var content = "citation_title=" + (ref.title) + ";";
|
5207 | ref.author.split(" and ").forEach(function (author) {
|
5208 | content += "citation_author=" + (author.trim()) + ";";
|
5209 | });
|
5210 | if ("journal" in ref){
|
5211 | content += "citation_journal_title=" + (ref.journal) + ";";
|
5212 | }
|
5213 | if ("volume" in ref) {
|
5214 | content += "citation_volume=" + (ref.volume) + ";";
|
5215 | }
|
5216 | if ("issue" in ref || "number" in ref){
|
5217 | content += "citation_number=" + (ref.issue || ref.number) + ";";
|
5218 | }
|
5219 | |
5220 |
|
5221 | return content;
|
5222 | }
|
5223 |
|
5224 | 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, awaiting review for publication in Distill</div>\n";
|
5225 |
|
5226 | var banner = function(dom, data) {
|
5227 | var banner = dom.createElement("dt-banner");
|
5228 | banner.innerHTML = html$1;
|
5229 | var b = dom.querySelector("body");
|
5230 | b.insertBefore(banner, b.firstChild);
|
5231 | banner.addEventListener("click", function() {
|
5232 | banner.style.display = "none";
|
5233 | });
|
5234 | };
|
5235 |
|
5236 | var 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";
|
5237 |
|
5238 | var html$2 = "\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}\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=\"/faq\">About</a>\n <a href=\"https://github.com/distillpub\">GitHub</a>\n <!-- https://twitter.com/distillpub -->\n </div>\n</div>\n";
|
5239 |
|
5240 | var header = function(dom, data) {
|
5241 | var el = dom.querySelector("dt-header");
|
5242 | if(el) {
|
5243 | el.innerHTML = html$2;
|
5244 | } else {
|
5245 | var header = dom.createElement("dt-header");
|
5246 | header.innerHTML = html$2;
|
5247 | var b = dom.querySelector("body");
|
5248 | b.insertBefore(header, b.firstChild);
|
5249 | }
|
5250 | };
|
5251 |
|
5252 | var mustache = createCommonjsModule(function (module, exports) {
|
5253 |
|
5254 |
|
5255 |
|
5256 |
|
5257 |
|
5258 |
|
5259 |
|
5260 | (function defineMustache (global, factory) {
|
5261 | if ('object' === 'object' && exports && typeof exports.nodeName !== 'string') {
|
5262 | factory(exports);
|
5263 | } else if (typeof undefined === 'function' && undefined.amd) {
|
5264 | undefined(['exports'], factory);
|
5265 | } else {
|
5266 | global.Mustache = {};
|
5267 | factory(global.Mustache);
|
5268 | }
|
5269 | }(commonjsGlobal, function mustacheFactory (mustache) {
|
5270 |
|
5271 | var objectToString = Object.prototype.toString;
|
5272 | var isArray = Array.isArray || function isArrayPolyfill (object) {
|
5273 | return objectToString.call(object) === '[object Array]';
|
5274 | };
|
5275 |
|
5276 | function isFunction (object) {
|
5277 | return typeof object === 'function';
|
5278 | }
|
5279 |
|
5280 | |
5281 |
|
5282 |
|
5283 |
|
5284 | function typeStr (obj) {
|
5285 | return isArray(obj) ? 'array' : typeof obj;
|
5286 | }
|
5287 |
|
5288 | function escapeRegExp (string) {
|
5289 | return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
|
5290 | }
|
5291 |
|
5292 | |
5293 |
|
5294 |
|
5295 |
|
5296 | function hasProperty (obj, propName) {
|
5297 | return obj != null && typeof obj === 'object' && (propName in obj);
|
5298 | }
|
5299 |
|
5300 |
|
5301 |
|
5302 | var regExpTest = RegExp.prototype.test;
|
5303 | function testRegExp (re, string) {
|
5304 | return regExpTest.call(re, string);
|
5305 | }
|
5306 |
|
5307 | var nonSpaceRe = /\S/;
|
5308 | function isWhitespace (string) {
|
5309 | return !testRegExp(nonSpaceRe, string);
|
5310 | }
|
5311 |
|
5312 | var entityMap = {
|
5313 | '&': '&',
|
5314 | '<': '<',
|
5315 | '>': '>',
|
5316 | '"': '"',
|
5317 | "'": ''',
|
5318 | '/': '/',
|
5319 | '`': '`',
|
5320 | '=': '='
|
5321 | };
|
5322 |
|
5323 | function escapeHtml (string) {
|
5324 | return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
|
5325 | return entityMap[s];
|
5326 | });
|
5327 | }
|
5328 |
|
5329 | var whiteRe = /\s*/;
|
5330 | var spaceRe = /\s+/;
|
5331 | var equalsRe = /\s*=/;
|
5332 | var curlyRe = /\s*\}/;
|
5333 | var tagRe = /#|\^|\/|>|\{|&|=|!/;
|
5334 |
|
5335 | |
5336 |
|
5337 |
|
5338 |
|
5339 |
|
5340 |
|
5341 |
|
5342 |
|
5343 |
|
5344 |
|
5345 |
|
5346 |
|
5347 |
|
5348 |
|
5349 |
|
5350 |
|
5351 |
|
5352 |
|
5353 |
|
5354 |
|
5355 |
|
5356 |
|
5357 | function parseTemplate (template, tags) {
|
5358 | if (!template)
|
5359 | { return []; }
|
5360 |
|
5361 | var sections = [];
|
5362 | var tokens = [];
|
5363 | var spaces = [];
|
5364 | var hasTag = false;
|
5365 | var nonSpace = false;
|
5366 |
|
5367 |
|
5368 |
|
5369 | function stripSpace () {
|
5370 | if (hasTag && !nonSpace) {
|
5371 | while (spaces.length)
|
5372 | { delete tokens[spaces.pop()]; }
|
5373 | } else {
|
5374 | spaces = [];
|
5375 | }
|
5376 |
|
5377 | hasTag = false;
|
5378 | nonSpace = false;
|
5379 | }
|
5380 |
|
5381 | var openingTagRe, closingTagRe, closingCurlyRe;
|
5382 | function compileTags (tagsToCompile) {
|
5383 | if (typeof tagsToCompile === 'string')
|
5384 | { tagsToCompile = tagsToCompile.split(spaceRe, 2); }
|
5385 |
|
5386 | if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
|
5387 | { throw new Error('Invalid tags: ' + tagsToCompile); }
|
5388 |
|
5389 | openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
|
5390 | closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
|
5391 | closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
|
5392 | }
|
5393 |
|
5394 | compileTags(tags || mustache.tags);
|
5395 |
|
5396 | var scanner = new Scanner(template);
|
5397 |
|
5398 | var start, type, value, chr, token, openSection;
|
5399 | while (!scanner.eos()) {
|
5400 | start = scanner.pos;
|
5401 |
|
5402 |
|
5403 | value = scanner.scanUntil(openingTagRe);
|
5404 |
|
5405 | if (value) {
|
5406 | for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
|
5407 | chr = value.charAt(i);
|
5408 |
|
5409 | if (isWhitespace(chr)) {
|
5410 | spaces.push(tokens.length);
|
5411 | } else {
|
5412 | nonSpace = true;
|
5413 | }
|
5414 |
|
5415 | tokens.push([ 'text', chr, start, start + 1 ]);
|
5416 | start += 1;
|
5417 |
|
5418 |
|
5419 | if (chr === '\n')
|
5420 | { stripSpace(); }
|
5421 | }
|
5422 | }
|
5423 |
|
5424 |
|
5425 | if (!scanner.scan(openingTagRe))
|
5426 | { break; }
|
5427 |
|
5428 | hasTag = true;
|
5429 |
|
5430 |
|
5431 | type = scanner.scan(tagRe) || 'name';
|
5432 | scanner.scan(whiteRe);
|
5433 |
|
5434 |
|
5435 | if (type === '=') {
|
5436 | value = scanner.scanUntil(equalsRe);
|
5437 | scanner.scan(equalsRe);
|
5438 | scanner.scanUntil(closingTagRe);
|
5439 | } else if (type === '{') {
|
5440 | value = scanner.scanUntil(closingCurlyRe);
|
5441 | scanner.scan(curlyRe);
|
5442 | scanner.scanUntil(closingTagRe);
|
5443 | type = '&';
|
5444 | } else {
|
5445 | value = scanner.scanUntil(closingTagRe);
|
5446 | }
|
5447 |
|
5448 |
|
5449 | if (!scanner.scan(closingTagRe))
|
5450 | { throw new Error('Unclosed tag at ' + scanner.pos); }
|
5451 |
|
5452 | token = [ type, value, start, scanner.pos ];
|
5453 | tokens.push(token);
|
5454 |
|
5455 | if (type === '#' || type === '^') {
|
5456 | sections.push(token);
|
5457 | } else if (type === '/') {
|
5458 |
|
5459 | openSection = sections.pop();
|
5460 |
|
5461 | if (!openSection)
|
5462 | { throw new Error('Unopened section "' + value + '" at ' + start); }
|
5463 |
|
5464 | if (openSection[1] !== value)
|
5465 | { throw new Error('Unclosed section "' + openSection[1] + '" at ' + start); }
|
5466 | } else if (type === 'name' || type === '{' || type === '&') {
|
5467 | nonSpace = true;
|
5468 | } else if (type === '=') {
|
5469 |
|
5470 | compileTags(value);
|
5471 | }
|
5472 | }
|
5473 |
|
5474 |
|
5475 | openSection = sections.pop();
|
5476 |
|
5477 | if (openSection)
|
5478 | { throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos); }
|
5479 |
|
5480 | return nestTokens(squashTokens(tokens));
|
5481 | }
|
5482 |
|
5483 | |
5484 |
|
5485 |
|
5486 |
|
5487 | function squashTokens (tokens) {
|
5488 | var squashedTokens = [];
|
5489 |
|
5490 | var token, lastToken;
|
5491 | for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
5492 | token = tokens[i];
|
5493 |
|
5494 | if (token) {
|
5495 | if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
|
5496 | lastToken[1] += token[1];
|
5497 | lastToken[3] = token[3];
|
5498 | } else {
|
5499 | squashedTokens.push(token);
|
5500 | lastToken = token;
|
5501 | }
|
5502 | }
|
5503 | }
|
5504 |
|
5505 | return squashedTokens;
|
5506 | }
|
5507 |
|
5508 | |
5509 |
|
5510 |
|
5511 |
|
5512 |
|
5513 |
|
5514 | function nestTokens (tokens) {
|
5515 | var nestedTokens = [];
|
5516 | var collector = nestedTokens;
|
5517 | var sections = [];
|
5518 |
|
5519 | var token, section;
|
5520 | for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
5521 | token = tokens[i];
|
5522 |
|
5523 | switch (token[0]) {
|
5524 | case '#':
|
5525 | case '^':
|
5526 | collector.push(token);
|
5527 | sections.push(token);
|
5528 | collector = token[4] = [];
|
5529 | break;
|
5530 | case '/':
|
5531 | section = sections.pop();
|
5532 | section[5] = token[2];
|
5533 | collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
|
5534 | break;
|
5535 | default:
|
5536 | collector.push(token);
|
5537 | }
|
5538 | }
|
5539 |
|
5540 | return nestedTokens;
|
5541 | }
|
5542 |
|
5543 | |
5544 |
|
5545 |
|
5546 |
|
5547 | function Scanner (string) {
|
5548 | this.string = string;
|
5549 | this.tail = string;
|
5550 | this.pos = 0;
|
5551 | }
|
5552 |
|
5553 | |
5554 |
|
5555 |
|
5556 | Scanner.prototype.eos = function eos () {
|
5557 | return this.tail === '';
|
5558 | };
|
5559 |
|
5560 | |
5561 |
|
5562 |
|
5563 |
|
5564 | Scanner.prototype.scan = function scan (re) {
|
5565 | var match = this.tail.match(re);
|
5566 |
|
5567 | if (!match || match.index !== 0)
|
5568 | { return ''; }
|
5569 |
|
5570 | var string = match[0];
|
5571 |
|
5572 | this.tail = this.tail.substring(string.length);
|
5573 | this.pos += string.length;
|
5574 |
|
5575 | return string;
|
5576 | };
|
5577 |
|
5578 | |
5579 |
|
5580 |
|
5581 |
|
5582 | Scanner.prototype.scanUntil = function scanUntil (re) {
|
5583 | var index = this.tail.search(re), match;
|
5584 |
|
5585 | switch (index) {
|
5586 | case -1:
|
5587 | match = this.tail;
|
5588 | this.tail = '';
|
5589 | break;
|
5590 | case 0:
|
5591 | match = '';
|
5592 | break;
|
5593 | default:
|
5594 | match = this.tail.substring(0, index);
|
5595 | this.tail = this.tail.substring(index);
|
5596 | }
|
5597 |
|
5598 | this.pos += match.length;
|
5599 |
|
5600 | return match;
|
5601 | };
|
5602 |
|
5603 | |
5604 |
|
5605 |
|
5606 |
|
5607 | function Context (view, parentContext) {
|
5608 | this.view = view;
|
5609 | this.cache = { '.': this.view };
|
5610 | this.parent = parentContext;
|
5611 | }
|
5612 |
|
5613 | |
5614 |
|
5615 |
|
5616 |
|
5617 | Context.prototype.push = function push (view) {
|
5618 | return new Context(view, this);
|
5619 | };
|
5620 |
|
5621 | |
5622 |
|
5623 |
|
5624 |
|
5625 | Context.prototype.lookup = function lookup (name) {
|
5626 | var cache = this.cache;
|
5627 |
|
5628 | var value;
|
5629 | if (cache.hasOwnProperty(name)) {
|
5630 | value = cache[name];
|
5631 | } else {
|
5632 | var context = this, names, index, lookupHit = false;
|
5633 |
|
5634 | while (context) {
|
5635 | if (name.indexOf('.') > 0) {
|
5636 | value = context.view;
|
5637 | names = name.split('.');
|
5638 | index = 0;
|
5639 |
|
5640 | |
5641 |
|
5642 |
|
5643 |
|
5644 |
|
5645 |
|
5646 |
|
5647 |
|
5648 |
|
5649 |
|
5650 |
|
5651 | while (value != null && index < names.length) {
|
5652 | if (index === names.length - 1)
|
5653 | { lookupHit = hasProperty(value, names[index]); }
|
5654 |
|
5655 | value = value[names[index++]];
|
5656 | }
|
5657 | } else {
|
5658 | value = context.view[name];
|
5659 | lookupHit = hasProperty(context.view, name);
|
5660 | }
|
5661 |
|
5662 | if (lookupHit)
|
5663 | { break; }
|
5664 |
|
5665 | context = context.parent;
|
5666 | }
|
5667 |
|
5668 | cache[name] = value;
|
5669 | }
|
5670 |
|
5671 | if (isFunction(value))
|
5672 | { value = value.call(this.view); }
|
5673 |
|
5674 | return value;
|
5675 | };
|
5676 |
|
5677 | |
5678 |
|
5679 |
|
5680 |
|
5681 |
|
5682 | function Writer () {
|
5683 | this.cache = {};
|
5684 | }
|
5685 |
|
5686 | |
5687 |
|
5688 |
|
5689 | Writer.prototype.clearCache = function clearCache () {
|
5690 | this.cache = {};
|
5691 | };
|
5692 |
|
5693 | |
5694 |
|
5695 |
|
5696 |
|
5697 | Writer.prototype.parse = function parse (template, tags) {
|
5698 | var cache = this.cache;
|
5699 | var tokens = cache[template];
|
5700 |
|
5701 | if (tokens == null)
|
5702 | { tokens = cache[template] = parseTemplate(template, tags); }
|
5703 |
|
5704 | return tokens;
|
5705 | };
|
5706 |
|
5707 | |
5708 |
|
5709 |
|
5710 |
|
5711 |
|
5712 |
|
5713 |
|
5714 |
|
5715 |
|
5716 | Writer.prototype.render = function render (template, view, partials) {
|
5717 | var tokens = this.parse(template);
|
5718 | var context = (view instanceof Context) ? view : new Context(view);
|
5719 | return this.renderTokens(tokens, context, partials, template);
|
5720 | };
|
5721 |
|
5722 | |
5723 |
|
5724 |
|
5725 |
|
5726 |
|
5727 |
|
5728 |
|
5729 |
|
5730 |
|
5731 | Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate) {
|
5732 | var this$1 = this;
|
5733 |
|
5734 | var buffer = '';
|
5735 |
|
5736 | var token, symbol, value;
|
5737 | for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
5738 | value = undefined;
|
5739 | token = tokens[i];
|
5740 | symbol = token[0];
|
5741 |
|
5742 | if (symbol === '#') { value = this$1.renderSection(token, context, partials, originalTemplate); }
|
5743 | else if (symbol === '^') { value = this$1.renderInverted(token, context, partials, originalTemplate); }
|
5744 | else if (symbol === '>') { value = this$1.renderPartial(token, context, partials, originalTemplate); }
|
5745 | else if (symbol === '&') { value = this$1.unescapedValue(token, context); }
|
5746 | else if (symbol === 'name') { value = this$1.escapedValue(token, context); }
|
5747 | else if (symbol === 'text') { value = this$1.rawValue(token); }
|
5748 |
|
5749 | if (value !== undefined)
|
5750 | { buffer += value; }
|
5751 | }
|
5752 |
|
5753 | return buffer;
|
5754 | };
|
5755 |
|
5756 | Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate) {
|
5757 | var this$1 = this;
|
5758 |
|
5759 | var self = this;
|
5760 | var buffer = '';
|
5761 | var value = context.lookup(token[1]);
|
5762 |
|
5763 |
|
5764 |
|
5765 | function subRender (template) {
|
5766 | return self.render(template, context, partials);
|
5767 | }
|
5768 |
|
5769 | if (!value) { return; }
|
5770 |
|
5771 | if (isArray(value)) {
|
5772 | for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
|
5773 | buffer += this$1.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
|
5774 | }
|
5775 | } else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
|
5776 | buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
|
5777 | } else if (isFunction(value)) {
|
5778 | if (typeof originalTemplate !== 'string')
|
5779 | { throw new Error('Cannot use higher-order sections without the original template'); }
|
5780 |
|
5781 |
|
5782 | value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
|
5783 |
|
5784 | if (value != null)
|
5785 | { buffer += value; }
|
5786 | } else {
|
5787 | buffer += this.renderTokens(token[4], context, partials, originalTemplate);
|
5788 | }
|
5789 | return buffer;
|
5790 | };
|
5791 |
|
5792 | Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate) {
|
5793 | var value = context.lookup(token[1]);
|
5794 |
|
5795 |
|
5796 |
|
5797 | if (!value || (isArray(value) && value.length === 0))
|
5798 | { return this.renderTokens(token[4], context, partials, originalTemplate); }
|
5799 | };
|
5800 |
|
5801 | Writer.prototype.renderPartial = function renderPartial (token, context, partials) {
|
5802 | if (!partials) { return; }
|
5803 |
|
5804 | var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
|
5805 | if (value != null)
|
5806 | { return this.renderTokens(this.parse(value), context, partials, value); }
|
5807 | };
|
5808 |
|
5809 | Writer.prototype.unescapedValue = function unescapedValue (token, context) {
|
5810 | var value = context.lookup(token[1]);
|
5811 | if (value != null)
|
5812 | { return value; }
|
5813 | };
|
5814 |
|
5815 | Writer.prototype.escapedValue = function escapedValue (token, context) {
|
5816 | var value = context.lookup(token[1]);
|
5817 | if (value != null)
|
5818 | { return mustache.escape(value); }
|
5819 | };
|
5820 |
|
5821 | Writer.prototype.rawValue = function rawValue (token) {
|
5822 | return token[1];
|
5823 | };
|
5824 |
|
5825 | mustache.name = 'mustache.js';
|
5826 | mustache.version = '2.3.0';
|
5827 | mustache.tags = [ '{{', '}}' ];
|
5828 |
|
5829 |
|
5830 | var defaultWriter = new Writer();
|
5831 |
|
5832 | |
5833 |
|
5834 |
|
5835 | mustache.clearCache = function clearCache () {
|
5836 | return defaultWriter.clearCache();
|
5837 | };
|
5838 |
|
5839 | |
5840 |
|
5841 |
|
5842 |
|
5843 |
|
5844 | mustache.parse = function parse (template, tags) {
|
5845 | return defaultWriter.parse(template, tags);
|
5846 | };
|
5847 |
|
5848 | |
5849 |
|
5850 |
|
5851 |
|
5852 | mustache.render = function render (template, view, partials) {
|
5853 | if (typeof template !== 'string') {
|
5854 | throw new TypeError('Invalid template! Template should be a "string" ' +
|
5855 | 'but "' + typeStr(template) + '" was given as the first ' +
|
5856 | 'argument for mustache#render(template, view, partials)');
|
5857 | }
|
5858 |
|
5859 | return defaultWriter.render(template, view, partials);
|
5860 | };
|
5861 |
|
5862 |
|
5863 |
|
5864 | mustache.to_html = function to_html (template, view, partials, send) {
|
5865 |
|
5866 |
|
5867 | var result = mustache.render(template, view, partials);
|
5868 |
|
5869 | if (isFunction(send)) {
|
5870 | send(result);
|
5871 | } else {
|
5872 | return result;
|
5873 | }
|
5874 | };
|
5875 |
|
5876 |
|
5877 |
|
5878 | mustache.escape = escapeHtml;
|
5879 |
|
5880 |
|
5881 | mustache.Scanner = Scanner;
|
5882 | mustache.Context = Context;
|
5883 | mustache.Writer = Writer;
|
5884 |
|
5885 | return mustache;
|
5886 | }));
|
5887 | });
|
5888 |
|
5889 | var html$3 = "\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";
|
5890 |
|
5891 | var 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 <div class=\"date\">\n <div class=\"month\">{{publishedMonth}}. {{publishedDay}}</div>\n <div class=\"year\">{{publishedYear}}</div>\n </div>\n <a class=\"citation\" href=\"#citation\">\n <div>Citation:</div>\n <div>{{concatenatedAuthors}}, {{publishedYear}}</div>\n </a>\n</div>\n";
|
5892 |
|
5893 | var byline = function(dom, data) {
|
5894 | var el = dom.querySelector('dt-byline');
|
5895 | if (el) {
|
5896 | el.innerHTML = html$3 + mustache.render(template, data);
|
5897 | }
|
5898 | };
|
5899 |
|
5900 | var html$4 = "\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 <h3>References</h3>\n <dt-bibliography></dt-bibliography>\n <h3 id=\"citation\">Errors, Reuse, and Citation</h3>\n <p>If you see mistakes or want to suggest changes, please <a class=\"github-issue\">create an issue on GitHub</a>.</p>\n <p>Diagrams 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\">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 <p>For attribution in academic contexts, please cite this work as</p>\n <pre class=\"citation short\"></pre>\n <p>BibTeX citation</p>\n <pre class=\"citation long\"></pre>\n</div>\n";
|
5901 |
|
5902 | var appendix = function(dom, data) {
|
5903 | var el = dom.querySelector('dt-appendix');
|
5904 | if (el) {
|
5905 | var oldHtml = el.innerHTML;
|
5906 | el.innerHTML = html$4;
|
5907 | var div = el.querySelector("div.l-body");
|
5908 |
|
5909 | if (dom.querySelector("dt-fn")) {
|
5910 | div.innerHTML = "<h3>Footnotes</h3><dt-fn-list></dt-fn-list>" + div.innerHTML;
|
5911 | }
|
5912 |
|
5913 | div.innerHTML = oldHtml + div.innerHTML;
|
5914 | if (data.githubCompareUpdatesUrl) {
|
5915 | div.innerHTML = "<h3>Updates</h3><p><a href=\"" + (data.githubCompareUpdatesUrl) + "\">View all changes</a> to this article since it was first published.</p>" + div.innerHTML;
|
5916 | }
|
5917 |
|
5918 | el.querySelector("a.github").setAttribute("href", data.githubUrl);
|
5919 | el.querySelector("a.github-issue").setAttribute("href", data.githubUrl + "/issues/new");
|
5920 | el.querySelector(".citation.short").textContent = data.concatenatedAuthors + ", " + '"' + data.title + '", Distill, ' + data.publishedYear + ".";
|
5921 | var bibtex = "@article{" + data.slug + ",\n";
|
5922 | bibtex += " author = {" + data.bibtexAuthors + "},\n";
|
5923 | bibtex += " title = {" + data.title + "},\n";
|
5924 | bibtex += " journal = {Distill},\n";
|
5925 | bibtex += " year = {" + data.publishedYear + "},\n";
|
5926 | bibtex += " note = {" + data.url + "}\n";
|
5927 | bibtex += "}";
|
5928 | el.querySelector(".citation.long").textContent = bibtex;
|
5929 | }
|
5930 |
|
5931 | };
|
5932 |
|
5933 | var 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}\n</style>\n\n<div class=\"l-screen-inset\">\n <a href=\"/\" class=\"logo\">\n " + logo + "\n Distill\n </a> is dedicated to clear explanations of machine learning\n</div>\n";
|
5934 |
|
5935 | var footer = function(dom, data) {
|
5936 | var el = dom.querySelector("dt-footer");
|
5937 | if(el) {
|
5938 | el.innerHTML = html$5;
|
5939 | } else {
|
5940 | var footer = dom.createElement("dt-footer");
|
5941 | footer.innerHTML = html$5;
|
5942 | var b = dom.querySelector("body");
|
5943 | b.appendChild(footer);
|
5944 | }
|
5945 | };
|
5946 |
|
5947 | var citation = function(dom, data) {
|
5948 | 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 ";
|
5949 |
|
5950 | var style = dom.createElement("style");
|
5951 | style.textContent = css;
|
5952 | dom.querySelector("body").appendChild(style);
|
5953 |
|
5954 | var citations = data.citations;
|
5955 | |
5956 |
|
5957 |
|
5958 |
|
5959 |
|
5960 |
|
5961 |
|
5962 | var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
|
5963 | citeTags.forEach(function (el,n) {
|
5964 | var key = el.getAttribute("key");
|
5965 | if (key) {
|
5966 | var keys = key.split(",");
|
5967 | var cite_string = inline_cite_short(keys);
|
5968 | var cite_hover_str = "";
|
5969 | keys.map(function (key,n) {
|
5970 | if (n>0) { cite_hover_str += "<br><br>"; }
|
5971 | cite_hover_str += hover_cite(data.bibliography[key]);
|
5972 | });
|
5973 | cite_hover_str = cite_hover_str.replace(/"/g, "'");
|
5974 | var orig_string = el.innerHTML;
|
5975 | if (orig_string != "") { orig_string += " "; }
|
5976 | el.innerHTML = "<span id=\"citation-" + n + "\" data-hover=\"" + cite_hover_str + "\">" + orig_string + "<span class=\"citation-number\">" + cite_string + "</span></span>";
|
5977 | }
|
5978 | });
|
5979 |
|
5980 | var bibEl = dom.querySelector("dt-bibliography");
|
5981 | if (bibEl) {
|
5982 | var ol = dom.createElement("ol");
|
5983 | citations.forEach(function (key) {
|
5984 | var el = dom.createElement("li");
|
5985 | el.innerHTML = bibliography_cite(data.bibliography[key]);
|
5986 | ol.appendChild(el);
|
5987 | });
|
5988 | bibEl.appendChild(ol);
|
5989 | }
|
5990 |
|
5991 | function inline_cite_short(keys){
|
5992 | function cite_string(key){
|
5993 | if (key in data.bibliography){
|
5994 | var n = data.citations.indexOf(key)+1;
|
5995 | return ""+n;
|
5996 | } else {
|
5997 | return "?";
|
5998 | }
|
5999 | }
|
6000 | return "["+keys.map(cite_string).join(", ")+"]";
|
6001 | }
|
6002 |
|
6003 | function inline_cite_long(keys){
|
6004 | function cite_string(key){
|
6005 | if (key in data.bibliography){
|
6006 | var ent = data.bibliography[key];
|
6007 | var names = ent.author.split(" and ");
|
6008 | names = names.map(function (name) { return name.split(",")[0].trim(); });
|
6009 | var year = ent.year;
|
6010 | if (names.length == 1) { return names[0] + ", " + year; }
|
6011 | if (names.length == 2) { return names[0] + " & " + names[1] + ", " + year; }
|
6012 | if (names.length > 2) { return names[0] + ", et al., " + year; }
|
6013 | } else {
|
6014 | return "?";
|
6015 | }
|
6016 | }
|
6017 | return keys.map(cite_string).join(", ");
|
6018 | }
|
6019 |
|
6020 | function author_string(ent, template, sep, finalSep){
|
6021 | var names = ent.author.split(" and ");
|
6022 | var name_strings = names.map(function (name) {
|
6023 | name = name.trim();
|
6024 | if (name.indexOf(",") != -1){
|
6025 | var last = name.split(",")[0].trim();
|
6026 | var firsts = name.split(",")[1];
|
6027 | } else {
|
6028 | var last = name.split(" ").slice(-1)[0].trim();
|
6029 | var firsts = name.split(" ").slice(0,-1).join(" ");
|
6030 | }
|
6031 | var initials = "";
|
6032 | if (firsts != undefined) {
|
6033 | initials = firsts.trim().split(" ").map(function (s) { return s.trim()[0]; });
|
6034 | initials = initials.join(".")+".";
|
6035 | }
|
6036 | return template.replace("${F}", firsts)
|
6037 | .replace("${L}", last)
|
6038 | .replace("${I}", initials);
|
6039 | });
|
6040 | if (names.length > 1) {
|
6041 | var str = name_strings.slice(0, names.length-1).join(sep);
|
6042 | str += (finalSep || sep) + name_strings[names.length-1];
|
6043 | return str;
|
6044 | } else {
|
6045 | return name_strings[0];
|
6046 | }
|
6047 | }
|
6048 |
|
6049 | function venue_string(ent) {
|
6050 | var cite = (ent.journal || ent.booktitle || "");
|
6051 | if ("volume" in ent){
|
6052 | var issue = ent.issue || ent.number;
|
6053 | issue = (issue != undefined)? "("+issue+")" : "";
|
6054 | cite += ", Vol " + ent.volume + issue;
|
6055 | }
|
6056 | if ("pages" in ent){
|
6057 | cite += ", pp. " + ent.pages;
|
6058 | }
|
6059 | if (cite != "") { cite += ". "; }
|
6060 | if ("publisher" in ent){
|
6061 | cite += ent.publisher;
|
6062 | if (cite[cite.length-1] != ".") { cite += "."; }
|
6063 | }
|
6064 | return cite;
|
6065 | }
|
6066 |
|
6067 | function link_string(ent){
|
6068 | if ("url" in ent){
|
6069 | var url = ent.url;
|
6070 | var arxiv_match = (/arxiv\.org\/abs\/([0-9\.]*)/).exec(url);
|
6071 | if (arxiv_match != null){
|
6072 | url = "http://arxiv.org/pdf/" + (arxiv_match[1]) + ".pdf";
|
6073 | }
|
6074 |
|
6075 | if (url.slice(-4) == ".pdf"){
|
6076 | var label = "PDF";
|
6077 | } else if (url.slice(-5) == ".html") {
|
6078 | var label = "HTML";
|
6079 | }
|
6080 | return ("  <a href=\"" + url + "\">[" + (label||"link") + "]</a>");
|
6081 | } |
6082 |
|
6083 | else {
|
6084 | return "";
|
6085 | }
|
6086 | }
|
6087 | function doi_string(ent, new_line){
|
6088 | if ("doi" in ent) {
|
6089 | return ((new_line?"<br>":"") + " <a href=\"https://doi.org/" + (ent.doi) + "\" style=\"text-decoration:inherit;\">DOI: " + (ent.doi) + "</a>");
|
6090 | } else {
|
6091 | return "";
|
6092 | }
|
6093 | }
|
6094 |
|
6095 | function bibliography_cite(ent, fancy){
|
6096 | if (ent){
|
6097 | var cite = "<b>" + ent.title + "</b> ";
|
6098 | cite += link_string(ent) + "<br>";
|
6099 | cite += author_string(ent, "${L}, ${I}", ", ", " and ");
|
6100 | if (ent.year || ent.date){
|
6101 | cite += ", " + (ent.year || ent.date) + ". ";
|
6102 | } else {
|
6103 | cite += ". ";
|
6104 | }
|
6105 | cite += venue_string(ent);
|
6106 | cite += doi_string(ent);
|
6107 | return cite
|
6108 | |
6109 |
|
6110 |
|
6111 |
|
6112 |
|
6113 |
|
6114 |
|
6115 |
|
6116 |
|
6117 |
|
6118 |
|
6119 | } else {
|
6120 | return "?";
|
6121 | }
|
6122 | }
|
6123 |
|
6124 | function hover_cite(ent){
|
6125 | if (ent){
|
6126 | var cite = "";
|
6127 | cite += "<b>" + ent.title + "</b>";
|
6128 | cite += link_string(ent);
|
6129 | cite += "<br>";
|
6130 |
|
6131 | var a_str = author_string(ent, "${I} ${L}", ", ") + ".";
|
6132 | var v_str = venue_string(ent).trim() + " " + ent.year + ". " + doi_string(ent, true);
|
6133 |
|
6134 | if ((a_str+v_str).length < Math.min(40, ent.title.length)) {
|
6135 | cite += a_str + " " + v_str;
|
6136 | } else {
|
6137 | cite += a_str + "<br>" + v_str;
|
6138 | }
|
6139 | return cite;
|
6140 | } else {
|
6141 | return "?";
|
6142 | }
|
6143 | }
|
6144 |
|
6145 |
|
6146 |
|
6147 | function get_GS_URL(ent){
|
6148 | if (ent){
|
6149 | var names = ent.author.split(" and ");
|
6150 | names = names.map(function (name) { return name.split(",")[0].trim(); });
|
6151 | var title = ent.title.split(" ");
|
6152 | var url = "http://search.labs.crossref.org/dois?";
|
6153 | url += uris({q: names.join(" ") + " " + title.join(" ")});
|
6154 | }
|
6155 |
|
6156 | }
|
6157 | };
|
6158 |
|
6159 | var footnote = function(dom, data) {
|
6160 |
|
6161 | var fnTags = [].slice.apply(dom.querySelectorAll("dt-fn"));
|
6162 | var fnContent = [];
|
6163 | fnTags.forEach(function (el,n) {
|
6164 | var content = el.innerHTML;
|
6165 | fnContent.push(content);
|
6166 | n = (n+1)+"";
|
6167 | var key = "fn-"+n;
|
6168 | var escaped_content = content.replace(/"/g, "'");
|
6169 | el.innerHTML = "<sup><span id=\"" + key + "\" data-hover=\"" + escaped_content + "\" style=\"cursor:pointer\">" + n + "</span></sup>";
|
6170 | });
|
6171 |
|
6172 | var fnList = dom.querySelector("dt-fn-list");
|
6173 | if (fnList) {
|
6174 | var ol = dom.createElement("ol");
|
6175 | fnContent.forEach(function (content) {
|
6176 | var el = dom.createElement("li");
|
6177 | el.innerHTML = content;
|
6178 | ol.appendChild(el);
|
6179 | });
|
6180 | fnList.appendChild(ol);
|
6181 | }
|
6182 |
|
6183 | };
|
6184 |
|
6185 | var marked = createCommonjsModule(function (module, exports) {
|
6186 |
|
6187 |
|
6188 |
|
6189 |
|
6190 |
|
6191 |
|
6192 | (function() {
|
6193 |
|
6194 |
|
6195 |
|
6196 |
|
6197 |
|
6198 | var block = {
|
6199 | newline: /^\n+/,
|
6200 | code: /^( {4}[^\n]+\n*)+/,
|
6201 | fences: noop,
|
6202 | hr: /^( *[-*_]){3,} *(?:\n+|$)/,
|
6203 | heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
|
6204 | nptable: noop,
|
6205 | lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
|
6206 | blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
|
6207 | list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
6208 | html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
|
6209 | def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
|
6210 | table: noop,
|
6211 | paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
|
6212 | text: /^[^\n]+/
|
6213 | };
|
6214 |
|
6215 | block.bullet = /(?:[*+-]|\d+\.)/;
|
6216 | block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
|
6217 | block.item = replace(block.item, 'gm')
|
6218 | (/bull/g, block.bullet)
|
6219 | ();
|
6220 |
|
6221 | block.list = replace(block.list)
|
6222 | (/bull/g, block.bullet)
|
6223 | ('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
|
6224 | ('def', '\\n+(?=' + block.def.source + ')')
|
6225 | ();
|
6226 |
|
6227 | block.blockquote = replace(block.blockquote)
|
6228 | ('def', block.def)
|
6229 | ();
|
6230 |
|
6231 | block._tag = '(?!(?:'
|
6232 | + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
|
6233 | + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
|
6234 | + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
|
6235 |
|
6236 | block.html = replace(block.html)
|
6237 | ('comment', //)
|
6238 | ('closed', /<(tag)[\s\S]+?<\/\1>/)
|
6239 | ('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
|
6240 | (/tag/g, block._tag)
|
6241 | ();
|
6242 |
|
6243 | block.paragraph = replace(block.paragraph)
|
6244 | ('hr', block.hr)
|
6245 | ('heading', block.heading)
|
6246 | ('lheading', block.lheading)
|
6247 | ('blockquote', block.blockquote)
|
6248 | ('tag', '<' + block._tag)
|
6249 | ('def', block.def)
|
6250 | ();
|
6251 |
|
6252 | /**
|
6253 | * Normal Block Grammar
|
6254 | */
|
6255 |
|
6256 | block.normal = merge({}, block);
|
6257 |
|
6258 | /**
|
6259 | * GFM Block Grammar
|
6260 | */
|
6261 |
|
6262 | block.gfm = merge({}, block.normal, {
|
6263 | fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
|
6264 | paragraph: /^/,
|
6265 | heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
|
6266 | });
|
6267 |
|
6268 | block.gfm.paragraph = replace(block.paragraph)
|
6269 | ('(?!', '(?!'
|
6270 | + block.gfm.fences.source.replace('\\1', '\\2') + '|'
|
6271 | + block.list.source.replace('\\1', '\\3') + '|')
|
6272 | ();
|
6273 |
|
6274 | /**
|
6275 | * GFM + Tables Block Grammar
|
6276 | */
|
6277 |
|
6278 | block.tables = merge({}, block.gfm, {
|
6279 | nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
|
6280 | table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
|
6281 | });
|
6282 |
|
6283 | /**
|
6284 | * Block Lexer
|
6285 | */
|
6286 |
|
6287 | function Lexer(options) {
|
6288 | this.tokens = [];
|
6289 | this.tokens.links = {};
|
6290 | this.options = options || marked.defaults;
|
6291 | this.rules = block.normal;
|
6292 |
|
6293 | if (this.options.gfm) {
|
6294 | if (this.options.tables) {
|
6295 | this.rules = block.tables;
|
6296 | } else {
|
6297 | this.rules = block.gfm;
|
6298 | }
|
6299 | }
|
6300 | }
|
6301 |
|
6302 | /**
|
6303 | * Expose Block Rules
|
6304 | */
|
6305 |
|
6306 | Lexer.rules = block;
|
6307 |
|
6308 | /**
|
6309 | * Static Lex Method
|
6310 | */
|
6311 |
|
6312 | Lexer.lex = function(src, options) {
|
6313 | var lexer = new Lexer(options);
|
6314 | return lexer.lex(src);
|
6315 | };
|
6316 |
|
6317 | /**
|
6318 | * Preprocessing
|
6319 | */
|
6320 |
|
6321 | Lexer.prototype.lex = function(src) {
|
6322 | src = src
|
6323 | .replace(/\r\n|\r/g, '\n')
|
6324 | .replace(/\t/g, ' ')
|
6325 | .replace(/\u00a0/g, ' ')
|
6326 | .replace(/\u2424/g, '\n');
|
6327 |
|
6328 | return this.token(src, true);
|
6329 | };
|
6330 |
|
6331 | /**
|
6332 | * Lexing
|
6333 | */
|
6334 |
|
6335 | Lexer.prototype.token = function(src, top, bq) {
|
6336 | var this$1 = this;
|
6337 |
|
6338 | var src = src.replace(/^ +$/gm, '')
|
6339 | , next
|
6340 | , loose
|
6341 | , cap
|
6342 | , bull
|
6343 | , b
|
6344 | , item
|
6345 | , space
|
6346 | , i
|
6347 | , l;
|
6348 |
|
6349 | while (src) {
|
6350 | // newline
|
6351 | if (cap = this$1.rules.newline.exec(src)) {
|
6352 | src = src.substring(cap[0].length);
|
6353 | if (cap[0].length > 1) {
|
6354 | this$1.tokens.push({
|
6355 | type: 'space'
|
6356 | });
|
6357 | }
|
6358 | }
|
6359 |
|
6360 | // code
|
6361 | if (cap = this$1.rules.code.exec(src)) {
|
6362 | src = src.substring(cap[0].length);
|
6363 | cap = cap[0].replace(/^ {4}/gm, '');
|
6364 | this$1.tokens.push({
|
6365 | type: 'code',
|
6366 | text: !this$1.options.pedantic
|
6367 | ? cap.replace(/\n+$/, '')
|
6368 | : cap
|
6369 | });
|
6370 | continue;
|
6371 | }
|
6372 |
|
6373 | // fences (gfm)
|
6374 | if (cap = this$1.rules.fences.exec(src)) {
|
6375 | src = src.substring(cap[0].length);
|
6376 | this$1.tokens.push({
|
6377 | type: 'code',
|
6378 | lang: cap[2],
|
6379 | text: cap[3] || ''
|
6380 | });
|
6381 | continue;
|
6382 | }
|
6383 |
|
6384 | // heading
|
6385 | if (cap = this$1.rules.heading.exec(src)) {
|
6386 | src = src.substring(cap[0].length);
|
6387 | this$1.tokens.push({
|
6388 | type: 'heading',
|
6389 | depth: cap[1].length,
|
6390 | text: cap[2]
|
6391 | });
|
6392 | continue;
|
6393 | }
|
6394 |
|
6395 | // table no leading pipe (gfm)
|
6396 | if (top && (cap = this$1.rules.nptable.exec(src))) {
|
6397 | src = src.substring(cap[0].length);
|
6398 |
|
6399 | item = {
|
6400 | type: 'table',
|
6401 | header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
|
6402 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
6403 | cells: cap[3].replace(/\n$/, '').split('\n')
|
6404 | };
|
6405 |
|
6406 | for (i = 0; i < item.align.length; i++) {
|
6407 | if (/^ *-+: *$/.test(item.align[i])) {
|
6408 | item.align[i] = 'right';
|
6409 | } else if (/^ *:-+: *$/.test(item.align[i])) {
|
6410 | item.align[i] = 'center';
|
6411 | } else if (/^ *:-+ *$/.test(item.align[i])) {
|
6412 | item.align[i] = 'left';
|
6413 | } else {
|
6414 | item.align[i] = null;
|
6415 | }
|
6416 | }
|
6417 |
|
6418 | for (i = 0; i < item.cells.length; i++) {
|
6419 | item.cells[i] = item.cells[i].split(/ *\| */);
|
6420 | }
|
6421 |
|
6422 | this$1.tokens.push(item);
|
6423 |
|
6424 | continue;
|
6425 | }
|
6426 |
|
6427 | // lheading
|
6428 | if (cap = this$1.rules.lheading.exec(src)) {
|
6429 | src = src.substring(cap[0].length);
|
6430 | this$1.tokens.push({
|
6431 | type: 'heading',
|
6432 | depth: cap[2] === '=' ? 1 : 2,
|
6433 | text: cap[1]
|
6434 | });
|
6435 | continue;
|
6436 | }
|
6437 |
|
6438 | // hr
|
6439 | if (cap = this$1.rules.hr.exec(src)) {
|
6440 | src = src.substring(cap[0].length);
|
6441 | this$1.tokens.push({
|
6442 | type: 'hr'
|
6443 | });
|
6444 | continue;
|
6445 | }
|
6446 |
|
6447 | // blockquote
|
6448 | if (cap = this$1.rules.blockquote.exec(src)) {
|
6449 | src = src.substring(cap[0].length);
|
6450 |
|
6451 | this$1.tokens.push({
|
6452 | type: 'blockquote_start'
|
6453 | });
|
6454 |
|
6455 | cap = cap[0].replace(/^ *> ?/gm, '');
|
6456 |
|
6457 | // Pass `top` to keep the current
|
6458 | // "toplevel" state. This is exactly
|
6459 | // how markdown.pl works.
|
6460 | this$1.token(cap, top, true);
|
6461 |
|
6462 | this$1.tokens.push({
|
6463 | type: 'blockquote_end'
|
6464 | });
|
6465 |
|
6466 | continue;
|
6467 | }
|
6468 |
|
6469 | // list
|
6470 | if (cap = this$1.rules.list.exec(src)) {
|
6471 | src = src.substring(cap[0].length);
|
6472 | bull = cap[2];
|
6473 |
|
6474 | this$1.tokens.push({
|
6475 | type: 'list_start',
|
6476 | ordered: bull.length > 1
|
6477 | });
|
6478 |
|
6479 | // Get each top-level item.
|
6480 | cap = cap[0].match(this$1.rules.item);
|
6481 |
|
6482 | next = false;
|
6483 | l = cap.length;
|
6484 | i = 0;
|
6485 |
|
6486 | for (; i < l; i++) {
|
6487 | item = cap[i];
|
6488 |
|
6489 | // Remove the list item's bullet
|
6490 | // so it is seen as the next token.
|
6491 | space = item.length;
|
6492 | item = item.replace(/^ *([*+-]|\d+\.) +/, '');
|
6493 |
|
6494 | // Outdent whatever the
|
6495 | // list item contains. Hacky.
|
6496 | if (~item.indexOf('\n ')) {
|
6497 | space -= item.length;
|
6498 | item = !this$1.options.pedantic
|
6499 | ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
|
6500 | : item.replace(/^ {1,4}/gm, '');
|
6501 | }
|
6502 |
|
6503 | // Determine whether the next list item belongs here.
|
6504 | // Backpedal if it does not belong in this list.
|
6505 | if (this$1.options.smartLists && i !== l - 1) {
|
6506 | b = block.bullet.exec(cap[i + 1])[0];
|
6507 | if (bull !== b && !(bull.length > 1 && b.length > 1)) {
|
6508 | src = cap.slice(i + 1).join('\n') + src;
|
6509 | i = l - 1;
|
6510 | }
|
6511 | }
|
6512 |
|
6513 | // Determine whether item is loose or not.
|
6514 | // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
|
6515 | // for discount behavior.
|
6516 | loose = next || /\n\n(?!\s*$)/.test(item);
|
6517 | if (i !== l - 1) {
|
6518 | next = item.charAt(item.length - 1) === '\n';
|
6519 | if (!loose) { loose = next; }
|
6520 | }
|
6521 |
|
6522 | this$1.tokens.push({
|
6523 | type: loose
|
6524 | ? 'loose_item_start'
|
6525 | : 'list_item_start'
|
6526 | });
|
6527 |
|
6528 | // Recurse.
|
6529 | this$1.token(item, false, bq);
|
6530 |
|
6531 | this$1.tokens.push({
|
6532 | type: 'list_item_end'
|
6533 | });
|
6534 | }
|
6535 |
|
6536 | this$1.tokens.push({
|
6537 | type: 'list_end'
|
6538 | });
|
6539 |
|
6540 | continue;
|
6541 | }
|
6542 |
|
6543 | // html
|
6544 | if (cap = this$1.rules.html.exec(src)) {
|
6545 | src = src.substring(cap[0].length);
|
6546 | this$1.tokens.push({
|
6547 | type: this$1.options.sanitize
|
6548 | ? 'paragraph'
|
6549 | : 'html',
|
6550 | pre: !this$1.options.sanitizer
|
6551 | && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
6552 | text: cap[0]
|
6553 | });
|
6554 | continue;
|
6555 | }
|
6556 |
|
6557 | // def
|
6558 | if ((!bq && top) && (cap = this$1.rules.def.exec(src))) {
|
6559 | src = src.substring(cap[0].length);
|
6560 | this$1.tokens.links[cap[1].toLowerCase()] = {
|
6561 | href: cap[2],
|
6562 | title: cap[3]
|
6563 | };
|
6564 | continue;
|
6565 | }
|
6566 |
|
6567 | // table (gfm)
|
6568 | if (top && (cap = this$1.rules.table.exec(src))) {
|
6569 | src = src.substring(cap[0].length);
|
6570 |
|
6571 | item = {
|
6572 | type: 'table',
|
6573 | header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
|
6574 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
6575 | cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
|
6576 | };
|
6577 |
|
6578 | for (i = 0; i < item.align.length; i++) {
|
6579 | if (/^ *-+: *$/.test(item.align[i])) {
|
6580 | item.align[i] = 'right';
|
6581 | } else if (/^ *:-+: *$/.test(item.align[i])) {
|
6582 | item.align[i] = 'center';
|
6583 | } else if (/^ *:-+ *$/.test(item.align[i])) {
|
6584 | item.align[i] = 'left';
|
6585 | } else {
|
6586 | item.align[i] = null;
|
6587 | }
|
6588 | }
|
6589 |
|
6590 | for (i = 0; i < item.cells.length; i++) {
|
6591 | item.cells[i] = item.cells[i]
|
6592 | .replace(/^ *\| *| *\| *$/g, '')
|
6593 | .split(/ *\| */);
|
6594 | }
|
6595 |
|
6596 | this$1.tokens.push(item);
|
6597 |
|
6598 | continue;
|
6599 | }
|
6600 |
|
6601 | // top-level paragraph
|
6602 | if (top && (cap = this$1.rules.paragraph.exec(src))) {
|
6603 | src = src.substring(cap[0].length);
|
6604 | this$1.tokens.push({
|
6605 | type: 'paragraph',
|
6606 | text: cap[1].charAt(cap[1].length - 1) === '\n'
|
6607 | ? cap[1].slice(0, -1)
|
6608 | : cap[1]
|
6609 | });
|
6610 | continue;
|
6611 | }
|
6612 |
|
6613 | // text
|
6614 | if (cap = this$1.rules.text.exec(src)) {
|
6615 | // Top-level should never reach here.
|
6616 | src = src.substring(cap[0].length);
|
6617 | this$1.tokens.push({
|
6618 | type: 'text',
|
6619 | text: cap[0]
|
6620 | });
|
6621 | continue;
|
6622 | }
|
6623 |
|
6624 | if (src) {
|
6625 | throw new
|
6626 | Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
6627 | }
|
6628 | }
|
6629 |
|
6630 | return this.tokens;
|
6631 | };
|
6632 |
|
6633 | /**
|
6634 | * Inline-Level Grammar
|
6635 | */
|
6636 |
|
6637 | var inline = {
|
6638 | escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
|
6639 | autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
|
6640 | url: noop,
|
6641 | tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
|
6642 | link: /^!?\[(inside)\]\(href\)/,
|
6643 | reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
|
6644 | nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
|
6645 | strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
|
6646 | em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
|
6647 | code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
|
6648 | br: /^ {2,}\n(?!\s*$)/,
|
6649 | del: noop,
|
6650 | text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
|
6651 | };
|
6652 |
|
6653 | inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
|
6654 | inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
|
6655 |
|
6656 | inline.link = replace(inline.link)
|
6657 | ('inside', inline._inside)
|
6658 | ('href', inline._href)
|
6659 | ();
|
6660 |
|
6661 | inline.reflink = replace(inline.reflink)
|
6662 | ('inside', inline._inside)
|
6663 | ();
|
6664 |
|
6665 | /**
|
6666 | * Normal Inline Grammar
|
6667 | */
|
6668 |
|
6669 | inline.normal = merge({}, inline);
|
6670 |
|
6671 | /**
|
6672 | * Pedantic Inline Grammar
|
6673 | */
|
6674 |
|
6675 | inline.pedantic = merge({}, inline.normal, {
|
6676 | strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
6677 | em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
|
6678 | });
|
6679 |
|
6680 | /**
|
6681 | * GFM Inline Grammar
|
6682 | */
|
6683 |
|
6684 | inline.gfm = merge({}, inline.normal, {
|
6685 | escape: replace(inline.escape)('])', '~|])')(),
|
6686 | url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
|
6687 | del: /^~~(?=\S)([\s\S]*?\S)~~/,
|
6688 | text: replace(inline.text)
|
6689 | (']|', '~]|')
|
6690 | ('|', '|https?://|')
|
6691 | ()
|
6692 | });
|
6693 |
|
6694 | /**
|
6695 | * GFM + Line Breaks Inline Grammar
|
6696 | */
|
6697 |
|
6698 | inline.breaks = merge({}, inline.gfm, {
|
6699 | br: replace(inline.br)('{2,}', '*')(),
|
6700 | text: replace(inline.gfm.text)('{2,}', '*')()
|
6701 | });
|
6702 |
|
6703 | /**
|
6704 | * Inline Lexer & Compiler
|
6705 | */
|
6706 |
|
6707 | function InlineLexer(links, options) {
|
6708 | this.options = options || marked.defaults;
|
6709 | this.links = links;
|
6710 | this.rules = inline.normal;
|
6711 | this.renderer = this.options.renderer || new Renderer;
|
6712 | this.renderer.options = this.options;
|
6713 |
|
6714 | if (!this.links) {
|
6715 | throw new
|
6716 | Error('Tokens array requires a `links` property.');
|
6717 | }
|
6718 |
|
6719 | if (this.options.gfm) {
|
6720 | if (this.options.breaks) {
|
6721 | this.rules = inline.breaks;
|
6722 | } else {
|
6723 | this.rules = inline.gfm;
|
6724 | }
|
6725 | } else if (this.options.pedantic) {
|
6726 | this.rules = inline.pedantic;
|
6727 | }
|
6728 | }
|
6729 |
|
6730 | /**
|
6731 | * Expose Inline Rules
|
6732 | */
|
6733 |
|
6734 | InlineLexer.rules = inline;
|
6735 |
|
6736 | /**
|
6737 | * Static Lexing/Compiling Method
|
6738 | */
|
6739 |
|
6740 | InlineLexer.output = function(src, links, options) {
|
6741 | var inline = new InlineLexer(links, options);
|
6742 | return inline.output(src);
|
6743 | };
|
6744 |
|
6745 | /**
|
6746 | * Lexing/Compiling
|
6747 | */
|
6748 |
|
6749 | InlineLexer.prototype.output = function(src) {
|
6750 | var this$1 = this;
|
6751 |
|
6752 | var out = ''
|
6753 | , link
|
6754 | , text
|
6755 | , href
|
6756 | , cap;
|
6757 |
|
6758 | while (src) {
|
6759 | // escape
|
6760 | if (cap = this$1.rules.escape.exec(src)) {
|
6761 | src = src.substring(cap[0].length);
|
6762 | out += cap[1];
|
6763 | continue;
|
6764 | }
|
6765 |
|
6766 | // autolink
|
6767 | if (cap = this$1.rules.autolink.exec(src)) {
|
6768 | src = src.substring(cap[0].length);
|
6769 | if (cap[2] === '@') {
|
6770 | text = cap[1].charAt(6) === ':'
|
6771 | ? this$1.mangle(cap[1].substring(7))
|
6772 | : this$1.mangle(cap[1]);
|
6773 | href = this$1.mangle('mailto:') + text;
|
6774 | } else {
|
6775 | text = escape(cap[1]);
|
6776 | href = text;
|
6777 | }
|
6778 | out += this$1.renderer.link(href, null, text);
|
6779 | continue;
|
6780 | }
|
6781 |
|
6782 | // url (gfm)
|
6783 | if (!this$1.inLink && (cap = this$1.rules.url.exec(src))) {
|
6784 | src = src.substring(cap[0].length);
|
6785 | text = escape(cap[1]);
|
6786 | href = text;
|
6787 | out += this$1.renderer.link(href, null, text);
|
6788 | continue;
|
6789 | }
|
6790 |
|
6791 | // tag
|
6792 | if (cap = this$1.rules.tag.exec(src)) {
|
6793 | if (!this$1.inLink && /^<a /i.test(cap[0])) {
|
6794 | this$1.inLink = true;
|
6795 | } else if (this$1.inLink && /^<\/a>/i.test(cap[0])) {
|
6796 | this$1.inLink = false;
|
6797 | }
|
6798 | src = src.substring(cap[0].length);
|
6799 | out += this$1.options.sanitize
|
6800 | ? this$1.options.sanitizer
|
6801 | ? this$1.options.sanitizer(cap[0])
|
6802 | : escape(cap[0])
|
6803 | : cap[0];
|
6804 | continue;
|
6805 | }
|
6806 |
|
6807 | // link
|
6808 | if (cap = this$1.rules.link.exec(src)) {
|
6809 | src = src.substring(cap[0].length);
|
6810 | this$1.inLink = true;
|
6811 | out += this$1.outputLink(cap, {
|
6812 | href: cap[2],
|
6813 | title: cap[3]
|
6814 | });
|
6815 | this$1.inLink = false;
|
6816 | continue;
|
6817 | }
|
6818 |
|
6819 | // reflink, nolink
|
6820 | if ((cap = this$1.rules.reflink.exec(src))
|
6821 | || (cap = this$1.rules.nolink.exec(src))) {
|
6822 | src = src.substring(cap[0].length);
|
6823 | link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
6824 | link = this$1.links[link.toLowerCase()];
|
6825 | if (!link || !link.href) {
|
6826 | out += cap[0].charAt(0);
|
6827 | src = cap[0].substring(1) + src;
|
6828 | continue;
|
6829 | }
|
6830 | this$1.inLink = true;
|
6831 | out += this$1.outputLink(cap, link);
|
6832 | this$1.inLink = false;
|
6833 | continue;
|
6834 | }
|
6835 |
|
6836 | // strong
|
6837 | if (cap = this$1.rules.strong.exec(src)) {
|
6838 | src = src.substring(cap[0].length);
|
6839 | out += this$1.renderer.strong(this$1.output(cap[2] || cap[1]));
|
6840 | continue;
|
6841 | }
|
6842 |
|
6843 | // em
|
6844 | if (cap = this$1.rules.em.exec(src)) {
|
6845 | src = src.substring(cap[0].length);
|
6846 | out += this$1.renderer.em(this$1.output(cap[2] || cap[1]));
|
6847 | continue;
|
6848 | }
|
6849 |
|
6850 | // code
|
6851 | if (cap = this$1.rules.code.exec(src)) {
|
6852 | src = src.substring(cap[0].length);
|
6853 | out += this$1.renderer.codespan(escape(cap[2], true));
|
6854 | continue;
|
6855 | }
|
6856 |
|
6857 | // br
|
6858 | if (cap = this$1.rules.br.exec(src)) {
|
6859 | src = src.substring(cap[0].length);
|
6860 | out += this$1.renderer.br();
|
6861 | continue;
|
6862 | }
|
6863 |
|
6864 | // del (gfm)
|
6865 | if (cap = this$1.rules.del.exec(src)) {
|
6866 | src = src.substring(cap[0].length);
|
6867 | out += this$1.renderer.del(this$1.output(cap[1]));
|
6868 | continue;
|
6869 | }
|
6870 |
|
6871 | // text
|
6872 | if (cap = this$1.rules.text.exec(src)) {
|
6873 | src = src.substring(cap[0].length);
|
6874 | out += this$1.renderer.text(escape(this$1.smartypants(cap[0])));
|
6875 | continue;
|
6876 | }
|
6877 |
|
6878 | if (src) {
|
6879 | throw new
|
6880 | Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
6881 | }
|
6882 | }
|
6883 |
|
6884 | return out;
|
6885 | };
|
6886 |
|
6887 | /**
|
6888 | * Compile Link
|
6889 | */
|
6890 |
|
6891 | InlineLexer.prototype.outputLink = function(cap, link) {
|
6892 | var href = escape(link.href)
|
6893 | , title = link.title ? escape(link.title) : null;
|
6894 |
|
6895 | return cap[0].charAt(0) !== '!'
|
6896 | ? this.renderer.link(href, title, this.output(cap[1]))
|
6897 | : this.renderer.image(href, title, escape(cap[1]));
|
6898 | };
|
6899 |
|
6900 | /**
|
6901 | * Smartypants Transformations
|
6902 | */
|
6903 |
|
6904 | InlineLexer.prototype.smartypants = function(text) {
|
6905 | if (!this.options.smartypants) { return text; }
|
6906 | return text
|
6907 | // em-dashes
|
6908 | .replace(/---/g, '\u2014')
|
6909 | // en-dashes
|
6910 | .replace(/--/g, '\u2013')
|
6911 | // opening singles
|
6912 | .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
|
6913 | // closing singles & apostrophes
|
6914 | .replace(/'/g, '\u2019')
|
6915 | // opening doubles
|
6916 | .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
|
6917 | // closing doubles
|
6918 | .replace(/"/g, '\u201d')
|
6919 | // ellipses
|
6920 | .replace(/\.{3}/g, '\u2026');
|
6921 | };
|
6922 |
|
6923 | /**
|
6924 | * Mangle Links
|
6925 | */
|
6926 |
|
6927 | InlineLexer.prototype.mangle = function(text) {
|
6928 | if (!this.options.mangle) { return text; }
|
6929 | var out = ''
|
6930 | , l = text.length
|
6931 | , i = 0
|
6932 | , ch;
|
6933 |
|
6934 | for (; i < l; i++) {
|
6935 | ch = text.charCodeAt(i);
|
6936 | if (Math.random() > 0.5) {
|
6937 | ch = 'x' + ch.toString(16);
|
6938 | }
|
6939 | out += '&#' + ch + ';';
|
6940 | }
|
6941 |
|
6942 | return out;
|
6943 | };
|
6944 |
|
6945 | /**
|
6946 | * Renderer
|
6947 | */
|
6948 |
|
6949 | function Renderer(options) {
|
6950 | this.options = options || {};
|
6951 | }
|
6952 |
|
6953 | Renderer.prototype.code = function(code, lang, escaped) {
|
6954 | if (this.options.highlight) {
|
6955 | var out = this.options.highlight(code, lang);
|
6956 | if (out != null && out !== code) {
|
6957 | escaped = true;
|
6958 | code = out;
|
6959 | }
|
6960 | }
|
6961 |
|
6962 | if (!lang) {
|
6963 | return '<pre><code>'
|
6964 | + (escaped ? code : escape(code, true))
|
6965 | + '\n</code></pre>';
|
6966 | }
|
6967 |
|
6968 | return '<pre><code class="'
|
6969 | + this.options.langPrefix
|
6970 | + escape(lang, true)
|
6971 | + '">'
|
6972 | + (escaped ? code : escape(code, true))
|
6973 | + '\n</code></pre>\n';
|
6974 | };
|
6975 |
|
6976 | Renderer.prototype.blockquote = function(quote) {
|
6977 | return '<blockquote>\n' + quote + '</blockquote>\n';
|
6978 | };
|
6979 |
|
6980 | Renderer.prototype.html = function(html) {
|
6981 | return html;
|
6982 | };
|
6983 |
|
6984 | Renderer.prototype.heading = function(text, level, raw) {
|
6985 | return '<h'
|
6986 | + level
|
6987 | + ' id="'
|
6988 | + this.options.headerPrefix
|
6989 | + raw.toLowerCase().replace(/[^\w]+/g, '-')
|
6990 | + '">'
|
6991 | + text
|
6992 | + '</h'
|
6993 | + level
|
6994 | + '>\n';
|
6995 | };
|
6996 |
|
6997 | Renderer.prototype.hr = function() {
|
6998 | return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
6999 | };
|
7000 |
|
7001 | Renderer.prototype.list = function(body, ordered) {
|
7002 | var type = ordered ? 'ol' : 'ul';
|
7003 | return '<' + type + '>\n' + body + '</' + type + '>\n';
|
7004 | };
|
7005 |
|
7006 | Renderer.prototype.listitem = function(text) {
|
7007 | return '<li>' + text + '</li>\n';
|
7008 | };
|
7009 |
|
7010 | Renderer.prototype.paragraph = function(text) {
|
7011 | return '<p>' + text + '</p>\n';
|
7012 | };
|
7013 |
|
7014 | Renderer.prototype.table = function(header, body) {
|
7015 | return '<table>\n'
|
7016 | + '<thead>\n'
|
7017 | + header
|
7018 | + '</thead>\n'
|
7019 | + '<tbody>\n'
|
7020 | + body
|
7021 | + '</tbody>\n'
|
7022 | + '</table>\n';
|
7023 | };
|
7024 |
|
7025 | Renderer.prototype.tablerow = function(content) {
|
7026 | return '<tr>\n' + content + '</tr>\n';
|
7027 | };
|
7028 |
|
7029 | Renderer.prototype.tablecell = function(content, flags) {
|
7030 | var type = flags.header ? 'th' : 'td';
|
7031 | var tag = flags.align
|
7032 | ? '<' + type + ' style="text-align:' + flags.align + '">'
|
7033 | : '<' + type + '>';
|
7034 | return tag + content + '</' + type + '>\n';
|
7035 | };
|
7036 |
|
7037 | // span level renderer
|
7038 | Renderer.prototype.strong = function(text) {
|
7039 | return '<strong>' + text + '</strong>';
|
7040 | };
|
7041 |
|
7042 | Renderer.prototype.em = function(text) {
|
7043 | return '<em>' + text + '</em>';
|
7044 | };
|
7045 |
|
7046 | Renderer.prototype.codespan = function(text) {
|
7047 | return '<code>' + text + '</code>';
|
7048 | };
|
7049 |
|
7050 | Renderer.prototype.br = function() {
|
7051 | return this.options.xhtml ? '<br/>' : '<br>';
|
7052 | };
|
7053 |
|
7054 | Renderer.prototype.del = function(text) {
|
7055 | return '<del>' + text + '</del>';
|
7056 | };
|
7057 |
|
7058 | Renderer.prototype.link = function(href, title, text) {
|
7059 | if (this.options.sanitize) {
|
7060 | try {
|
7061 | var prot = decodeURIComponent(unescape(href))
|
7062 | .replace(/[^\w:]/g, '')
|
7063 | .toLowerCase();
|
7064 | } catch (e) {
|
7065 | return '';
|
7066 | }
|
7067 | if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) {
|
7068 | return '';
|
7069 | }
|
7070 | }
|
7071 | var out = '<a href="' + href + '"';
|
7072 | if (title) {
|
7073 | out += ' title="' + title + '"';
|
7074 | }
|
7075 | out += '>' + text + '</a>';
|
7076 | return out;
|
7077 | };
|
7078 |
|
7079 | Renderer.prototype.image = function(href, title, text) {
|
7080 | var out = '<img src="' + href + '" alt="' + text + '"';
|
7081 | if (title) {
|
7082 | out += ' title="' + title + '"';
|
7083 | }
|
7084 | out += this.options.xhtml ? '/>' : '>';
|
7085 | return out;
|
7086 | };
|
7087 |
|
7088 | Renderer.prototype.text = function(text) {
|
7089 | return text;
|
7090 | };
|
7091 |
|
7092 | /**
|
7093 | * Parsing & Compiling
|
7094 | */
|
7095 |
|
7096 | function Parser(options) {
|
7097 | this.tokens = [];
|
7098 | this.token = null;
|
7099 | this.options = options || marked.defaults;
|
7100 | this.options.renderer = this.options.renderer || new Renderer;
|
7101 | this.renderer = this.options.renderer;
|
7102 | this.renderer.options = this.options;
|
7103 | }
|
7104 |
|
7105 | /**
|
7106 | * Static Parse Method
|
7107 | */
|
7108 |
|
7109 | Parser.parse = function(src, options, renderer) {
|
7110 | var parser = new Parser(options, renderer);
|
7111 | return parser.parse(src);
|
7112 | };
|
7113 |
|
7114 | /**
|
7115 | * Parse Loop
|
7116 | */
|
7117 |
|
7118 | Parser.prototype.parse = function(src) {
|
7119 | var this$1 = this;
|
7120 |
|
7121 | this.inline = new InlineLexer(src.links, this.options, this.renderer);
|
7122 | this.tokens = src.reverse();
|
7123 |
|
7124 | var out = '';
|
7125 | while (this.next()) {
|
7126 | out += this$1.tok();
|
7127 | }
|
7128 |
|
7129 | return out;
|
7130 | };
|
7131 |
|
7132 | /**
|
7133 | * Next Token
|
7134 | */
|
7135 |
|
7136 | Parser.prototype.next = function() {
|
7137 | return this.token = this.tokens.pop();
|
7138 | };
|
7139 |
|
7140 | /**
|
7141 | * Preview Next Token
|
7142 | */
|
7143 |
|
7144 | Parser.prototype.peek = function() {
|
7145 | return this.tokens[this.tokens.length - 1] || 0;
|
7146 | };
|
7147 |
|
7148 | /**
|
7149 | * Parse Text Tokens
|
7150 | */
|
7151 |
|
7152 | Parser.prototype.parseText = function() {
|
7153 | var this$1 = this;
|
7154 |
|
7155 | var body = this.token.text;
|
7156 |
|
7157 | while (this.peek().type === 'text') {
|
7158 | body += '\n' + this$1.next().text;
|
7159 | }
|
7160 |
|
7161 | return this.inline.output(body);
|
7162 | };
|
7163 |
|
7164 | /**
|
7165 | * Parse Current Token
|
7166 | */
|
7167 |
|
7168 | Parser.prototype.tok = function() {
|
7169 | var this$1 = this;
|
7170 |
|
7171 | switch (this.token.type) {
|
7172 | case 'space': {
|
7173 | return '';
|
7174 | }
|
7175 | case 'hr': {
|
7176 | return this.renderer.hr();
|
7177 | }
|
7178 | case 'heading': {
|
7179 | return this.renderer.heading(
|
7180 | this.inline.output(this.token.text),
|
7181 | this.token.depth,
|
7182 | this.token.text);
|
7183 | }
|
7184 | case 'code': {
|
7185 | return this.renderer.code(this.token.text,
|
7186 | this.token.lang,
|
7187 | this.token.escaped);
|
7188 | }
|
7189 | case 'table': {
|
7190 | var header = ''
|
7191 | , body = ''
|
7192 | , i
|
7193 | , row
|
7194 | , cell
|
7195 | , flags
|
7196 | , j;
|
7197 |
|
7198 | // header
|
7199 | cell = '';
|
7200 | for (i = 0; i < this.token.header.length; i++) {
|
7201 | flags = { header: true, align: this$1.token.align[i] };
|
7202 | cell += this$1.renderer.tablecell(
|
7203 | this$1.inline.output(this$1.token.header[i]),
|
7204 | { header: true, align: this$1.token.align[i] }
|
7205 | );
|
7206 | }
|
7207 | header += this.renderer.tablerow(cell);
|
7208 |
|
7209 | for (i = 0; i < this.token.cells.length; i++) {
|
7210 | row = this$1.token.cells[i];
|
7211 |
|
7212 | cell = '';
|
7213 | for (j = 0; j < row.length; j++) {
|
7214 | cell += this$1.renderer.tablecell(
|
7215 | this$1.inline.output(row[j]),
|
7216 | { header: false, align: this$1.token.align[j] }
|
7217 | );
|
7218 | }
|
7219 |
|
7220 | body += this$1.renderer.tablerow(cell);
|
7221 | }
|
7222 | return this.renderer.table(header, body);
|
7223 | }
|
7224 | case 'blockquote_start': {
|
7225 | var body = '';
|
7226 |
|
7227 | while (this.next().type !== 'blockquote_end') {
|
7228 | body += this$1.tok();
|
7229 | }
|
7230 |
|
7231 | return this.renderer.blockquote(body);
|
7232 | }
|
7233 | case 'list_start': {
|
7234 | var body = ''
|
7235 | , ordered = this.token.ordered;
|
7236 |
|
7237 | while (this.next().type !== 'list_end') {
|
7238 | body += this$1.tok();
|
7239 | }
|
7240 |
|
7241 | return this.renderer.list(body, ordered);
|
7242 | }
|
7243 | case 'list_item_start': {
|
7244 | var body = '';
|
7245 |
|
7246 | while (this.next().type !== 'list_item_end') {
|
7247 | body += this$1.token.type === 'text'
|
7248 | ? this$1.parseText()
|
7249 | : this$1.tok();
|
7250 | }
|
7251 |
|
7252 | return this.renderer.listitem(body);
|
7253 | }
|
7254 | case 'loose_item_start': {
|
7255 | var body = '';
|
7256 |
|
7257 | while (this.next().type !== 'list_item_end') {
|
7258 | body += this$1.tok();
|
7259 | }
|
7260 |
|
7261 | return this.renderer.listitem(body);
|
7262 | }
|
7263 | case 'html': {
|
7264 | var html = !this.token.pre && !this.options.pedantic
|
7265 | ? this.inline.output(this.token.text)
|
7266 | : this.token.text;
|
7267 | return this.renderer.html(html);
|
7268 | }
|
7269 | case 'paragraph': {
|
7270 | return this.renderer.paragraph(this.inline.output(this.token.text));
|
7271 | }
|
7272 | case 'text': {
|
7273 | return this.renderer.paragraph(this.parseText());
|
7274 | }
|
7275 | }
|
7276 | };
|
7277 |
|
7278 | /**
|
7279 | * Helpers
|
7280 | */
|
7281 |
|
7282 | function escape(html, encode) {
|
7283 | return html
|
7284 | .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
|
7285 | .replace(/</g, '<')
|
7286 | .replace(/>/g, '>')
|
7287 | .replace(/"/g, '"')
|
7288 | .replace(/'/g, ''');
|
7289 | }
|
7290 |
|
7291 | function unescape(html) {
|
7292 | // explicitly match decimal, hex, and named HTML entities
|
7293 | return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
|
7294 | n = n.toLowerCase();
|
7295 | if (n === 'colon') { return ':'; }
|
7296 | if (n.charAt(0) === '#') {
|
7297 | return n.charAt(1) === 'x'
|
7298 | ? String.fromCharCode(parseInt(n.substring(2), 16))
|
7299 | : String.fromCharCode(+n.substring(1));
|
7300 | }
|
7301 | return '';
|
7302 | });
|
7303 | }
|
7304 |
|
7305 | function replace(regex, opt) {
|
7306 | regex = regex.source;
|
7307 | opt = opt || '';
|
7308 | return function self(name, val) {
|
7309 | if (!name) { return new RegExp(regex, opt); }
|
7310 | val = val.source || val;
|
7311 | val = val.replace(/(^|[^\[])\^/g, '$1');
|
7312 | regex = regex.replace(name, val);
|
7313 | return self;
|
7314 | };
|
7315 | }
|
7316 |
|
7317 | function noop() {}
|
7318 | noop.exec = noop;
|
7319 |
|
7320 | function merge(obj) {
|
7321 | var arguments$1 = arguments;
|
7322 |
|
7323 | var i = 1
|
7324 | , target
|
7325 | , key;
|
7326 |
|
7327 | for (; i < arguments.length; i++) {
|
7328 | target = arguments$1[i];
|
7329 | for (key in target) {
|
7330 | if (Object.prototype.hasOwnProperty.call(target, key)) {
|
7331 | obj[key] = target[key];
|
7332 | }
|
7333 | }
|
7334 | }
|
7335 |
|
7336 | return obj;
|
7337 | }
|
7338 |
|
7339 |
|
7340 | /**
|
7341 | * Marked
|
7342 | */
|
7343 |
|
7344 | function marked(src, opt, callback) {
|
7345 | if (callback || typeof opt === 'function') {
|
7346 | if (!callback) {
|
7347 | callback = opt;
|
7348 | opt = null;
|
7349 | }
|
7350 |
|
7351 | opt = merge({}, marked.defaults, opt || {});
|
7352 |
|
7353 | var highlight = opt.highlight
|
7354 | , tokens
|
7355 | , pending
|
7356 | , i = 0;
|
7357 |
|
7358 | try {
|
7359 | tokens = Lexer.lex(src, opt);
|
7360 | } catch (e) {
|
7361 | return callback(e);
|
7362 | }
|
7363 |
|
7364 | pending = tokens.length;
|
7365 |
|
7366 | var done = function(err) {
|
7367 | if (err) {
|
7368 | opt.highlight = highlight;
|
7369 | return callback(err);
|
7370 | }
|
7371 |
|
7372 | var out;
|
7373 |
|
7374 | try {
|
7375 | out = Parser.parse(tokens, opt);
|
7376 | } catch (e) {
|
7377 | err = e;
|
7378 | }
|
7379 |
|
7380 | opt.highlight = highlight;
|
7381 |
|
7382 | return err
|
7383 | ? callback(err)
|
7384 | : callback(null, out);
|
7385 | };
|
7386 |
|
7387 | if (!highlight || highlight.length < 3) {
|
7388 | return done();
|
7389 | }
|
7390 |
|
7391 | delete opt.highlight;
|
7392 |
|
7393 | if (!pending) { return done(); }
|
7394 |
|
7395 | for (; i < tokens.length; i++) {
|
7396 | (function(token) {
|
7397 | if (token.type !== 'code') {
|
7398 | return --pending || done();
|
7399 | }
|
7400 | return highlight(token.text, token.lang, function(err, code) {
|
7401 | if (err) { return done(err); }
|
7402 | if (code == null || code === token.text) {
|
7403 | return --pending || done();
|
7404 | }
|
7405 | token.text = code;
|
7406 | token.escaped = true;
|
7407 | --pending || done();
|
7408 | });
|
7409 | })(tokens[i]);
|
7410 | }
|
7411 |
|
7412 | return;
|
7413 | }
|
7414 | try {
|
7415 | if (opt) { opt = merge({}, marked.defaults, opt); }
|
7416 | return Parser.parse(Lexer.lex(src, opt), opt);
|
7417 | } catch (e) {
|
7418 | e.message += '\nPlease report this to https://github.com/chjj/marked.';
|
7419 | if ((opt || marked.defaults).silent) {
|
7420 | return '<p>An error occured:</p><pre>'
|
7421 | + escape(e.message + '', true)
|
7422 | + '</pre>';
|
7423 | }
|
7424 | throw e;
|
7425 | }
|
7426 | }
|
7427 |
|
7428 | /**
|
7429 | * Options
|
7430 | */
|
7431 |
|
7432 | marked.options =
|
7433 | marked.setOptions = function(opt) {
|
7434 | merge(marked.defaults, opt);
|
7435 | return marked;
|
7436 | };
|
7437 |
|
7438 | marked.defaults = {
|
7439 | gfm: true,
|
7440 | tables: true,
|
7441 | breaks: false,
|
7442 | pedantic: false,
|
7443 | sanitize: false,
|
7444 | sanitizer: null,
|
7445 | mangle: true,
|
7446 | smartLists: false,
|
7447 | silent: false,
|
7448 | highlight: null,
|
7449 | langPrefix: 'lang-',
|
7450 | smartypants: false,
|
7451 | headerPrefix: '',
|
7452 | renderer: new Renderer,
|
7453 | xhtml: false
|
7454 | };
|
7455 |
|
7456 | /**
|
7457 | * Expose
|
7458 | */
|
7459 |
|
7460 | marked.Parser = Parser;
|
7461 | marked.parser = Parser.parse;
|
7462 |
|
7463 | marked.Renderer = Renderer;
|
7464 |
|
7465 | marked.Lexer = Lexer;
|
7466 | marked.lexer = Lexer.lex;
|
7467 |
|
7468 | marked.InlineLexer = InlineLexer;
|
7469 | marked.inlineLexer = InlineLexer.output;
|
7470 |
|
7471 | marked.parse = marked;
|
7472 |
|
7473 | if ('object' !== 'undefined' && 'object' === 'object') {
|
7474 | module.exports = marked;
|
7475 | } else if (typeof undefined === 'function' && undefined.amd) {
|
7476 | undefined(function() { return marked; });
|
7477 | } else {
|
7478 | this.marked = marked;
|
7479 | }
|
7480 |
|
7481 | }).call(function() {
|
7482 | return this || (typeof window !== 'undefined' ? window : commonjsGlobal);
|
7483 | }());
|
7484 | });
|
7485 |
|
7486 | marked.setOptions({
|
7487 | gfm: true,
|
7488 | smartypants: true
|
7489 | });
|
7490 |
|
7491 | var markdown = function(dom, data) {
|
7492 | var markdownElements = [].slice.call(dom.querySelectorAll('[markdown]'));
|
7493 | markdownElements.forEach(function (el) {
|
7494 | var content = el.innerHTML;
|
7495 | // Set default indents
|
7496 | content = content.replace(/\n/, "");
|
7497 | var tabs = content.match(/\s*/);
|
7498 | content = content.replace(new RegExp("\n" + tabs, "g"), "\n");
|
7499 | content = content.trim();
|
7500 |
|
7501 | el.innerHTML = marked(content);
|
7502 | });
|
7503 | };
|
7504 |
|
7505 | var prism = createCommonjsModule(function (module) {
|
7506 | /* **********************************************
|
7507 | Begin prism-core.js
|
7508 | ********************************************** */
|
7509 |
|
7510 | var _self = (typeof window !== 'undefined')
|
7511 | ? window // if in browser
|
7512 | : (
|
7513 | (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
|
7514 | ? self // if in worker
|
7515 | : {} // if in node js
|
7516 | );
|
7517 |
|
7518 | /**
|
7519 | * Prism: Lightweight, robust, elegant syntax highlighting
|
7520 | * MIT license http://www.opensource.org/licenses/mit-license.php/
|
7521 | * @author Lea Verou http://lea.verou.me
|
7522 | */
|
7523 |
|
7524 | var Prism = (function(){
|
7525 |
|
7526 | // Private helper vars
|
7527 | var lang = /\blang(?:uage)?-(\w+)\b/i;
|
7528 | var uniqueId = 0;
|
7529 |
|
7530 | var _ = _self.Prism = {
|
7531 | util: {
|
7532 | encode: function (tokens) {
|
7533 | if (tokens instanceof Token) {
|
7534 | return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
|
7535 | } else if (_.util.type(tokens) === 'Array') {
|
7536 | return tokens.map(_.util.encode);
|
7537 | } else {
|
7538 | return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
|
7539 | }
|
7540 | },
|
7541 |
|
7542 | type: function (o) {
|
7543 | return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
|
7544 | },
|
7545 |
|
7546 | objId: function (obj) {
|
7547 | if (!obj['__id']) {
|
7548 | Object.defineProperty(obj, '__id', { value: ++uniqueId });
|
7549 | }
|
7550 | return obj['__id'];
|
7551 | },
|
7552 |
|
7553 | // Deep clone a language definition (e.g. to extend it)
|
7554 | clone: function (o) {
|
7555 | var type = _.util.type(o);
|
7556 |
|
7557 | switch (type) {
|
7558 | case 'Object':
|
7559 | var clone = {};
|
7560 |
|
7561 | for (var key in o) {
|
7562 | if (o.hasOwnProperty(key)) {
|
7563 | clone[key] = _.util.clone(o[key]);
|
7564 | }
|
7565 | }
|
7566 |
|
7567 | return clone;
|
7568 |
|
7569 | case 'Array':
|
7570 | // Check for existence for IE8
|
7571 | return o.map && o.map(function(v) { return _.util.clone(v); });
|
7572 | }
|
7573 |
|
7574 | return o;
|
7575 | }
|
7576 | },
|
7577 |
|
7578 | languages: {
|
7579 | extend: function (id, redef) {
|
7580 | var lang = _.util.clone(_.languages[id]);
|
7581 |
|
7582 | for (var key in redef) {
|
7583 | lang[key] = redef[key];
|
7584 | }
|
7585 |
|
7586 | return lang;
|
7587 | },
|
7588 |
|
7589 | /**
|
7590 | * Insert a token before another token in a language literal
|
7591 | * As this needs to recreate the object (we cannot actually insert before keys in object literals),
|
7592 | * we cannot just provide an object, we need anobject and a key.
|
7593 | * @param inside The key (or language id) of the parent
|
7594 | * @param before The key to insert before. If not provided, the function appends instead.
|
7595 | * @param insert Object with the key/value pairs to insert
|
7596 | * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
|
7597 | */
|
7598 | insertBefore: function (inside, before, insert, root) {
|
7599 | root = root || _.languages;
|
7600 | var grammar = root[inside];
|
7601 |
|
7602 | if (arguments.length == 2) {
|
7603 | insert = arguments[1];
|
7604 |
|
7605 | for (var newToken in insert) {
|
7606 | if (insert.hasOwnProperty(newToken)) {
|
7607 | grammar[newToken] = insert[newToken];
|
7608 | }
|
7609 | }
|
7610 |
|
7611 | return grammar;
|
7612 | }
|
7613 |
|
7614 | var ret = {};
|
7615 |
|
7616 | for (var token in grammar) {
|
7617 |
|
7618 | if (grammar.hasOwnProperty(token)) {
|
7619 |
|
7620 | if (token == before) {
|
7621 |
|
7622 | for (var newToken in insert) {
|
7623 |
|
7624 | if (insert.hasOwnProperty(newToken)) {
|
7625 | ret[newToken] = insert[newToken];
|
7626 | }
|
7627 | }
|
7628 | }
|
7629 |
|
7630 | ret[token] = grammar[token];
|
7631 | }
|
7632 | }
|
7633 |
|
7634 | // Update references in other language definitions
|
7635 | _.languages.DFS(_.languages, function(key, value) {
|
7636 | if (value === root[inside] && key != inside) {
|
7637 | this[key] = ret;
|
7638 | }
|
7639 | });
|
7640 |
|
7641 | return root[inside] = ret;
|
7642 | },
|
7643 |
|
7644 | // Traverse a language definition with Depth First Search
|
7645 | DFS: function(o, callback, type, visited) {
|
7646 | visited = visited || {};
|
7647 | for (var i in o) {
|
7648 | if (o.hasOwnProperty(i)) {
|
7649 | callback.call(o, i, o[i], type || i);
|
7650 |
|
7651 | if (_.util.type(o[i]) === 'Object' && !visited[_.util.objId(o[i])]) {
|
7652 | visited[_.util.objId(o[i])] = true;
|
7653 | _.languages.DFS(o[i], callback, null, visited);
|
7654 | }
|
7655 | else if (_.util.type(o[i]) === 'Array' && !visited[_.util.objId(o[i])]) {
|
7656 | visited[_.util.objId(o[i])] = true;
|
7657 | _.languages.DFS(o[i], callback, i, visited);
|
7658 | }
|
7659 | }
|
7660 | }
|
7661 | }
|
7662 | },
|
7663 | plugins: {},
|
7664 |
|
7665 | highlightAll: function(async, callback) {
|
7666 | var env = {
|
7667 | callback: callback,
|
7668 | selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
7669 | };
|
7670 |
|
7671 | _.hooks.run("before-highlightall", env);
|
7672 |
|
7673 | var elements = env.elements || document.querySelectorAll(env.selector);
|
7674 |
|
7675 | for (var i=0, element; element = elements[i++];) {
|
7676 | _.highlightElement(element, async === true, env.callback);
|
7677 | }
|
7678 | },
|
7679 |
|
7680 | highlightElement: function(element, async, callback) {
|
7681 | // Find language
|
7682 | var language, grammar, parent = element;
|
7683 |
|
7684 | while (parent && !lang.test(parent.className)) {
|
7685 | parent = parent.parentNode;
|
7686 | }
|
7687 |
|
7688 | if (parent) {
|
7689 | language = (parent.className.match(lang) || [,''])[1].toLowerCase();
|
7690 | grammar = _.languages[language];
|
7691 | }
|
7692 |
|
7693 | // Set language on the element, if not present
|
7694 | element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
|
7695 |
|
7696 | // Set language on the parent, for styling
|
7697 | parent = element.parentNode;
|
7698 |
|
7699 | if (/pre/i.test(parent.nodeName)) {
|
7700 | parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
|
7701 | }
|
7702 |
|
7703 | var code = element.textContent;
|
7704 |
|
7705 | var env = {
|
7706 | element: element,
|
7707 | language: language,
|
7708 | grammar: grammar,
|
7709 | code: code
|
7710 | };
|
7711 |
|
7712 | _.hooks.run('before-sanity-check', env);
|
7713 |
|
7714 | if (!env.code || !env.grammar) {
|
7715 | if (env.code) {
|
7716 | env.element.textContent = env.code;
|
7717 | }
|
7718 | _.hooks.run('complete', env);
|
7719 | return;
|
7720 | }
|
7721 |
|
7722 | _.hooks.run('before-highlight', env);
|
7723 |
|
7724 | if (async && _self.Worker) {
|
7725 | var worker = new Worker(_.filename);
|
7726 |
|
7727 | worker.onmessage = function(evt) {
|
7728 | env.highlightedCode = evt.data;
|
7729 |
|
7730 | _.hooks.run('before-insert', env);
|
7731 |
|
7732 | env.element.innerHTML = env.highlightedCode;
|
7733 |
|
7734 | callback && callback.call(env.element);
|
7735 | _.hooks.run('after-highlight', env);
|
7736 | _.hooks.run('complete', env);
|
7737 | };
|
7738 |
|
7739 | worker.postMessage(JSON.stringify({
|
7740 | language: env.language,
|
7741 | code: env.code,
|
7742 | immediateClose: true
|
7743 | }));
|
7744 | }
|
7745 | else {
|
7746 | env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
|
7747 |
|
7748 | _.hooks.run('before-insert', env);
|
7749 |
|
7750 | env.element.innerHTML = env.highlightedCode;
|
7751 |
|
7752 | callback && callback.call(element);
|
7753 |
|
7754 | _.hooks.run('after-highlight', env);
|
7755 | _.hooks.run('complete', env);
|
7756 | }
|
7757 | },
|
7758 |
|
7759 | highlight: function (text, grammar, language) {
|
7760 | var tokens = _.tokenize(text, grammar);
|
7761 | return Token.stringify(_.util.encode(tokens), language);
|
7762 | },
|
7763 |
|
7764 | tokenize: function(text, grammar, language) {
|
7765 | var Token = _.Token;
|
7766 |
|
7767 | var strarr = [text];
|
7768 |
|
7769 | var rest = grammar.rest;
|
7770 |
|
7771 | if (rest) {
|
7772 | for (var token in rest) {
|
7773 | grammar[token] = rest[token];
|
7774 | }
|
7775 |
|
7776 | delete grammar.rest;
|
7777 | }
|
7778 |
|
7779 | tokenloop: for (var token in grammar) {
|
7780 | if(!grammar.hasOwnProperty(token) || !grammar[token]) {
|
7781 | continue;
|
7782 | }
|
7783 |
|
7784 | var patterns = grammar[token];
|
7785 | patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
|
7786 |
|
7787 | for (var j = 0; j < patterns.length; ++j) {
|
7788 | var pattern = patterns[j],
|
7789 | inside = pattern.inside,
|
7790 | lookbehind = !!pattern.lookbehind,
|
7791 | greedy = !!pattern.greedy,
|
7792 | lookbehindLength = 0,
|
7793 | alias = pattern.alias;
|
7794 |
|
7795 | if (greedy && !pattern.pattern.global) {
|
7796 | // Without the global flag, lastIndex won't work
|
7797 | var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
|
7798 | pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
|
7799 | }
|
7800 |
|
7801 | pattern = pattern.pattern || pattern;
|
7802 |
|
7803 | // Don’t cache length as it changes during the loop
|
7804 | for (var i=0, pos = 0; i<strarr.length; pos += strarr[i].length, ++i) {
|
7805 |
|
7806 | var str = strarr[i];
|
7807 |
|
7808 | if (strarr.length > text.length) {
|
7809 | // Something went terribly wrong, ABORT, ABORT!
|
7810 | break tokenloop;
|
7811 | }
|
7812 |
|
7813 | if (str instanceof Token) {
|
7814 | continue;
|
7815 | }
|
7816 |
|
7817 | pattern.lastIndex = 0;
|
7818 |
|
7819 | var match = pattern.exec(str),
|
7820 | delNum = 1;
|
7821 |
|
7822 | // Greedy patterns can override/remove up to two previously matched tokens
|
7823 | if (!match && greedy && i != strarr.length - 1) {
|
7824 | pattern.lastIndex = pos;
|
7825 | match = pattern.exec(text);
|
7826 | if (!match) {
|
7827 | break;
|
7828 | }
|
7829 |
|
7830 | var from = match.index + (lookbehind ? match[1].length : 0),
|
7831 | to = match.index + match[0].length,
|
7832 | k = i,
|
7833 | p = pos;
|
7834 |
|
7835 | for (var len = strarr.length; k < len && p < to; ++k) {
|
7836 | p += strarr[k].length;
|
7837 | // Move the index i to the element in strarr that is closest to from
|
7838 | if (from >= p) {
|
7839 | ++i;
|
7840 | pos = p;
|
7841 | }
|
7842 | }
|
7843 |
|
7844 | /*
|
7845 | * If strarr[i] is a Token, then the match starts inside another Token, which is invalid
|
7846 | * If strarr[k - 1] is greedy we are in conflict with another greedy pattern
|
7847 | */
|
7848 | if (strarr[i] instanceof Token || strarr[k - 1].greedy) {
|
7849 | continue;
|
7850 | }
|
7851 |
|
7852 | // Number of tokens to delete and replace with the new match
|
7853 | delNum = k - i;
|
7854 | str = text.slice(pos, p);
|
7855 | match.index -= pos;
|
7856 | }
|
7857 |
|
7858 | if (!match) {
|
7859 | continue;
|
7860 | }
|
7861 |
|
7862 | if(lookbehind) {
|
7863 | lookbehindLength = match[1].length;
|
7864 | }
|
7865 |
|
7866 | var from = match.index + lookbehindLength,
|
7867 | match = match[0].slice(lookbehindLength),
|
7868 | to = from + match.length,
|
7869 | before = str.slice(0, from),
|
7870 | after = str.slice(to);
|
7871 |
|
7872 | var args = [i, delNum];
|
7873 |
|
7874 | if (before) {
|
7875 | args.push(before);
|
7876 | }
|
7877 |
|
7878 | var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
|
7879 |
|
7880 | args.push(wrapped);
|
7881 |
|
7882 | if (after) {
|
7883 | args.push(after);
|
7884 | }
|
7885 |
|
7886 | Array.prototype.splice.apply(strarr, args);
|
7887 | }
|
7888 | }
|
7889 | }
|
7890 |
|
7891 | return strarr;
|
7892 | },
|
7893 |
|
7894 | hooks: {
|
7895 | all: {},
|
7896 |
|
7897 | add: function (name, callback) {
|
7898 | var hooks = _.hooks.all;
|
7899 |
|
7900 | hooks[name] = hooks[name] || [];
|
7901 |
|
7902 | hooks[name].push(callback);
|
7903 | },
|
7904 |
|
7905 | run: function (name, env) {
|
7906 | var callbacks = _.hooks.all[name];
|
7907 |
|
7908 | if (!callbacks || !callbacks.length) {
|
7909 | return;
|
7910 | }
|
7911 |
|
7912 | for (var i=0, callback; callback = callbacks[i++];) {
|
7913 | callback(env);
|
7914 | }
|
7915 | }
|
7916 | }
|
7917 | };
|
7918 |
|
7919 | var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
|
7920 | this.type = type;
|
7921 | this.content = content;
|
7922 | this.alias = alias;
|
7923 | // Copy of the full string this token was created from
|
7924 | this.length = (matchedStr || "").length|0;
|
7925 | this.greedy = !!greedy;
|
7926 | };
|
7927 |
|
7928 | Token.stringify = function(o, language, parent) {
|
7929 | if (typeof o == 'string') {
|
7930 | return o;
|
7931 | }
|
7932 |
|
7933 | if (_.util.type(o) === 'Array') {
|
7934 | return o.map(function(element) {
|
7935 | return Token.stringify(element, language, o);
|
7936 | }).join('');
|
7937 | }
|
7938 |
|
7939 | var env = {
|
7940 | type: o.type,
|
7941 | content: Token.stringify(o.content, language, parent),
|
7942 | tag: 'span',
|
7943 | classes: ['token', o.type],
|
7944 | attributes: {},
|
7945 | language: language,
|
7946 | parent: parent
|
7947 | };
|
7948 |
|
7949 | if (env.type == 'comment') {
|
7950 | env.attributes['spellcheck'] = 'true';
|
7951 | }
|
7952 |
|
7953 | if (o.alias) {
|
7954 | var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
|
7955 | Array.prototype.push.apply(env.classes, aliases);
|
7956 | }
|
7957 |
|
7958 | _.hooks.run('wrap', env);
|
7959 |
|
7960 | var attributes = Object.keys(env.attributes).map(function(name) {
|
7961 | return name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"';
|
7962 | }).join(' ');
|
7963 |
|
7964 | return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
|
7965 |
|
7966 | };
|
7967 |
|
7968 | if (!_self.document) {
|
7969 | if (!_self.addEventListener) {
|
7970 | // in Node.js
|
7971 | return _self.Prism;
|
7972 | }
|
7973 | // In worker
|
7974 | _self.addEventListener('message', function(evt) {
|
7975 | var message = JSON.parse(evt.data),
|
7976 | lang = message.language,
|
7977 | code = message.code,
|
7978 | immediateClose = message.immediateClose;
|
7979 |
|
7980 | _self.postMessage(_.highlight(code, _.languages[lang], lang));
|
7981 | if (immediateClose) {
|
7982 | _self.close();
|
7983 | }
|
7984 | }, false);
|
7985 |
|
7986 | return _self.Prism;
|
7987 | }
|
7988 |
|
7989 | //Get current script and highlight
|
7990 | var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
|
7991 |
|
7992 | if (script) {
|
7993 | _.filename = script.src;
|
7994 |
|
7995 | if (document.addEventListener && !script.hasAttribute('data-manual')) {
|
7996 | if(document.readyState !== "loading") {
|
7997 | if (window.requestAnimationFrame) {
|
7998 | window.requestAnimationFrame(_.highlightAll);
|
7999 | } else {
|
8000 | window.setTimeout(_.highlightAll, 16);
|
8001 | }
|
8002 | }
|
8003 | else {
|
8004 | document.addEventListener('DOMContentLoaded', _.highlightAll);
|
8005 | }
|
8006 | }
|
8007 | }
|
8008 |
|
8009 | return _self.Prism;
|
8010 |
|
8011 | })();
|
8012 |
|
8013 | if ('object' !== 'undefined' && module.exports) {
|
8014 | module.exports = Prism;
|
8015 | }
|
8016 |
|
8017 | // hack for components to work correctly in node.js
|
8018 | if (typeof commonjsGlobal !== 'undefined') {
|
8019 | commonjsGlobal.Prism = Prism;
|
8020 | }
|
8021 |
|
8022 |
|
8023 | /* **********************************************
|
8024 | Begin prism-markup.js
|
8025 | ********************************************** */
|
8026 |
|
8027 | Prism.languages.markup = {
|
8028 | 'comment': /<!--[\w\W]*?-->/,
|
8029 | 'prolog': /<\?[\w\W]+?\?>/,
|
8030 | 'doctype': /<!DOCTYPE[\w\W]+?>/i,
|
8031 | 'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
|
8032 | 'tag': {
|
8033 | pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
|
8034 | inside: {
|
8035 | 'tag': {
|
8036 | pattern: /^<\/?[^\s>\/]+/i,
|
8037 | inside: {
|
8038 | 'punctuation': /^<\/?/,
|
8039 | 'namespace': /^[^\s>\/:]+:/
|
8040 | }
|
8041 | },
|
8042 | 'attr-value': {
|
8043 | pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,
|
8044 | inside: {
|
8045 | 'punctuation': /[=>"']/
|
8046 | }
|
8047 | },
|
8048 | 'punctuation': /\/?>/,
|
8049 | 'attr-name': {
|
8050 | pattern: /[^\s>\/]+/,
|
8051 | inside: {
|
8052 | 'namespace': /^[^\s>\/:]+:/
|
8053 | }
|
8054 | }
|
8055 |
|
8056 | }
|
8057 | },
|
8058 | 'entity': /&#?[\da-z]{1,8};/i
|
8059 | };
|
8060 |
|
8061 | // Plugin to make entity title show the real entity, idea by Roman Komarov
|
8062 | Prism.hooks.add('wrap', function(env) {
|
8063 |
|
8064 | if (env.type === 'entity') {
|
8065 | env.attributes['title'] = env.content.replace(/&/, '&');
|
8066 | }
|
8067 | });
|
8068 |
|
8069 | Prism.languages.xml = Prism.languages.markup;
|
8070 | Prism.languages.html = Prism.languages.markup;
|
8071 | Prism.languages.mathml = Prism.languages.markup;
|
8072 | Prism.languages.svg = Prism.languages.markup;
|
8073 |
|
8074 |
|
8075 | /* **********************************************
|
8076 | Begin prism-css.js
|
8077 | ********************************************** */
|
8078 |
|
8079 | Prism.languages.css = {
|
8080 | 'comment': /\/\*[\w\W]*?\*\//,
|
8081 | 'atrule': {
|
8082 | pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
|
8083 | inside: {
|
8084 | 'rule': /@[\w-]+/
|
8085 | // See rest below
|
8086 | }
|
8087 | },
|
8088 | 'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
|
8089 | 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
|
8090 | 'string': {
|
8091 | pattern: /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
|
8092 | greedy: true
|
8093 | },
|
8094 | 'property': /(\b|\B)[\w-]+(?=\s*:)/i,
|
8095 | 'important': /\B!important\b/i,
|
8096 | 'function': /[-a-z0-9]+(?=\()/i,
|
8097 | 'punctuation': /[(){};:]/
|
8098 | };
|
8099 |
|
8100 | Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
|
8101 |
|
8102 | if (Prism.languages.markup) {
|
8103 | Prism.languages.insertBefore('markup', 'tag', {
|
8104 | 'style': {
|
8105 | pattern: /(<style[\w\W]*?>)[\w\W]*?(?=<\/style>)/i,
|
8106 | lookbehind: true,
|
8107 | inside: Prism.languages.css,
|
8108 | alias: 'language-css'
|
8109 | }
|
8110 | });
|
8111 |
|
8112 | Prism.languages.insertBefore('inside', 'attr-value', {
|
8113 | 'style-attr': {
|
8114 | pattern: /\s*style=("|').*?\1/i,
|
8115 | inside: {
|
8116 | 'attr-name': {
|
8117 | pattern: /^\s*style/i,
|
8118 | inside: Prism.languages.markup.tag.inside
|
8119 | },
|
8120 | 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
|
8121 | 'attr-value': {
|
8122 | pattern: /.+/i,
|
8123 | inside: Prism.languages.css
|
8124 | }
|
8125 | },
|
8126 | alias: 'language-css'
|
8127 | }
|
8128 | }, Prism.languages.markup.tag);
|
8129 | }
|
8130 |
|
8131 | /* **********************************************
|
8132 | Begin prism-clike.js
|
8133 | ********************************************** */
|
8134 |
|
8135 | Prism.languages.clike = {
|
8136 | 'comment': [
|
8137 | {
|
8138 | pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
|
8139 | lookbehind: true
|
8140 | },
|
8141 | {
|
8142 | pattern: /(^|[^\\:])\/\/.*/,
|
8143 | lookbehind: true
|
8144 | }
|
8145 | ],
|
8146 | 'string': {
|
8147 | pattern: /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
8148 | greedy: true
|
8149 | },
|
8150 | 'class-name': {
|
8151 | pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
|
8152 | lookbehind: true,
|
8153 | inside: {
|
8154 | punctuation: /(\.|\\)/
|
8155 | }
|
8156 | },
|
8157 | 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
|
8158 | 'boolean': /\b(true|false)\b/,
|
8159 | 'function': /[a-z0-9_]+(?=\()/i,
|
8160 | 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
|
8161 | 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
|
8162 | 'punctuation': /[{}[\];(),.:]/
|
8163 | };
|
8164 |
|
8165 |
|
8166 | /* **********************************************
|
8167 | Begin prism-javascript.js
|
8168 | ********************************************** */
|
8169 |
|
8170 | Prism.languages.javascript = Prism.languages.extend('clike', {
|
8171 | '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/,
|
8172 | 'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
|
8173 | // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
8174 | 'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,
|
8175 | 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/
|
8176 | });
|
8177 |
|
8178 | Prism.languages.insertBefore('javascript', 'keyword', {
|
8179 | 'regex': {
|
8180 | pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
|
8181 | lookbehind: true,
|
8182 | greedy: true
|
8183 | }
|
8184 | });
|
8185 |
|
8186 | Prism.languages.insertBefore('javascript', 'string', {
|
8187 | 'template-string': {
|
8188 | pattern: /`(?:\\\\|\\?[^\\])*?`/,
|
8189 | greedy: true,
|
8190 | inside: {
|
8191 | 'interpolation': {
|
8192 | pattern: /\$\{[^}]+\}/,
|
8193 | inside: {
|
8194 | 'interpolation-punctuation': {
|
8195 | pattern: /^\$\{|\}$/,
|
8196 | alias: 'punctuation'
|
8197 | },
|
8198 | rest: Prism.languages.javascript
|
8199 | }
|
8200 | },
|
8201 | 'string': /[\s\S]+/
|
8202 | }
|
8203 | }
|
8204 | });
|
8205 |
|
8206 | if (Prism.languages.markup) {
|
8207 | Prism.languages.insertBefore('markup', 'tag', {
|
8208 | 'script': {
|
8209 | pattern: /(<script[\w\W]*?>)[\w\W]*?(?=<\/script>)/i,
|
8210 | lookbehind: true,
|
8211 | inside: Prism.languages.javascript,
|
8212 | alias: 'language-javascript'
|
8213 | }
|
8214 | });
|
8215 | }
|
8216 |
|
8217 | Prism.languages.js = Prism.languages.javascript;
|
8218 |
|
8219 | /* **********************************************
|
8220 | Begin prism-file-highlight.js
|
8221 | ********************************************** */
|
8222 |
|
8223 | (function () {
|
8224 | if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
|
8225 | return;
|
8226 | }
|
8227 |
|
8228 | self.Prism.fileHighlight = function() {
|
8229 |
|
8230 | var Extensions = {
|
8231 | 'js': 'javascript',
|
8232 | 'py': 'python',
|
8233 | 'rb': 'ruby',
|
8234 | 'ps1': 'powershell',
|
8235 | 'psm1': 'powershell',
|
8236 | 'sh': 'bash',
|
8237 | 'bat': 'batch',
|
8238 | 'h': 'c',
|
8239 | 'tex': 'latex'
|
8240 | };
|
8241 |
|
8242 | if(Array.prototype.forEach) { // Check to prevent error in IE8
|
8243 | Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {
|
8244 | var src = pre.getAttribute('data-src');
|
8245 |
|
8246 | var language, parent = pre;
|
8247 | var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
|
8248 | while (parent && !lang.test(parent.className)) {
|
8249 | parent = parent.parentNode;
|
8250 | }
|
8251 |
|
8252 | if (parent) {
|
8253 | language = (pre.className.match(lang) || [, ''])[1];
|
8254 | }
|
8255 |
|
8256 | if (!language) {
|
8257 | var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
|
8258 | language = Extensions[extension] || extension;
|
8259 | }
|
8260 |
|
8261 | var code = document.createElement('code');
|
8262 | code.className = 'language-' + language;
|
8263 |
|
8264 | pre.textContent = '';
|
8265 |
|
8266 | code.textContent = 'Loading…';
|
8267 |
|
8268 | pre.appendChild(code);
|
8269 |
|
8270 | var xhr = new XMLHttpRequest();
|
8271 |
|
8272 | xhr.open('GET', src, true);
|
8273 |
|
8274 | xhr.onreadystatechange = function () {
|
8275 | if (xhr.readyState == 4) {
|
8276 |
|
8277 | if (xhr.status < 400 && xhr.responseText) {
|
8278 | code.textContent = xhr.responseText;
|
8279 |
|
8280 | Prism.highlightElement(code);
|
8281 | }
|
8282 | else if (xhr.status >= 400) {
|
8283 | code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
8284 | }
|
8285 | else {
|
8286 | code.textContent = '✖ Error: File does not exist or is empty';
|
8287 | }
|
8288 | }
|
8289 | };
|
8290 |
|
8291 | xhr.send(null);
|
8292 | });
|
8293 | }
|
8294 |
|
8295 | };
|
8296 |
|
8297 | document.addEventListener('DOMContentLoaded', self.Prism.fileHighlight);
|
8298 |
|
8299 | })();
|
8300 | });
|
8301 |
|
8302 | var code$1 = function(dom, data) {
|
8303 | var codeElements = [].slice.call(dom.querySelectorAll("dt-code"));
|
8304 | codeElements.forEach(function (el) {
|
8305 | var content = el.textContent;
|
8306 | el.innerHTML = "";
|
8307 | var language = el.getAttribute("language");
|
8308 | var c = dom.createElement("code");
|
8309 | if (el.getAttribute("block") === "") {
|
8310 | // Let's normalize the tab indents
|
8311 | content = content.replace(/\n/, "");
|
8312 | var tabs = content.match(/\s*/);
|
8313 | content = content.replace(new RegExp("\n" + tabs, "g"), "\n");
|
8314 | content = content.trim();
|
8315 | var p = dom.createElement("pre");
|
8316 | p.appendChild(c);
|
8317 | el.appendChild(p);
|
8318 | } else {
|
8319 | el.appendChild(c);
|
8320 | }
|
8321 | var highlighted = content;
|
8322 | if (prism.languages[language]) {
|
8323 | c.setAttribute("class", "language-" + language);
|
8324 | highlighted = prism.highlight(content, prism.languages[language]);
|
8325 | }
|
8326 | c.innerHTML = highlighted;
|
8327 | });
|
8328 | };
|
8329 |
|
8330 | var typeset = function(dom, data) {
|
8331 |
|
8332 | var textNodes = dom.createTreeWalker(
|
8333 | dom.body,
|
8334 | dom.defaultView.NodeFilter.SHOW_TEXT
|
8335 | );
|
8336 | while (textNodes.nextNode()) {
|
8337 | var n = textNodes.currentNode,
|
8338 | text = n.nodeValue;
|
8339 | if (text && acceptNode(n)) {
|
8340 | text = quotes(text);
|
8341 | text = punctuation(text);
|
8342 | text = ligatures(text);
|
8343 | n.nodeValue = text;
|
8344 | }
|
8345 | }
|
8346 | };
|
8347 |
|
8348 | function acceptNode(node) {
|
8349 | var parent = node.parentElement;
|
8350 | var isMath = (parent && parent.getAttribute && parent.getAttribute("class")) ? parent.getAttribute("class").includes("katex") || parent.getAttribute("class").includes("MathJax") : false;
|
8351 | return parent &&
|
8352 | parent.nodeName !== "SCRIPT" &&
|
8353 | parent.nodeName !== "STYLE" &&
|
8354 | parent.nodeName !== "CODE" &&
|
8355 | parent.nodeName !== "PRE" &&
|
8356 | parent.nodeName !== "SPAN" &&
|
8357 | parent.nodeName !== "DT-HEADER" &&
|
8358 | parent.nodeName !== "DT-BYLINE" &&
|
8359 | parent.nodeName !== "DT-MATH" &&
|
8360 | parent.nodeName !== "DT-CODE" &&
|
8361 | parent.nodeName !== "DT-BIBLIOGRAPHY" &&
|
8362 | parent.nodeName !== "DT-FOOTER" &&
|
8363 | parent.nodeType !== 8 && //comment nodes
|
8364 | !isMath;
|
8365 | }
|
8366 |
|
8367 |
|
8368 | /*!
|
8369 | * typeset - Typesetting for the web
|
8370 | * @version v0.1.6
|
8371 | * @link https://github.com/davidmerfield/Typeset.js
|
8372 | * @author David Merfield
|
8373 | */
|
8374 | // which has a CC0 license
|
8375 | // http://creativecommons.org/publicdomain/zero/1.0/
|
8376 |
|
8377 |
|
8378 | function punctuation(text){
|
8379 |
|
8380 | // Dashes
|
8381 | text = text.replace(/--/g, '\u2014');
|
8382 | text = text.replace(/ \u2014 /g,"\u2009\u2014\u2009"); //this has thin spaces
|
8383 |
|
8384 | // Elipses
|
8385 | text = text.replace(/\.\.\./g,'…');
|
8386 |
|
8387 | // Nbsp for punc with spaces
|
8388 | var NBSP = "\u00a0";
|
8389 | var NBSP_PUNCTUATION_START = /([«¿¡]) /g;
|
8390 | var NBSP_PUNCTUATION_END = / ([\!\?:;\.,‽»])/g;
|
8391 |
|
8392 | text = text.replace(NBSP_PUNCTUATION_START, '$1' + NBSP);
|
8393 | text = text.replace(NBSP_PUNCTUATION_END, NBSP + '$1');
|
8394 |
|
8395 | return text;
|
8396 | }
|
8397 |
|
8398 | function quotes(text) {
|
8399 |
|
8400 | text = text
|
8401 | .replace(/(\W|^)"([^\s\!\?:;\.,‽»])/g, '$1\u201c$2') // beginning "
|
8402 | .replace(/(\u201c[^"]*)"([^"]*$|[^\u201c"]*\u201c)/g, '$1\u201d$2') // ending "
|
8403 | .replace(/([^0-9])"/g,'$1\u201d') // remaining " at end of word
|
8404 | .replace(/(\W|^)'(\S)/g, '$1\u2018$2') // beginning '
|
8405 | .replace(/([a-z])'([a-z])/ig, '$1\u2019$2') // conjunction's possession
|
8406 | .replace(/((\u2018[^']*)|[a-z])'([^0-9]|$)/ig, '$1\u2019$3') // ending '
|
8407 | .replace(/(\u2018)([0-9]{2}[^\u2019]*)(\u2018([^0-9]|$)|$|\u2019[a-z])/ig, '\u2019$2$3') // abbrev. years like '93
|
8408 | .replace(/(\B|^)\u2018(?=([^\u2019]*\u2019\b)*([^\u2019\u2018]*\W[\u2019\u2018]\b|[^\u2019\u2018]*$))/ig, '$1\u2019') // backwards apostrophe
|
8409 | .replace(/'''/g, '\u2034') // triple prime
|
8410 | .replace(/("|'')/g, '\u2033') // double prime
|
8411 | .replace(/'/g, '\u2032');
|
8412 |
|
8413 | // Allow escaped quotes
|
8414 | text = text.replace(/\\“/, '\"');
|
8415 | text = text.replace(/\\”/, '\"');
|
8416 | text = text.replace(/\\’/, '\'');
|
8417 | text = text.replace(/\\‘/, '\'');
|
8418 |
|
8419 | return text;
|
8420 | }
|
8421 |
|
8422 | function ligatures(text){
|
8423 |
|
8424 | text = text.replace(/fi/g, 'fi');
|
8425 | text = text.replace(/fl/g, 'fl');
|
8426 |
|
8427 | return text;
|
8428 | }
|
8429 |
|
8430 | var code$2 = "// DistillHoverBox\n//=====================================\n\nfunction DistillHoverBox(key, pos){\n\n if (!(key in DistillHoverBox.contentMap)){\n console.error(\"No DistillHoverBox content registered for key\", key);\n }\n if (key in DistillHoverBox.liveBoxes) {\n console.error(\"There already exists a DistillHoverBox for key\", key);\n } else {\n for (var k in DistillHoverBox.liveBoxes)\n DistillHoverBox.liveBoxes[k].remove();\n DistillHoverBox.liveBoxes[key] = this;\n }\n this.key = key;\n\n var pretty = window.innerWidth > 600;\n\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\n var str = `<div style=\"position: absolute;\n background-color: #FFF;\n white-s\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 ${DistillHoverBox.contentMap[key]}\n </div>`;\n\n this.div = appendBody(str);\n\n DistillHoverBox.bind (this.div, key);\n}\n\nDistillHoverBox.prototype.remove = function remove(){\n if (this.div) this.div.remove();\n if (this.timeout) clearTimeout(this.timeout);\n delete DistillHoverBox.liveBoxes[this.key];\n}\n\nDistillHoverBox.prototype.stopTimeout = function stopTimeout() {\n if (this.timeout) clearTimeout(this.timeout);\n}\n\nDistillHoverBox.prototype.extendTimeout = function extendTimeout(T) {\n //console.log(\"extend\", T)\n var this_ = this;\n this.stopTimeout();\n this.timeout = setTimeout(() => this_.remove(), T);\n}\n\nDistillHoverBox.liveBoxes = {};\nDistillHoverBox.contentMap = {};\n\nDistillHoverBox.bind = function bind(node, key) {\n if (typeof node == \"string\"){\n node = document.querySelector(node);\n }\n node.addEventListener(\"mouseover\", () => {\n var bbox = node.getBoundingClientRect();\n if (!(key in DistillHoverBox.liveBoxes)){\n new DistillHoverBox(key, [bbox.right, bbox.bottom]);\n }\n DistillHoverBox.liveBoxes[key].stopTimeout();\n });\n node.addEventListener(\"mouseout\", () => {\n if (key in DistillHoverBox.liveBoxes){\n DistillHoverBox.liveBoxes[key].extendTimeout(250);\n }\n });\n\n}\n\n\nfunction appendBody(str){\n var node = nodeFromString(str);\n var body = document.querySelector(\"body\");\n body.appendChild(node);\n return node;\n}\n\nfunction nodeFromString(str) {\n var div = document.createElement(\"div\");\n div.innerHTML = str;\n return div.firstChild;\n}\n\nvar hover_es = document.querySelectorAll(\"span[data-hover]\");\nhover_es = [].slice.apply(hover_es);\nhover_es.forEach((e,n) => {\n var key = \"hover-\"+n;\n var content = e.getAttribute(\"data-hover\");\n DistillHoverBox.contentMap[key] = content;\n DistillHoverBox.bind(e, key);\n});\n";
|
8431 |
|
8432 | var hoverBox = function(dom) {
|
8433 | var s = dom.createElement("script");
|
8434 | s.textContent = code$2;
|
8435 | dom.querySelector("body").appendChild(s);
|
8436 | };
|
8437 |
|
8438 | //import xml from "xml";
|
8439 |
|
8440 | var generateCrossref = function(data) {
|
8441 |
|
8442 |
|
8443 | var date = data.publishedDate;
|
8444 |
|
8445 | var batch_timestamp = Math.floor(Date.now() / 1000);
|
8446 | var batch_id = data.authors.length ? data.authors[0].lastName.toLowerCase().slice(0,20) : "Anonymous";
|
8447 | batch_id += "_" + date.getFullYear();
|
8448 | batch_id += "_" + data.title.split(" ")[0].toLowerCase().slice(0,20) + "_" + batch_timestamp;
|
8449 | // generate XML
|
8450 | var crf_data =
|
8451 | {doi_batch : [
|
8452 |
|
8453 | { _attr: {
|
8454 | version: "4.3.7",
|
8455 | xmlns: "http://www.crossref.org/schema/4.3.7",
|
8456 | "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
|
8457 | "xsi:schemaLocation": "http://www.crossref.org/schema/4.3.7 http://www.crossref.org/schemas/crossref4.3.7.xsd",
|
8458 | }},
|
8459 |
|
8460 | { head: [
|
8461 | {doi_batch_id: batch_id},
|
8462 | {timestamp: batch_timestamp},
|
8463 | {depositor: [
|
8464 | {depositor_name: data.journal.publisherName},
|
8465 | {email_address: data.journal.publisherEmail} ]},
|
8466 | {registrant: data.journal.publisherName} ]},
|
8467 |
|
8468 | {body: [
|
8469 | {journal: [
|
8470 |
|
8471 | {journal_metadata: [
|
8472 | {full_title: data.journal.full_title || data.journal.title},
|
8473 | {abbrev_title: data.journal.abbrev_title || data.journal.title || data.journal.full_title},
|
8474 | {doi_data: [
|
8475 | {doi: data.journal.doi},
|
8476 | {resource: data.journal.url} ]} ]},
|
8477 |
|
8478 | {journal_issue: [
|
8479 | {publication_date: [
|
8480 | {month: date.getMonth()+1},
|
8481 | {year: date.getFullYear()} ]},
|
8482 | {journal_volume: [
|
8483 | {volume: data.volume} ]},
|
8484 | {issue: data.issue} ]},
|
8485 |
|
8486 | {journal_article: [
|
8487 | {titles: [
|
8488 | {title: data.title} ]},
|
8489 | { contributors:
|
8490 | data.authors.map(function (author, ind) { return (
|
8491 | {person_name: [
|
8492 | { _attr: {
|
8493 | contributor_role: "author",
|
8494 | sequence: (ind == 0)? "first" : "additional"
|
8495 | }},
|
8496 | {given_name: author.firstName},
|
8497 | {surname: author.lastName},
|
8498 | {affiliation: author.affiliation}
|
8499 | // TODO: ORCID?
|
8500 | ]}
|
8501 | ); })
|
8502 | },
|
8503 | {publication_date: [
|
8504 | {month: date.getMonth()+1},
|
8505 | {day: date.getDate()},
|
8506 | {year: date.getFullYear()}
|
8507 | ]},
|
8508 | { publisher_item: [
|
8509 | {item_number: data.doi}
|
8510 | ]},
|
8511 | {doi_data: [
|
8512 | {doi: data.doi},
|
8513 | //{timestamp: ""},
|
8514 | {resource: data.url} ]},
|
8515 | {citation_list:
|
8516 | data.citations.map(function (key) { return citation_xml(key, data.bibliography[key]); })
|
8517 | }
|
8518 |
|
8519 | ]} ]} ]} ]};
|
8520 |
|
8521 | return xml(crf_data);
|
8522 | };
|
8523 |
|
8524 | function citation_xml(key, ent){
|
8525 | if (ent == undefined) { return {}; }
|
8526 | var info = [];
|
8527 | info.push({_attr: {key: key}});
|
8528 | if ("title" in ent)
|
8529 | { info.push({article_title: ent.title}); }
|
8530 | if ("author" in ent)
|
8531 | { info.push({author: ent.author.split(" and ")[0].split(",")[0].trim()}); }
|
8532 | if ("journal" in ent)
|
8533 | { info.push({journal_title: ent.journal}); }
|
8534 | if ("booktitle" in ent)
|
8535 | { info.push({volume_title: ent.booktitle}); }
|
8536 | if ("volume" in ent)
|
8537 | { info.push({volume: ent.volume}); }
|
8538 | if ("issue" in ent)
|
8539 | { info.push({issue: ent.issue}); }
|
8540 | if ("doi" in ent)
|
8541 | { info.push({doi: ent.doi}); }
|
8542 | return {citation: info}
|
8543 | }
|
8544 |
|
8545 | function xml(obj) {
|
8546 | //console.log(typeof(obj), obj)
|
8547 | if (typeof obj === 'string') { return obj; }
|
8548 | if (typeof obj === 'number') { return ""+obj; }
|
8549 | var keys = Object.keys(obj);
|
8550 | if (keys.length != 1) { console.error("can't interpret ", obj, "as xml"); }
|
8551 | var name = keys[0];
|
8552 | var full_content = obj[name];
|
8553 | var attr = {};
|
8554 | if (Array.isArray(full_content)){
|
8555 | var content = [];
|
8556 | for (var i in full_content) {
|
8557 | var obj = full_content[i];
|
8558 | var obj_name = Object.keys(obj)[0];
|
8559 | if ("_attr" == obj_name) {
|
8560 | attr = obj["_attr"];
|
8561 | } else {
|
8562 | //console.log(Object.keys(obj)[0])
|
8563 | content.push(obj);
|
8564 | }
|
8565 | }
|
8566 | } else {
|
8567 | content = full_content;
|
8568 | }
|
8569 | if (content == undefined){
|
8570 | content = "undefined";
|
8571 | }
|
8572 |
|
8573 | var attr_string = "";
|
8574 | for (var k in attr) {
|
8575 | attr_string += " " + k + "=\"" + (attr[k]) + "\"";
|
8576 | }
|
8577 |
|
8578 | //console.log(typeof content, Array.isArray(content), content instanceof String, content)
|
8579 | if (Array.isArray(content)){
|
8580 | content = content.map(xml);
|
8581 | content = content.join("\n").split("\n");
|
8582 | content = content.map(function (s) { return " " + s; }).join("\n");
|
8583 | var result = "<" + name + attr_string + ">\n" + content + "\n</" + name + ">";
|
8584 | } else {
|
8585 | content = xml(content);
|
8586 | var result = "<" + name + attr_string + ">" + content + "</" + name + ">";
|
8587 | }
|
8588 | return result;
|
8589 | }
|
8590 |
|
8591 | function renderImmediately(dom) {
|
8592 | html(dom);
|
8593 | styles(dom);
|
8594 | }
|
8595 |
|
8596 | function renderOnLoad(dom, data) {
|
8597 | frontMatter(dom, data);
|
8598 | bibliography(dom, data);
|
8599 | expandData(dom, data);
|
8600 | meta(dom, data);
|
8601 | header(dom, data);
|
8602 | byline(dom, data);
|
8603 | appendix(dom, data);
|
8604 | footer(dom, data);
|
8605 | markdown(dom, data);
|
8606 | code$1(dom, data);
|
8607 | citation(dom, data);
|
8608 | footnote(dom, data);
|
8609 | typeset(dom, data);
|
8610 | hoverBox(dom, data);
|
8611 | }
|
8612 |
|
8613 | // If we are in a browser, render automatically...
|
8614 | if(window && window.document) {
|
8615 | var data = {};
|
8616 | renderImmediately(window.document);
|
8617 | window.document.addEventListener("DOMContentLoaded", function (event) {
|
8618 | renderOnLoad(window.document, data);
|
8619 | // Add a banner if we're not on localhost.
|
8620 | if (window.location.hostname !== "localhost" && window.location.origin !== "file://") {
|
8621 | banner(window.document, data);
|
8622 | }
|
8623 | generateCrossref(data);
|
8624 | });
|
8625 | }
|
8626 |
|
8627 | // If we are in node...
|
8628 | function render$1(dom, data) {
|
8629 | renderImmediately(dom);
|
8630 | renderOnLoad(dom, data);
|
8631 | // Remove script tag so it doesn't run again in the client
|
8632 | var s = dom.querySelector('script[src="http://distill.pub/template.js"]');
|
8633 | if (s) { s.parentElement.removeChild(s); }
|
8634 | }
|
8635 |
|
8636 | exports.render = render$1;
|
8637 | exports.generateCrossref = generateCrossref;
|
8638 |
|
8639 | Object.defineProperty(exports, '__esModule', { value: true });
|
8640 |
|
8641 | })));
|
8642 | //# sourceMappingURL=template.js.map
|