'use strict'; var obsidian = require('obsidian'); var require$$0 = require('path'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } /*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ function isNothing(subject) { return (typeof subject === 'undefined') || (subject === null); } function isObject(subject) { return (typeof subject === 'object') && (subject !== null); } function toArray(sequence) { if (Array.isArray(sequence)) return sequence; else if (isNothing(sequence)) return []; return [ sequence ]; } function extend$1(target, source) { var index, length, key, sourceKeys; if (source) { sourceKeys = Object.keys(source); for (index = 0, length = sourceKeys.length; index < length; index += 1) { key = sourceKeys[index]; target[key] = source[key]; } } return target; } function repeat$1(string, count) { var result = '', cycle; for (cycle = 0; cycle < count; cycle += 1) { result += string; } return result; } function isNegativeZero(number) { return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); } var isNothing_1 = isNothing; var isObject_1 = isObject; var toArray_1 = toArray; var repeat_1 = repeat$1; var isNegativeZero_1 = isNegativeZero; var extend_1 = extend$1; var common = { isNothing: isNothing_1, isObject: isObject_1, toArray: toArray_1, repeat: repeat_1, isNegativeZero: isNegativeZero_1, extend: extend_1 }; // YAML error class. http://stackoverflow.com/questions/8458984 function formatError(exception, compact) { var where = '', message = exception.reason || '(unknown reason)'; if (!exception.mark) return message; if (exception.mark.name) { where += 'in "' + exception.mark.name + '" '; } where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')'; if (!compact && exception.mark.snippet) { where += '\n\n' + exception.mark.snippet; } return message + ' ' + where; } function YAMLException$1(reason, mark) { // Super constructor Error.call(this); this.name = 'YAMLException'; this.reason = reason; this.mark = mark; this.message = formatError(this, false); // Include stack trace in error object if (Error.captureStackTrace) { // Chrome and NodeJS Error.captureStackTrace(this, this.constructor); } else { // FF, IE 10+ and Safari 6+. Fallback for others this.stack = (new Error()).stack || ''; } } // Inherit from Error YAMLException$1.prototype = Object.create(Error.prototype); YAMLException$1.prototype.constructor = YAMLException$1; YAMLException$1.prototype.toString = function toString(compact) { return this.name + ': ' + formatError(this, compact); }; var exception = YAMLException$1; // get snippet for a single line, respecting maxLength function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { var head = ''; var tail = ''; var maxHalfLength = Math.floor(maxLineLength / 2) - 1; if (position - lineStart > maxHalfLength) { head = ' ... '; lineStart = position - maxHalfLength + head.length; } if (lineEnd - position > maxHalfLength) { tail = ' ...'; lineEnd = position + maxHalfLength - tail.length; } return { str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, pos: position - lineStart + head.length // relative position }; } function padStart(string, max) { return common.repeat(' ', max - string.length) + string; } function makeSnippet(mark, options) { options = Object.create(options || null); if (!mark.buffer) return null; if (!options.maxLength) options.maxLength = 79; if (typeof options.indent !== 'number') options.indent = 1; if (typeof options.linesBefore !== 'number') options.linesBefore = 3; if (typeof options.linesAfter !== 'number') options.linesAfter = 2; var re = /\r?\n|\r|\0/g; var lineStarts = [ 0 ]; var lineEnds = []; var match; var foundLineNo = -1; while ((match = re.exec(mark.buffer))) { lineEnds.push(match.index); lineStarts.push(match.index + match[0].length); if (mark.position <= match.index && foundLineNo < 0) { foundLineNo = lineStarts.length - 2; } } if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; var result = '', i, line; var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); for (i = 1; i <= options.linesBefore; i++) { if (foundLineNo - i < 0) break; line = getLine( mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength ); result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + ' | ' + line.str + '\n' + result; } line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + ' | ' + line.str + '\n'; result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; for (i = 1; i <= options.linesAfter; i++) { if (foundLineNo + i >= lineEnds.length) break; line = getLine( mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength ); result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + ' | ' + line.str + '\n'; } return result.replace(/\n$/, ''); } var snippet = makeSnippet; var TYPE_CONSTRUCTOR_OPTIONS = [ 'kind', 'multi', 'resolve', 'construct', 'instanceOf', 'predicate', 'represent', 'representName', 'defaultStyle', 'styleAliases' ]; var YAML_NODE_KINDS = [ 'scalar', 'sequence', 'mapping' ]; function compileStyleAliases(map) { var result = {}; if (map !== null) { Object.keys(map).forEach(function (style) { map[style].forEach(function (alias) { result[String(alias)] = style; }); }); } return result; } function Type$1(tag, options) { options = options || {}; Object.keys(options).forEach(function (name) { if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); } }); // TODO: Add tag format check. this.options = options; // keep original options in case user wants to extend this type later this.tag = tag; this.kind = options['kind'] || null; this.resolve = options['resolve'] || function () { return true; }; this.construct = options['construct'] || function (data) { return data; }; this.instanceOf = options['instanceOf'] || null; this.predicate = options['predicate'] || null; this.represent = options['represent'] || null; this.representName = options['representName'] || null; this.defaultStyle = options['defaultStyle'] || null; this.multi = options['multi'] || false; this.styleAliases = compileStyleAliases(options['styleAliases'] || null); if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); } } var type = Type$1; /*eslint-disable max-len*/ function compileList(schema, name) { var result = []; schema[name].forEach(function (currentType) { var newIndex = result.length; result.forEach(function (previousType, previousIndex) { if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) { newIndex = previousIndex; } }); result[newIndex] = currentType; }); return result; } function compileMap(/* lists... */) { var result = { scalar: {}, sequence: {}, mapping: {}, fallback: {}, multi: { scalar: [], sequence: [], mapping: [], fallback: [] } }, index, length; function collectType(type) { if (type.multi) { result.multi[type.kind].push(type); result.multi['fallback'].push(type); } else { result[type.kind][type.tag] = result['fallback'][type.tag] = type; } } for (index = 0, length = arguments.length; index < length; index += 1) { arguments[index].forEach(collectType); } return result; } function Schema$1(definition) { return this.extend(definition); } Schema$1.prototype.extend = function extend(definition) { var implicit = []; var explicit = []; if (definition instanceof type) { // Schema.extend(type) explicit.push(definition); } else if (Array.isArray(definition)) { // Schema.extend([ type1, type2, ... ]) explicit = explicit.concat(definition); } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) if (definition.implicit) implicit = implicit.concat(definition.implicit); if (definition.explicit) explicit = explicit.concat(definition.explicit); } else { throw new exception('Schema.extend argument should be a Type, [ Type ], ' + 'or a schema definition ({ implicit: [...], explicit: [...] })'); } implicit.forEach(function (type$1) { if (!(type$1 instanceof type)) { throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); } if (type$1.loadKind && type$1.loadKind !== 'scalar') { throw new exception('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); } if (type$1.multi) { throw new exception('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); } }); explicit.forEach(function (type$1) { if (!(type$1 instanceof type)) { throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); } }); var result = Object.create(Schema$1.prototype); result.implicit = (this.implicit || []).concat(implicit); result.explicit = (this.explicit || []).concat(explicit); result.compiledImplicit = compileList(result, 'implicit'); result.compiledExplicit = compileList(result, 'explicit'); result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); return result; }; var schema = Schema$1; var str = new type('tag:yaml.org,2002:str', { kind: 'scalar', construct: function (data) { return data !== null ? data : ''; } }); var seq = new type('tag:yaml.org,2002:seq', { kind: 'sequence', construct: function (data) { return data !== null ? data : []; } }); var map$4 = new type('tag:yaml.org,2002:map', { kind: 'mapping', construct: function (data) { return data !== null ? data : {}; } }); var failsafe = new schema({ explicit: [ str, seq, map$4 ] }); function resolveYamlNull(data) { if (data === null) return true; var max = data.length; return (max === 1 && data === '~') || (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); } function constructYamlNull() { return null; } function isNull(object) { return object === null; } var _null = new type('tag:yaml.org,2002:null', { kind: 'scalar', resolve: resolveYamlNull, construct: constructYamlNull, predicate: isNull, represent: { canonical: function () { return '~'; }, lowercase: function () { return 'null'; }, uppercase: function () { return 'NULL'; }, camelcase: function () { return 'Null'; }, empty: function () { return ''; } }, defaultStyle: 'lowercase' }); function resolveYamlBoolean(data) { if (data === null) return false; var max = data.length; return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); } function constructYamlBoolean(data) { return data === 'true' || data === 'True' || data === 'TRUE'; } function isBoolean(object) { return Object.prototype.toString.call(object) === '[object Boolean]'; } var bool = new type('tag:yaml.org,2002:bool', { kind: 'scalar', resolve: resolveYamlBoolean, construct: constructYamlBoolean, predicate: isBoolean, represent: { lowercase: function (object) { return object ? 'true' : 'false'; }, uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, camelcase: function (object) { return object ? 'True' : 'False'; } }, defaultStyle: 'lowercase' }); function isHexCode(c) { return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || ((0x61/* a */ <= c) && (c <= 0x66/* f */)); } function isOctCode(c) { return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); } function isDecCode(c) { return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); } function resolveYamlInteger(data) { if (data === null) return false; var max = data.length, index = 0, hasDigits = false, ch; if (!max) return false; ch = data[index]; // sign if (ch === '-' || ch === '+') { ch = data[++index]; } if (ch === '0') { // 0 if (index + 1 === max) return true; ch = data[++index]; // base 2, base 8, base 16 if (ch === 'b') { // base 2 index++; for (; index < max; index++) { ch = data[index]; if (ch === '_') continue; if (ch !== '0' && ch !== '1') return false; hasDigits = true; } return hasDigits && ch !== '_'; } if (ch === 'x') { // base 16 index++; for (; index < max; index++) { ch = data[index]; if (ch === '_') continue; if (!isHexCode(data.charCodeAt(index))) return false; hasDigits = true; } return hasDigits && ch !== '_'; } if (ch === 'o') { // base 8 index++; for (; index < max; index++) { ch = data[index]; if (ch === '_') continue; if (!isOctCode(data.charCodeAt(index))) return false; hasDigits = true; } return hasDigits && ch !== '_'; } } // base 10 (except 0) // value should not start with `_`; if (ch === '_') return false; for (; index < max; index++) { ch = data[index]; if (ch === '_') continue; if (!isDecCode(data.charCodeAt(index))) { return false; } hasDigits = true; } // Should have digits and should not end with `_` if (!hasDigits || ch === '_') return false; return true; } function constructYamlInteger(data) { var value = data, sign = 1, ch; if (value.indexOf('_') !== -1) { value = value.replace(/_/g, ''); } ch = value[0]; if (ch === '-' || ch === '+') { if (ch === '-') sign = -1; value = value.slice(1); ch = value[0]; } if (value === '0') return 0; if (ch === '0') { if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); } return sign * parseInt(value, 10); } function isInteger(object) { return (Object.prototype.toString.call(object)) === '[object Number]' && (object % 1 === 0 && !common.isNegativeZero(object)); } var int$1 = new type('tag:yaml.org,2002:int', { kind: 'scalar', resolve: resolveYamlInteger, construct: constructYamlInteger, predicate: isInteger, represent: { binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, decimal: function (obj) { return obj.toString(10); }, /* eslint-disable max-len */ hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } }, defaultStyle: 'decimal', styleAliases: { binary: [ 2, 'bin' ], octal: [ 8, 'oct' ], decimal: [ 10, 'dec' ], hexadecimal: [ 16, 'hex' ] } }); var YAML_FLOAT_PATTERN = new RegExp( // 2.5e4, 2.5 and integers '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + // .2e4, .2 // special case, seems not from spec '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + // .inf '|[-+]?\\.(?:inf|Inf|INF)' + // .nan '|\\.(?:nan|NaN|NAN))$'); function resolveYamlFloat(data) { if (data === null) return false; if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_` // Probably should update regexp & check speed data[data.length - 1] === '_') { return false; } return true; } function constructYamlFloat(data) { var value, sign; value = data.replace(/_/g, '').toLowerCase(); sign = value[0] === '-' ? -1 : 1; if ('+-'.indexOf(value[0]) >= 0) { value = value.slice(1); } if (value === '.inf') { return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; } else if (value === '.nan') { return NaN; } return sign * parseFloat(value, 10); } var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; function representYamlFloat(object, style) { var res; if (isNaN(object)) { switch (style) { case 'lowercase': return '.nan'; case 'uppercase': return '.NAN'; case 'camelcase': return '.NaN'; } } else if (Number.POSITIVE_INFINITY === object) { switch (style) { case 'lowercase': return '.inf'; case 'uppercase': return '.INF'; case 'camelcase': return '.Inf'; } } else if (Number.NEGATIVE_INFINITY === object) { switch (style) { case 'lowercase': return '-.inf'; case 'uppercase': return '-.INF'; case 'camelcase': return '-.Inf'; } } else if (common.isNegativeZero(object)) { return '-0.0'; } res = object.toString(10); // JS stringifier can build scientific format without dots: 5e-100, // while YAML requres dot: 5.e-100. Fix it with simple hack return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; } function isFloat(object) { return (Object.prototype.toString.call(object) === '[object Number]') && (object % 1 !== 0 || common.isNegativeZero(object)); } var float = new type('tag:yaml.org,2002:float', { kind: 'scalar', resolve: resolveYamlFloat, construct: constructYamlFloat, predicate: isFloat, represent: representYamlFloat, defaultStyle: 'lowercase' }); var json = failsafe.extend({ implicit: [ _null, bool, int$1, float ] }); var core$1 = json; var YAML_DATE_REGEXP = new RegExp( '^([0-9][0-9][0-9][0-9])' + // [1] year '-([0-9][0-9])' + // [2] month '-([0-9][0-9])$'); // [3] day var YAML_TIMESTAMP_REGEXP = new RegExp( '^([0-9][0-9][0-9][0-9])' + // [1] year '-([0-9][0-9]?)' + // [2] month '-([0-9][0-9]?)' + // [3] day '(?:[Tt]|[ \\t]+)' + // ... '([0-9][0-9]?)' + // [4] hour ':([0-9][0-9])' + // [5] minute ':([0-9][0-9])' + // [6] second '(?:\\.([0-9]*))?' + // [7] fraction '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour '(?::([0-9][0-9]))?))?$'); // [11] tz_minute function resolveYamlTimestamp(data) { if (data === null) return false; if (YAML_DATE_REGEXP.exec(data) !== null) return true; if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; return false; } function constructYamlTimestamp(data) { var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date; match = YAML_DATE_REGEXP.exec(data); if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); if (match === null) throw new Error('Date resolve error'); // match: [1] year [2] month [3] day year = +(match[1]); month = +(match[2]) - 1; // JS month starts with 0 day = +(match[3]); if (!match[4]) { // no hour return new Date(Date.UTC(year, month, day)); } // match: [4] hour [5] minute [6] second [7] fraction hour = +(match[4]); minute = +(match[5]); second = +(match[6]); if (match[7]) { fraction = match[7].slice(0, 3); while (fraction.length < 3) { // milli-seconds fraction += '0'; } fraction = +fraction; } // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute if (match[9]) { tz_hour = +(match[10]); tz_minute = +(match[11] || 0); delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds if (match[9] === '-') delta = -delta; } date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); if (delta) date.setTime(date.getTime() - delta); return date; } function representYamlTimestamp(object /*, style*/) { return object.toISOString(); } var timestamp = new type('tag:yaml.org,2002:timestamp', { kind: 'scalar', resolve: resolveYamlTimestamp, construct: constructYamlTimestamp, instanceOf: Date, represent: representYamlTimestamp }); function resolveYamlMerge(data) { return data === '<<' || data === null; } var merge = new type('tag:yaml.org,2002:merge', { kind: 'scalar', resolve: resolveYamlMerge }); /*eslint-disable no-bitwise*/ // [ 64, 65, 66 ] -> [ padding, CR, LF ] var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; function resolveYamlBinary(data) { if (data === null) return false; var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; // Convert one by one. for (idx = 0; idx < max; idx++) { code = map.indexOf(data.charAt(idx)); // Skip CR/LF if (code > 64) continue; // Fail on illegal characters if (code < 0) return false; bitlen += 6; } // If there are any bits left, source was corrupted return (bitlen % 8) === 0; } function constructYamlBinary(data) { var idx, tailbits, input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan max = input.length, map = BASE64_MAP, bits = 0, result = []; // Collect by 6*4 bits (3 bytes) for (idx = 0; idx < max; idx++) { if ((idx % 4 === 0) && idx) { result.push((bits >> 16) & 0xFF); result.push((bits >> 8) & 0xFF); result.push(bits & 0xFF); } bits = (bits << 6) | map.indexOf(input.charAt(idx)); } // Dump tail tailbits = (max % 4) * 6; if (tailbits === 0) { result.push((bits >> 16) & 0xFF); result.push((bits >> 8) & 0xFF); result.push(bits & 0xFF); } else if (tailbits === 18) { result.push((bits >> 10) & 0xFF); result.push((bits >> 2) & 0xFF); } else if (tailbits === 12) { result.push((bits >> 4) & 0xFF); } return new Uint8Array(result); } function representYamlBinary(object /*, style*/) { var result = '', bits = 0, idx, tail, max = object.length, map = BASE64_MAP; // Convert every three bytes to 4 ASCII characters. for (idx = 0; idx < max; idx++) { if ((idx % 3 === 0) && idx) { result += map[(bits >> 18) & 0x3F]; result += map[(bits >> 12) & 0x3F]; result += map[(bits >> 6) & 0x3F]; result += map[bits & 0x3F]; } bits = (bits << 8) + object[idx]; } // Dump tail tail = max % 3; if (tail === 0) { result += map[(bits >> 18) & 0x3F]; result += map[(bits >> 12) & 0x3F]; result += map[(bits >> 6) & 0x3F]; result += map[bits & 0x3F]; } else if (tail === 2) { result += map[(bits >> 10) & 0x3F]; result += map[(bits >> 4) & 0x3F]; result += map[(bits << 2) & 0x3F]; result += map[64]; } else if (tail === 1) { result += map[(bits >> 2) & 0x3F]; result += map[(bits << 4) & 0x3F]; result += map[64]; result += map[64]; } return result; } function isBinary(obj) { return Object.prototype.toString.call(obj) === '[object Uint8Array]'; } var binary = new type('tag:yaml.org,2002:binary', { kind: 'scalar', resolve: resolveYamlBinary, construct: constructYamlBinary, predicate: isBinary, represent: representYamlBinary }); var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; var _toString$2 = Object.prototype.toString; function resolveYamlOmap(data) { if (data === null) return true; var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data; for (index = 0, length = object.length; index < length; index += 1) { pair = object[index]; pairHasKey = false; if (_toString$2.call(pair) !== '[object Object]') return false; for (pairKey in pair) { if (_hasOwnProperty$3.call(pair, pairKey)) { if (!pairHasKey) pairHasKey = true; else return false; } } if (!pairHasKey) return false; if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); else return false; } return true; } function constructYamlOmap(data) { return data !== null ? data : []; } var omap = new type('tag:yaml.org,2002:omap', { kind: 'sequence', resolve: resolveYamlOmap, construct: constructYamlOmap }); var _toString$1 = Object.prototype.toString; function resolveYamlPairs(data) { if (data === null) return true; var index, length, pair, keys, result, object = data; result = new Array(object.length); for (index = 0, length = object.length; index < length; index += 1) { pair = object[index]; if (_toString$1.call(pair) !== '[object Object]') return false; keys = Object.keys(pair); if (keys.length !== 1) return false; result[index] = [ keys[0], pair[keys[0]] ]; } return true; } function constructYamlPairs(data) { if (data === null) return []; var index, length, pair, keys, result, object = data; result = new Array(object.length); for (index = 0, length = object.length; index < length; index += 1) { pair = object[index]; keys = Object.keys(pair); result[index] = [ keys[0], pair[keys[0]] ]; } return result; } var pairs = new type('tag:yaml.org,2002:pairs', { kind: 'sequence', resolve: resolveYamlPairs, construct: constructYamlPairs }); var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; function resolveYamlSet(data) { if (data === null) return true; var key, object = data; for (key in object) { if (_hasOwnProperty$2.call(object, key)) { if (object[key] !== null) return false; } } return true; } function constructYamlSet(data) { return data !== null ? data : {}; } var set = new type('tag:yaml.org,2002:set', { kind: 'mapping', resolve: resolveYamlSet, construct: constructYamlSet }); var _default = core$1.extend({ implicit: [ timestamp, merge ], explicit: [ binary, omap, pairs, set ] }); /*eslint-disable max-len,no-use-before-define*/ var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; var CONTEXT_FLOW_IN = 1; var CONTEXT_FLOW_OUT = 2; var CONTEXT_BLOCK_IN = 3; var CONTEXT_BLOCK_OUT = 4; var CHOMPING_CLIP = 1; var CHOMPING_STRIP = 2; var CHOMPING_KEEP = 3; var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; function _class(obj) { return Object.prototype.toString.call(obj); } function is_EOL(c) { return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); } function is_WHITE_SPACE(c) { return (c === 0x09/* Tab */) || (c === 0x20/* Space */); } function is_WS_OR_EOL(c) { return (c === 0x09/* Tab */) || (c === 0x20/* Space */) || (c === 0x0A/* LF */) || (c === 0x0D/* CR */); } function is_FLOW_INDICATOR(c) { return c === 0x2C/* , */ || c === 0x5B/* [ */ || c === 0x5D/* ] */ || c === 0x7B/* { */ || c === 0x7D/* } */; } function fromHexCode(c) { var lc; if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { return c - 0x30; } /*eslint-disable no-bitwise*/ lc = c | 0x20; if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { return lc - 0x61 + 10; } return -1; } function escapedHexLen(c) { if (c === 0x78/* x */) { return 2; } if (c === 0x75/* u */) { return 4; } if (c === 0x55/* U */) { return 8; } return 0; } function fromDecimalCode(c) { if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { return c - 0x30; } return -1; } function simpleEscapeSequence(c) { /* eslint-disable indent */ return (c === 0x30/* 0 */) ? '\x00' : (c === 0x61/* a */) ? '\x07' : (c === 0x62/* b */) ? '\x08' : (c === 0x74/* t */) ? '\x09' : (c === 0x09/* Tab */) ? '\x09' : (c === 0x6E/* n */) ? '\x0A' : (c === 0x76/* v */) ? '\x0B' : (c === 0x66/* f */) ? '\x0C' : (c === 0x72/* r */) ? '\x0D' : (c === 0x65/* e */) ? '\x1B' : (c === 0x20/* Space */) ? ' ' : (c === 0x22/* " */) ? '\x22' : (c === 0x2F/* / */) ? '/' : (c === 0x5C/* \ */) ? '\x5C' : (c === 0x4E/* N */) ? '\x85' : (c === 0x5F/* _ */) ? '\xA0' : (c === 0x4C/* L */) ? '\u2028' : (c === 0x50/* P */) ? '\u2029' : ''; } function charFromCodepoint(c) { if (c <= 0xFFFF) { return String.fromCharCode(c); } // Encode UTF-16 surrogate pair // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF return String.fromCharCode( ((c - 0x010000) >> 10) + 0xD800, ((c - 0x010000) & 0x03FF) + 0xDC00 ); } var simpleEscapeCheck = new Array(256); // integer, for fast access var simpleEscapeMap = new Array(256); for (var i$1 = 0; i$1 < 256; i$1++) { simpleEscapeCheck[i$1] = simpleEscapeSequence(i$1) ? 1 : 0; simpleEscapeMap[i$1] = simpleEscapeSequence(i$1); } function State$1(input, options) { this.input = input; this.filename = options['filename'] || null; this.schema = options['schema'] || _default; this.onWarning = options['onWarning'] || null; // (Hidden) Remove? makes the loader to expect YAML 1.1 documents // if such documents have no explicit %YAML directive this.legacy = options['legacy'] || false; this.json = options['json'] || false; this.listener = options['listener'] || null; this.implicitTypes = this.schema.compiledImplicit; this.typeMap = this.schema.compiledTypeMap; this.length = input.length; this.position = 0; this.line = 0; this.lineStart = 0; this.lineIndent = 0; // position of first leading tab in the current line, // used to make sure there are no tabs in the indentation this.firstTabInLine = -1; this.documents = []; /* this.version; this.checkLineBreaks; this.tagMap; this.anchorMap; this.tag; this.anchor; this.kind; this.result;*/ } function generateError(state, message) { var mark = { name: state.filename, buffer: state.input.slice(0, -1), // omit trailing \0 position: state.position, line: state.line, column: state.position - state.lineStart }; mark.snippet = snippet(mark); return new exception(message, mark); } function throwError(state, message) { throw generateError(state, message); } function throwWarning(state, message) { if (state.onWarning) { state.onWarning.call(null, generateError(state, message)); } } var directiveHandlers = { YAML: function handleYamlDirective(state, name, args) { var match, major, minor; if (state.version !== null) { throwError(state, 'duplication of %YAML directive'); } if (args.length !== 1) { throwError(state, 'YAML directive accepts exactly one argument'); } match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); if (match === null) { throwError(state, 'ill-formed argument of the YAML directive'); } major = parseInt(match[1], 10); minor = parseInt(match[2], 10); if (major !== 1) { throwError(state, 'unacceptable YAML version of the document'); } state.version = args[0]; state.checkLineBreaks = (minor < 2); if (minor !== 1 && minor !== 2) { throwWarning(state, 'unsupported YAML version of the document'); } }, TAG: function handleTagDirective(state, name, args) { var handle, prefix; if (args.length !== 2) { throwError(state, 'TAG directive accepts exactly two arguments'); } handle = args[0]; prefix = args[1]; if (!PATTERN_TAG_HANDLE.test(handle)) { throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); } if (_hasOwnProperty$1.call(state.tagMap, handle)) { throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); } if (!PATTERN_TAG_URI.test(prefix)) { throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); } try { prefix = decodeURIComponent(prefix); } catch (err) { throwError(state, 'tag prefix is malformed: ' + prefix); } state.tagMap[handle] = prefix; } }; function captureSegment(state, start, end, checkJson) { var _position, _length, _character, _result; if (start < end) { _result = state.input.slice(start, end); if (checkJson) { for (_position = 0, _length = _result.length; _position < _length; _position += 1) { _character = _result.charCodeAt(_position); if (!(_character === 0x09 || (0x20 <= _character && _character <= 0x10FFFF))) { throwError(state, 'expected valid JSON character'); } } } else if (PATTERN_NON_PRINTABLE.test(_result)) { throwError(state, 'the stream contains non-printable characters'); } state.result += _result; } } function mergeMappings(state, destination, source, overridableKeys) { var sourceKeys, key, index, quantity; if (!common.isObject(source)) { throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); } sourceKeys = Object.keys(source); for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { key = sourceKeys[index]; if (!_hasOwnProperty$1.call(destination, key)) { destination[key] = source[key]; overridableKeys[key] = true; } } } function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) { var index, quantity; // The output is a plain object here, so keys can only be strings. // We need to convert keyNode to a string, but doing so can hang the process // (deeply nested arrays that explode exponentially using aliases). if (Array.isArray(keyNode)) { keyNode = Array.prototype.slice.call(keyNode); for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { if (Array.isArray(keyNode[index])) { throwError(state, 'nested arrays are not supported inside keys'); } if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { keyNode[index] = '[object Object]'; } } } // Avoid code execution in load() via toString property // (still use its own toString for arrays, timestamps, // and whatever user schema extensions happen to have @@toStringTag) if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { keyNode = '[object Object]'; } keyNode = String(keyNode); if (_result === null) { _result = {}; } if (keyTag === 'tag:yaml.org,2002:merge') { if (Array.isArray(valueNode)) { for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { mergeMappings(state, _result, valueNode[index], overridableKeys); } } else { mergeMappings(state, _result, valueNode, overridableKeys); } } else { if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) { state.line = startLine || state.line; state.lineStart = startLineStart || state.lineStart; state.position = startPos || state.position; throwError(state, 'duplicated mapping key'); } // used for this specific key only because Object.defineProperty is slow if (keyNode === '__proto__') { Object.defineProperty(_result, keyNode, { configurable: true, enumerable: true, writable: true, value: valueNode }); } else { _result[keyNode] = valueNode; } delete overridableKeys[keyNode]; } return _result; } function readLineBreak(state) { var ch; ch = state.input.charCodeAt(state.position); if (ch === 0x0A/* LF */) { state.position++; } else if (ch === 0x0D/* CR */) { state.position++; if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { state.position++; } } else { throwError(state, 'a line break is expected'); } state.line += 1; state.lineStart = state.position; state.firstTabInLine = -1; } function skipSeparationSpace(state, allowComments, checkIndent) { var lineBreaks = 0, ch = state.input.charCodeAt(state.position); while (ch !== 0) { while (is_WHITE_SPACE(ch)) { if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { state.firstTabInLine = state.position; } ch = state.input.charCodeAt(++state.position); } if (allowComments && ch === 0x23/* # */) { do { ch = state.input.charCodeAt(++state.position); } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); } if (is_EOL(ch)) { readLineBreak(state); ch = state.input.charCodeAt(state.position); lineBreaks++; state.lineIndent = 0; while (ch === 0x20/* Space */) { state.lineIndent++; ch = state.input.charCodeAt(++state.position); } } else { break; } } if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { throwWarning(state, 'deficient indentation'); } return lineBreaks; } function testDocumentSeparator(state) { var _position = state.position, ch; ch = state.input.charCodeAt(_position); // Condition state.position === state.lineStart is tested // in parent on each call, for efficiency. No needs to test here again. if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) { _position += 3; ch = state.input.charCodeAt(_position); if (ch === 0 || is_WS_OR_EOL(ch)) { return true; } } return false; } function writeFoldedLines(state, count) { if (count === 1) { state.result += ' '; } else if (count > 1) { state.result += common.repeat('\n', count - 1); } } function readPlainScalar(state, nodeIndent, withinFlowCollection) { var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch; ch = state.input.charCodeAt(state.position); if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 0x23/* # */ || ch === 0x26/* & */ || ch === 0x2A/* * */ || ch === 0x21/* ! */ || ch === 0x7C/* | */ || ch === 0x3E/* > */ || ch === 0x27/* ' */ || ch === 0x22/* " */ || ch === 0x25/* % */ || ch === 0x40/* @ */ || ch === 0x60/* ` */) { return false; } if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { following = state.input.charCodeAt(state.position + 1); if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { return false; } } state.kind = 'scalar'; state.result = ''; captureStart = captureEnd = state.position; hasPendingContent = false; while (ch !== 0) { if (ch === 0x3A/* : */) { following = state.input.charCodeAt(state.position + 1); if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { break; } } else if (ch === 0x23/* # */) { preceding = state.input.charCodeAt(state.position - 1); if (is_WS_OR_EOL(preceding)) { break; } } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || withinFlowCollection && is_FLOW_INDICATOR(ch)) { break; } else if (is_EOL(ch)) { _line = state.line; _lineStart = state.lineStart; _lineIndent = state.lineIndent; skipSeparationSpace(state, false, -1); if (state.lineIndent >= nodeIndent) { hasPendingContent = true; ch = state.input.charCodeAt(state.position); continue; } else { state.position = captureEnd; state.line = _line; state.lineStart = _lineStart; state.lineIndent = _lineIndent; break; } } if (hasPendingContent) { captureSegment(state, captureStart, captureEnd, false); writeFoldedLines(state, state.line - _line); captureStart = captureEnd = state.position; hasPendingContent = false; } if (!is_WHITE_SPACE(ch)) { captureEnd = state.position + 1; } ch = state.input.charCodeAt(++state.position); } captureSegment(state, captureStart, captureEnd, false); if (state.result) { return true; } state.kind = _kind; state.result = _result; return false; } function readSingleQuotedScalar(state, nodeIndent) { var ch, captureStart, captureEnd; ch = state.input.charCodeAt(state.position); if (ch !== 0x27/* ' */) { return false; } state.kind = 'scalar'; state.result = ''; state.position++; captureStart = captureEnd = state.position; while ((ch = state.input.charCodeAt(state.position)) !== 0) { if (ch === 0x27/* ' */) { captureSegment(state, captureStart, state.position, true); ch = state.input.charCodeAt(++state.position); if (ch === 0x27/* ' */) { captureStart = state.position; state.position++; captureEnd = state.position; } else { return true; } } else if (is_EOL(ch)) { captureSegment(state, captureStart, captureEnd, true); writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); captureStart = captureEnd = state.position; } else if (state.position === state.lineStart && testDocumentSeparator(state)) { throwError(state, 'unexpected end of the document within a single quoted scalar'); } else { state.position++; captureEnd = state.position; } } throwError(state, 'unexpected end of the stream within a single quoted scalar'); } function readDoubleQuotedScalar(state, nodeIndent) { var captureStart, captureEnd, hexLength, hexResult, tmp, ch; ch = state.input.charCodeAt(state.position); if (ch !== 0x22/* " */) { return false; } state.kind = 'scalar'; state.result = ''; state.position++; captureStart = captureEnd = state.position; while ((ch = state.input.charCodeAt(state.position)) !== 0) { if (ch === 0x22/* " */) { captureSegment(state, captureStart, state.position, true); state.position++; return true; } else if (ch === 0x5C/* \ */) { captureSegment(state, captureStart, state.position, true); ch = state.input.charCodeAt(++state.position); if (is_EOL(ch)) { skipSeparationSpace(state, false, nodeIndent); // TODO: rework to inline fn with no type cast? } else if (ch < 256 && simpleEscapeCheck[ch]) { state.result += simpleEscapeMap[ch]; state.position++; } else if ((tmp = escapedHexLen(ch)) > 0) { hexLength = tmp; hexResult = 0; for (; hexLength > 0; hexLength--) { ch = state.input.charCodeAt(++state.position); if ((tmp = fromHexCode(ch)) >= 0) { hexResult = (hexResult << 4) + tmp; } else { throwError(state, 'expected hexadecimal character'); } } state.result += charFromCodepoint(hexResult); state.position++; } else { throwError(state, 'unknown escape sequence'); } captureStart = captureEnd = state.position; } else if (is_EOL(ch)) { captureSegment(state, captureStart, captureEnd, true); writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); captureStart = captureEnd = state.position; } else if (state.position === state.lineStart && testDocumentSeparator(state)) { throwError(state, 'unexpected end of the document within a double quoted scalar'); } else { state.position++; captureEnd = state.position; } } throwError(state, 'unexpected end of the stream within a double quoted scalar'); } function readFlowCollection(state, nodeIndent) { var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = Object.create(null), keyNode, keyTag, valueNode, ch; ch = state.input.charCodeAt(state.position); if (ch === 0x5B/* [ */) { terminator = 0x5D;/* ] */ isMapping = false; _result = []; } else if (ch === 0x7B/* { */) { terminator = 0x7D;/* } */ isMapping = true; _result = {}; } else { return false; } if (state.anchor !== null) { state.anchorMap[state.anchor] = _result; } ch = state.input.charCodeAt(++state.position); while (ch !== 0) { skipSeparationSpace(state, true, nodeIndent); ch = state.input.charCodeAt(state.position); if (ch === terminator) { state.position++; state.tag = _tag; state.anchor = _anchor; state.kind = isMapping ? 'mapping' : 'sequence'; state.result = _result; return true; } else if (!readNext) { throwError(state, 'missed comma between flow collection entries'); } else if (ch === 0x2C/* , */) { // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 throwError(state, "expected the node content, but found ','"); } keyTag = keyNode = valueNode = null; isPair = isExplicitPair = false; if (ch === 0x3F/* ? */) { following = state.input.charCodeAt(state.position + 1); if (is_WS_OR_EOL(following)) { isPair = isExplicitPair = true; state.position++; skipSeparationSpace(state, true, nodeIndent); } } _line = state.line; // Save the current line. _lineStart = state.lineStart; _pos = state.position; composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); keyTag = state.tag; keyNode = state.result; skipSeparationSpace(state, true, nodeIndent); ch = state.input.charCodeAt(state.position); if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { isPair = true; ch = state.input.charCodeAt(++state.position); skipSeparationSpace(state, true, nodeIndent); composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); valueNode = state.result; } if (isMapping) { storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); } else if (isPair) { _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); } else { _result.push(keyNode); } skipSeparationSpace(state, true, nodeIndent); ch = state.input.charCodeAt(state.position); if (ch === 0x2C/* , */) { readNext = true; ch = state.input.charCodeAt(++state.position); } else { readNext = false; } } throwError(state, 'unexpected end of the stream within a flow collection'); } function readBlockScalar(state, nodeIndent) { var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch; ch = state.input.charCodeAt(state.position); if (ch === 0x7C/* | */) { folding = false; } else if (ch === 0x3E/* > */) { folding = true; } else { return false; } state.kind = 'scalar'; state.result = ''; while (ch !== 0) { ch = state.input.charCodeAt(++state.position); if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { if (CHOMPING_CLIP === chomping) { chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; } else { throwError(state, 'repeat of a chomping mode identifier'); } } else if ((tmp = fromDecimalCode(ch)) >= 0) { if (tmp === 0) { throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); } else if (!detectedIndent) { textIndent = nodeIndent + tmp - 1; detectedIndent = true; } else { throwError(state, 'repeat of an indentation width identifier'); } } else { break; } } if (is_WHITE_SPACE(ch)) { do { ch = state.input.charCodeAt(++state.position); } while (is_WHITE_SPACE(ch)); if (ch === 0x23/* # */) { do { ch = state.input.charCodeAt(++state.position); } while (!is_EOL(ch) && (ch !== 0)); } } while (ch !== 0) { readLineBreak(state); state.lineIndent = 0; ch = state.input.charCodeAt(state.position); while ((!detectedIndent || state.lineIndent < textIndent) && (ch === 0x20/* Space */)) { state.lineIndent++; ch = state.input.charCodeAt(++state.position); } if (!detectedIndent && state.lineIndent > textIndent) { textIndent = state.lineIndent; } if (is_EOL(ch)) { emptyLines++; continue; } // End of the scalar. if (state.lineIndent < textIndent) { // Perform the chomping. if (chomping === CHOMPING_KEEP) { state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); } else if (chomping === CHOMPING_CLIP) { if (didReadContent) { // i.e. only if the scalar is not empty. state.result += '\n'; } } // Break this `while` cycle and go to the funciton's epilogue. break; } // Folded style: use fancy rules to handle line breaks. if (folding) { // Lines starting with white space characters (more-indented lines) are not folded. if (is_WHITE_SPACE(ch)) { atMoreIndented = true; // except for the first content line (cf. Example 8.1) state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); // End of more-indented block. } else if (atMoreIndented) { atMoreIndented = false; state.result += common.repeat('\n', emptyLines + 1); // Just one line break - perceive as the same line. } else if (emptyLines === 0) { if (didReadContent) { // i.e. only if we have already read some scalar content. state.result += ' '; } // Several line breaks - perceive as different lines. } else { state.result += common.repeat('\n', emptyLines); } // Literal style: just add exact number of line breaks between content lines. } else { // Keep all line breaks except the header line break. state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); } didReadContent = true; detectedIndent = true; emptyLines = 0; captureStart = state.position; while (!is_EOL(ch) && (ch !== 0)) { ch = state.input.charCodeAt(++state.position); } captureSegment(state, captureStart, state.position, false); } return true; } function readBlockSequence(state, nodeIndent) { var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch; // there is a leading tab before this token, so it can't be a block sequence/mapping; // it can still be flow sequence/mapping or a scalar if (state.firstTabInLine !== -1) return false; if (state.anchor !== null) { state.anchorMap[state.anchor] = _result; } ch = state.input.charCodeAt(state.position); while (ch !== 0) { if (state.firstTabInLine !== -1) { state.position = state.firstTabInLine; throwError(state, 'tab characters must not be used in indentation'); } if (ch !== 0x2D/* - */) { break; } following = state.input.charCodeAt(state.position + 1); if (!is_WS_OR_EOL(following)) { break; } detected = true; state.position++; if (skipSeparationSpace(state, true, -1)) { if (state.lineIndent <= nodeIndent) { _result.push(null); ch = state.input.charCodeAt(state.position); continue; } } _line = state.line; composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); _result.push(state.result); skipSeparationSpace(state, true, -1); ch = state.input.charCodeAt(state.position); if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { throwError(state, 'bad indentation of a sequence entry'); } else if (state.lineIndent < nodeIndent) { break; } } if (detected) { state.tag = _tag; state.anchor = _anchor; state.kind = 'sequence'; state.result = _result; return true; } return false; } function readBlockMapping(state, nodeIndent, flowIndent) { var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch; // there is a leading tab before this token, so it can't be a block sequence/mapping; // it can still be flow sequence/mapping or a scalar if (state.firstTabInLine !== -1) return false; if (state.anchor !== null) { state.anchorMap[state.anchor] = _result; } ch = state.input.charCodeAt(state.position); while (ch !== 0) { if (!atExplicitKey && state.firstTabInLine !== -1) { state.position = state.firstTabInLine; throwError(state, 'tab characters must not be used in indentation'); } following = state.input.charCodeAt(state.position + 1); _line = state.line; // Save the current line. // // Explicit notation case. There are two separate blocks: // first for the key (denoted by "?") and second for the value (denoted by ":") // if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { if (ch === 0x3F/* ? */) { if (atExplicitKey) { storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); keyTag = keyNode = valueNode = null; } detected = true; atExplicitKey = true; allowCompact = true; } else if (atExplicitKey) { // i.e. 0x3A/* : */ === character after the explicit key. atExplicitKey = false; allowCompact = true; } else { throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); } state.position += 1; ch = following; // // Implicit notation case. Flow-style node as the key first, then ":", and the value. // } else { _keyLine = state.line; _keyLineStart = state.lineStart; _keyPos = state.position; if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { // Neither implicit nor explicit notation. // Reading is done. Go to the epilogue. break; } if (state.line === _line) { ch = state.input.charCodeAt(state.position); while (is_WHITE_SPACE(ch)) { ch = state.input.charCodeAt(++state.position); } if (ch === 0x3A/* : */) { ch = state.input.charCodeAt(++state.position); if (!is_WS_OR_EOL(ch)) { throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); } if (atExplicitKey) { storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); keyTag = keyNode = valueNode = null; } detected = true; atExplicitKey = false; allowCompact = false; keyTag = state.tag; keyNode = state.result; } else if (detected) { throwError(state, 'can not read an implicit mapping pair; a colon is missed'); } else { state.tag = _tag; state.anchor = _anchor; return true; // Keep the result of `composeNode`. } } else if (detected) { throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); } else { state.tag = _tag; state.anchor = _anchor; return true; // Keep the result of `composeNode`. } } // // Common reading code for both explicit and implicit notations. // if (state.line === _line || state.lineIndent > nodeIndent) { if (atExplicitKey) { _keyLine = state.line; _keyLineStart = state.lineStart; _keyPos = state.position; } if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { if (atExplicitKey) { keyNode = state.result; } else { valueNode = state.result; } } if (!atExplicitKey) { storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); keyTag = keyNode = valueNode = null; } skipSeparationSpace(state, true, -1); ch = state.input.charCodeAt(state.position); } if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { throwError(state, 'bad indentation of a mapping entry'); } else if (state.lineIndent < nodeIndent) { break; } } // // Epilogue. // // Special case: last mapping's node contains only the key in explicit notation. if (atExplicitKey) { storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); } // Expose the resulting mapping. if (detected) { state.tag = _tag; state.anchor = _anchor; state.kind = 'mapping'; state.result = _result; } return detected; } function readTagProperty(state) { var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch; ch = state.input.charCodeAt(state.position); if (ch !== 0x21/* ! */) return false; if (state.tag !== null) { throwError(state, 'duplication of a tag property'); } ch = state.input.charCodeAt(++state.position); if (ch === 0x3C/* < */) { isVerbatim = true; ch = state.input.charCodeAt(++state.position); } else if (ch === 0x21/* ! */) { isNamed = true; tagHandle = '!!'; ch = state.input.charCodeAt(++state.position); } else { tagHandle = '!'; } _position = state.position; if (isVerbatim) { do { ch = state.input.charCodeAt(++state.position); } while (ch !== 0 && ch !== 0x3E/* > */); if (state.position < state.length) { tagName = state.input.slice(_position, state.position); ch = state.input.charCodeAt(++state.position); } else { throwError(state, 'unexpected end of the stream within a verbatim tag'); } } else { while (ch !== 0 && !is_WS_OR_EOL(ch)) { if (ch === 0x21/* ! */) { if (!isNamed) { tagHandle = state.input.slice(_position - 1, state.position + 1); if (!PATTERN_TAG_HANDLE.test(tagHandle)) { throwError(state, 'named tag handle cannot contain such characters'); } isNamed = true; _position = state.position + 1; } else { throwError(state, 'tag suffix cannot contain exclamation marks'); } } ch = state.input.charCodeAt(++state.position); } tagName = state.input.slice(_position, state.position); if (PATTERN_FLOW_INDICATORS.test(tagName)) { throwError(state, 'tag suffix cannot contain flow indicator characters'); } } if (tagName && !PATTERN_TAG_URI.test(tagName)) { throwError(state, 'tag name cannot contain such characters: ' + tagName); } try { tagName = decodeURIComponent(tagName); } catch (err) { throwError(state, 'tag name is malformed: ' + tagName); } if (isVerbatim) { state.tag = tagName; } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) { state.tag = state.tagMap[tagHandle] + tagName; } else if (tagHandle === '!') { state.tag = '!' + tagName; } else if (tagHandle === '!!') { state.tag = 'tag:yaml.org,2002:' + tagName; } else { throwError(state, 'undeclared tag handle "' + tagHandle + '"'); } return true; } function readAnchorProperty(state) { var _position, ch; ch = state.input.charCodeAt(state.position); if (ch !== 0x26/* & */) return false; if (state.anchor !== null) { throwError(state, 'duplication of an anchor property'); } ch = state.input.charCodeAt(++state.position); _position = state.position; while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { ch = state.input.charCodeAt(++state.position); } if (state.position === _position) { throwError(state, 'name of an anchor node must contain at least one character'); } state.anchor = state.input.slice(_position, state.position); return true; } function readAlias(state) { var _position, alias, ch; ch = state.input.charCodeAt(state.position); if (ch !== 0x2A/* * */) return false; ch = state.input.charCodeAt(++state.position); _position = state.position; while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { ch = state.input.charCodeAt(++state.position); } if (state.position === _position) { throwError(state, 'name of an alias node must contain at least one character'); } alias = state.input.slice(_position, state.position); if (!_hasOwnProperty$1.call(state.anchorMap, alias)) { throwError(state, 'unidentified alias "' + alias + '"'); } state.result = state.anchorMap[alias]; skipSeparationSpace(state, true, -1); return true; } function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { indentStatus = 1; } else if (state.lineIndent === parentIndent) { indentStatus = 0; } else if (state.lineIndent < parentIndent) { indentStatus = -1; } } } if (indentStatus === 1) { while (readTagProperty(state) || readAnchorProperty(state)) { if (skipSeparationSpace(state, true, -1)) { atNewLine = true; allowBlockCollections = allowBlockStyles; if (state.lineIndent > parentIndent) { indentStatus = 1; } else if (state.lineIndent === parentIndent) { indentStatus = 0; } else if (state.lineIndent < parentIndent) { indentStatus = -1; } } else { allowBlockCollections = false; } } } if (allowBlockCollections) { allowBlockCollections = atNewLine || allowCompact; } if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { flowIndent = parentIndent; } else { flowIndent = parentIndent + 1; } blockIndent = state.position - state.lineStart; if (indentStatus === 1) { if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) { hasContent = true; } else { if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) { hasContent = true; } else if (readAlias(state)) { hasContent = true; if (state.tag !== null || state.anchor !== null) { throwError(state, 'alias node should not have any properties'); } } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { hasContent = true; if (state.tag === null) { state.tag = '?'; } } if (state.anchor !== null) { state.anchorMap[state.anchor] = state.result; } } } else if (indentStatus === 0) { // Special case: block sequences are allowed to have same indentation level as the parent. // http://www.yaml.org/spec/1.2/spec.html#id2799784 hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); } } if (state.tag === null) { if (state.anchor !== null) { state.anchorMap[state.anchor] = state.result; } } else if (state.tag === '?') { // Implicit resolving is not allowed for non-scalar types, and '?' // non-specific tag is only automatically assigned to plain scalars. // // We only need to check kind conformity in case user explicitly assigns '?' // tag, for example like this: "! [0]" // if (state.result !== null && state.kind !== 'scalar') { throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); } for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { type = state.implicitTypes[typeIndex]; if (type.resolve(state.result)) { // `state.result` updated in resolver if matched state.result = type.construct(state.result); state.tag = type.tag; if (state.anchor !== null) { state.anchorMap[state.anchor] = state.result; } break; } } } else if (state.tag !== '!') { if (_hasOwnProperty$1.call(state.typeMap[state.kind || 'fallback'], state.tag)) { type = state.typeMap[state.kind || 'fallback'][state.tag]; } else { // looking for multi type type = null; typeList = state.typeMap.multi[state.kind || 'fallback']; for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { type = typeList[typeIndex]; break; } } } if (!type) { throwError(state, 'unknown tag !<' + state.tag + '>'); } if (state.result !== null && type.kind !== state.kind) { throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); } if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); } else { state.result = type.construct(state.result, state.tag); if (state.anchor !== null) { state.anchorMap[state.anchor] = state.result; } } } if (state.listener !== null) { state.listener('close', state); } return state.tag !== null || state.anchor !== null || hasContent; } function readDocument(state) { var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch; state.version = null; state.checkLineBreaks = state.legacy; state.tagMap = Object.create(null); state.anchorMap = Object.create(null); while ((ch = state.input.charCodeAt(state.position)) !== 0) { skipSeparationSpace(state, true, -1); ch = state.input.charCodeAt(state.position); if (state.lineIndent > 0 || ch !== 0x25/* % */) { break; } hasDirectives = true; ch = state.input.charCodeAt(++state.position); _position = state.position; while (ch !== 0 && !is_WS_OR_EOL(ch)) { ch = state.input.charCodeAt(++state.position); } directiveName = state.input.slice(_position, state.position); directiveArgs = []; if (directiveName.length < 1) { throwError(state, 'directive name must not be less than one character in length'); } while (ch !== 0) { while (is_WHITE_SPACE(ch)) { ch = state.input.charCodeAt(++state.position); } if (ch === 0x23/* # */) { do { ch = state.input.charCodeAt(++state.position); } while (ch !== 0 && !is_EOL(ch)); break; } if (is_EOL(ch)) break; _position = state.position; while (ch !== 0 && !is_WS_OR_EOL(ch)) { ch = state.input.charCodeAt(++state.position); } directiveArgs.push(state.input.slice(_position, state.position)); } if (ch !== 0) readLineBreak(state); if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { directiveHandlers[directiveName](state, directiveName, directiveArgs); } else { throwWarning(state, 'unknown document directive "' + directiveName + '"'); } } skipSeparationSpace(state, true, -1); if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 0x2D/* - */ && state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { state.position += 3; skipSeparationSpace(state, true, -1); } else if (hasDirectives) { throwError(state, 'directives end mark is expected'); } composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); skipSeparationSpace(state, true, -1); if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { throwWarning(state, 'non-ASCII line breaks are interpreted as content'); } state.documents.push(state.result); if (state.position === state.lineStart && testDocumentSeparator(state)) { if (state.input.charCodeAt(state.position) === 0x2E/* . */) { state.position += 3; skipSeparationSpace(state, true, -1); } return; } if (state.position < (state.length - 1)) { throwError(state, 'end of the stream or a document separator is expected'); } else { return; } } function loadDocuments(input, options) { input = String(input); options = options || {}; if (input.length !== 0) { // Add tailing `\n` if not exists if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { input += '\n'; } // Strip BOM if (input.charCodeAt(0) === 0xFEFF) { input = input.slice(1); } } var state = new State$1(input, options); var nullpos = input.indexOf('\0'); if (nullpos !== -1) { state.position = nullpos; throwError(state, 'null byte is not allowed in input'); } // Use 0 as string terminator. That significantly simplifies bounds check. state.input += '\0'; while (state.input.charCodeAt(state.position) === 0x20/* Space */) { state.lineIndent += 1; state.position += 1; } while (state.position < (state.length - 1)) { readDocument(state); } return state.documents; } function loadAll$1(input, iterator, options) { if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { options = iterator; iterator = null; } var documents = loadDocuments(input, options); if (typeof iterator !== 'function') { return documents; } for (var index = 0, length = documents.length; index < length; index += 1) { iterator(documents[index]); } } function load$1(input, options) { var documents = loadDocuments(input, options); if (documents.length === 0) { /*eslint-disable no-undefined*/ return undefined; } else if (documents.length === 1) { return documents[0]; } throw new exception('expected a single document in the stream, but found more'); } var loadAll_1 = loadAll$1; var load_1 = load$1; var loader = { loadAll: loadAll_1, load: load_1 }; /*eslint-disable no-use-before-define*/ var _toString = Object.prototype.toString; var _hasOwnProperty = Object.prototype.hasOwnProperty; var CHAR_BOM = 0xFEFF; var CHAR_TAB = 0x09; /* Tab */ var CHAR_LINE_FEED = 0x0A; /* LF */ var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ var CHAR_SPACE = 0x20; /* Space */ var CHAR_EXCLAMATION = 0x21; /* ! */ var CHAR_DOUBLE_QUOTE = 0x22; /* " */ var CHAR_SHARP = 0x23; /* # */ var CHAR_PERCENT = 0x25; /* % */ var CHAR_AMPERSAND = 0x26; /* & */ var CHAR_SINGLE_QUOTE = 0x27; /* ' */ var CHAR_ASTERISK = 0x2A; /* * */ var CHAR_COMMA = 0x2C; /* , */ var CHAR_MINUS = 0x2D; /* - */ var CHAR_COLON = 0x3A; /* : */ var CHAR_EQUALS = 0x3D; /* = */ var CHAR_GREATER_THAN = 0x3E; /* > */ var CHAR_QUESTION = 0x3F; /* ? */ var CHAR_COMMERCIAL_AT = 0x40; /* @ */ var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ var CHAR_GRAVE_ACCENT = 0x60; /* ` */ var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ var CHAR_VERTICAL_LINE = 0x7C; /* | */ var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ var ESCAPE_SEQUENCES = {}; ESCAPE_SEQUENCES[0x00] = '\\0'; ESCAPE_SEQUENCES[0x07] = '\\a'; ESCAPE_SEQUENCES[0x08] = '\\b'; ESCAPE_SEQUENCES[0x09] = '\\t'; ESCAPE_SEQUENCES[0x0A] = '\\n'; ESCAPE_SEQUENCES[0x0B] = '\\v'; ESCAPE_SEQUENCES[0x0C] = '\\f'; ESCAPE_SEQUENCES[0x0D] = '\\r'; ESCAPE_SEQUENCES[0x1B] = '\\e'; ESCAPE_SEQUENCES[0x22] = '\\"'; ESCAPE_SEQUENCES[0x5C] = '\\\\'; ESCAPE_SEQUENCES[0x85] = '\\N'; ESCAPE_SEQUENCES[0xA0] = '\\_'; ESCAPE_SEQUENCES[0x2028] = '\\L'; ESCAPE_SEQUENCES[0x2029] = '\\P'; var DEPRECATED_BOOLEANS_SYNTAX = [ 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' ]; var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; function compileStyleMap(schema, map) { var result, keys, index, length, tag, style, type; if (map === null) return {}; result = {}; keys = Object.keys(map); for (index = 0, length = keys.length; index < length; index += 1) { tag = keys[index]; style = String(map[tag]); if (tag.slice(0, 2) === '!!') { tag = 'tag:yaml.org,2002:' + tag.slice(2); } type = schema.compiledTypeMap['fallback'][tag]; if (type && _hasOwnProperty.call(type.styleAliases, style)) { style = type.styleAliases[style]; } result[tag] = style; } return result; } function encodeHex(character) { var string, handle, length; string = character.toString(16).toUpperCase(); if (character <= 0xFF) { handle = 'x'; length = 2; } else if (character <= 0xFFFF) { handle = 'u'; length = 4; } else if (character <= 0xFFFFFFFF) { handle = 'U'; length = 8; } else { throw new exception('code point within a string may not be greater than 0xFFFFFFFF'); } return '\\' + handle + common.repeat('0', length - string.length) + string; } var QUOTING_TYPE_SINGLE = 1, QUOTING_TYPE_DOUBLE = 2; function State(options) { this.schema = options['schema'] || _default; this.indent = Math.max(1, (options['indent'] || 2)); this.noArrayIndent = options['noArrayIndent'] || false; this.skipInvalid = options['skipInvalid'] || false; this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); this.styleMap = compileStyleMap(this.schema, options['styles'] || null); this.sortKeys = options['sortKeys'] || false; this.lineWidth = options['lineWidth'] || 80; this.noRefs = options['noRefs'] || false; this.noCompatMode = options['noCompatMode'] || false; this.condenseFlow = options['condenseFlow'] || false; this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; this.forceQuotes = options['forceQuotes'] || false; this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; this.implicitTypes = this.schema.compiledImplicit; this.explicitTypes = this.schema.compiledExplicit; this.tag = null; this.result = ''; this.duplicates = []; this.usedDuplicates = null; } // Indents every line in a string. Empty lines (\n only) are not indented. function indentString(string, spaces) { var ind = common.repeat(' ', spaces), position = 0, next = -1, result = '', line, length = string.length; while (position < length) { next = string.indexOf('\n', position); if (next === -1) { line = string.slice(position); position = length; } else { line = string.slice(position, next + 1); position = next + 1; } if (line.length && line !== '\n') result += ind; result += line; } return result; } function generateNextLine(state, level) { return '\n' + common.repeat(' ', state.indent * level); } function testImplicitResolving(state, str) { var index, length, type; for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { type = state.implicitTypes[index]; if (type.resolve(str)) { return true; } } return false; } // [33] s-white ::= s-space | s-tab function isWhitespace(c) { return c === CHAR_SPACE || c === CHAR_TAB; } // Returns true if the character can be printed without escaping. // From YAML 1.2: "any allowed characters known to be non-printable // should also be escaped. [However,] This isn’t mandatory" // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. function isPrintable(c) { return (0x00020 <= c && c <= 0x00007E) || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) || (0x10000 <= c && c <= 0x10FFFF); } // [34] ns-char ::= nb-char - s-white // [27] nb-char ::= c-printable - b-char - c-byte-order-mark // [26] b-char ::= b-line-feed | b-carriage-return // Including s-white (for some reason, examples doesn't match specs in this aspect) // ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark function isNsCharOrWhitespace(c) { return isPrintable(c) && c !== CHAR_BOM // - b-char && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED; } // [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out // c = flow-in ⇒ ns-plain-safe-in // c = block-key ⇒ ns-plain-safe-out // c = flow-key ⇒ ns-plain-safe-in // [128] ns-plain-safe-out ::= ns-char // [129] ns-plain-safe-in ::= ns-char - c-flow-indicator // [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) // | ( /* An ns-char preceding */ “#” ) // | ( “:” /* Followed by an ns-plain-safe(c) */ ) function isPlainSafe(c, prev, inblock) { var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); return ( // ns-plain-safe inblock ? // c = flow-in cIsNsCharOrWhitespace : cIsNsCharOrWhitespace // - c-flow-indicator && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET ) // ns-plain-char && c !== CHAR_SHARP // false on '#' && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' } // Simplified test for values allowed as the first character in plain style. function isPlainSafeFirst(c) { // Uses a subset of ns-char - c-indicator // where ns-char = nb-char - s-white. // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) // - s-white // - (c-indicator ::= // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE // | “%” | “@” | “`”) && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT; } // Simplified test for values allowed as the last character in plain style. function isPlainSafeLast(c) { // just not whitespace or colon, it will be checked to be plain character later return !isWhitespace(c) && c !== CHAR_COLON; } // Same as 'string'.codePointAt(pos), but works in older browsers. function codePointAt(string, pos) { var first = string.charCodeAt(pos), second; if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { second = string.charCodeAt(pos + 1); if (second >= 0xDC00 && second <= 0xDFFF) { // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; } } return first; } // Determines whether block indentation indicator is required. function needIndentIndicator(string) { var leadingSpaceRe = /^\n* /; return leadingSpaceRe.test(string); } var STYLE_PLAIN = 1, STYLE_SINGLE = 2, STYLE_LITERAL = 3, STYLE_FOLDED = 4, STYLE_DOUBLE = 5; // Determines which scalar styles are possible and returns the preferred style. // lineWidth = -1 => no limit. // Pre-conditions: str.length > 0. // Post-conditions: // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) { var i; var char = 0; var prevChar = null; var hasLineBreak = false; var hasFoldableLine = false; // only checked if shouldTrackWidth var shouldTrackWidth = lineWidth !== -1; var previousLineBreak = -1; // count the first line correctly var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1)); if (singleLineOnly || forceQuotes) { // Case: no block styles. // Check for disallowed characters to rule out plain and single. for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { char = codePointAt(string, i); if (!isPrintable(char)) { return STYLE_DOUBLE; } plain = plain && isPlainSafe(char, prevChar, inblock); prevChar = char; } } else { // Case: block styles permitted. for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { char = codePointAt(string, i); if (char === CHAR_LINE_FEED) { hasLineBreak = true; // Check if any line can be folded. if (shouldTrackWidth) { hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented. (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== ' '); previousLineBreak = i; } } else if (!isPrintable(char)) { return STYLE_DOUBLE; } plain = plain && isPlainSafe(char, prevChar, inblock); prevChar = char; } // in case the end is missing a \n hasFoldableLine = hasFoldableLine || (shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== ' ')); } // Although every style can represent \n without escaping, prefer block styles // for multiline, since they're more readable and they don't add empty lines. // Also prefer folding a super-long line. if (!hasLineBreak && !hasFoldableLine) { // Strings interpretable as another type have to be quoted; // e.g. the string 'true' vs. the boolean true. if (plain && !forceQuotes && !testAmbiguousType(string)) { return STYLE_PLAIN; } return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; } // Edge case: block indentation indicator can only have one digit. if (indentPerLevel > 9 && needIndentIndicator(string)) { return STYLE_DOUBLE; } // At this point we know block styles are valid. // Prefer literal style unless we want to fold. if (!forceQuotes) { return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; } return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; } // Note: line breaking/folding is implemented for only the folded style. // NB. We drop the last trailing newline (if any) of a returned block scalar // since the dumper adds its own newline. This always works: // • No ending newline => unaffected; already using strip "-" chomping. // • Ending newline => removed then restored. // Importantly, this keeps the "+" chomp indicator from gaining an extra line. function writeScalar(state, string, level, iskey, inblock) { state.dump = (function () { if (string.length === 0) { return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; } if (!state.noCompatMode) { if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); } } var indent = state.indent * Math.max(1, level); // no 0-indent scalars // As indentation gets deeper, let the width decrease monotonically // to the lower bound min(state.lineWidth, 40). // Note that this implies // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. // state.lineWidth > 40 + state.indent: width decreases until the lower bound. // This behaves better than a constant minimum width which disallows narrower options, // or an indent threshold which causes the width to suddenly increase. var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); // Without knowing if keys are implicit/explicit, assume implicit for safety. var singleLineOnly = iskey // No block styles in flow mode. || (state.flowLevel > -1 && level >= state.flowLevel); function testAmbiguity(string) { return testImplicitResolving(state, string); } switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { case STYLE_PLAIN: return string; case STYLE_SINGLE: return "'" + string.replace(/'/g, "''") + "'"; case STYLE_LITERAL: return '|' + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent)); case STYLE_FOLDED: return '>' + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); case STYLE_DOUBLE: return '"' + escapeString(string) + '"'; default: throw new exception('impossible error: invalid scalar style'); } }()); } // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. function blockHeader(string, indentPerLevel) { var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; // note the special case: the string '\n' counts as a "trailing" empty line. var clip = string[string.length - 1] === '\n'; var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); var chomp = keep ? '+' : (clip ? '' : '-'); return indentIndicator + chomp + '\n'; } // (See the note for writeScalar.) function dropEndingNewline(string) { return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; } // Note: a long line without a suitable break point will exceed the width limit. // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. function foldString(string, width) { // In folded style, $k$ consecutive newlines output as $k+1$ newlines— // unless they're before or after a more-indented line, or at the very // beginning or end, in which case $k$ maps to $k$. // Therefore, parse each chunk as newline(s) followed by a content line. var lineRe = /(\n+)([^\n]*)/g; // first line (possibly an empty line) var result = (function () { var nextLF = string.indexOf('\n'); nextLF = nextLF !== -1 ? nextLF : string.length; lineRe.lastIndex = nextLF; return foldLine(string.slice(0, nextLF), width); }()); // If we haven't reached the first content line yet, don't add an extra \n. var prevMoreIndented = string[0] === '\n' || string[0] === ' '; var moreIndented; // rest of the lines var match; while ((match = lineRe.exec(string))) { var prefix = match[1], line = match[2]; moreIndented = (line[0] === ' '); result += prefix + (!prevMoreIndented && !moreIndented && line !== '' ? '\n' : '') + foldLine(line, width); prevMoreIndented = moreIndented; } return result; } // Greedy line breaking. // Picks the longest line under the limit each time, // otherwise settles for the shortest line over the limit. // NB. More-indented lines *cannot* be folded, as that would add an extra \n. function foldLine(line, width) { if (line === '' || line[0] === ' ') return line; // Since a more-indented line adds a \n, breaks can't be followed by a space. var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. var match; // start is an inclusive index. end, curr, and next are exclusive. var start = 0, end, curr = 0, next = 0; var result = ''; // Invariants: 0 <= start <= length-1. // 0 <= curr <= next <= max(0, length-2). curr - start <= width. // Inside the loop: // A match implies length >= 2, so curr and next are <= length-2. while ((match = breakRe.exec(line))) { next = match.index; // maintain invariant: curr - start <= width if (next - start > width) { end = (curr > start) ? curr : next; // derive end <= length-2 result += '\n' + line.slice(start, end); // skip the space that was output as \n start = end + 1; // derive start <= length-1 } curr = next; } // By the invariants, start <= length-1, so there is something left over. // It is either the whole string or a part starting from non-whitespace. result += '\n'; // Insert a break if the remainder is too long and there is a break available. if (line.length - start > width && curr > start) { result += line.slice(start, curr) + '\n' + line.slice(curr + 1); } else { result += line.slice(start); } return result.slice(1); // drop extra \n joiner } // Escapes a double-quoted string. function escapeString(string) { var result = ''; var char = 0; var escapeSeq; for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { char = codePointAt(string, i); escapeSeq = ESCAPE_SEQUENCES[char]; if (!escapeSeq && isPrintable(char)) { result += string[i]; if (char >= 0x10000) result += string[i + 1]; } else { result += escapeSeq || encodeHex(char); } } return result; } function writeFlowSequence(state, level, object) { var _result = '', _tag = state.tag, index, length, value; for (index = 0, length = object.length; index < length; index += 1) { value = object[index]; if (state.replacer) { value = state.replacer.call(object, String(index), value); } // Write only valid elements, put null instead of invalid elements. if (writeNode(state, level, value, false, false) || (typeof value === 'undefined' && writeNode(state, level, null, false, false))) { if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); _result += state.dump; } } state.tag = _tag; state.dump = '[' + _result + ']'; } function writeBlockSequence(state, level, object, compact) { var _result = '', _tag = state.tag, index, length, value; for (index = 0, length = object.length; index < length; index += 1) { value = object[index]; if (state.replacer) { value = state.replacer.call(object, String(index), value); } // Write only valid elements, put null instead of invalid elements. if (writeNode(state, level + 1, value, true, true, false, true) || (typeof value === 'undefined' && writeNode(state, level + 1, null, true, true, false, true))) { if (!compact || _result !== '') { _result += generateNextLine(state, level); } if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { _result += '-'; } else { _result += '- '; } _result += state.dump; } } state.tag = _tag; state.dump = _result || '[]'; // Empty sequence if no valid values. } function writeFlowMapping(state, level, object) { var _result = '', _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer; for (index = 0, length = objectKeyList.length; index < length; index += 1) { pairBuffer = ''; if (_result !== '') pairBuffer += ', '; if (state.condenseFlow) pairBuffer += '"'; objectKey = objectKeyList[index]; objectValue = object[objectKey]; if (state.replacer) { objectValue = state.replacer.call(object, objectKey, objectValue); } if (!writeNode(state, level, objectKey, false, false)) { continue; // Skip this pair because of invalid key; } if (state.dump.length > 1024) pairBuffer += '? '; pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); if (!writeNode(state, level, objectValue, false, false)) { continue; // Skip this pair because of invalid value. } pairBuffer += state.dump; // Both key and value are valid. _result += pairBuffer; } state.tag = _tag; state.dump = '{' + _result + '}'; } function writeBlockMapping(state, level, object, compact) { var _result = '', _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer; // Allow sorting keys so that the output file is deterministic if (state.sortKeys === true) { // Default sorting objectKeyList.sort(); } else if (typeof state.sortKeys === 'function') { // Custom sort function objectKeyList.sort(state.sortKeys); } else if (state.sortKeys) { // Something is wrong throw new exception('sortKeys must be a boolean or a function'); } for (index = 0, length = objectKeyList.length; index < length; index += 1) { pairBuffer = ''; if (!compact || _result !== '') { pairBuffer += generateNextLine(state, level); } objectKey = objectKeyList[index]; objectValue = object[objectKey]; if (state.replacer) { objectValue = state.replacer.call(object, objectKey, objectValue); } if (!writeNode(state, level + 1, objectKey, true, true, true)) { continue; // Skip this pair because of invalid key. } explicitPair = (state.tag !== null && state.tag !== '?') || (state.dump && state.dump.length > 1024); if (explicitPair) { if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { pairBuffer += '?'; } else { pairBuffer += '? '; } } pairBuffer += state.dump; if (explicitPair) { pairBuffer += generateNextLine(state, level); } if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { continue; // Skip this pair because of invalid value. } if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { pairBuffer += ':'; } else { pairBuffer += ': '; } pairBuffer += state.dump; // Both key and value are valid. _result += pairBuffer; } state.tag = _tag; state.dump = _result || '{}'; // Empty mapping if no valid pairs. } function detectType(state, object, explicit) { var _result, typeList, index, length, type, style; typeList = explicit ? state.explicitTypes : state.implicitTypes; for (index = 0, length = typeList.length; index < length; index += 1) { type = typeList[index]; if ((type.instanceOf || type.predicate) && (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && (!type.predicate || type.predicate(object))) { if (explicit) { if (type.multi && type.representName) { state.tag = type.representName(object); } else { state.tag = type.tag; } } else { state.tag = '?'; } if (type.represent) { style = state.styleMap[type.tag] || type.defaultStyle; if (_toString.call(type.represent) === '[object Function]') { _result = type.represent(object, style); } else if (_hasOwnProperty.call(type.represent, style)) { _result = type.represent[style](object, style); } else { throw new exception('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); } state.dump = _result; } return true; } } return false; } // Serializes `object` and writes it to global `result`. // Returns true on success, or false on invalid object. // function writeNode(state, level, object, block, compact, iskey, isblockseq) { state.tag = null; state.dump = object; if (!detectType(state, object, false)) { detectType(state, object, true); } var type = _toString.call(state.dump); var inblock = block; var tagStr; if (block) { block = (state.flowLevel < 0 || state.flowLevel > level); } var objectOrArray = type === '[object Object]' || type === '[object Array]', duplicateIndex, duplicate; if (objectOrArray) { duplicateIndex = state.duplicates.indexOf(object); duplicate = duplicateIndex !== -1; } if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { compact = false; } if (duplicate && state.usedDuplicates[duplicateIndex]) { state.dump = '*ref_' + duplicateIndex; } else { if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { state.usedDuplicates[duplicateIndex] = true; } if (type === '[object Object]') { if (block && (Object.keys(state.dump).length !== 0)) { writeBlockMapping(state, level, state.dump, compact); if (duplicate) { state.dump = '&ref_' + duplicateIndex + state.dump; } } else { writeFlowMapping(state, level, state.dump); if (duplicate) { state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; } } } else if (type === '[object Array]') { if (block && (state.dump.length !== 0)) { if (state.noArrayIndent && !isblockseq && level > 0) { writeBlockSequence(state, level - 1, state.dump, compact); } else { writeBlockSequence(state, level, state.dump, compact); } if (duplicate) { state.dump = '&ref_' + duplicateIndex + state.dump; } } else { writeFlowSequence(state, level, state.dump); if (duplicate) { state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; } } } else if (type === '[object String]') { if (state.tag !== '?') { writeScalar(state, state.dump, level, iskey, inblock); } } else if (type === '[object Undefined]') { return false; } else { if (state.skipInvalid) return false; throw new exception('unacceptable kind of an object to dump ' + type); } if (state.tag !== null && state.tag !== '?') { // Need to encode all characters except those allowed by the spec: // // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */ // [36] ns-hex-digit ::= ns-dec-digit // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */ // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */ // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#” // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,” // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]” // // Also need to encode '!' because it has special meaning (end of tag prefix). // tagStr = encodeURI( state.tag[0] === '!' ? state.tag.slice(1) : state.tag ).replace(/!/g, '%21'); if (state.tag[0] === '!') { tagStr = '!' + tagStr; } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { tagStr = '!!' + tagStr.slice(18); } else { tagStr = '!<' + tagStr + '>'; } state.dump = tagStr + ' ' + state.dump; } } return true; } function getDuplicateReferences(object, state) { var objects = [], duplicatesIndexes = [], index, length; inspectNode(object, objects, duplicatesIndexes); for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { state.duplicates.push(objects[duplicatesIndexes[index]]); } state.usedDuplicates = new Array(length); } function inspectNode(object, objects, duplicatesIndexes) { var objectKeyList, index, length; if (object !== null && typeof object === 'object') { index = objects.indexOf(object); if (index !== -1) { if (duplicatesIndexes.indexOf(index) === -1) { duplicatesIndexes.push(index); } } else { objects.push(object); if (Array.isArray(object)) { for (index = 0, length = object.length; index < length; index += 1) { inspectNode(object[index], objects, duplicatesIndexes); } } else { objectKeyList = Object.keys(object); for (index = 0, length = objectKeyList.length; index < length; index += 1) { inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); } } } } } function dump$1(input, options) { options = options || {}; var state = new State(options); if (!state.noRefs) getDuplicateReferences(input, state); var value = input; if (state.replacer) { value = state.replacer.call({ '': value }, '', value); } if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; return ''; } var dump_1 = dump$1; var dumper = { dump: dump_1 }; function renamed(from, to) { return function () { throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + 'Use yaml.' + to + ' instead, which is now safe by default.'); }; } var Type = type; var Schema = schema; var FAILSAFE_SCHEMA = failsafe; var JSON_SCHEMA = json; var CORE_SCHEMA = core$1; var DEFAULT_SCHEMA = _default; var load = loader.load; var loadAll = loader.loadAll; var dump = dumper.dump; var YAMLException = exception; // Re-export all types in case user wants to create custom schema var types = { binary: binary, float: float, map: map$4, null: _null, pairs: pairs, set: set, timestamp: timestamp, bool: bool, int: int$1, merge: merge, omap: omap, seq: seq, str: str }; // Removed functions from JS-YAML 3.0.x var safeLoad = renamed('safeLoad', 'load'); var safeLoadAll = renamed('safeLoadAll', 'loadAll'); var safeDump = renamed('safeDump', 'dump'); var jsYaml = { Type: Type, Schema: Schema, FAILSAFE_SCHEMA: FAILSAFE_SCHEMA, JSON_SCHEMA: JSON_SCHEMA, CORE_SCHEMA: CORE_SCHEMA, DEFAULT_SCHEMA: DEFAULT_SCHEMA, load: load, loadAll: loadAll, dump: dump, YAMLException: YAMLException, types: types, safeLoad: safeLoad, safeLoadAll: safeLoadAll, safeDump: safeDump }; var DEFAULT_DATE_FORMAT = 'YYYYMMDDHHmm'; var DATE_REGEX = /(?{{date:?(?[^}]*)}})/g; var NEW_HEADER_TEMPLATE = "\ndate created: \"{{date:YYYY-MM-DD HH:mm}}\" \n"; var UPDATE_HEADER_TEMPLATE = "\ndate updated: \"{{date:YYYY-MM-DD HH:mm}}\" \n"; var DEFAULT_OPTIONS = { bullet: "-", fence: "`", emphasis: "*", rule: "-", fences: true, listItemIndent: "one", tightDefinitions: false, incrementListMarker: true, createHeaderIfNotPresent: false, newHeaderTemplate: NEW_HEADER_TEMPLATE, updateHeader: false, updateHeaderTemplate: UPDATE_HEADER_TEMPLATE, newlinesAroundHeadings: true }; // Unique ID creation requires a high quality random # generator. In the browser we therefore // require the crypto API and do not support built-in fallback to lower quality random number // generators (like Math.random()). var getRandomValues; var rnds8 = new Uint8Array(16); function rng() { // lazy load so that environments that need to polyfill have a chance to do so if (!getRandomValues) { // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, // find the complete implementation of crypto (msCrypto) on IE11. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); if (!getRandomValues) { throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); } } return getRandomValues(rnds8); } var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; function validate(uuid) { return typeof uuid === 'string' && REGEX.test(uuid); } /** * Convert array of 16 byte values to UUID string format of the form: * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */ var byteToHex = []; for (var i = 0; i < 256; ++i) { byteToHex.push((i + 0x100).toString(16).substr(1)); } function stringify$3(arr) { var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; // Note: Be careful editing this code! It's been tuned for performance // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one // of the following: // - One or more input array values don't map to a hex octet (leading to // "undefined" in the uuid) // - Invalid input values for the RFC `version` or `variant` fields if (!validate(uuid)) { throw TypeError('Stringified UUID is invalid'); } return uuid; } function v4(options, buf, offset) { options = options || {}; var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` rnds[6] = rnds[6] & 0x0f | 0x40; rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided if (buf) { offset = offset || 0; for (var i = 0; i < 16; ++i) { buf[offset + i] = rnds[i]; } return buf; } return stringify$3(rnds); } /** * From note-refactor-obsidian */ var Templates = /** @class */ (function () { function Templates() { } Templates.prototype.findHashtags = function (searchText) { return searchText.split(/\s/gm).filter(function (s) { if (s === "#") { return false; } if (s.startsWith("##")) { return false; } return s.startsWith("#"); }); }; Templates.prototype.isValidYaml = function (input) { try { jsYaml.dump(jsYaml.load(String(input))); return true; } catch (error) { return false; } }; Templates.prototype.replaceUUID = function (input) { if (input.includes('{{UUID}}')) { var uuid = v4(); input = input.replace('{{UUID}}', uuid); } return input; }; Templates.prototype.replaceDates = function (input, moment) { //A regex to capture multiple matches, each with a target group ({date:YYMMDD}) and date group (YYMMDD) var dateRegex = DATE_REGEX; var customFolderString = input; //Iterate through the matches to collect them in a single array var matches = []; var match; while ((match = dateRegex.exec(customFolderString))) { matches.push(match); } //Return the custom folder setting value if no dates are found if (!matches || matches.length === 0) { return input; } //Transform date matches into moment formatted dates var formattedDates = matches.map(function (m) { //Default to YYYYMMDDHHmm if {{date}} is used var dateFormat = m.groups.date === "" ? DEFAULT_DATE_FORMAT : m.groups.date; return [m.groups.target, moment.format(dateFormat)]; }); //Check to see if any date formatting is needed. If not return the unformatted setting text. var output = customFolderString; formattedDates.forEach(function (fd) { output = output.replace(fd[0], fd[1]); }); return output; }; return Templates; }()); var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function createCommonjsModule(fn, basedir, module) { return module = { path: basedir, exports: {}, require: function (path, base) { return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); } }, fn(module, module.exports), module.exports; } function commonjsRequire () { throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); } var moment = createCommonjsModule(function (module, exports) { (function (global, factory) { module.exports = factory() ; }(commonjsGlobal, (function () { var hookCallback; function hooks() { return hookCallback.apply(null, arguments); } // This is done to register the method called with moment() // without creating circular dependencies. function setHookCallback(callback) { hookCallback = callback; } function isArray(input) { return ( input instanceof Array || Object.prototype.toString.call(input) === '[object Array]' ); } function isObject(input) { // IE8 will treat undefined and null as object if it wasn't for // input != null return ( input != null && Object.prototype.toString.call(input) === '[object Object]' ); } function hasOwnProp(a, b) { return Object.prototype.hasOwnProperty.call(a, b); } function isObjectEmpty(obj) { if (Object.getOwnPropertyNames) { return Object.getOwnPropertyNames(obj).length === 0; } else { var k; for (k in obj) { if (hasOwnProp(obj, k)) { return false; } } return true; } } function isUndefined(input) { return input === void 0; } function isNumber(input) { return ( typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]' ); } function isDate(input) { return ( input instanceof Date || Object.prototype.toString.call(input) === '[object Date]' ); } function map(arr, fn) { var res = [], i; for (i = 0; i < arr.length; ++i) { res.push(fn(arr[i], i)); } return res; } function extend(a, b) { for (var i in b) { if (hasOwnProp(b, i)) { a[i] = b[i]; } } if (hasOwnProp(b, 'toString')) { a.toString = b.toString; } if (hasOwnProp(b, 'valueOf')) { a.valueOf = b.valueOf; } return a; } function createUTC(input, format, locale, strict) { return createLocalOrUTC(input, format, locale, strict, true).utc(); } function defaultParsingFlags() { // We need to deep clone this object. return { empty: false, unusedTokens: [], unusedInput: [], overflow: -2, charsLeftOver: 0, nullInput: false, invalidEra: null, invalidMonth: null, invalidFormat: false, userInvalidated: false, iso: false, parsedDateParts: [], era: null, meridiem: null, rfc2822: false, weekdayMismatch: false, }; } function getParsingFlags(m) { if (m._pf == null) { m._pf = defaultParsingFlags(); } return m._pf; } var some; if (Array.prototype.some) { some = Array.prototype.some; } else { some = function (fun) { var t = Object(this), len = t.length >>> 0, i; for (i = 0; i < len; i++) { if (i in t && fun.call(this, t[i], i, t)) { return true; } } return false; }; } function isValid(m) { if (m._isValid == null) { var flags = getParsingFlags(m), parsedParts = some.call(flags.parsedDateParts, function (i) { return i != null; }), isNowValid = !isNaN(m._d.getTime()) && flags.overflow < 0 && !flags.empty && !flags.invalidEra && !flags.invalidMonth && !flags.invalidWeekday && !flags.weekdayMismatch && !flags.nullInput && !flags.invalidFormat && !flags.userInvalidated && (!flags.meridiem || (flags.meridiem && parsedParts)); if (m._strict) { isNowValid = isNowValid && flags.charsLeftOver === 0 && flags.unusedTokens.length === 0 && flags.bigHour === undefined; } if (Object.isFrozen == null || !Object.isFrozen(m)) { m._isValid = isNowValid; } else { return isNowValid; } } return m._isValid; } function createInvalid(flags) { var m = createUTC(NaN); if (flags != null) { extend(getParsingFlags(m), flags); } else { getParsingFlags(m).userInvalidated = true; } return m; } // Plugins that add properties should also add the key here (null value), // so we can properly clone ourselves. var momentProperties = (hooks.momentProperties = []), updateInProgress = false; function copyConfig(to, from) { var i, prop, val; if (!isUndefined(from._isAMomentObject)) { to._isAMomentObject = from._isAMomentObject; } if (!isUndefined(from._i)) { to._i = from._i; } if (!isUndefined(from._f)) { to._f = from._f; } if (!isUndefined(from._l)) { to._l = from._l; } if (!isUndefined(from._strict)) { to._strict = from._strict; } if (!isUndefined(from._tzm)) { to._tzm = from._tzm; } if (!isUndefined(from._isUTC)) { to._isUTC = from._isUTC; } if (!isUndefined(from._offset)) { to._offset = from._offset; } if (!isUndefined(from._pf)) { to._pf = getParsingFlags(from); } if (!isUndefined(from._locale)) { to._locale = from._locale; } if (momentProperties.length > 0) { for (i = 0; i < momentProperties.length; i++) { prop = momentProperties[i]; val = from[prop]; if (!isUndefined(val)) { to[prop] = val; } } } return to; } // Moment prototype object function Moment(config) { copyConfig(this, config); this._d = new Date(config._d != null ? config._d.getTime() : NaN); if (!this.isValid()) { this._d = new Date(NaN); } // Prevent infinite loop in case updateOffset creates new moment // objects. if (updateInProgress === false) { updateInProgress = true; hooks.updateOffset(this); updateInProgress = false; } } function isMoment(obj) { return ( obj instanceof Moment || (obj != null && obj._isAMomentObject != null) ); } function warn(msg) { if ( hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn ) { console.warn('Deprecation warning: ' + msg); } } function deprecate(msg, fn) { var firstTime = true; return extend(function () { if (hooks.deprecationHandler != null) { hooks.deprecationHandler(null, msg); } if (firstTime) { var args = [], arg, i, key; for (i = 0; i < arguments.length; i++) { arg = ''; if (typeof arguments[i] === 'object') { arg += '\n[' + i + '] '; for (key in arguments[0]) { if (hasOwnProp(arguments[0], key)) { arg += key + ': ' + arguments[0][key] + ', '; } } arg = arg.slice(0, -2); // Remove trailing comma and space } else { arg = arguments[i]; } args.push(arg); } warn( msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + new Error().stack ); firstTime = false; } return fn.apply(this, arguments); }, fn); } var deprecations = {}; function deprecateSimple(name, msg) { if (hooks.deprecationHandler != null) { hooks.deprecationHandler(name, msg); } if (!deprecations[name]) { warn(msg); deprecations[name] = true; } } hooks.suppressDeprecationWarnings = false; hooks.deprecationHandler = null; function isFunction(input) { return ( (typeof Function !== 'undefined' && input instanceof Function) || Object.prototype.toString.call(input) === '[object Function]' ); } function set(config) { var prop, i; for (i in config) { if (hasOwnProp(config, i)) { prop = config[i]; if (isFunction(prop)) { this[i] = prop; } else { this['_' + i] = prop; } } } this._config = config; // Lenient ordinal parsing accepts just a number in addition to // number + (possibly) stuff coming from _dayOfMonthOrdinalParse. // TODO: Remove "ordinalParse" fallback in next major release. this._dayOfMonthOrdinalParseLenient = new RegExp( (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + '|' + /\d{1,2}/.source ); } function mergeConfigs(parentConfig, childConfig) { var res = extend({}, parentConfig), prop; for (prop in childConfig) { if (hasOwnProp(childConfig, prop)) { if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) { res[prop] = {}; extend(res[prop], parentConfig[prop]); extend(res[prop], childConfig[prop]); } else if (childConfig[prop] != null) { res[prop] = childConfig[prop]; } else { delete res[prop]; } } } for (prop in parentConfig) { if ( hasOwnProp(parentConfig, prop) && !hasOwnProp(childConfig, prop) && isObject(parentConfig[prop]) ) { // make sure changes to properties don't modify parent config res[prop] = extend({}, res[prop]); } } return res; } function Locale(config) { if (config != null) { this.set(config); } } var keys; if (Object.keys) { keys = Object.keys; } else { keys = function (obj) { var i, res = []; for (i in obj) { if (hasOwnProp(obj, i)) { res.push(i); } } return res; }; } var defaultCalendar = { sameDay: '[Today at] LT', nextDay: '[Tomorrow at] LT', nextWeek: 'dddd [at] LT', lastDay: '[Yesterday at] LT', lastWeek: '[Last] dddd [at] LT', sameElse: 'L', }; function calendar(key, mom, now) { var output = this._calendar[key] || this._calendar['sameElse']; return isFunction(output) ? output.call(mom, now) : output; } function zeroFill(number, targetLength, forceSign) { var absNumber = '' + Math.abs(number), zerosToFill = targetLength - absNumber.length, sign = number >= 0; return ( (sign ? (forceSign ? '+' : '') : '-') + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber ); } var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g, localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, formatFunctions = {}, formatTokenFunctions = {}; // token: 'M' // padded: ['MM', 2] // ordinal: 'Mo' // callback: function () { this.month() + 1 } function addFormatToken(token, padded, ordinal, callback) { var func = callback; if (typeof callback === 'string') { func = function () { return this[callback](); }; } if (token) { formatTokenFunctions[token] = func; } if (padded) { formatTokenFunctions[padded[0]] = function () { return zeroFill(func.apply(this, arguments), padded[1], padded[2]); }; } if (ordinal) { formatTokenFunctions[ordinal] = function () { return this.localeData().ordinal( func.apply(this, arguments), token ); }; } } function removeFormattingTokens(input) { if (input.match(/\[[\s\S]/)) { return input.replace(/^\[|\]$/g, ''); } return input.replace(/\\/g, ''); } function makeFormatFunction(format) { var array = format.match(formattingTokens), i, length; for (i = 0, length = array.length; i < length; i++) { if (formatTokenFunctions[array[i]]) { array[i] = formatTokenFunctions[array[i]]; } else { array[i] = removeFormattingTokens(array[i]); } } return function (mom) { var output = '', i; for (i = 0; i < length; i++) { output += isFunction(array[i]) ? array[i].call(mom, format) : array[i]; } return output; }; } // format date using native date object function formatMoment(m, format) { if (!m.isValid()) { return m.localeData().invalidDate(); } format = expandFormat(format, m.localeData()); formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format); return formatFunctions[format](m); } function expandFormat(format, locale) { var i = 5; function replaceLongDateFormatTokens(input) { return locale.longDateFormat(input) || input; } localFormattingTokens.lastIndex = 0; while (i >= 0 && localFormattingTokens.test(format)) { format = format.replace( localFormattingTokens, replaceLongDateFormatTokens ); localFormattingTokens.lastIndex = 0; i -= 1; } return format; } var defaultLongDateFormat = { LTS: 'h:mm:ss A', LT: 'h:mm A', L: 'MM/DD/YYYY', LL: 'MMMM D, YYYY', LLL: 'MMMM D, YYYY h:mm A', LLLL: 'dddd, MMMM D, YYYY h:mm A', }; function longDateFormat(key) { var format = this._longDateFormat[key], formatUpper = this._longDateFormat[key.toUpperCase()]; if (format || !formatUpper) { return format; } this._longDateFormat[key] = formatUpper .match(formattingTokens) .map(function (tok) { if ( tok === 'MMMM' || tok === 'MM' || tok === 'DD' || tok === 'dddd' ) { return tok.slice(1); } return tok; }) .join(''); return this._longDateFormat[key]; } var defaultInvalidDate = 'Invalid date'; function invalidDate() { return this._invalidDate; } var defaultOrdinal = '%d', defaultDayOfMonthOrdinalParse = /\d{1,2}/; function ordinal(number) { return this._ordinal.replace('%d', number); } var defaultRelativeTime = { future: 'in %s', past: '%s ago', s: 'a few seconds', ss: '%d seconds', m: 'a minute', mm: '%d minutes', h: 'an hour', hh: '%d hours', d: 'a day', dd: '%d days', w: 'a week', ww: '%d weeks', M: 'a month', MM: '%d months', y: 'a year', yy: '%d years', }; function relativeTime(number, withoutSuffix, string, isFuture) { var output = this._relativeTime[string]; return isFunction(output) ? output(number, withoutSuffix, string, isFuture) : output.replace(/%d/i, number); } function pastFuture(diff, output) { var format = this._relativeTime[diff > 0 ? 'future' : 'past']; return isFunction(format) ? format(output) : format.replace(/%s/i, output); } var aliases = {}; function addUnitAlias(unit, shorthand) { var lowerCase = unit.toLowerCase(); aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit; } function normalizeUnits(units) { return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined; } function normalizeObjectUnits(inputObject) { var normalizedInput = {}, normalizedProp, prop; for (prop in inputObject) { if (hasOwnProp(inputObject, prop)) { normalizedProp = normalizeUnits(prop); if (normalizedProp) { normalizedInput[normalizedProp] = inputObject[prop]; } } } return normalizedInput; } var priorities = {}; function addUnitPriority(unit, priority) { priorities[unit] = priority; } function getPrioritizedUnits(unitsObj) { var units = [], u; for (u in unitsObj) { if (hasOwnProp(unitsObj, u)) { units.push({ unit: u, priority: priorities[u] }); } } units.sort(function (a, b) { return a.priority - b.priority; }); return units; } function isLeapYear(year) { return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; } function absFloor(number) { if (number < 0) { // -0 -> 0 return Math.ceil(number) || 0; } else { return Math.floor(number); } } function toInt(argumentForCoercion) { var coercedNumber = +argumentForCoercion, value = 0; if (coercedNumber !== 0 && isFinite(coercedNumber)) { value = absFloor(coercedNumber); } return value; } function makeGetSet(unit, keepTime) { return function (value) { if (value != null) { set$1(this, unit, value); hooks.updateOffset(this, keepTime); return this; } else { return get(this, unit); } }; } function get(mom, unit) { return mom.isValid() ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN; } function set$1(mom, unit, value) { if (mom.isValid() && !isNaN(value)) { if ( unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29 ) { value = toInt(value); mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit]( value, mom.month(), daysInMonth(value, mom.month()) ); } else { mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value); } } } // MOMENTS function stringGet(units) { units = normalizeUnits(units); if (isFunction(this[units])) { return this[units](); } return this; } function stringSet(units, value) { if (typeof units === 'object') { units = normalizeObjectUnits(units); var prioritized = getPrioritizedUnits(units), i; for (i = 0; i < prioritized.length; i++) { this[prioritized[i].unit](units[prioritized[i].unit]); } } else { units = normalizeUnits(units); if (isFunction(this[units])) { return this[units](value); } } return this; } var match1 = /\d/, // 0 - 9 match2 = /\d\d/, // 00 - 99 match3 = /\d{3}/, // 000 - 999 match4 = /\d{4}/, // 0000 - 9999 match6 = /[+-]?\d{6}/, // -999999 - 999999 match1to2 = /\d\d?/, // 0 - 99 match3to4 = /\d\d\d\d?/, // 999 - 9999 match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999 match1to3 = /\d{1,3}/, // 0 - 999 match1to4 = /\d{1,4}/, // 0 - 9999 match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999 matchUnsigned = /\d+/, // 0 - inf matchSigned = /[+-]?\d+/, // -inf - inf matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123 // any word (or two) characters or numbers including two/three word month in arabic. // includes scottish gaelic two word and hyphenated months matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i, regexes; regexes = {}; function addRegexToken(token, regex, strictRegex) { regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) { return isStrict && strictRegex ? strictRegex : regex; }; } function getParseRegexForToken(token, config) { if (!hasOwnProp(regexes, token)) { return new RegExp(unescapeFormat(token)); } return regexes[token](config._strict, config._locale); } // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript function unescapeFormat(s) { return regexEscape( s .replace('\\', '') .replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function ( matched, p1, p2, p3, p4 ) { return p1 || p2 || p3 || p4; }) ); } function regexEscape(s) { return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); } var tokens = {}; function addParseToken(token, callback) { var i, func = callback; if (typeof token === 'string') { token = [token]; } if (isNumber(callback)) { func = function (input, array) { array[callback] = toInt(input); }; } for (i = 0; i < token.length; i++) { tokens[token[i]] = func; } } function addWeekParseToken(token, callback) { addParseToken(token, function (input, array, config, token) { config._w = config._w || {}; callback(input, config._w, config, token); }); } function addTimeToArrayFromToken(token, input, config) { if (input != null && hasOwnProp(tokens, token)) { tokens[token](input, config._a, config, token); } } var YEAR = 0, MONTH = 1, DATE = 2, HOUR = 3, MINUTE = 4, SECOND = 5, MILLISECOND = 6, WEEK = 7, WEEKDAY = 8; function mod(n, x) { return ((n % x) + x) % x; } var indexOf; if (Array.prototype.indexOf) { indexOf = Array.prototype.indexOf; } else { indexOf = function (o) { // I know var i; for (i = 0; i < this.length; ++i) { if (this[i] === o) { return i; } } return -1; }; } function daysInMonth(year, month) { if (isNaN(year) || isNaN(month)) { return NaN; } var modMonth = mod(month, 12); year += (month - modMonth) / 12; return modMonth === 1 ? isLeapYear(year) ? 29 : 28 : 31 - ((modMonth % 7) % 2); } // FORMATTING addFormatToken('M', ['MM', 2], 'Mo', function () { return this.month() + 1; }); addFormatToken('MMM', 0, 0, function (format) { return this.localeData().monthsShort(this, format); }); addFormatToken('MMMM', 0, 0, function (format) { return this.localeData().months(this, format); }); // ALIASES addUnitAlias('month', 'M'); // PRIORITY addUnitPriority('month', 8); // PARSING addRegexToken('M', match1to2); addRegexToken('MM', match1to2, match2); addRegexToken('MMM', function (isStrict, locale) { return locale.monthsShortRegex(isStrict); }); addRegexToken('MMMM', function (isStrict, locale) { return locale.monthsRegex(isStrict); }); addParseToken(['M', 'MM'], function (input, array) { array[MONTH] = toInt(input) - 1; }); addParseToken(['MMM', 'MMMM'], function (input, array, config, token) { var month = config._locale.monthsParse(input, token, config._strict); // if we didn't find a month name, mark the date as invalid. if (month != null) { array[MONTH] = month; } else { getParsingFlags(config).invalidMonth = input; } }); // LOCALES var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split( '_' ), defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split( '_' ), MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/, defaultMonthsShortRegex = matchWord, defaultMonthsRegex = matchWord; function localeMonths(m, format) { if (!m) { return isArray(this._months) ? this._months : this._months['standalone']; } return isArray(this._months) ? this._months[m.month()] : this._months[ (this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone' ][m.month()]; } function localeMonthsShort(m, format) { if (!m) { return isArray(this._monthsShort) ? this._monthsShort : this._monthsShort['standalone']; } return isArray(this._monthsShort) ? this._monthsShort[m.month()] : this._monthsShort[ MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone' ][m.month()]; } function handleStrictParse(monthName, format, strict) { var i, ii, mom, llc = monthName.toLocaleLowerCase(); if (!this._monthsParse) { // this is not used this._monthsParse = []; this._longMonthsParse = []; this._shortMonthsParse = []; for (i = 0; i < 12; ++i) { mom = createUTC([2000, i]); this._shortMonthsParse[i] = this.monthsShort( mom, '' ).toLocaleLowerCase(); this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase(); } } if (strict) { if (format === 'MMM') { ii = indexOf.call(this._shortMonthsParse, llc); return ii !== -1 ? ii : null; } else { ii = indexOf.call(this._longMonthsParse, llc); return ii !== -1 ? ii : null; } } else { if (format === 'MMM') { ii = indexOf.call(this._shortMonthsParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._longMonthsParse, llc); return ii !== -1 ? ii : null; } else { ii = indexOf.call(this._longMonthsParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._shortMonthsParse, llc); return ii !== -1 ? ii : null; } } } function localeMonthsParse(monthName, format, strict) { var i, mom, regex; if (this._monthsParseExact) { return handleStrictParse.call(this, monthName, format, strict); } if (!this._monthsParse) { this._monthsParse = []; this._longMonthsParse = []; this._shortMonthsParse = []; } // TODO: add sorting // Sorting makes sure if one month (or abbr) is a prefix of another // see sorting in computeMonthsParse for (i = 0; i < 12; i++) { // make the regex if we don't have it already mom = createUTC([2000, i]); if (strict && !this._longMonthsParse[i]) { this._longMonthsParse[i] = new RegExp( '^' + this.months(mom, '').replace('.', '') + '$', 'i' ); this._shortMonthsParse[i] = new RegExp( '^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i' ); } if (!strict && !this._monthsParse[i]) { regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); } // test the regex if ( strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName) ) { return i; } else if ( strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName) ) { return i; } else if (!strict && this._monthsParse[i].test(monthName)) { return i; } } } // MOMENTS function setMonth(mom, value) { var dayOfMonth; if (!mom.isValid()) { // No op return mom; } if (typeof value === 'string') { if (/^\d+$/.test(value)) { value = toInt(value); } else { value = mom.localeData().monthsParse(value); // TODO: Another silent failure? if (!isNumber(value)) { return mom; } } } dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value)); mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); return mom; } function getSetMonth(value) { if (value != null) { setMonth(this, value); hooks.updateOffset(this, true); return this; } else { return get(this, 'Month'); } } function getDaysInMonth() { return daysInMonth(this.year(), this.month()); } function monthsShortRegex(isStrict) { if (this._monthsParseExact) { if (!hasOwnProp(this, '_monthsRegex')) { computeMonthsParse.call(this); } if (isStrict) { return this._monthsShortStrictRegex; } else { return this._monthsShortRegex; } } else { if (!hasOwnProp(this, '_monthsShortRegex')) { this._monthsShortRegex = defaultMonthsShortRegex; } return this._monthsShortStrictRegex && isStrict ? this._monthsShortStrictRegex : this._monthsShortRegex; } } function monthsRegex(isStrict) { if (this._monthsParseExact) { if (!hasOwnProp(this, '_monthsRegex')) { computeMonthsParse.call(this); } if (isStrict) { return this._monthsStrictRegex; } else { return this._monthsRegex; } } else { if (!hasOwnProp(this, '_monthsRegex')) { this._monthsRegex = defaultMonthsRegex; } return this._monthsStrictRegex && isStrict ? this._monthsStrictRegex : this._monthsRegex; } } function computeMonthsParse() { function cmpLenRev(a, b) { return b.length - a.length; } var shortPieces = [], longPieces = [], mixedPieces = [], i, mom; for (i = 0; i < 12; i++) { // make the regex if we don't have it already mom = createUTC([2000, i]); shortPieces.push(this.monthsShort(mom, '')); longPieces.push(this.months(mom, '')); mixedPieces.push(this.months(mom, '')); mixedPieces.push(this.monthsShort(mom, '')); } // Sorting makes sure if one month (or abbr) is a prefix of another it // will match the longer piece. shortPieces.sort(cmpLenRev); longPieces.sort(cmpLenRev); mixedPieces.sort(cmpLenRev); for (i = 0; i < 12; i++) { shortPieces[i] = regexEscape(shortPieces[i]); longPieces[i] = regexEscape(longPieces[i]); } for (i = 0; i < 24; i++) { mixedPieces[i] = regexEscape(mixedPieces[i]); } this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); this._monthsShortRegex = this._monthsRegex; this._monthsStrictRegex = new RegExp( '^(' + longPieces.join('|') + ')', 'i' ); this._monthsShortStrictRegex = new RegExp( '^(' + shortPieces.join('|') + ')', 'i' ); } // FORMATTING addFormatToken('Y', 0, 0, function () { var y = this.year(); return y <= 9999 ? zeroFill(y, 4) : '+' + y; }); addFormatToken(0, ['YY', 2], 0, function () { return this.year() % 100; }); addFormatToken(0, ['YYYY', 4], 0, 'year'); addFormatToken(0, ['YYYYY', 5], 0, 'year'); addFormatToken(0, ['YYYYYY', 6, true], 0, 'year'); // ALIASES addUnitAlias('year', 'y'); // PRIORITIES addUnitPriority('year', 1); // PARSING addRegexToken('Y', matchSigned); addRegexToken('YY', match1to2, match2); addRegexToken('YYYY', match1to4, match4); addRegexToken('YYYYY', match1to6, match6); addRegexToken('YYYYYY', match1to6, match6); addParseToken(['YYYYY', 'YYYYYY'], YEAR); addParseToken('YYYY', function (input, array) { array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input); }); addParseToken('YY', function (input, array) { array[YEAR] = hooks.parseTwoDigitYear(input); }); addParseToken('Y', function (input, array) { array[YEAR] = parseInt(input, 10); }); // HELPERS function daysInYear(year) { return isLeapYear(year) ? 366 : 365; } // HOOKS hooks.parseTwoDigitYear = function (input) { return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); }; // MOMENTS var getSetYear = makeGetSet('FullYear', true); function getIsLeapYear() { return isLeapYear(this.year()); } function createDate(y, m, d, h, M, s, ms) { // can't just apply() to create a date: // https://stackoverflow.com/q/181348 var date; // the date constructor remaps years 0-99 to 1900-1999 if (y < 100 && y >= 0) { // preserve leap years using a full 400 year cycle, then reset date = new Date(y + 400, m, d, h, M, s, ms); if (isFinite(date.getFullYear())) { date.setFullYear(y); } } else { date = new Date(y, m, d, h, M, s, ms); } return date; } function createUTCDate(y) { var date, args; // the Date.UTC function remaps years 0-99 to 1900-1999 if (y < 100 && y >= 0) { args = Array.prototype.slice.call(arguments); // preserve leap years using a full 400 year cycle, then reset args[0] = y + 400; date = new Date(Date.UTC.apply(null, args)); if (isFinite(date.getUTCFullYear())) { date.setUTCFullYear(y); } } else { date = new Date(Date.UTC.apply(null, arguments)); } return date; } // start-of-first-week - start-of-year function firstWeekOffset(year, dow, doy) { var // first-week day -- which january is always in the first week (4 for iso, 1 for other) fwd = 7 + dow - doy, // first-week day local weekday -- which local weekday is fwd fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7; return -fwdlw + fwd - 1; } // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday function dayOfYearFromWeeks(year, week, weekday, dow, doy) { var localWeekday = (7 + weekday - dow) % 7, weekOffset = firstWeekOffset(year, dow, doy), dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset, resYear, resDayOfYear; if (dayOfYear <= 0) { resYear = year - 1; resDayOfYear = daysInYear(resYear) + dayOfYear; } else if (dayOfYear > daysInYear(year)) { resYear = year + 1; resDayOfYear = dayOfYear - daysInYear(year); } else { resYear = year; resDayOfYear = dayOfYear; } return { year: resYear, dayOfYear: resDayOfYear, }; } function weekOfYear(mom, dow, doy) { var weekOffset = firstWeekOffset(mom.year(), dow, doy), week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1, resWeek, resYear; if (week < 1) { resYear = mom.year() - 1; resWeek = week + weeksInYear(resYear, dow, doy); } else if (week > weeksInYear(mom.year(), dow, doy)) { resWeek = week - weeksInYear(mom.year(), dow, doy); resYear = mom.year() + 1; } else { resYear = mom.year(); resWeek = week; } return { week: resWeek, year: resYear, }; } function weeksInYear(year, dow, doy) { var weekOffset = firstWeekOffset(year, dow, doy), weekOffsetNext = firstWeekOffset(year + 1, dow, doy); return (daysInYear(year) - weekOffset + weekOffsetNext) / 7; } // FORMATTING addFormatToken('w', ['ww', 2], 'wo', 'week'); addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek'); // ALIASES addUnitAlias('week', 'w'); addUnitAlias('isoWeek', 'W'); // PRIORITIES addUnitPriority('week', 5); addUnitPriority('isoWeek', 5); // PARSING addRegexToken('w', match1to2); addRegexToken('ww', match1to2, match2); addRegexToken('W', match1to2); addRegexToken('WW', match1to2, match2); addWeekParseToken(['w', 'ww', 'W', 'WW'], function ( input, week, config, token ) { week[token.substr(0, 1)] = toInt(input); }); // HELPERS // LOCALES function localeWeek(mom) { return weekOfYear(mom, this._week.dow, this._week.doy).week; } var defaultLocaleWeek = { dow: 0, // Sunday is the first day of the week. doy: 6, // The week that contains Jan 6th is the first week of the year. }; function localeFirstDayOfWeek() { return this._week.dow; } function localeFirstDayOfYear() { return this._week.doy; } // MOMENTS function getSetWeek(input) { var week = this.localeData().week(this); return input == null ? week : this.add((input - week) * 7, 'd'); } function getSetISOWeek(input) { var week = weekOfYear(this, 1, 4).week; return input == null ? week : this.add((input - week) * 7, 'd'); } // FORMATTING addFormatToken('d', 0, 'do', 'day'); addFormatToken('dd', 0, 0, function (format) { return this.localeData().weekdaysMin(this, format); }); addFormatToken('ddd', 0, 0, function (format) { return this.localeData().weekdaysShort(this, format); }); addFormatToken('dddd', 0, 0, function (format) { return this.localeData().weekdays(this, format); }); addFormatToken('e', 0, 0, 'weekday'); addFormatToken('E', 0, 0, 'isoWeekday'); // ALIASES addUnitAlias('day', 'd'); addUnitAlias('weekday', 'e'); addUnitAlias('isoWeekday', 'E'); // PRIORITY addUnitPriority('day', 11); addUnitPriority('weekday', 11); addUnitPriority('isoWeekday', 11); // PARSING addRegexToken('d', match1to2); addRegexToken('e', match1to2); addRegexToken('E', match1to2); addRegexToken('dd', function (isStrict, locale) { return locale.weekdaysMinRegex(isStrict); }); addRegexToken('ddd', function (isStrict, locale) { return locale.weekdaysShortRegex(isStrict); }); addRegexToken('dddd', function (isStrict, locale) { return locale.weekdaysRegex(isStrict); }); addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { var weekday = config._locale.weekdaysParse(input, token, config._strict); // if we didn't get a weekday name, mark the date as invalid if (weekday != null) { week.d = weekday; } else { getParsingFlags(config).invalidWeekday = input; } }); addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { week[token] = toInt(input); }); // HELPERS function parseWeekday(input, locale) { if (typeof input !== 'string') { return input; } if (!isNaN(input)) { return parseInt(input, 10); } input = locale.weekdaysParse(input); if (typeof input === 'number') { return input; } return null; } function parseIsoWeekday(input, locale) { if (typeof input === 'string') { return locale.weekdaysParse(input) % 7 || 7; } return isNaN(input) ? null : input; } // LOCALES function shiftWeekdays(ws, n) { return ws.slice(n, 7).concat(ws.slice(0, n)); } var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split( '_' ), defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), defaultWeekdaysRegex = matchWord, defaultWeekdaysShortRegex = matchWord, defaultWeekdaysMinRegex = matchWord; function localeWeekdays(m, format) { var weekdays = isArray(this._weekdays) ? this._weekdays : this._weekdays[ m && m !== true && this._weekdays.isFormat.test(format) ? 'format' : 'standalone' ]; return m === true ? shiftWeekdays(weekdays, this._week.dow) : m ? weekdays[m.day()] : weekdays; } function localeWeekdaysShort(m) { return m === true ? shiftWeekdays(this._weekdaysShort, this._week.dow) : m ? this._weekdaysShort[m.day()] : this._weekdaysShort; } function localeWeekdaysMin(m) { return m === true ? shiftWeekdays(this._weekdaysMin, this._week.dow) : m ? this._weekdaysMin[m.day()] : this._weekdaysMin; } function handleStrictParse$1(weekdayName, format, strict) { var i, ii, mom, llc = weekdayName.toLocaleLowerCase(); if (!this._weekdaysParse) { this._weekdaysParse = []; this._shortWeekdaysParse = []; this._minWeekdaysParse = []; for (i = 0; i < 7; ++i) { mom = createUTC([2000, 1]).day(i); this._minWeekdaysParse[i] = this.weekdaysMin( mom, '' ).toLocaleLowerCase(); this._shortWeekdaysParse[i] = this.weekdaysShort( mom, '' ).toLocaleLowerCase(); this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase(); } } if (strict) { if (format === 'dddd') { ii = indexOf.call(this._weekdaysParse, llc); return ii !== -1 ? ii : null; } else if (format === 'ddd') { ii = indexOf.call(this._shortWeekdaysParse, llc); return ii !== -1 ? ii : null; } else { ii = indexOf.call(this._minWeekdaysParse, llc); return ii !== -1 ? ii : null; } } else { if (format === 'dddd') { ii = indexOf.call(this._weekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._shortWeekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._minWeekdaysParse, llc); return ii !== -1 ? ii : null; } else if (format === 'ddd') { ii = indexOf.call(this._shortWeekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._weekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._minWeekdaysParse, llc); return ii !== -1 ? ii : null; } else { ii = indexOf.call(this._minWeekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._weekdaysParse, llc); if (ii !== -1) { return ii; } ii = indexOf.call(this._shortWeekdaysParse, llc); return ii !== -1 ? ii : null; } } } function localeWeekdaysParse(weekdayName, format, strict) { var i, mom, regex; if (this._weekdaysParseExact) { return handleStrictParse$1.call(this, weekdayName, format, strict); } if (!this._weekdaysParse) { this._weekdaysParse = []; this._minWeekdaysParse = []; this._shortWeekdaysParse = []; this._fullWeekdaysParse = []; } for (i = 0; i < 7; i++) { // make the regex if we don't have it already mom = createUTC([2000, 1]).day(i); if (strict && !this._fullWeekdaysParse[i]) { this._fullWeekdaysParse[i] = new RegExp( '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i' ); this._shortWeekdaysParse[i] = new RegExp( '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i' ); this._minWeekdaysParse[i] = new RegExp( '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i' ); } if (!this._weekdaysParse[i]) { regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); } // test the regex if ( strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName) ) { return i; } else if ( strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName) ) { return i; } else if ( strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName) ) { return i; } else if (!strict && this._weekdaysParse[i].test(weekdayName)) { return i; } } } // MOMENTS function getSetDayOfWeek(input) { if (!this.isValid()) { return input != null ? this : NaN; } var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); if (input != null) { input = parseWeekday(input, this.localeData()); return this.add(input - day, 'd'); } else { return day; } } function getSetLocaleDayOfWeek(input) { if (!this.isValid()) { return input != null ? this : NaN; } var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; return input == null ? weekday : this.add(input - weekday, 'd'); } function getSetISODayOfWeek(input) { if (!this.isValid()) { return input != null ? this : NaN; } // behaves the same as moment#day except // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) // as a setter, sunday should belong to the previous week. if (input != null) { var weekday = parseIsoWeekday(input, this.localeData()); return this.day(this.day() % 7 ? weekday : weekday - 7); } else { return this.day() || 7; } } function weekdaysRegex(isStrict) { if (this._weekdaysParseExact) { if (!hasOwnProp(this, '_weekdaysRegex')) { computeWeekdaysParse.call(this); } if (isStrict) { return this._weekdaysStrictRegex; } else { return this._weekdaysRegex; } } else { if (!hasOwnProp(this, '_weekdaysRegex')) { this._weekdaysRegex = defaultWeekdaysRegex; } return this._weekdaysStrictRegex && isStrict ? this._weekdaysStrictRegex : this._weekdaysRegex; } } function weekdaysShortRegex(isStrict) { if (this._weekdaysParseExact) { if (!hasOwnProp(this, '_weekdaysRegex')) { computeWeekdaysParse.call(this); } if (isStrict) { return this._weekdaysShortStrictRegex; } else { return this._weekdaysShortRegex; } } else { if (!hasOwnProp(this, '_weekdaysShortRegex')) { this._weekdaysShortRegex = defaultWeekdaysShortRegex; } return this._weekdaysShortStrictRegex && isStrict ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex; } } function weekdaysMinRegex(isStrict) { if (this._weekdaysParseExact) { if (!hasOwnProp(this, '_weekdaysRegex')) { computeWeekdaysParse.call(this); } if (isStrict) { return this._weekdaysMinStrictRegex; } else { return this._weekdaysMinRegex; } } else { if (!hasOwnProp(this, '_weekdaysMinRegex')) { this._weekdaysMinRegex = defaultWeekdaysMinRegex; } return this._weekdaysMinStrictRegex && isStrict ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex; } } function computeWeekdaysParse() { function cmpLenRev(a, b) { return b.length - a.length; } var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [], i, mom, minp, shortp, longp; for (i = 0; i < 7; i++) { // make the regex if we don't have it already mom = createUTC([2000, 1]).day(i); minp = regexEscape(this.weekdaysMin(mom, '')); shortp = regexEscape(this.weekdaysShort(mom, '')); longp = regexEscape(this.weekdays(mom, '')); minPieces.push(minp); shortPieces.push(shortp); longPieces.push(longp); mixedPieces.push(minp); mixedPieces.push(shortp); mixedPieces.push(longp); } // Sorting makes sure if one weekday (or abbr) is a prefix of another it // will match the longer piece. minPieces.sort(cmpLenRev); shortPieces.sort(cmpLenRev); longPieces.sort(cmpLenRev); mixedPieces.sort(cmpLenRev); this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); this._weekdaysShortRegex = this._weekdaysRegex; this._weekdaysMinRegex = this._weekdaysRegex; this._weekdaysStrictRegex = new RegExp( '^(' + longPieces.join('|') + ')', 'i' ); this._weekdaysShortStrictRegex = new RegExp( '^(' + shortPieces.join('|') + ')', 'i' ); this._weekdaysMinStrictRegex = new RegExp( '^(' + minPieces.join('|') + ')', 'i' ); } // FORMATTING function hFormat() { return this.hours() % 12 || 12; } function kFormat() { return this.hours() || 24; } addFormatToken('H', ['HH', 2], 0, 'hour'); addFormatToken('h', ['hh', 2], 0, hFormat); addFormatToken('k', ['kk', 2], 0, kFormat); addFormatToken('hmm', 0, 0, function () { return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2); }); addFormatToken('hmmss', 0, 0, function () { return ( '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2) ); }); addFormatToken('Hmm', 0, 0, function () { return '' + this.hours() + zeroFill(this.minutes(), 2); }); addFormatToken('Hmmss', 0, 0, function () { return ( '' + this.hours() + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2) ); }); function meridiem(token, lowercase) { addFormatToken(token, 0, 0, function () { return this.localeData().meridiem( this.hours(), this.minutes(), lowercase ); }); } meridiem('a', true); meridiem('A', false); // ALIASES addUnitAlias('hour', 'h'); // PRIORITY addUnitPriority('hour', 13); // PARSING function matchMeridiem(isStrict, locale) { return locale._meridiemParse; } addRegexToken('a', matchMeridiem); addRegexToken('A', matchMeridiem); addRegexToken('H', match1to2); addRegexToken('h', match1to2); addRegexToken('k', match1to2); addRegexToken('HH', match1to2, match2); addRegexToken('hh', match1to2, match2); addRegexToken('kk', match1to2, match2); addRegexToken('hmm', match3to4); addRegexToken('hmmss', match5to6); addRegexToken('Hmm', match3to4); addRegexToken('Hmmss', match5to6); addParseToken(['H', 'HH'], HOUR); addParseToken(['k', 'kk'], function (input, array, config) { var kInput = toInt(input); array[HOUR] = kInput === 24 ? 0 : kInput; }); addParseToken(['a', 'A'], function (input, array, config) { config._isPm = config._locale.isPM(input); config._meridiem = input; }); addParseToken(['h', 'hh'], function (input, array, config) { array[HOUR] = toInt(input); getParsingFlags(config).bigHour = true; }); addParseToken('hmm', function (input, array, config) { var pos = input.length - 2; array[HOUR] = toInt(input.substr(0, pos)); array[MINUTE] = toInt(input.substr(pos)); getParsingFlags(config).bigHour = true; }); addParseToken('hmmss', function (input, array, config) { var pos1 = input.length - 4, pos2 = input.length - 2; array[HOUR] = toInt(input.substr(0, pos1)); array[MINUTE] = toInt(input.substr(pos1, 2)); array[SECOND] = toInt(input.substr(pos2)); getParsingFlags(config).bigHour = true; }); addParseToken('Hmm', function (input, array, config) { var pos = input.length - 2; array[HOUR] = toInt(input.substr(0, pos)); array[MINUTE] = toInt(input.substr(pos)); }); addParseToken('Hmmss', function (input, array, config) { var pos1 = input.length - 4, pos2 = input.length - 2; array[HOUR] = toInt(input.substr(0, pos1)); array[MINUTE] = toInt(input.substr(pos1, 2)); array[SECOND] = toInt(input.substr(pos2)); }); // LOCALES function localeIsPM(input) { // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays // Using charAt should be more compatible. return (input + '').toLowerCase().charAt(0) === 'p'; } var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i, // Setting the hour should keep the time, because the user explicitly // specified which hour they want. So trying to maintain the same hour (in // a new timezone) makes sense. Adding/subtracting hours does not follow // this rule. getSetHour = makeGetSet('Hours', true); function localeMeridiem(hours, minutes, isLower) { if (hours > 11) { return isLower ? 'pm' : 'PM'; } else { return isLower ? 'am' : 'AM'; } } var baseConfig = { calendar: defaultCalendar, longDateFormat: defaultLongDateFormat, invalidDate: defaultInvalidDate, ordinal: defaultOrdinal, dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse, relativeTime: defaultRelativeTime, months: defaultLocaleMonths, monthsShort: defaultLocaleMonthsShort, week: defaultLocaleWeek, weekdays: defaultLocaleWeekdays, weekdaysMin: defaultLocaleWeekdaysMin, weekdaysShort: defaultLocaleWeekdaysShort, meridiemParse: defaultLocaleMeridiemParse, }; // internal storage for locale config files var locales = {}, localeFamilies = {}, globalLocale; function commonPrefix(arr1, arr2) { var i, minl = Math.min(arr1.length, arr2.length); for (i = 0; i < minl; i += 1) { if (arr1[i] !== arr2[i]) { return i; } } return minl; } function normalizeLocale(key) { return key ? key.toLowerCase().replace('_', '-') : key; } // pick the locale from the array // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root function chooseLocale(names) { var i = 0, j, next, locale, split; while (i < names.length) { split = normalizeLocale(names[i]).split('-'); j = split.length; next = normalizeLocale(names[i + 1]); next = next ? next.split('-') : null; while (j > 0) { locale = loadLocale(split.slice(0, j).join('-')); if (locale) { return locale; } if ( next && next.length >= j && commonPrefix(split, next) >= j - 1 ) { //the next array item is better than a shallower substring of this one break; } j--; } i++; } return globalLocale; } function loadLocale(name) { var oldLocale = null, aliasedRequire; // TODO: Find a better way to register and load all the locales in Node if ( locales[name] === undefined && 'object' !== 'undefined' && module && module.exports ) { try { oldLocale = globalLocale._abbr; aliasedRequire = commonjsRequire; aliasedRequire('./locale/' + name); getSetGlobalLocale(oldLocale); } catch (e) { // mark as not found to avoid repeating expensive file require call causing high CPU // when trying to find en-US, en_US, en-us for every format call locales[name] = null; // null means not found } } return locales[name]; } // This function will load locale and then set the global locale. If // no arguments are passed in, it will simply return the current global // locale key. function getSetGlobalLocale(key, values) { var data; if (key) { if (isUndefined(values)) { data = getLocale(key); } else { data = defineLocale(key, values); } if (data) { // moment.duration._locale = moment._locale = data; globalLocale = data; } else { if (typeof console !== 'undefined' && console.warn) { //warn user if arguments are passed but the locale could not be set console.warn( 'Locale ' + key + ' not found. Did you forget to load it?' ); } } } return globalLocale._abbr; } function defineLocale(name, config) { if (config !== null) { var locale, parentConfig = baseConfig; config.abbr = name; if (locales[name] != null) { deprecateSimple( 'defineLocaleOverride', 'use moment.updateLocale(localeName, config) to change ' + 'an existing locale. moment.defineLocale(localeName, ' + 'config) should only be used for creating a new locale ' + 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.' ); parentConfig = locales[name]._config; } else if (config.parentLocale != null) { if (locales[config.parentLocale] != null) { parentConfig = locales[config.parentLocale]._config; } else { locale = loadLocale(config.parentLocale); if (locale != null) { parentConfig = locale._config; } else { if (!localeFamilies[config.parentLocale]) { localeFamilies[config.parentLocale] = []; } localeFamilies[config.parentLocale].push({ name: name, config: config, }); return null; } } } locales[name] = new Locale(mergeConfigs(parentConfig, config)); if (localeFamilies[name]) { localeFamilies[name].forEach(function (x) { defineLocale(x.name, x.config); }); } // backwards compat for now: also set the locale // make sure we set the locale AFTER all child locales have been // created, so we won't end up with the child locale set. getSetGlobalLocale(name); return locales[name]; } else { // useful for testing delete locales[name]; return null; } } function updateLocale(name, config) { if (config != null) { var locale, tmpLocale, parentConfig = baseConfig; if (locales[name] != null && locales[name].parentLocale != null) { // Update existing child locale in-place to avoid memory-leaks locales[name].set(mergeConfigs(locales[name]._config, config)); } else { // MERGE tmpLocale = loadLocale(name); if (tmpLocale != null) { parentConfig = tmpLocale._config; } config = mergeConfigs(parentConfig, config); if (tmpLocale == null) { // updateLocale is called for creating a new locale // Set abbr so it will have a name (getters return // undefined otherwise). config.abbr = name; } locale = new Locale(config); locale.parentLocale = locales[name]; locales[name] = locale; } // backwards compat for now: also set the locale getSetGlobalLocale(name); } else { // pass null for config to unupdate, useful for tests if (locales[name] != null) { if (locales[name].parentLocale != null) { locales[name] = locales[name].parentLocale; if (name === getSetGlobalLocale()) { getSetGlobalLocale(name); } } else if (locales[name] != null) { delete locales[name]; } } } return locales[name]; } // returns locale data function getLocale(key) { var locale; if (key && key._locale && key._locale._abbr) { key = key._locale._abbr; } if (!key) { return globalLocale; } if (!isArray(key)) { //short-circuit everything else locale = loadLocale(key); if (locale) { return locale; } key = [key]; } return chooseLocale(key); } function listLocales() { return keys(locales); } function checkOverflow(m) { var overflow, a = m._a; if (a && getParsingFlags(m).overflow === -2) { overflow = a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR : a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : -1; if ( getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE) ) { overflow = DATE; } if (getParsingFlags(m)._overflowWeeks && overflow === -1) { overflow = WEEK; } if (getParsingFlags(m)._overflowWeekday && overflow === -1) { overflow = WEEKDAY; } getParsingFlags(m).overflow = overflow; } return m; } // iso 8601 regex // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, tzRegex = /Z|[+-]\d\d(?::?\d\d)?/, isoDates = [ ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], ['GGGG-[W]WW', /\d{4}-W\d\d/, false], ['YYYY-DDD', /\d{4}-\d{3}/], ['YYYY-MM', /\d{4}-\d\d/, false], ['YYYYYYMMDD', /[+-]\d{10}/], ['YYYYMMDD', /\d{8}/], ['GGGG[W]WWE', /\d{4}W\d{3}/], ['GGGG[W]WW', /\d{4}W\d{2}/, false], ['YYYYDDD', /\d{7}/], ['YYYYMM', /\d{6}/, false], ['YYYY', /\d{4}/, false], ], // iso time formats and regexes isoTimes = [ ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], ['HH:mm:ss', /\d\d:\d\d:\d\d/], ['HH:mm', /\d\d:\d\d/], ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], ['HHmmss', /\d\d\d\d\d\d/], ['HHmm', /\d\d\d\d/], ['HH', /\d\d/], ], aspNetJsonRegex = /^\/?Date\((-?\d+)/i, // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3 rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/, obsOffsets = { UT: 0, GMT: 0, EDT: -4 * 60, EST: -5 * 60, CDT: -5 * 60, CST: -6 * 60, MDT: -6 * 60, MST: -7 * 60, PDT: -7 * 60, PST: -8 * 60, }; // date from iso format function configFromISO(config) { var i, l, string = config._i, match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string), allowTime, dateFormat, timeFormat, tzFormat; if (match) { getParsingFlags(config).iso = true; for (i = 0, l = isoDates.length; i < l; i++) { if (isoDates[i][1].exec(match[1])) { dateFormat = isoDates[i][0]; allowTime = isoDates[i][2] !== false; break; } } if (dateFormat == null) { config._isValid = false; return; } if (match[3]) { for (i = 0, l = isoTimes.length; i < l; i++) { if (isoTimes[i][1].exec(match[3])) { // match[2] should be 'T' or space timeFormat = (match[2] || ' ') + isoTimes[i][0]; break; } } if (timeFormat == null) { config._isValid = false; return; } } if (!allowTime && timeFormat != null) { config._isValid = false; return; } if (match[4]) { if (tzRegex.exec(match[4])) { tzFormat = 'Z'; } else { config._isValid = false; return; } } config._f = dateFormat + (timeFormat || '') + (tzFormat || ''); configFromStringAndFormat(config); } else { config._isValid = false; } } function extractFromRFC2822Strings( yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr ) { var result = [ untruncateYear(yearStr), defaultLocaleMonthsShort.indexOf(monthStr), parseInt(dayStr, 10), parseInt(hourStr, 10), parseInt(minuteStr, 10), ]; if (secondStr) { result.push(parseInt(secondStr, 10)); } return result; } function untruncateYear(yearStr) { var year = parseInt(yearStr, 10); if (year <= 49) { return 2000 + year; } else if (year <= 999) { return 1900 + year; } return year; } function preprocessRFC2822(s) { // Remove comments and folding whitespace and replace multiple-spaces with a single space return s .replace(/\([^)]*\)|[\n\t]/g, ' ') .replace(/(\s\s+)/g, ' ') .replace(/^\s\s*/, '') .replace(/\s\s*$/, ''); } function checkWeekday(weekdayStr, parsedInput, config) { if (weekdayStr) { // TODO: Replace the vanilla JS Date object with an independent day-of-week check. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr), weekdayActual = new Date( parsedInput[0], parsedInput[1], parsedInput[2] ).getDay(); if (weekdayProvided !== weekdayActual) { getParsingFlags(config).weekdayMismatch = true; config._isValid = false; return false; } } return true; } function calculateOffset(obsOffset, militaryOffset, numOffset) { if (obsOffset) { return obsOffsets[obsOffset]; } else if (militaryOffset) { // the only allowed military tz is Z return 0; } else { var hm = parseInt(numOffset, 10), m = hm % 100, h = (hm - m) / 100; return h * 60 + m; } } // date and time from ref 2822 format function configFromRFC2822(config) { var match = rfc2822.exec(preprocessRFC2822(config._i)), parsedArray; if (match) { parsedArray = extractFromRFC2822Strings( match[4], match[3], match[2], match[5], match[6], match[7] ); if (!checkWeekday(match[1], parsedArray, config)) { return; } config._a = parsedArray; config._tzm = calculateOffset(match[8], match[9], match[10]); config._d = createUTCDate.apply(null, config._a); config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); getParsingFlags(config).rfc2822 = true; } else { config._isValid = false; } } // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict function configFromString(config) { var matched = aspNetJsonRegex.exec(config._i); if (matched !== null) { config._d = new Date(+matched[1]); return; } configFromISO(config); if (config._isValid === false) { delete config._isValid; } else { return; } configFromRFC2822(config); if (config._isValid === false) { delete config._isValid; } else { return; } if (config._strict) { config._isValid = false; } else { // Final attempt, use Input Fallback hooks.createFromInputFallback(config); } } hooks.createFromInputFallback = deprecate( 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.', function (config) { config._d = new Date(config._i + (config._useUTC ? ' UTC' : '')); } ); // Pick the first defined of two or three arguments. function defaults(a, b, c) { if (a != null) { return a; } if (b != null) { return b; } return c; } function currentDateArray(config) { // hooks is actually the exported moment object var nowValue = new Date(hooks.now()); if (config._useUTC) { return [ nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate(), ]; } return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()]; } // convert an array to a date. // the array should mirror the parameters below // note: all values past the year are optional and will default to the lowest possible value. // [year, month, day , hour, minute, second, millisecond] function configFromArray(config) { var i, date, input = [], currentDate, expectedWeekday, yearToUse; if (config._d) { return; } currentDate = currentDateArray(config); //compute day of the year from weeks and weekdays if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { dayOfYearFromWeekInfo(config); } //if the day of the year is set, figure out what it is if (config._dayOfYear != null) { yearToUse = defaults(config._a[YEAR], currentDate[YEAR]); if ( config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0 ) { getParsingFlags(config)._overflowDayOfYear = true; } date = createUTCDate(yearToUse, 0, config._dayOfYear); config._a[MONTH] = date.getUTCMonth(); config._a[DATE] = date.getUTCDate(); } // Default to current date. // * if no year, month, day of month are given, default to today // * if day of month is given, default month and year // * if month is given, default only year // * if year is given, don't default anything for (i = 0; i < 3 && config._a[i] == null; ++i) { config._a[i] = input[i] = currentDate[i]; } // Zero out whatever was not defaulted, including time for (; i < 7; i++) { config._a[i] = input[i] = config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i]; } // Check for 24:00:00.000 if ( config._a[HOUR] === 24 && config._a[MINUTE] === 0 && config._a[SECOND] === 0 && config._a[MILLISECOND] === 0 ) { config._nextDay = true; config._a[HOUR] = 0; } config._d = (config._useUTC ? createUTCDate : createDate).apply( null, input ); expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay(); // Apply timezone offset from input. The actual utcOffset can be changed // with parseZone. if (config._tzm != null) { config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); } if (config._nextDay) { config._a[HOUR] = 24; } // check for mismatching day of week if ( config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday ) { getParsingFlags(config).weekdayMismatch = true; } } function dayOfYearFromWeekInfo(config) { var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek; w = config._w; if (w.GG != null || w.W != null || w.E != null) { dow = 1; doy = 4; // TODO: We need to take the current isoWeekYear, but that depends on // how we interpret now (local, utc, fixed offset). So create // a now version of current config (take local/utc/offset flags, and // create now). weekYear = defaults( w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year ); week = defaults(w.W, 1); weekday = defaults(w.E, 1); if (weekday < 1 || weekday > 7) { weekdayOverflow = true; } } else { dow = config._locale._week.dow; doy = config._locale._week.doy; curWeek = weekOfYear(createLocal(), dow, doy); weekYear = defaults(w.gg, config._a[YEAR], curWeek.year); // Default to current week. week = defaults(w.w, curWeek.week); if (w.d != null) { // weekday -- low day numbers are considered next week weekday = w.d; if (weekday < 0 || weekday > 6) { weekdayOverflow = true; } } else if (w.e != null) { // local weekday -- counting starts from beginning of week weekday = w.e + dow; if (w.e < 0 || w.e > 6) { weekdayOverflow = true; } } else { // default to beginning of week weekday = dow; } } if (week < 1 || week > weeksInYear(weekYear, dow, doy)) { getParsingFlags(config)._overflowWeeks = true; } else if (weekdayOverflow != null) { getParsingFlags(config)._overflowWeekday = true; } else { temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy); config._a[YEAR] = temp.year; config._dayOfYear = temp.dayOfYear; } } // constant that refers to the ISO standard hooks.ISO_8601 = function () {}; // constant that refers to the RFC 2822 form hooks.RFC_2822 = function () {}; // date from string and format string function configFromStringAndFormat(config) { // TODO: Move this to another part of the creation flow to prevent circular deps if (config._f === hooks.ISO_8601) { configFromISO(config); return; } if (config._f === hooks.RFC_2822) { configFromRFC2822(config); return; } config._a = []; getParsingFlags(config).empty = true; // This array is used to make a Date, either with `new Date` or `Date.UTC` var string = '' + config._i, i, parsedInput, tokens, token, skipped, stringLength = string.length, totalParsedInputLength = 0, era; tokens = expandFormat(config._f, config._locale).match(formattingTokens) || []; for (i = 0; i < tokens.length; i++) { token = tokens[i]; parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; if (parsedInput) { skipped = string.substr(0, string.indexOf(parsedInput)); if (skipped.length > 0) { getParsingFlags(config).unusedInput.push(skipped); } string = string.slice( string.indexOf(parsedInput) + parsedInput.length ); totalParsedInputLength += parsedInput.length; } // don't parse if it's not a known token if (formatTokenFunctions[token]) { if (parsedInput) { getParsingFlags(config).empty = false; } else { getParsingFlags(config).unusedTokens.push(token); } addTimeToArrayFromToken(token, parsedInput, config); } else if (config._strict && !parsedInput) { getParsingFlags(config).unusedTokens.push(token); } } // add remaining unparsed input length to the string getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength; if (string.length > 0) { getParsingFlags(config).unusedInput.push(string); } // clear _12h flag if hour is <= 12 if ( config._a[HOUR] <= 12 && getParsingFlags(config).bigHour === true && config._a[HOUR] > 0 ) { getParsingFlags(config).bigHour = undefined; } getParsingFlags(config).parsedDateParts = config._a.slice(0); getParsingFlags(config).meridiem = config._meridiem; // handle meridiem config._a[HOUR] = meridiemFixWrap( config._locale, config._a[HOUR], config._meridiem ); // handle era era = getParsingFlags(config).era; if (era !== null) { config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]); } configFromArray(config); checkOverflow(config); } function meridiemFixWrap(locale, hour, meridiem) { var isPm; if (meridiem == null) { // nothing to do return hour; } if (locale.meridiemHour != null) { return locale.meridiemHour(hour, meridiem); } else if (locale.isPM != null) { // Fallback isPm = locale.isPM(meridiem); if (isPm && hour < 12) { hour += 12; } if (!isPm && hour === 12) { hour = 0; } return hour; } else { // this is not supposed to happen return hour; } } // date from string and array of format strings function configFromStringAndArray(config) { var tempConfig, bestMoment, scoreToBeat, i, currentScore, validFormatFound, bestFormatIsValid = false; if (config._f.length === 0) { getParsingFlags(config).invalidFormat = true; config._d = new Date(NaN); return; } for (i = 0; i < config._f.length; i++) { currentScore = 0; validFormatFound = false; tempConfig = copyConfig({}, config); if (config._useUTC != null) { tempConfig._useUTC = config._useUTC; } tempConfig._f = config._f[i]; configFromStringAndFormat(tempConfig); if (isValid(tempConfig)) { validFormatFound = true; } // if there is any input that was not parsed add a penalty for that format currentScore += getParsingFlags(tempConfig).charsLeftOver; //or tokens currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10; getParsingFlags(tempConfig).score = currentScore; if (!bestFormatIsValid) { if ( scoreToBeat == null || currentScore < scoreToBeat || validFormatFound ) { scoreToBeat = currentScore; bestMoment = tempConfig; if (validFormatFound) { bestFormatIsValid = true; } } } else { if (currentScore < scoreToBeat) { scoreToBeat = currentScore; bestMoment = tempConfig; } } } extend(config, bestMoment || tempConfig); } function configFromObject(config) { if (config._d) { return; } var i = normalizeObjectUnits(config._i), dayOrDate = i.day === undefined ? i.date : i.day; config._a = map( [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond], function (obj) { return obj && parseInt(obj, 10); } ); configFromArray(config); } function createFromConfig(config) { var res = new Moment(checkOverflow(prepareConfig(config))); if (res._nextDay) { // Adding is smart enough around DST res.add(1, 'd'); res._nextDay = undefined; } return res; } function prepareConfig(config) { var input = config._i, format = config._f; config._locale = config._locale || getLocale(config._l); if (input === null || (format === undefined && input === '')) { return createInvalid({ nullInput: true }); } if (typeof input === 'string') { config._i = input = config._locale.preparse(input); } if (isMoment(input)) { return new Moment(checkOverflow(input)); } else if (isDate(input)) { config._d = input; } else if (isArray(format)) { configFromStringAndArray(config); } else if (format) { configFromStringAndFormat(config); } else { configFromInput(config); } if (!isValid(config)) { config._d = null; } return config; } function configFromInput(config) { var input = config._i; if (isUndefined(input)) { config._d = new Date(hooks.now()); } else if (isDate(input)) { config._d = new Date(input.valueOf()); } else if (typeof input === 'string') { configFromString(config); } else if (isArray(input)) { config._a = map(input.slice(0), function (obj) { return parseInt(obj, 10); }); configFromArray(config); } else if (isObject(input)) { configFromObject(config); } else if (isNumber(input)) { // from milliseconds config._d = new Date(input); } else { hooks.createFromInputFallback(config); } } function createLocalOrUTC(input, format, locale, strict, isUTC) { var c = {}; if (format === true || format === false) { strict = format; format = undefined; } if (locale === true || locale === false) { strict = locale; locale = undefined; } if ( (isObject(input) && isObjectEmpty(input)) || (isArray(input) && input.length === 0) ) { input = undefined; } // object construction must be done this way. // https://github.com/moment/moment/issues/1423 c._isAMomentObject = true; c._useUTC = c._isUTC = isUTC; c._l = locale; c._i = input; c._f = format; c._strict = strict; return createFromConfig(c); } function createLocal(input, format, locale, strict) { return createLocalOrUTC(input, format, locale, strict, false); } var prototypeMin = deprecate( 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', function () { var other = createLocal.apply(null, arguments); if (this.isValid() && other.isValid()) { return other < this ? this : other; } else { return createInvalid(); } } ), prototypeMax = deprecate( 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', function () { var other = createLocal.apply(null, arguments); if (this.isValid() && other.isValid()) { return other > this ? this : other; } else { return createInvalid(); } } ); // Pick a moment m from moments so that m[fn](other) is true for all // other. This relies on the function fn to be transitive. // // moments should either be an array of moment objects or an array, whose // first element is an array of moment objects. function pickBy(fn, moments) { var res, i; if (moments.length === 1 && isArray(moments[0])) { moments = moments[0]; } if (!moments.length) { return createLocal(); } res = moments[0]; for (i = 1; i < moments.length; ++i) { if (!moments[i].isValid() || moments[i][fn](res)) { res = moments[i]; } } return res; } // TODO: Use [].sort instead? function min() { var args = [].slice.call(arguments, 0); return pickBy('isBefore', args); } function max() { var args = [].slice.call(arguments, 0); return pickBy('isAfter', args); } var now = function () { return Date.now ? Date.now() : +new Date(); }; var ordering = [ 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond', ]; function isDurationValid(m) { var key, unitHasDecimal = false, i; for (key in m) { if ( hasOwnProp(m, key) && !( indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])) ) ) { return false; } } for (i = 0; i < ordering.length; ++i) { if (m[ordering[i]]) { if (unitHasDecimal) { return false; // only allow non-integers for smallest unit } if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) { unitHasDecimal = true; } } } return true; } function isValid$1() { return this._isValid; } function createInvalid$1() { return createDuration(NaN); } function Duration(duration) { var normalizedInput = normalizeObjectUnits(duration), years = normalizedInput.year || 0, quarters = normalizedInput.quarter || 0, months = normalizedInput.month || 0, weeks = normalizedInput.week || normalizedInput.isoWeek || 0, days = normalizedInput.day || 0, hours = normalizedInput.hour || 0, minutes = normalizedInput.minute || 0, seconds = normalizedInput.second || 0, milliseconds = normalizedInput.millisecond || 0; this._isValid = isDurationValid(normalizedInput); // representation for dateAddRemove this._milliseconds = +milliseconds + seconds * 1e3 + // 1000 minutes * 6e4 + // 1000 * 60 hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978 // Because of dateAddRemove treats 24 hours as different from a // day when working around DST, we need to store them separately this._days = +days + weeks * 7; // It is impossible to translate months into days without knowing // which months you are are talking about, so we have to store // it separately. this._months = +months + quarters * 3 + years * 12; this._data = {}; this._locale = getLocale(); this._bubble(); } function isDuration(obj) { return obj instanceof Duration; } function absRound(number) { if (number < 0) { return Math.round(-1 * number) * -1; } else { return Math.round(number); } } // compare two arrays, return the number of differences function compareArrays(array1, array2, dontConvert) { var len = Math.min(array1.length, array2.length), lengthDiff = Math.abs(array1.length - array2.length), diffs = 0, i; for (i = 0; i < len; i++) { if ( (dontConvert && array1[i] !== array2[i]) || (!dontConvert && toInt(array1[i]) !== toInt(array2[i])) ) { diffs++; } } return diffs + lengthDiff; } // FORMATTING function offset(token, separator) { addFormatToken(token, 0, 0, function () { var offset = this.utcOffset(), sign = '+'; if (offset < 0) { offset = -offset; sign = '-'; } return ( sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~offset % 60, 2) ); }); } offset('Z', ':'); offset('ZZ', ''); // PARSING addRegexToken('Z', matchShortOffset); addRegexToken('ZZ', matchShortOffset); addParseToken(['Z', 'ZZ'], function (input, array, config) { config._useUTC = true; config._tzm = offsetFromString(matchShortOffset, input); }); // HELPERS // timezone chunker // '+10:00' > ['10', '00'] // '-1530' > ['-15', '30'] var chunkOffset = /([\+\-]|\d\d)/gi; function offsetFromString(matcher, string) { var matches = (string || '').match(matcher), chunk, parts, minutes; if (matches === null) { return null; } chunk = matches[matches.length - 1] || []; parts = (chunk + '').match(chunkOffset) || ['-', 0, 0]; minutes = +(parts[1] * 60) + toInt(parts[2]); return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes; } // Return a moment from input, that is local/utc/zone equivalent to model. function cloneWithOffset(input, model) { var res, diff; if (model._isUTC) { res = model.clone(); diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf(); // Use low-level api, because this fn is low-level api. res._d.setTime(res._d.valueOf() + diff); hooks.updateOffset(res, false); return res; } else { return createLocal(input).local(); } } function getDateOffset(m) { // On Firefox.24 Date#getTimezoneOffset returns a floating point. // https://github.com/moment/moment/pull/1871 return -Math.round(m._d.getTimezoneOffset()); } // HOOKS // This function will be called whenever a moment is mutated. // It is intended to keep the offset in sync with the timezone. hooks.updateOffset = function () {}; // MOMENTS // keepLocalTime = true means only change the timezone, without // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]--> // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset // +0200, so we adjust the time as needed, to be valid. // // Keeping the time actually adds/subtracts (one hour) // from the actual represented time. That is why we call updateOffset // a second time. In case it wants us to change the offset again // _changeInProgress == true case, then we have to adjust, because // there is no such time in the given timezone. function getSetOffset(input, keepLocalTime, keepMinutes) { var offset = this._offset || 0, localAdjust; if (!this.isValid()) { return input != null ? this : NaN; } if (input != null) { if (typeof input === 'string') { input = offsetFromString(matchShortOffset, input); if (input === null) { return this; } } else if (Math.abs(input) < 16 && !keepMinutes) { input = input * 60; } if (!this._isUTC && keepLocalTime) { localAdjust = getDateOffset(this); } this._offset = input; this._isUTC = true; if (localAdjust != null) { this.add(localAdjust, 'm'); } if (offset !== input) { if (!keepLocalTime || this._changeInProgress) { addSubtract( this, createDuration(input - offset, 'm'), 1, false ); } else if (!this._changeInProgress) { this._changeInProgress = true; hooks.updateOffset(this, true); this._changeInProgress = null; } } return this; } else { return this._isUTC ? offset : getDateOffset(this); } } function getSetZone(input, keepLocalTime) { if (input != null) { if (typeof input !== 'string') { input = -input; } this.utcOffset(input, keepLocalTime); return this; } else { return -this.utcOffset(); } } function setOffsetToUTC(keepLocalTime) { return this.utcOffset(0, keepLocalTime); } function setOffsetToLocal(keepLocalTime) { if (this._isUTC) { this.utcOffset(0, keepLocalTime); this._isUTC = false; if (keepLocalTime) { this.subtract(getDateOffset(this), 'm'); } } return this; } function setOffsetToParsedOffset() { if (this._tzm != null) { this.utcOffset(this._tzm, false, true); } else if (typeof this._i === 'string') { var tZone = offsetFromString(matchOffset, this._i); if (tZone != null) { this.utcOffset(tZone); } else { this.utcOffset(0, true); } } return this; } function hasAlignedHourOffset(input) { if (!this.isValid()) { return false; } input = input ? createLocal(input).utcOffset() : 0; return (this.utcOffset() - input) % 60 === 0; } function isDaylightSavingTime() { return ( this.utcOffset() > this.clone().month(0).utcOffset() || this.utcOffset() > this.clone().month(5).utcOffset() ); } function isDaylightSavingTimeShifted() { if (!isUndefined(this._isDSTShifted)) { return this._isDSTShifted; } var c = {}, other; copyConfig(c, this); c = prepareConfig(c); if (c._a) { other = c._isUTC ? createUTC(c._a) : createLocal(c._a); this._isDSTShifted = this.isValid() && compareArrays(c._a, other.toArray()) > 0; } else { this._isDSTShifted = false; } return this._isDSTShifted; } function isLocal() { return this.isValid() ? !this._isUTC : false; } function isUtcOffset() { return this.isValid() ? this._isUTC : false; } function isUtc() { return this.isValid() ? this._isUTC && this._offset === 0 : false; } // ASP.NET json date format regex var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/, // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere // and further modified to allow for strings containing both week and day isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/; function createDuration(input, key) { var duration = input, // matching against regexp is expensive, do it on demand match = null, sign, ret, diffRes; if (isDuration(input)) { duration = { ms: input._milliseconds, d: input._days, M: input._months, }; } else if (isNumber(input) || !isNaN(+input)) { duration = {}; if (key) { duration[key] = +input; } else { duration.milliseconds = +input; } } else if ((match = aspNetRegex.exec(input))) { sign = match[1] === '-' ? -1 : 1; duration = { y: 0, d: toInt(match[DATE]) * sign, h: toInt(match[HOUR]) * sign, m: toInt(match[MINUTE]) * sign, s: toInt(match[SECOND]) * sign, ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match }; } else if ((match = isoRegex.exec(input))) { sign = match[1] === '-' ? -1 : 1; duration = { y: parseIso(match[2], sign), M: parseIso(match[3], sign), w: parseIso(match[4], sign), d: parseIso(match[5], sign), h: parseIso(match[6], sign), m: parseIso(match[7], sign), s: parseIso(match[8], sign), }; } else if (duration == null) { // checks for null or undefined duration = {}; } else if ( typeof duration === 'object' && ('from' in duration || 'to' in duration) ) { diffRes = momentsDifference( createLocal(duration.from), createLocal(duration.to) ); duration = {}; duration.ms = diffRes.milliseconds; duration.M = diffRes.months; } ret = new Duration(duration); if (isDuration(input) && hasOwnProp(input, '_locale')) { ret._locale = input._locale; } if (isDuration(input) && hasOwnProp(input, '_isValid')) { ret._isValid = input._isValid; } return ret; } createDuration.fn = Duration.prototype; createDuration.invalid = createInvalid$1; function parseIso(inp, sign) { // We'd normally use ~~inp for this, but unfortunately it also // converts floats to ints. // inp may be undefined, so careful calling replace on it. var res = inp && parseFloat(inp.replace(',', '.')); // apply sign while we're at it return (isNaN(res) ? 0 : res) * sign; } function positiveMomentsDifference(base, other) { var res = {}; res.months = other.month() - base.month() + (other.year() - base.year()) * 12; if (base.clone().add(res.months, 'M').isAfter(other)) { --res.months; } res.milliseconds = +other - +base.clone().add(res.months, 'M'); return res; } function momentsDifference(base, other) { var res; if (!(base.isValid() && other.isValid())) { return { milliseconds: 0, months: 0 }; } other = cloneWithOffset(other, base); if (base.isBefore(other)) { res = positiveMomentsDifference(base, other); } else { res = positiveMomentsDifference(other, base); res.milliseconds = -res.milliseconds; res.months = -res.months; } return res; } // TODO: remove 'name' arg after deprecation is removed function createAdder(direction, name) { return function (val, period) { var dur, tmp; //invert the arguments, but complain about it if (period !== null && !isNaN(+period)) { deprecateSimple( name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' + 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.' ); tmp = val; val = period; period = tmp; } dur = createDuration(val, period); addSubtract(this, dur, direction); return this; }; } function addSubtract(mom, duration, isAdding, updateOffset) { var milliseconds = duration._milliseconds, days = absRound(duration._days), months = absRound(duration._months); if (!mom.isValid()) { // No op return; } updateOffset = updateOffset == null ? true : updateOffset; if (months) { setMonth(mom, get(mom, 'Month') + months * isAdding); } if (days) { set$1(mom, 'Date', get(mom, 'Date') + days * isAdding); } if (milliseconds) { mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding); } if (updateOffset) { hooks.updateOffset(mom, days || months); } } var add = createAdder(1, 'add'), subtract = createAdder(-1, 'subtract'); function isString(input) { return typeof input === 'string' || input instanceof String; } // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined function isMomentInput(input) { return ( isMoment(input) || isDate(input) || isString(input) || isNumber(input) || isNumberOrStringArray(input) || isMomentInputObject(input) || input === null || input === undefined ); } function isMomentInputObject(input) { var objectTest = isObject(input) && !isObjectEmpty(input), propertyTest = false, properties = [ 'years', 'year', 'y', 'months', 'month', 'M', 'days', 'day', 'd', 'dates', 'date', 'D', 'hours', 'hour', 'h', 'minutes', 'minute', 'm', 'seconds', 'second', 's', 'milliseconds', 'millisecond', 'ms', ], i, property; for (i = 0; i < properties.length; i += 1) { property = properties[i]; propertyTest = propertyTest || hasOwnProp(input, property); } return objectTest && propertyTest; } function isNumberOrStringArray(input) { var arrayTest = isArray(input), dataTypeTest = false; if (arrayTest) { dataTypeTest = input.filter(function (item) { return !isNumber(item) && isString(input); }).length === 0; } return arrayTest && dataTypeTest; } function isCalendarSpec(input) { var objectTest = isObject(input) && !isObjectEmpty(input), propertyTest = false, properties = [ 'sameDay', 'nextDay', 'lastDay', 'nextWeek', 'lastWeek', 'sameElse', ], i, property; for (i = 0; i < properties.length; i += 1) { property = properties[i]; propertyTest = propertyTest || hasOwnProp(input, property); } return objectTest && propertyTest; } function getCalendarFormat(myMoment, now) { var diff = myMoment.diff(now, 'days', true); return diff < -6 ? 'sameElse' : diff < -1 ? 'lastWeek' : diff < 0 ? 'lastDay' : diff < 1 ? 'sameDay' : diff < 2 ? 'nextDay' : diff < 7 ? 'nextWeek' : 'sameElse'; } function calendar$1(time, formats) { // Support for single parameter, formats only overload to the calendar function if (arguments.length === 1) { if (!arguments[0]) { time = undefined; formats = undefined; } else if (isMomentInput(arguments[0])) { time = arguments[0]; formats = undefined; } else if (isCalendarSpec(arguments[0])) { formats = arguments[0]; time = undefined; } } // We want to compare the start of today, vs this. // Getting start-of-today depends on whether we're local/utc/offset or not. var now = time || createLocal(), sod = cloneWithOffset(now, this).startOf('day'), format = hooks.calendarFormat(this, sod) || 'sameElse', output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]); return this.format( output || this.localeData().calendar(format, this, createLocal(now)) ); } function clone() { return new Moment(this); } function isAfter(input, units) { var localInput = isMoment(input) ? input : createLocal(input); if (!(this.isValid() && localInput.isValid())) { return false; } units = normalizeUnits(units) || 'millisecond'; if (units === 'millisecond') { return this.valueOf() > localInput.valueOf(); } else { return localInput.valueOf() < this.clone().startOf(units).valueOf(); } } function isBefore(input, units) { var localInput = isMoment(input) ? input : createLocal(input); if (!(this.isValid() && localInput.isValid())) { return false; } units = normalizeUnits(units) || 'millisecond'; if (units === 'millisecond') { return this.valueOf() < localInput.valueOf(); } else { return this.clone().endOf(units).valueOf() < localInput.valueOf(); } } function isBetween(from, to, units, inclusivity) { var localFrom = isMoment(from) ? from : createLocal(from), localTo = isMoment(to) ? to : createLocal(to); if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) { return false; } inclusivity = inclusivity || '()'; return ( (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) && (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units)) ); } function isSame(input, units) { var localInput = isMoment(input) ? input : createLocal(input), inputMs; if (!(this.isValid() && localInput.isValid())) { return false; } units = normalizeUnits(units) || 'millisecond'; if (units === 'millisecond') { return this.valueOf() === localInput.valueOf(); } else { inputMs = localInput.valueOf(); return ( this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf() ); } } function isSameOrAfter(input, units) { return this.isSame(input, units) || this.isAfter(input, units); } function isSameOrBefore(input, units) { return this.isSame(input, units) || this.isBefore(input, units); } function diff(input, units, asFloat) { var that, zoneDelta, output; if (!this.isValid()) { return NaN; } that = cloneWithOffset(input, this); if (!that.isValid()) { return NaN; } zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4; units = normalizeUnits(units); switch (units) { case 'year': output = monthDiff(this, that) / 12; break; case 'month': output = monthDiff(this, that); break; case 'quarter': output = monthDiff(this, that) / 3; break; case 'second': output = (this - that) / 1e3; break; // 1000 case 'minute': output = (this - that) / 6e4; break; // 1000 * 60 case 'hour': output = (this - that) / 36e5; break; // 1000 * 60 * 60 case 'day': output = (this - that - zoneDelta) / 864e5; break; // 1000 * 60 * 60 * 24, negate dst case 'week': output = (this - that - zoneDelta) / 6048e5; break; // 1000 * 60 * 60 * 24 * 7, negate dst default: output = this - that; } return asFloat ? output : absFloor(output); } function monthDiff(a, b) { if (a.date() < b.date()) { // end-of-month calculations work correct when the start month has more // days than the end month. return -monthDiff(b, a); } // difference in months var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()), // b is in (anchor - 1 month, anchor + 1 month) anchor = a.clone().add(wholeMonthDiff, 'months'), anchor2, adjust; if (b - anchor < 0) { anchor2 = a.clone().add(wholeMonthDiff - 1, 'months'); // linear across the month adjust = (b - anchor) / (anchor - anchor2); } else { anchor2 = a.clone().add(wholeMonthDiff + 1, 'months'); // linear across the month adjust = (b - anchor) / (anchor2 - anchor); } //check for negative zero, return zero if negative zero return -(wholeMonthDiff + adjust) || 0; } hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ'; hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]'; function toString() { return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'); } function toISOString(keepOffset) { if (!this.isValid()) { return null; } var utc = keepOffset !== true, m = utc ? this.clone().utc() : this; if (m.year() < 0 || m.year() > 9999) { return formatMoment( m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ' ); } if (isFunction(Date.prototype.toISOString)) { // native implementation is ~50x faster, use it when we can if (utc) { return this.toDate().toISOString(); } else { return new Date(this.valueOf() + this.utcOffset() * 60 * 1000) .toISOString() .replace('Z', formatMoment(m, 'Z')); } } return formatMoment( m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ' ); } /** * Return a human readable representation of a moment that can * also be evaluated to get a new moment which is the same * * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects */ function inspect() { if (!this.isValid()) { return 'moment.invalid(/* ' + this._i + ' */)'; } var func = 'moment', zone = '', prefix, year, datetime, suffix; if (!this.isLocal()) { func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone'; zone = 'Z'; } prefix = '[' + func + '("]'; year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY'; datetime = '-MM-DD[T]HH:mm:ss.SSS'; suffix = zone + '[")]'; return this.format(prefix + year + datetime + suffix); } function format(inputString) { if (!inputString) { inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat; } var output = formatMoment(this, inputString); return this.localeData().postformat(output); } function from(time, withoutSuffix) { if ( this.isValid() && ((isMoment(time) && time.isValid()) || createLocal(time).isValid()) ) { return createDuration({ to: this, from: time }) .locale(this.locale()) .humanize(!withoutSuffix); } else { return this.localeData().invalidDate(); } } function fromNow(withoutSuffix) { return this.from(createLocal(), withoutSuffix); } function to(time, withoutSuffix) { if ( this.isValid() && ((isMoment(time) && time.isValid()) || createLocal(time).isValid()) ) { return createDuration({ from: this, to: time }) .locale(this.locale()) .humanize(!withoutSuffix); } else { return this.localeData().invalidDate(); } } function toNow(withoutSuffix) { return this.to(createLocal(), withoutSuffix); } // If passed a locale key, it will set the locale for this // instance. Otherwise, it will return the locale configuration // variables for this instance. function locale(key) { var newLocaleData; if (key === undefined) { return this._locale._abbr; } else { newLocaleData = getLocale(key); if (newLocaleData != null) { this._locale = newLocaleData; } return this; } } var lang = deprecate( 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', function (key) { if (key === undefined) { return this.localeData(); } else { return this.locale(key); } } ); function localeData() { return this._locale; } var MS_PER_SECOND = 1000, MS_PER_MINUTE = 60 * MS_PER_SECOND, MS_PER_HOUR = 60 * MS_PER_MINUTE, MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR; // actual modulo - handles negative numbers (for dates before 1970): function mod$1(dividend, divisor) { return ((dividend % divisor) + divisor) % divisor; } function localStartOfDate(y, m, d) { // the date constructor remaps years 0-99 to 1900-1999 if (y < 100 && y >= 0) { // preserve leap years using a full 400 year cycle, then reset return new Date(y + 400, m, d) - MS_PER_400_YEARS; } else { return new Date(y, m, d).valueOf(); } } function utcStartOfDate(y, m, d) { // Date.UTC remaps years 0-99 to 1900-1999 if (y < 100 && y >= 0) { // preserve leap years using a full 400 year cycle, then reset return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS; } else { return Date.UTC(y, m, d); } } function startOf(units) { var time, startOfDate; units = normalizeUnits(units); if (units === undefined || units === 'millisecond' || !this.isValid()) { return this; } startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; switch (units) { case 'year': time = startOfDate(this.year(), 0, 1); break; case 'quarter': time = startOfDate( this.year(), this.month() - (this.month() % 3), 1 ); break; case 'month': time = startOfDate(this.year(), this.month(), 1); break; case 'week': time = startOfDate( this.year(), this.month(), this.date() - this.weekday() ); break; case 'isoWeek': time = startOfDate( this.year(), this.month(), this.date() - (this.isoWeekday() - 1) ); break; case 'day': case 'date': time = startOfDate(this.year(), this.month(), this.date()); break; case 'hour': time = this._d.valueOf(); time -= mod$1( time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR ); break; case 'minute': time = this._d.valueOf(); time -= mod$1(time, MS_PER_MINUTE); break; case 'second': time = this._d.valueOf(); time -= mod$1(time, MS_PER_SECOND); break; } this._d.setTime(time); hooks.updateOffset(this, true); return this; } function endOf(units) { var time, startOfDate; units = normalizeUnits(units); if (units === undefined || units === 'millisecond' || !this.isValid()) { return this; } startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; switch (units) { case 'year': time = startOfDate(this.year() + 1, 0, 1) - 1; break; case 'quarter': time = startOfDate( this.year(), this.month() - (this.month() % 3) + 3, 1 ) - 1; break; case 'month': time = startOfDate(this.year(), this.month() + 1, 1) - 1; break; case 'week': time = startOfDate( this.year(), this.month(), this.date() - this.weekday() + 7 ) - 1; break; case 'isoWeek': time = startOfDate( this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7 ) - 1; break; case 'day': case 'date': time = startOfDate(this.year(), this.month(), this.date() + 1) - 1; break; case 'hour': time = this._d.valueOf(); time += MS_PER_HOUR - mod$1( time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR ) - 1; break; case 'minute': time = this._d.valueOf(); time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1; break; case 'second': time = this._d.valueOf(); time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1; break; } this._d.setTime(time); hooks.updateOffset(this, true); return this; } function valueOf() { return this._d.valueOf() - (this._offset || 0) * 60000; } function unix() { return Math.floor(this.valueOf() / 1000); } function toDate() { return new Date(this.valueOf()); } function toArray() { var m = this; return [ m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond(), ]; } function toObject() { var m = this; return { years: m.year(), months: m.month(), date: m.date(), hours: m.hours(), minutes: m.minutes(), seconds: m.seconds(), milliseconds: m.milliseconds(), }; } function toJSON() { // new Date(NaN).toJSON() === null return this.isValid() ? this.toISOString() : null; } function isValid$2() { return isValid(this); } function parsingFlags() { return extend({}, getParsingFlags(this)); } function invalidAt() { return getParsingFlags(this).overflow; } function creationData() { return { input: this._i, format: this._f, locale: this._locale, isUTC: this._isUTC, strict: this._strict, }; } addFormatToken('N', 0, 0, 'eraAbbr'); addFormatToken('NN', 0, 0, 'eraAbbr'); addFormatToken('NNN', 0, 0, 'eraAbbr'); addFormatToken('NNNN', 0, 0, 'eraName'); addFormatToken('NNNNN', 0, 0, 'eraNarrow'); addFormatToken('y', ['y', 1], 'yo', 'eraYear'); addFormatToken('y', ['yy', 2], 0, 'eraYear'); addFormatToken('y', ['yyy', 3], 0, 'eraYear'); addFormatToken('y', ['yyyy', 4], 0, 'eraYear'); addRegexToken('N', matchEraAbbr); addRegexToken('NN', matchEraAbbr); addRegexToken('NNN', matchEraAbbr); addRegexToken('NNNN', matchEraName); addRegexToken('NNNNN', matchEraNarrow); addParseToken(['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], function ( input, array, config, token ) { var era = config._locale.erasParse(input, token, config._strict); if (era) { getParsingFlags(config).era = era; } else { getParsingFlags(config).invalidEra = input; } }); addRegexToken('y', matchUnsigned); addRegexToken('yy', matchUnsigned); addRegexToken('yyy', matchUnsigned); addRegexToken('yyyy', matchUnsigned); addRegexToken('yo', matchEraYearOrdinal); addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR); addParseToken(['yo'], function (input, array, config, token) { var match; if (config._locale._eraYearOrdinalRegex) { match = input.match(config._locale._eraYearOrdinalRegex); } if (config._locale.eraYearOrdinalParse) { array[YEAR] = config._locale.eraYearOrdinalParse(input, match); } else { array[YEAR] = parseInt(input, 10); } }); function localeEras(m, format) { var i, l, date, eras = this._eras || getLocale('en')._eras; for (i = 0, l = eras.length; i < l; ++i) { switch (typeof eras[i].since) { case 'string': // truncate time date = hooks(eras[i].since).startOf('day'); eras[i].since = date.valueOf(); break; } switch (typeof eras[i].until) { case 'undefined': eras[i].until = +Infinity; break; case 'string': // truncate time date = hooks(eras[i].until).startOf('day').valueOf(); eras[i].until = date.valueOf(); break; } } return eras; } function localeErasParse(eraName, format, strict) { var i, l, eras = this.eras(), name, abbr, narrow; eraName = eraName.toUpperCase(); for (i = 0, l = eras.length; i < l; ++i) { name = eras[i].name.toUpperCase(); abbr = eras[i].abbr.toUpperCase(); narrow = eras[i].narrow.toUpperCase(); if (strict) { switch (format) { case 'N': case 'NN': case 'NNN': if (abbr === eraName) { return eras[i]; } break; case 'NNNN': if (name === eraName) { return eras[i]; } break; case 'NNNNN': if (narrow === eraName) { return eras[i]; } break; } } else if ([name, abbr, narrow].indexOf(eraName) >= 0) { return eras[i]; } } } function localeErasConvertYear(era, year) { var dir = era.since <= era.until ? +1 : -1; if (year === undefined) { return hooks(era.since).year(); } else { return hooks(era.since).year() + (year - era.offset) * dir; } } function getEraName() { var i, l, val, eras = this.localeData().eras(); for (i = 0, l = eras.length; i < l; ++i) { // truncate time val = this.clone().startOf('day').valueOf(); if (eras[i].since <= val && val <= eras[i].until) { return eras[i].name; } if (eras[i].until <= val && val <= eras[i].since) { return eras[i].name; } } return ''; } function getEraNarrow() { var i, l, val, eras = this.localeData().eras(); for (i = 0, l = eras.length; i < l; ++i) { // truncate time val = this.clone().startOf('day').valueOf(); if (eras[i].since <= val && val <= eras[i].until) { return eras[i].narrow; } if (eras[i].until <= val && val <= eras[i].since) { return eras[i].narrow; } } return ''; } function getEraAbbr() { var i, l, val, eras = this.localeData().eras(); for (i = 0, l = eras.length; i < l; ++i) { // truncate time val = this.clone().startOf('day').valueOf(); if (eras[i].since <= val && val <= eras[i].until) { return eras[i].abbr; } if (eras[i].until <= val && val <= eras[i].since) { return eras[i].abbr; } } return ''; } function getEraYear() { var i, l, dir, val, eras = this.localeData().eras(); for (i = 0, l = eras.length; i < l; ++i) { dir = eras[i].since <= eras[i].until ? +1 : -1; // truncate time val = this.clone().startOf('day').valueOf(); if ( (eras[i].since <= val && val <= eras[i].until) || (eras[i].until <= val && val <= eras[i].since) ) { return ( (this.year() - hooks(eras[i].since).year()) * dir + eras[i].offset ); } } return this.year(); } function erasNameRegex(isStrict) { if (!hasOwnProp(this, '_erasNameRegex')) { computeErasParse.call(this); } return isStrict ? this._erasNameRegex : this._erasRegex; } function erasAbbrRegex(isStrict) { if (!hasOwnProp(this, '_erasAbbrRegex')) { computeErasParse.call(this); } return isStrict ? this._erasAbbrRegex : this._erasRegex; } function erasNarrowRegex(isStrict) { if (!hasOwnProp(this, '_erasNarrowRegex')) { computeErasParse.call(this); } return isStrict ? this._erasNarrowRegex : this._erasRegex; } function matchEraAbbr(isStrict, locale) { return locale.erasAbbrRegex(isStrict); } function matchEraName(isStrict, locale) { return locale.erasNameRegex(isStrict); } function matchEraNarrow(isStrict, locale) { return locale.erasNarrowRegex(isStrict); } function matchEraYearOrdinal(isStrict, locale) { return locale._eraYearOrdinalRegex || matchUnsigned; } function computeErasParse() { var abbrPieces = [], namePieces = [], narrowPieces = [], mixedPieces = [], i, l, eras = this.eras(); for (i = 0, l = eras.length; i < l; ++i) { namePieces.push(regexEscape(eras[i].name)); abbrPieces.push(regexEscape(eras[i].abbr)); narrowPieces.push(regexEscape(eras[i].narrow)); mixedPieces.push(regexEscape(eras[i].name)); mixedPieces.push(regexEscape(eras[i].abbr)); mixedPieces.push(regexEscape(eras[i].narrow)); } this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i'); this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i'); this._erasNarrowRegex = new RegExp( '^(' + narrowPieces.join('|') + ')', 'i' ); } // FORMATTING addFormatToken(0, ['gg', 2], 0, function () { return this.weekYear() % 100; }); addFormatToken(0, ['GG', 2], 0, function () { return this.isoWeekYear() % 100; }); function addWeekYearFormatToken(token, getter) { addFormatToken(0, [token, token.length], 0, getter); } addWeekYearFormatToken('gggg', 'weekYear'); addWeekYearFormatToken('ggggg', 'weekYear'); addWeekYearFormatToken('GGGG', 'isoWeekYear'); addWeekYearFormatToken('GGGGG', 'isoWeekYear'); // ALIASES addUnitAlias('weekYear', 'gg'); addUnitAlias('isoWeekYear', 'GG'); // PRIORITY addUnitPriority('weekYear', 1); addUnitPriority('isoWeekYear', 1); // PARSING addRegexToken('G', matchSigned); addRegexToken('g', matchSigned); addRegexToken('GG', match1to2, match2); addRegexToken('gg', match1to2, match2); addRegexToken('GGGG', match1to4, match4); addRegexToken('gggg', match1to4, match4); addRegexToken('GGGGG', match1to6, match6); addRegexToken('ggggg', match1to6, match6); addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function ( input, week, config, token ) { week[token.substr(0, 2)] = toInt(input); }); addWeekParseToken(['gg', 'GG'], function (input, week, config, token) { week[token] = hooks.parseTwoDigitYear(input); }); // MOMENTS function getSetWeekYear(input) { return getSetWeekYearHelper.call( this, input, this.week(), this.weekday(), this.localeData()._week.dow, this.localeData()._week.doy ); } function getSetISOWeekYear(input) { return getSetWeekYearHelper.call( this, input, this.isoWeek(), this.isoWeekday(), 1, 4 ); } function getISOWeeksInYear() { return weeksInYear(this.year(), 1, 4); } function getISOWeeksInISOWeekYear() { return weeksInYear(this.isoWeekYear(), 1, 4); } function getWeeksInYear() { var weekInfo = this.localeData()._week; return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); } function getWeeksInWeekYear() { var weekInfo = this.localeData()._week; return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy); } function getSetWeekYearHelper(input, week, weekday, dow, doy) { var weeksTarget; if (input == null) { return weekOfYear(this, dow, doy).year; } else { weeksTarget = weeksInYear(input, dow, doy); if (week > weeksTarget) { week = weeksTarget; } return setWeekAll.call(this, input, week, weekday, dow, doy); } } function setWeekAll(weekYear, week, weekday, dow, doy) { var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy), date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear); this.year(date.getUTCFullYear()); this.month(date.getUTCMonth()); this.date(date.getUTCDate()); return this; } // FORMATTING addFormatToken('Q', 0, 'Qo', 'quarter'); // ALIASES addUnitAlias('quarter', 'Q'); // PRIORITY addUnitPriority('quarter', 7); // PARSING addRegexToken('Q', match1); addParseToken('Q', function (input, array) { array[MONTH] = (toInt(input) - 1) * 3; }); // MOMENTS function getSetQuarter(input) { return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + (this.month() % 3)); } // FORMATTING addFormatToken('D', ['DD', 2], 'Do', 'date'); // ALIASES addUnitAlias('date', 'D'); // PRIORITY addUnitPriority('date', 9); // PARSING addRegexToken('D', match1to2); addRegexToken('DD', match1to2, match2); addRegexToken('Do', function (isStrict, locale) { // TODO: Remove "ordinalParse" fallback in next major release. return isStrict ? locale._dayOfMonthOrdinalParse || locale._ordinalParse : locale._dayOfMonthOrdinalParseLenient; }); addParseToken(['D', 'DD'], DATE); addParseToken('Do', function (input, array) { array[DATE] = toInt(input.match(match1to2)[0]); }); // MOMENTS var getSetDayOfMonth = makeGetSet('Date', true); // FORMATTING addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear'); // ALIASES addUnitAlias('dayOfYear', 'DDD'); // PRIORITY addUnitPriority('dayOfYear', 4); // PARSING addRegexToken('DDD', match1to3); addRegexToken('DDDD', match3); addParseToken(['DDD', 'DDDD'], function (input, array, config) { config._dayOfYear = toInt(input); }); // HELPERS // MOMENTS function getSetDayOfYear(input) { var dayOfYear = Math.round( (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5 ) + 1; return input == null ? dayOfYear : this.add(input - dayOfYear, 'd'); } // FORMATTING addFormatToken('m', ['mm', 2], 0, 'minute'); // ALIASES addUnitAlias('minute', 'm'); // PRIORITY addUnitPriority('minute', 14); // PARSING addRegexToken('m', match1to2); addRegexToken('mm', match1to2, match2); addParseToken(['m', 'mm'], MINUTE); // MOMENTS var getSetMinute = makeGetSet('Minutes', false); // FORMATTING addFormatToken('s', ['ss', 2], 0, 'second'); // ALIASES addUnitAlias('second', 's'); // PRIORITY addUnitPriority('second', 15); // PARSING addRegexToken('s', match1to2); addRegexToken('ss', match1to2, match2); addParseToken(['s', 'ss'], SECOND); // MOMENTS var getSetSecond = makeGetSet('Seconds', false); // FORMATTING addFormatToken('S', 0, 0, function () { return ~~(this.millisecond() / 100); }); addFormatToken(0, ['SS', 2], 0, function () { return ~~(this.millisecond() / 10); }); addFormatToken(0, ['SSS', 3], 0, 'millisecond'); addFormatToken(0, ['SSSS', 4], 0, function () { return this.millisecond() * 10; }); addFormatToken(0, ['SSSSS', 5], 0, function () { return this.millisecond() * 100; }); addFormatToken(0, ['SSSSSS', 6], 0, function () { return this.millisecond() * 1000; }); addFormatToken(0, ['SSSSSSS', 7], 0, function () { return this.millisecond() * 10000; }); addFormatToken(0, ['SSSSSSSS', 8], 0, function () { return this.millisecond() * 100000; }); addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { return this.millisecond() * 1000000; }); // ALIASES addUnitAlias('millisecond', 'ms'); // PRIORITY addUnitPriority('millisecond', 16); // PARSING addRegexToken('S', match1to3, match1); addRegexToken('SS', match1to3, match2); addRegexToken('SSS', match1to3, match3); var token, getSetMillisecond; for (token = 'SSSS'; token.length <= 9; token += 'S') { addRegexToken(token, matchUnsigned); } function parseMs(input, array) { array[MILLISECOND] = toInt(('0.' + input) * 1000); } for (token = 'S'; token.length <= 9; token += 'S') { addParseToken(token, parseMs); } getSetMillisecond = makeGetSet('Milliseconds', false); // FORMATTING addFormatToken('z', 0, 0, 'zoneAbbr'); addFormatToken('zz', 0, 0, 'zoneName'); // MOMENTS function getZoneAbbr() { return this._isUTC ? 'UTC' : ''; } function getZoneName() { return this._isUTC ? 'Coordinated Universal Time' : ''; } var proto = Moment.prototype; proto.add = add; proto.calendar = calendar$1; proto.clone = clone; proto.diff = diff; proto.endOf = endOf; proto.format = format; proto.from = from; proto.fromNow = fromNow; proto.to = to; proto.toNow = toNow; proto.get = stringGet; proto.invalidAt = invalidAt; proto.isAfter = isAfter; proto.isBefore = isBefore; proto.isBetween = isBetween; proto.isSame = isSame; proto.isSameOrAfter = isSameOrAfter; proto.isSameOrBefore = isSameOrBefore; proto.isValid = isValid$2; proto.lang = lang; proto.locale = locale; proto.localeData = localeData; proto.max = prototypeMax; proto.min = prototypeMin; proto.parsingFlags = parsingFlags; proto.set = stringSet; proto.startOf = startOf; proto.subtract = subtract; proto.toArray = toArray; proto.toObject = toObject; proto.toDate = toDate; proto.toISOString = toISOString; proto.inspect = inspect; if (typeof Symbol !== 'undefined' && Symbol.for != null) { proto[Symbol.for('nodejs.util.inspect.custom')] = function () { return 'Moment<' + this.format() + '>'; }; } proto.toJSON = toJSON; proto.toString = toString; proto.unix = unix; proto.valueOf = valueOf; proto.creationData = creationData; proto.eraName = getEraName; proto.eraNarrow = getEraNarrow; proto.eraAbbr = getEraAbbr; proto.eraYear = getEraYear; proto.year = getSetYear; proto.isLeapYear = getIsLeapYear; proto.weekYear = getSetWeekYear; proto.isoWeekYear = getSetISOWeekYear; proto.quarter = proto.quarters = getSetQuarter; proto.month = getSetMonth; proto.daysInMonth = getDaysInMonth; proto.week = proto.weeks = getSetWeek; proto.isoWeek = proto.isoWeeks = getSetISOWeek; proto.weeksInYear = getWeeksInYear; proto.weeksInWeekYear = getWeeksInWeekYear; proto.isoWeeksInYear = getISOWeeksInYear; proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear; proto.date = getSetDayOfMonth; proto.day = proto.days = getSetDayOfWeek; proto.weekday = getSetLocaleDayOfWeek; proto.isoWeekday = getSetISODayOfWeek; proto.dayOfYear = getSetDayOfYear; proto.hour = proto.hours = getSetHour; proto.minute = proto.minutes = getSetMinute; proto.second = proto.seconds = getSetSecond; proto.millisecond = proto.milliseconds = getSetMillisecond; proto.utcOffset = getSetOffset; proto.utc = setOffsetToUTC; proto.local = setOffsetToLocal; proto.parseZone = setOffsetToParsedOffset; proto.hasAlignedHourOffset = hasAlignedHourOffset; proto.isDST = isDaylightSavingTime; proto.isLocal = isLocal; proto.isUtcOffset = isUtcOffset; proto.isUtc = isUtc; proto.isUTC = isUtc; proto.zoneAbbr = getZoneAbbr; proto.zoneName = getZoneName; proto.dates = deprecate( 'dates accessor is deprecated. Use date instead.', getSetDayOfMonth ); proto.months = deprecate( 'months accessor is deprecated. Use month instead', getSetMonth ); proto.years = deprecate( 'years accessor is deprecated. Use year instead', getSetYear ); proto.zone = deprecate( 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone ); proto.isDSTShifted = deprecate( 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted ); function createUnix(input) { return createLocal(input * 1000); } function createInZone() { return createLocal.apply(null, arguments).parseZone(); } function preParsePostFormat(string) { return string; } var proto$1 = Locale.prototype; proto$1.calendar = calendar; proto$1.longDateFormat = longDateFormat; proto$1.invalidDate = invalidDate; proto$1.ordinal = ordinal; proto$1.preparse = preParsePostFormat; proto$1.postformat = preParsePostFormat; proto$1.relativeTime = relativeTime; proto$1.pastFuture = pastFuture; proto$1.set = set; proto$1.eras = localeEras; proto$1.erasParse = localeErasParse; proto$1.erasConvertYear = localeErasConvertYear; proto$1.erasAbbrRegex = erasAbbrRegex; proto$1.erasNameRegex = erasNameRegex; proto$1.erasNarrowRegex = erasNarrowRegex; proto$1.months = localeMonths; proto$1.monthsShort = localeMonthsShort; proto$1.monthsParse = localeMonthsParse; proto$1.monthsRegex = monthsRegex; proto$1.monthsShortRegex = monthsShortRegex; proto$1.week = localeWeek; proto$1.firstDayOfYear = localeFirstDayOfYear; proto$1.firstDayOfWeek = localeFirstDayOfWeek; proto$1.weekdays = localeWeekdays; proto$1.weekdaysMin = localeWeekdaysMin; proto$1.weekdaysShort = localeWeekdaysShort; proto$1.weekdaysParse = localeWeekdaysParse; proto$1.weekdaysRegex = weekdaysRegex; proto$1.weekdaysShortRegex = weekdaysShortRegex; proto$1.weekdaysMinRegex = weekdaysMinRegex; proto$1.isPM = localeIsPM; proto$1.meridiem = localeMeridiem; function get$1(format, index, field, setter) { var locale = getLocale(), utc = createUTC().set(setter, index); return locale[field](utc, format); } function listMonthsImpl(format, index, field) { if (isNumber(format)) { index = format; format = undefined; } format = format || ''; if (index != null) { return get$1(format, index, field, 'month'); } var i, out = []; for (i = 0; i < 12; i++) { out[i] = get$1(format, i, field, 'month'); } return out; } // () // (5) // (fmt, 5) // (fmt) // (true) // (true, 5) // (true, fmt, 5) // (true, fmt) function listWeekdaysImpl(localeSorted, format, index, field) { if (typeof localeSorted === 'boolean') { if (isNumber(format)) { index = format; format = undefined; } format = format || ''; } else { format = localeSorted; index = format; localeSorted = false; if (isNumber(format)) { index = format; format = undefined; } format = format || ''; } var locale = getLocale(), shift = localeSorted ? locale._week.dow : 0, i, out = []; if (index != null) { return get$1(format, (index + shift) % 7, field, 'day'); } for (i = 0; i < 7; i++) { out[i] = get$1(format, (i + shift) % 7, field, 'day'); } return out; } function listMonths(format, index) { return listMonthsImpl(format, index, 'months'); } function listMonthsShort(format, index) { return listMonthsImpl(format, index, 'monthsShort'); } function listWeekdays(localeSorted, format, index) { return listWeekdaysImpl(localeSorted, format, index, 'weekdays'); } function listWeekdaysShort(localeSorted, format, index) { return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort'); } function listWeekdaysMin(localeSorted, format, index) { return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin'); } getSetGlobalLocale('en', { eras: [ { since: '0001-01-01', until: +Infinity, offset: 1, name: 'Anno Domini', narrow: 'AD', abbr: 'AD', }, { since: '0000-12-31', until: -Infinity, offset: 1, name: 'Before Christ', narrow: 'BC', abbr: 'BC', }, ], dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/, ordinal: function (number) { var b = number % 10, output = toInt((number % 100) / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th'; return number + output; }, }); // Side effect imports hooks.lang = deprecate( 'moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale ); hooks.langData = deprecate( 'moment.langData is deprecated. Use moment.localeData instead.', getLocale ); var mathAbs = Math.abs; function abs() { var data = this._data; this._milliseconds = mathAbs(this._milliseconds); this._days = mathAbs(this._days); this._months = mathAbs(this._months); data.milliseconds = mathAbs(data.milliseconds); data.seconds = mathAbs(data.seconds); data.minutes = mathAbs(data.minutes); data.hours = mathAbs(data.hours); data.months = mathAbs(data.months); data.years = mathAbs(data.years); return this; } function addSubtract$1(duration, input, value, direction) { var other = createDuration(input, value); duration._milliseconds += direction * other._milliseconds; duration._days += direction * other._days; duration._months += direction * other._months; return duration._bubble(); } // supports only 2.0-style add(1, 's') or add(duration) function add$1(input, value) { return addSubtract$1(this, input, value, 1); } // supports only 2.0-style subtract(1, 's') or subtract(duration) function subtract$1(input, value) { return addSubtract$1(this, input, value, -1); } function absCeil(number) { if (number < 0) { return Math.floor(number); } else { return Math.ceil(number); } } function bubble() { var milliseconds = this._milliseconds, days = this._days, months = this._months, data = this._data, seconds, minutes, hours, years, monthsFromDays; // if we have a mix of positive and negative values, bubble down first // check: https://github.com/moment/moment/issues/2166 if ( !( (milliseconds >= 0 && days >= 0 && months >= 0) || (milliseconds <= 0 && days <= 0 && months <= 0) ) ) { milliseconds += absCeil(monthsToDays(months) + days) * 864e5; days = 0; months = 0; } // The following code bubbles up values, see the tests for // examples of what that means. data.milliseconds = milliseconds % 1000; seconds = absFloor(milliseconds / 1000); data.seconds = seconds % 60; minutes = absFloor(seconds / 60); data.minutes = minutes % 60; hours = absFloor(minutes / 60); data.hours = hours % 24; days += absFloor(hours / 24); // convert days to months monthsFromDays = absFloor(daysToMonths(days)); months += monthsFromDays; days -= absCeil(monthsToDays(monthsFromDays)); // 12 months -> 1 year years = absFloor(months / 12); months %= 12; data.days = days; data.months = months; data.years = years; return this; } function daysToMonths(days) { // 400 years have 146097 days (taking into account leap year rules) // 400 years have 12 months === 4800 return (days * 4800) / 146097; } function monthsToDays(months) { // the reverse of daysToMonths return (months * 146097) / 4800; } function as(units) { if (!this.isValid()) { return NaN; } var days, months, milliseconds = this._milliseconds; units = normalizeUnits(units); if (units === 'month' || units === 'quarter' || units === 'year') { days = this._days + milliseconds / 864e5; months = this._months + daysToMonths(days); switch (units) { case 'month': return months; case 'quarter': return months / 3; case 'year': return months / 12; } } else { // handle milliseconds separately because of floating point math errors (issue #1867) days = this._days + Math.round(monthsToDays(this._months)); switch (units) { case 'week': return days / 7 + milliseconds / 6048e5; case 'day': return days + milliseconds / 864e5; case 'hour': return days * 24 + milliseconds / 36e5; case 'minute': return days * 1440 + milliseconds / 6e4; case 'second': return days * 86400 + milliseconds / 1000; // Math.floor prevents floating point math errors here case 'millisecond': return Math.floor(days * 864e5) + milliseconds; default: throw new Error('Unknown unit ' + units); } } } // TODO: Use this.as('ms')? function valueOf$1() { if (!this.isValid()) { return NaN; } return ( this._milliseconds + this._days * 864e5 + (this._months % 12) * 2592e6 + toInt(this._months / 12) * 31536e6 ); } function makeAs(alias) { return function () { return this.as(alias); }; } var asMilliseconds = makeAs('ms'), asSeconds = makeAs('s'), asMinutes = makeAs('m'), asHours = makeAs('h'), asDays = makeAs('d'), asWeeks = makeAs('w'), asMonths = makeAs('M'), asQuarters = makeAs('Q'), asYears = makeAs('y'); function clone$1() { return createDuration(this); } function get$2(units) { units = normalizeUnits(units); return this.isValid() ? this[units + 's']() : NaN; } function makeGetter(name) { return function () { return this.isValid() ? this._data[name] : NaN; }; } var milliseconds = makeGetter('milliseconds'), seconds = makeGetter('seconds'), minutes = makeGetter('minutes'), hours = makeGetter('hours'), days = makeGetter('days'), months = makeGetter('months'), years = makeGetter('years'); function weeks() { return absFloor(this.days() / 7); } var round = Math.round, thresholds = { ss: 44, // a few seconds to seconds s: 45, // seconds to minute m: 45, // minutes to hour h: 22, // hours to day d: 26, // days to month/week w: null, // weeks to month M: 11, // months to year }; // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); } function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) { var duration = createDuration(posNegDuration).abs(), seconds = round(duration.as('s')), minutes = round(duration.as('m')), hours = round(duration.as('h')), days = round(duration.as('d')), months = round(duration.as('M')), weeks = round(duration.as('w')), years = round(duration.as('y')), a = (seconds <= thresholds.ss && ['s', seconds]) || (seconds < thresholds.s && ['ss', seconds]) || (minutes <= 1 && ['m']) || (minutes < thresholds.m && ['mm', minutes]) || (hours <= 1 && ['h']) || (hours < thresholds.h && ['hh', hours]) || (days <= 1 && ['d']) || (days < thresholds.d && ['dd', days]); if (thresholds.w != null) { a = a || (weeks <= 1 && ['w']) || (weeks < thresholds.w && ['ww', weeks]); } a = a || (months <= 1 && ['M']) || (months < thresholds.M && ['MM', months]) || (years <= 1 && ['y']) || ['yy', years]; a[2] = withoutSuffix; a[3] = +posNegDuration > 0; a[4] = locale; return substituteTimeAgo.apply(null, a); } // This function allows you to set the rounding function for relative time strings function getSetRelativeTimeRounding(roundingFunction) { if (roundingFunction === undefined) { return round; } if (typeof roundingFunction === 'function') { round = roundingFunction; return true; } return false; } // This function allows you to set a threshold for relative time strings function getSetRelativeTimeThreshold(threshold, limit) { if (thresholds[threshold] === undefined) { return false; } if (limit === undefined) { return thresholds[threshold]; } thresholds[threshold] = limit; if (threshold === 's') { thresholds.ss = limit - 1; } return true; } function humanize(argWithSuffix, argThresholds) { if (!this.isValid()) { return this.localeData().invalidDate(); } var withSuffix = false, th = thresholds, locale, output; if (typeof argWithSuffix === 'object') { argThresholds = argWithSuffix; argWithSuffix = false; } if (typeof argWithSuffix === 'boolean') { withSuffix = argWithSuffix; } if (typeof argThresholds === 'object') { th = Object.assign({}, thresholds, argThresholds); if (argThresholds.s != null && argThresholds.ss == null) { th.ss = argThresholds.s - 1; } } locale = this.localeData(); output = relativeTime$1(this, !withSuffix, th, locale); if (withSuffix) { output = locale.pastFuture(+this, output); } return locale.postformat(output); } var abs$1 = Math.abs; function sign(x) { return (x > 0) - (x < 0) || +x; } function toISOString$1() { // for ISO strings we do not use the normal bubbling rules: // * milliseconds bubble up until they become hours // * days do not bubble at all // * months bubble up until they become years // This is because there is no context-free conversion between hours and days // (think of clock changes) // and also not between days and months (28-31 days per month) if (!this.isValid()) { return this.localeData().invalidDate(); } var seconds = abs$1(this._milliseconds) / 1000, days = abs$1(this._days), months = abs$1(this._months), minutes, hours, years, s, total = this.asSeconds(), totalSign, ymSign, daysSign, hmsSign; if (!total) { // this is the same as C#'s (Noda) and python (isodate)... // but not other JS (goog.date) return 'P0D'; } // 3600 seconds -> 60 minutes -> 1 hour minutes = absFloor(seconds / 60); hours = absFloor(minutes / 60); seconds %= 60; minutes %= 60; // 12 months -> 1 year years = absFloor(months / 12); months %= 12; // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : ''; totalSign = total < 0 ? '-' : ''; ymSign = sign(this._months) !== sign(total) ? '-' : ''; daysSign = sign(this._days) !== sign(total) ? '-' : ''; hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : ''; return ( totalSign + 'P' + (years ? ymSign + years + 'Y' : '') + (months ? ymSign + months + 'M' : '') + (days ? daysSign + days + 'D' : '') + (hours || minutes || seconds ? 'T' : '') + (hours ? hmsSign + hours + 'H' : '') + (minutes ? hmsSign + minutes + 'M' : '') + (seconds ? hmsSign + s + 'S' : '') ); } var proto$2 = Duration.prototype; proto$2.isValid = isValid$1; proto$2.abs = abs; proto$2.add = add$1; proto$2.subtract = subtract$1; proto$2.as = as; proto$2.asMilliseconds = asMilliseconds; proto$2.asSeconds = asSeconds; proto$2.asMinutes = asMinutes; proto$2.asHours = asHours; proto$2.asDays = asDays; proto$2.asWeeks = asWeeks; proto$2.asMonths = asMonths; proto$2.asQuarters = asQuarters; proto$2.asYears = asYears; proto$2.valueOf = valueOf$1; proto$2._bubble = bubble; proto$2.clone = clone$1; proto$2.get = get$2; proto$2.milliseconds = milliseconds; proto$2.seconds = seconds; proto$2.minutes = minutes; proto$2.hours = hours; proto$2.days = days; proto$2.weeks = weeks; proto$2.months = months; proto$2.years = years; proto$2.humanize = humanize; proto$2.toISOString = toISOString$1; proto$2.toString = toISOString$1; proto$2.toJSON = toISOString$1; proto$2.locale = locale; proto$2.localeData = localeData; proto$2.toIsoString = deprecate( 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1 ); proto$2.lang = lang; // FORMATTING addFormatToken('X', 0, 0, 'unix'); addFormatToken('x', 0, 0, 'valueOf'); // PARSING addRegexToken('x', matchSigned); addRegexToken('X', matchTimestamp); addParseToken('X', function (input, array, config) { config._d = new Date(parseFloat(input) * 1000); }); addParseToken('x', function (input, array, config) { config._d = new Date(toInt(input)); }); //! moment.js hooks.version = '2.29.1'; setHookCallback(createLocal); hooks.fn = proto; hooks.min = min; hooks.max = max; hooks.now = now; hooks.utc = createUTC; hooks.unix = createUnix; hooks.months = listMonths; hooks.isDate = isDate; hooks.locale = getSetGlobalLocale; hooks.invalid = createInvalid; hooks.duration = createDuration; hooks.isMoment = isMoment; hooks.weekdays = listWeekdays; hooks.parseZone = createInZone; hooks.localeData = getLocale; hooks.isDuration = isDuration; hooks.monthsShort = listMonthsShort; hooks.weekdaysMin = listWeekdaysMin; hooks.defineLocale = defineLocale; hooks.updateLocale = updateLocale; hooks.locales = listLocales; hooks.weekdaysShort = listWeekdaysShort; hooks.normalizeUnits = normalizeUnits; hooks.relativeTimeRounding = getSetRelativeTimeRounding; hooks.relativeTimeThreshold = getSetRelativeTimeThreshold; hooks.calendarFormat = getCalendarFormat; hooks.prototype = proto; // currently HTML5 input type only supports 24-hour formats hooks.HTML5_FMT = { DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // DATE: 'YYYY-MM-DD', // TIME: 'HH:mm', // TIME_SECONDS: 'HH:mm:ss', // TIME_MS: 'HH:mm:ss.SSS', // WEEK: 'GGGG-[W]WW', // MONTH: 'YYYY-MM', // }; return hooks; }))); }); var format = createCommonjsModule(function (module) { (function() { //// Export the API var namespace; // CommonJS / Node module { namespace = module.exports = format; } namespace.format = format; namespace.vsprintf = vsprintf; if (typeof console !== 'undefined' && typeof console.log === 'function') { namespace.printf = printf; } function printf(/* ... */) { console.log(format.apply(null, arguments)); } function vsprintf(fmt, replacements) { return format.apply(null, [fmt].concat(replacements)); } function format(fmt) { var argIndex = 1 // skip initial format argument , args = [].slice.call(arguments) , i = 0 , n = fmt.length , result = '' , c , escaped = false , arg , tmp , leadingZero = false , precision , nextArg = function() { return args[argIndex++]; } , slurpNumber = function() { var digits = ''; while (/\d/.test(fmt[i])) { digits += fmt[i++]; c = fmt[i]; } return digits.length > 0 ? parseInt(digits) : null; } ; for (; i < n; ++i) { c = fmt[i]; if (escaped) { escaped = false; if (c == '.') { leadingZero = false; c = fmt[++i]; } else if (c == '0' && fmt[i + 1] == '.') { leadingZero = true; i += 2; c = fmt[i]; } else { leadingZero = true; } precision = slurpNumber(); switch (c) { case 'b': // number in binary result += parseInt(nextArg(), 10).toString(2); break; case 'c': // character arg = nextArg(); if (typeof arg === 'string' || arg instanceof String) result += arg; else result += String.fromCharCode(parseInt(arg, 10)); break; case 'd': // number in decimal result += parseInt(nextArg(), 10); break; case 'f': // floating point number tmp = String(parseFloat(nextArg()).toFixed(precision || 6)); result += leadingZero ? tmp : tmp.replace(/^0/, ''); break; case 'j': // JSON result += JSON.stringify(nextArg()); break; case 'o': // number in octal result += '0' + parseInt(nextArg(), 10).toString(8); break; case 's': // string result += nextArg(); break; case 'x': // lowercase hexadecimal result += '0x' + parseInt(nextArg(), 10).toString(16); break; case 'X': // uppercase hexadecimal result += '0x' + parseInt(nextArg(), 10).toString(16).toUpperCase(); break; default: result += c; break; } } else if (c === '%') { escaped = true; } else { result += c; } } return result; } }()); }); var fault = create$3(Error); var fault_1 = fault; fault.eval = create$3(EvalError); fault.range = create$3(RangeError); fault.reference = create$3(ReferenceError); fault.syntax = create$3(SyntaxError); fault.type = create$3(TypeError); fault.uri = create$3(URIError); fault.create = create$3; // Create a new `EConstructor`, with the formatted `format` as a first argument. function create$3(EConstructor) { FormattedError.displayName = EConstructor.displayName || EConstructor.name; return FormattedError function FormattedError(format$1) { if (format$1) { format$1 = format.apply(null, arguments); } return new EConstructor(format$1) } } var matters_1 = matters; var own$7 = {}.hasOwnProperty; var markers = {yaml: '-', toml: '+'}; function matters(options) { var settings = options || 'yaml'; var results = []; var index = -1; var length; // One preset or matter. if (typeof settings === 'string' || !('length' in settings)) { settings = [settings]; } length = settings.length; while (++index < length) { results[index] = matter(settings[index]); } return results } function matter(option) { var result = option; if (typeof result === 'string') { if (!own$7.call(markers, result)) { throw fault_1('Missing matter definition for `%s`', result) } result = {type: result, marker: markers[result]}; } else if (typeof result !== 'object') { throw fault_1('Expected matter to be an object, not `%j`', result) } if (!own$7.call(result, 'type')) { throw fault_1('Missing `type` in matter `%j`', result) } if (!own$7.call(result, 'fence') && !own$7.call(result, 'marker')) { throw fault_1('Missing `marker` or `fence` in matter `%j`', result) } return result } var syntax$5 = create$2; function create$2(options) { var settings = matters_1(options); var length = settings.length; var index = -1; var flow = {}; var matter; var code; while (++index < length) { matter = settings[index]; code = fence$1(matter, 'open').charCodeAt(0); if (code in flow) { flow[code].push(parse$2(matter)); } else { flow[code] = [parse$2(matter)]; } } return {flow: flow} } function parse$2(matter) { var name = matter.type; var anywhere = matter.anywhere; var valueType = name + 'Value'; var fenceType = name + 'Fence'; var sequenceType = fenceType + 'Sequence'; var fenceConstruct = {tokenize: tokenizeFence, partial: true}; var buffer; return {tokenize: tokenizeFrontmatter, concrete: true} function tokenizeFrontmatter(effects, ok, nok) { var self = this; return start function start(code) { var position = self.now(); if (position.column !== 1 || (!anywhere && position.line !== 1)) { return nok(code) } effects.enter(name); buffer = fence$1(matter, 'open'); return effects.attempt(fenceConstruct, afterOpeningFence, nok)(code) } function afterOpeningFence(code) { buffer = fence$1(matter, 'close'); return lineEnd(code) } function lineStart(code) { if (code === -5 || code === -4 || code === -3 || code === null) { return lineEnd(code) } effects.enter(valueType); return lineData(code) } function lineData(code) { if (code === -5 || code === -4 || code === -3 || code === null) { effects.exit(valueType); return lineEnd(code) } effects.consume(code); return lineData } function lineEnd(code) { // Require a closing fence. if (code === null) { return nok(code) } // Can only be an eol. effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return effects.attempt(fenceConstruct, after, lineStart) } function after(code) { effects.exit(name); return ok(code) } } function tokenizeFence(effects, ok, nok) { var bufferIndex = 0; return start function start(code) { if (code === buffer.charCodeAt(bufferIndex)) { effects.enter(fenceType); effects.enter(sequenceType); return insideSequence(code) } return nok(code) } function insideSequence(code) { if (bufferIndex === buffer.length) { effects.exit(sequenceType); if (code === -2 || code === -1 || code === 32) { effects.enter('whitespace'); return insideWhitespace(code) } return fenceEnd(code) } if (code === buffer.charCodeAt(bufferIndex)) { effects.consume(code); bufferIndex++; return insideSequence } return nok(code) } function insideWhitespace(code) { if (code === -2 || code === -1 || code === 32) { effects.consume(code); return insideWhitespace } effects.exit('whitespace'); return fenceEnd(code) } function fenceEnd(code) { if (code === -5 || code === -4 || code === -3 || code === null) { effects.exit(fenceType); return ok(code) } return nok(code) } } } function fence$1(matter, prop) { var marker; if (matter.marker) { marker = pick$1(matter.marker, prop); return marker + marker + marker } return pick$1(matter.fence, prop) } function pick$1(schema, prop) { return typeof schema === 'string' ? schema : schema[prop] } var micromarkExtensionFrontmatter = syntax$5; var fromMarkdown$8 = createFromMarkdown; function createFromMarkdown(options) { var settings = matters_1(options); var length = settings.length; var index = -1; var enter = {}; var exit = {}; var matter; while (++index < length) { matter = settings[index]; enter[matter.type] = opener(matter); exit[matter.type] = close; exit[matter.type + 'Value'] = value; } return {enter: enter, exit: exit} } function opener(matter) { return open function open(token) { this.enter({type: matter.type, value: ''}, token); this.buffer(); } } function close(token) { var data = this.resume(); // Remove the initial and final eol. this.exit(token).value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ''); } function value(token) { this.config.enter.data.call(this, token); this.config.exit.data.call(this, token); } var toMarkdown$9 = createToMarkdown; function createToMarkdown(options) { var unsafe = []; var handlers = {}; var settings = matters_1(options); var length = settings.length; var index = -1; var matter; while (++index < length) { matter = settings[index]; handlers[matter.type] = handler(matter); unsafe.push({atBreak: true, character: fence(matter, 'open').charAt(0)}); } return {unsafe: unsafe, handlers: handlers} } function handler(matter) { var open = fence(matter, 'open'); var close = fence(matter, 'close'); return handle function handle(node) { return open + (node.value ? '\n' + node.value : '') + '\n' + close } } function fence(matter, prop) { var marker; if (matter.marker) { marker = pick(matter.marker, prop); return marker + marker + marker } return pick(matter.fence, prop) } function pick(schema, prop) { return typeof schema === 'string' ? schema : schema[prop] } var remarkFrontmatter = frontmatter; function frontmatter(options) { var data = this.data(); add('micromarkExtensions', micromarkExtensionFrontmatter(options)); add('fromMarkdownExtensions', fromMarkdown$8(options)); add('toMarkdownExtensions', toMarkdown$9(options)); function add(field, value) { /* istanbul ignore if - other extensions. */ if (data[field]) data[field].push(value); else data[field] = [value]; } } var template = new Templates(); /** * Returns the transformer which acts on the MDAST tree and given VFile. * * @link https://github.com/unifiedjs/unified#function-transformernode-file-next * @link https://github.com/syntax-tree/mdast * @link https://github.com/vfile/vfile * @return {function} */ function metadataWriter(options, input) { //@ts-ignore var transformer = function (ast, vFile, next) { var metadataNode = getMetadataNode(ast); var hasMetadata = !(metadataNode == null); // If we don't have a Matter node in the AST, put it in. if (!hasMetadata && options.createHeaderIfNotPresent) { metadataNode = { type: "yaml", value: jsYaml.dump(newHeaderTemplateYAML(options.newHeaderTemplate, input)).replace(/\n$/, ""), }; ast.children.unshift(metadataNode); hasMetadata = true; } else { // Only updates if frontmatter already created if (options.updateHeader && hasMetadata) { // Write metadata (by reference) metadataNode.value = mergeValues(metadataNode.value, newHeaderTemplateYAML(options.updateHeaderTemplate, input)).replace(/\n$/, ""); } } if (typeof next === "function") { return next(null, ast, vFile); } return ast; }; return transformer; } function newHeaderTemplateYAML(newHeaderTemplate, frontMatterData) { // Update uuids newHeaderTemplate = template.replaceUUID(newHeaderTemplate); // Update dates and times if (frontMatterData.today) { newHeaderTemplate = String(template.replaceDates(newHeaderTemplate, frontMatterData.today)); } // Add things like new tags var resultYaml = jsYaml.load(newHeaderTemplate); if (frontMatterData.tags && frontMatterData.tags.length > 0) { resultYaml.tags = frontMatterData.tags; } // Return a map return resultYaml; } //@ts-ignore function getMetadataNode(ast, types) { if (types === void 0) { types = ["yaml", "toml"]; } //@ts-ignore return ast.children.find(function (node) { return types.includes(node.type); }); } function mergeValues(currentValues, newValues) { // put quotes around the // - #value // // and tags: #value // and tag: #value currentValues = currentValues.replace(/(^|-\s|tags:\s|tag:\s)(#[a-z//\d-_]+)/gi, "$1'$2'"); var fm = jsYaml.load(currentValues); // Calculate the union of tags var currentTags = []; if (fm.tags) { currentTags = fm.tags; } var newTags = []; if (newValues.tags) { newTags = newValues.tags; } if (typeof currentTags === "string" || currentTags instanceof String) { currentTags = [currentTags]; } if (typeof newTags === "string" || newTags instanceof String) { newTags = [newTags]; } var tagUnion = Array.from(new Set(__spreadArray(__spreadArray([], currentTags, true), newTags, true)).values()); // Assign all new values if (fm) { Object.assign(fm, newValues); } else { fm = newValues; } fm.tags = tagUnion; if (fm.tags.length === 0) { delete fm.tags; } // stringify return jsYaml.dump(fm); // eslint-disable-line no-param-reassign } const codes = { horizontalTab: -2, virtualSpace: -1, nul: 0, eof: null, space: 32, }; function markdownLineEndingOrSpace$1(code) { return code < codes.nul || code === codes.space; } function markdownLineEnding$1(code) { return code < codes.horizontalTab; } function wikiLink(opts = {}) { const aliasDivider = opts.aliasDivider || ":"; const aliasMarker = aliasDivider; const startMarker = "[["; const endMarker = "]]"; function tokenize(effects, ok, nok) { var data; var alias; var aliasCursor = 0; var startMarkerCursor = 0; var endMarkerCursor = 0; return start; function start(code) { if (code !== startMarker.charCodeAt(startMarkerCursor)) return nok(code); effects.enter("wikiLink"); effects.enter("wikiLinkMarker"); return consumeStart(code); } function consumeStart(code) { if (startMarkerCursor === startMarker.length) { effects.exit("wikiLinkMarker"); return consumeData(code); } if (code !== startMarker.charCodeAt(startMarkerCursor)) { return nok(code); } effects.consume(code); startMarkerCursor++; return consumeStart; } function consumeData(code) { if (markdownLineEnding$1(code) || code === codes.eof) { return nok(code); } effects.enter("wikiLinkData"); effects.enter("wikiLinkTarget"); return consumeTarget(code); } function consumeTarget(code) { if (code === aliasMarker.charCodeAt(aliasCursor)) { if (!data) return nok(code); effects.exit("wikiLinkTarget"); effects.enter("wikiLinkAliasMarker"); return consumeAliasMarker(code); } if (code === endMarker.charCodeAt(endMarkerCursor)) { if (!data) return nok(code); effects.exit("wikiLinkTarget"); effects.exit("wikiLinkData"); effects.enter("wikiLinkMarker"); return consumeEnd(code); } if (markdownLineEnding$1(code) || code === codes.eof) { return nok(code); } if (!markdownLineEndingOrSpace$1(code)) { data = true; } effects.consume(code); return consumeTarget; } function consumeAliasMarker(code) { if (aliasCursor === aliasMarker.length) { effects.exit("wikiLinkAliasMarker"); effects.enter("wikiLinkAlias"); return consumeAlias(code); } if (code !== aliasMarker.charCodeAt(aliasCursor)) { return nok(code); } effects.consume(code); aliasCursor++; return consumeAliasMarker; } function consumeAlias(code) { if (code === endMarker.charCodeAt(endMarkerCursor)) { if (!alias) return nok(code); effects.exit("wikiLinkAlias"); effects.exit("wikiLinkData"); effects.enter("wikiLinkMarker"); return consumeEnd(code); } if (markdownLineEnding$1(code) || code === codes.eof) { return nok(code); } if (!markdownLineEndingOrSpace$1(code)) { alias = true; } effects.consume(code); return consumeAlias; } function consumeEnd(code) { if (endMarkerCursor === endMarker.length) { effects.exit("wikiLinkMarker"); effects.exit("wikiLink"); return ok(code); } if (code !== endMarker.charCodeAt(endMarkerCursor)) { return nok(code); } effects.consume(code); endMarkerCursor++; return consumeEnd; } } var call = { tokenize: tokenize }; return { text: { 91: call }, // left square bracket }; } function fromMarkdown$7 (opts = {}) { const permalinks = opts.permalinks || []; const defaultPageResolver = (name) => [name.replace(/ /g, '_').toLowerCase()]; const pageResolver = opts.pageResolver || defaultPageResolver; const newClassName = opts.newClassName || 'new'; const wikiLinkClassName = opts.wikiLinkClassName || 'internal'; const defaultHrefTemplate = (permalink) => `#/page/${permalink}`; const hrefTemplate = opts.hrefTemplate || defaultHrefTemplate; function enterWikiLink (token) { this.enter( { type: 'wikiLink', value: null, data: { alias: null, permalink: null, exists: null } }, token ); } function top (stack) { return stack[stack.length - 1] } function exitWikiLinkAlias (token) { const alias = this.sliceSerialize(token); const current = top(this.stack); current.data.alias = alias; } function exitWikiLinkTarget (token) { const target = this.sliceSerialize(token); const current = top(this.stack); current.value = target; } function exitWikiLink (token) { const wikiLink = this.exit(token); const pagePermalinks = pageResolver(wikiLink.value); let permalink = pagePermalinks.find(p => permalinks.indexOf(p) !== -1); const exists = permalink !== undefined; if (!exists) { permalink = pagePermalinks[0]; } let displayName = wikiLink.value; if (wikiLink.data.alias) { displayName = wikiLink.data.alias; } let classNames = wikiLinkClassName; if (!exists) { classNames += ' ' + newClassName; } wikiLink.data.alias = displayName; wikiLink.data.permalink = permalink; wikiLink.data.exists = exists; wikiLink.data.hName = 'a'; wikiLink.data.hProperties = { className: classNames, href: hrefTemplate(permalink) }; wikiLink.data.hChildren = [{ type: 'text', value: displayName }]; } return { enter: { wikiLink: enterWikiLink }, exit: { wikiLinkTarget: exitWikiLinkTarget, wikiLinkAlias: exitWikiLinkAlias, wikiLink: exitWikiLink } } } var patternCompile_1$1 = patternCompile$1; function patternCompile$1(pattern) { var before; var after; if (!pattern._compiled) { before = pattern.before ? '(?:' + pattern.before + ')' : ''; after = pattern.after ? '(?:' + pattern.after + ')' : ''; if (pattern.atBreak) { before = '[\\r\\n][\\t ]*' + before; } pattern._compiled = new RegExp( (before ? '(' + before + ')' : '') + (/[|\\{}()[\]^$+*?.-]/.test(pattern.character) ? '\\' : '') + pattern.character + (after || ''), 'g' ); } return pattern._compiled } var patternInScope_1$1 = patternInScope$1; function patternInScope$1(stack, pattern) { return ( listInScope$1(stack, pattern.inConstruct, true) && !listInScope$1(stack, pattern.notInConstruct) ) } function listInScope$1(stack, list, none) { var index; if (!list) { return none } if (typeof list === 'string') { list = [list]; } index = -1; while (++index < list.length) { if (stack.indexOf(list[index]) !== -1) { return true } } return false } var safe_1$1 = safe$1; function safe$1(context, input, config) { var value = (config.before || '') + (input || '') + (config.after || ''); var positions = []; var result = []; var infos = {}; var index = -1; var before; var after; var position; var pattern; var expression; var match; var start; var end; while (++index < context.unsafe.length) { pattern = context.unsafe[index]; if (!patternInScope_1$1(context.stack, pattern)) { continue } expression = patternCompile_1$1(pattern); while ((match = expression.exec(value))) { before = 'before' in pattern || pattern.atBreak; after = 'after' in pattern; position = match.index + (before ? match[1].length : 0); if (positions.indexOf(position) === -1) { positions.push(position); infos[position] = {before: before, after: after}; } else { if (infos[position].before && !before) { infos[position].before = false; } if (infos[position].after && !after) { infos[position].after = false; } } } } positions.sort(numerical$1); start = config.before ? config.before.length : 0; end = value.length - (config.after ? config.after.length : 0); index = -1; while (++index < positions.length) { position = positions[index]; if ( // Character before or after matched: position < start || position >= end ) { continue } // If this character is supposed to be escaped because it has a condition on // the next character, and the next character is definitly being escaped, // then skip this escape. if ( position + 1 < end && positions[index + 1] === position + 1 && infos[position].after && !infos[position + 1].before && !infos[position + 1].after ) { continue } if (start !== position) { // If we have to use a character reference, an ampersand would be more // correct, but as backslashes only care about punctuation, either will // do the trick result.push(escapeBackslashes$1(value.slice(start, position), '\\')); } start = position; if ( /[!-/:-@[-`{-~]/.test(value.charAt(position)) && (!config.encode || config.encode.indexOf(value.charAt(position)) === -1) ) { // Character escape. result.push('\\'); } else { // Character reference. result.push( '&#x' + value.charCodeAt(position).toString(16).toUpperCase() + ';' ); start++; } } result.push(escapeBackslashes$1(value.slice(start, end), config.after)); return result.join('') } function numerical$1(a, b) { return a - b } function escapeBackslashes$1(value, after) { var expression = /\\(?=[!-/:-@[-`{-~])/g; var positions = []; var results = []; var index = -1; var start = 0; var whole = value + after; var match; while ((match = expression.exec(whole))) { positions.push(match.index); } while (++index < positions.length) { if (start !== positions[index]) { results.push(value.slice(start, positions[index])); } results.push('\\'); start = positions[index]; } results.push(value.slice(start)); return results.join('') } function toMarkdown$8 (opts = {}) { const aliasDivider = opts.aliasDivider || ':'; const unsafe = [ { character: '[', inConstruct: ['phrasing', 'label', 'reference'] }, { character: ']', inConstruct: ['label', 'reference'] } ]; function handler (node, _, context) { const exit = context.enter('wikiLink'); const nodeValue = safe_1$1(context, node.value, { before: '[', after: ']' }); const nodeAlias = safe_1$1(context, node.data.alias, { before: '[', after: ']' }); let value; if (nodeAlias !== nodeValue) { value = `[[${nodeValue}${aliasDivider}${nodeAlias}]]`; } else { value = `[[${nodeValue}]]`; } exit(); return value } return { unsafe: unsafe, handlers: { wikiLink: handler } } } let warningIssued$2; function wikiLinkPlugin(opts = {}) { const data = this.data(); function add(field, value) { if (data[field]) data[field].push(value); else data[field] = [value]; } if ( !warningIssued$2 && ((this.Parser && this.Parser.prototype && this.Parser.prototype.blockTokenizers) || (this.Compiler && this.Compiler.prototype && this.Compiler.prototype.visitors)) ) { warningIssued$2 = true; console.warn( "[remark-wiki-link] Warning: please upgrade to remark 13 to use this plugin" ); } add("micromarkExtensions", wikiLink(opts)); add("fromMarkdownExtensions", fromMarkdown$7(opts)); add("toMarkdownExtensions", toMarkdown$8(opts)); } var own$6 = {}.hasOwnProperty; var hasOwnProperty_1 = own$6; var splice$1 = [].splice; var splice_1 = splice$1; // causes a stack overflow in V8 when trying to insert 100k items for instance. function chunkedSplice(list, start, remove, items) { var end = list.length; var chunkStart = 0; var parameters; // Make start between zero and `end` (included). if (start < 0) { start = -start > end ? 0 : end + start; } else { start = start > end ? end : start; } remove = remove > 0 ? remove : 0; // No need to chunk the items if there’s only a couple (10k) items. if (items.length < 10000) { parameters = Array.from(items); parameters.unshift(start, remove); splice_1.apply(list, parameters); } else { // Delete `remove` items starting from `start` if (remove) splice_1.apply(list, [start, remove]); // Insert the items in chunks to not cause stack overflows. while (chunkStart < items.length) { parameters = items.slice(chunkStart, chunkStart + 10000); parameters.unshift(start, 0); splice_1.apply(list, parameters); chunkStart += 10000; start += 10000; } } } var chunkedSplice_1 = chunkedSplice; function miniflat(value) { return value === null || value === undefined ? [] : 'length' in value ? value : [value] } var miniflat_1 = miniflat; function combineExtensions(extensions) { var all = {}; var index = -1; while (++index < extensions.length) { extension$2(all, extensions[index]); } return all } function extension$2(all, extension) { var hook; var left; var right; var code; for (hook in extension) { left = hasOwnProperty_1.call(all, hook) ? all[hook] : (all[hook] = {}); right = extension[hook]; for (code in right) { left[code] = constructs$1( miniflat_1(right[code]), hasOwnProperty_1.call(left, code) ? left[code] : [] ); } } } function constructs$1(list, existing) { var index = -1; var before = []; while (++index < list.length) { (list[index].add === 'after' ? existing : before).push(list[index]); } chunkedSplice_1(existing, 0, 0, before); return existing } var combineExtensions_1 = combineExtensions; var fromCharCode = String.fromCharCode; var fromCharCode_1 = fromCharCode; function regexCheck(regex) { return check function check(code) { return regex.test(fromCharCode_1(code)) } } var regexCheck_1 = regexCheck; var asciiAlpha = regexCheck_1(/[A-Za-z]/); var asciiAlpha_1 = asciiAlpha; var asciiAlphanumeric = regexCheck_1(/[\dA-Za-z]/); var asciiAlphanumeric_1 = asciiAlphanumeric; // Note: EOF is seen as ASCII control here, because `null < 32 == true`. function asciiControl(code) { return ( // Special whitespace codes (which have negative values), C0 and Control // character DEL code < 32 || code === 127 ) } var asciiControl_1 = asciiControl; function markdownLineEnding(code) { return code < -2 } var markdownLineEnding_1 = markdownLineEnding; // This module is generated by `script/`. // // CommonMark handles attention (emphasis, strong) markers based on what comes // before or after them. // One such difference is if those characters are Unicode punctuation. // This script is generated from the Unicode data. var unicodePunctuation$1 = /[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/; var unicodePunctuationRegex = unicodePunctuation$1; // In fact adds to the bundle size. var unicodePunctuation = regexCheck_1(unicodePunctuationRegex); var unicodePunctuation_1 = unicodePunctuation; var unicodeWhitespace = regexCheck_1(/\s/); var unicodeWhitespace_1 = unicodeWhitespace; var www = {tokenize: tokenizeWww, partial: true}; var domain = {tokenize: tokenizeDomain, partial: true}; var path = {tokenize: tokenizePath, partial: true}; var punctuation = {tokenize: tokenizePunctuation, partial: true}; var namedCharacterReference = { tokenize: tokenizeNamedCharacterReference, partial: true }; var wwwAutolink = {tokenize: tokenizeWwwAutolink, previous: previousWww}; var httpAutolink = {tokenize: tokenizeHttpAutolink, previous: previousHttp}; var emailAutolink = {tokenize: tokenizeEmailAutolink, previous: previousEmail}; var text$6 = {}; // Export hooked constructs. var text_1$3 = text$6; // `0` var code$4 = 48; // While the code is smaller than `{`. while (code$4 < 123) { text$6[code$4] = emailAutolink; code$4++; // Jump from `:` -> `A` if (code$4 === 58) code$4 = 65; // Jump from `[` -> `a` else if (code$4 === 91) code$4 = 97; } // `+` text$6[43] = emailAutolink; // `-` text$6[45] = emailAutolink; // `.` text$6[46] = emailAutolink; // `_` text$6[95] = emailAutolink; // `h`. text$6[72] = [emailAutolink, httpAutolink]; text$6[104] = [emailAutolink, httpAutolink]; // `w`. text$6[87] = [emailAutolink, wwwAutolink]; text$6[119] = [emailAutolink, wwwAutolink]; function tokenizeEmailAutolink(effects, ok, nok) { var self = this; var hasDot; return start function start(code) { /* istanbul ignore next - hooks. */ if ( !gfmAtext(code) || !previousEmail(self.previous) || previous$3(self.events) ) { return nok(code) } effects.enter('literalAutolink'); effects.enter('literalAutolinkEmail'); return atext(code) } function atext(code) { if (gfmAtext(code)) { effects.consume(code); return atext } // `@` if (code === 64) { effects.consume(code); return label } return nok(code) } function label(code) { // `.` if (code === 46) { return effects.check(punctuation, done, dotContinuation)(code) } if ( // `-` code === 45 || // `_` code === 95 ) { return effects.check(punctuation, nok, dashOrUnderscoreContinuation)(code) } if (asciiAlphanumeric_1(code)) { effects.consume(code); return label } return done(code) } function dotContinuation(code) { effects.consume(code); hasDot = true; return label } function dashOrUnderscoreContinuation(code) { effects.consume(code); return afterDashOrUnderscore } function afterDashOrUnderscore(code) { // `.` if (code === 46) { return effects.check(punctuation, nok, dotContinuation)(code) } return label(code) } function done(code) { if (hasDot) { effects.exit('literalAutolinkEmail'); effects.exit('literalAutolink'); return ok(code) } return nok(code) } } function tokenizeWwwAutolink(effects, ok, nok) { var self = this; return start function start(code) { /* istanbul ignore next - hooks. */ if ( (code !== 87 && code - 32 !== 87) || !previousWww(self.previous) || previous$3(self.events) ) { return nok(code) } effects.enter('literalAutolink'); effects.enter('literalAutolinkWww'); // For `www.` we check instead of attempt, because when it matches, GH // treats it as part of a domain (yes, it says a valid domain must come // after `www.`, but that’s not how it’s implemented by them). return effects.check( www, effects.attempt(domain, effects.attempt(path, done), nok), nok )(code) } function done(code) { effects.exit('literalAutolinkWww'); effects.exit('literalAutolink'); return ok(code) } } function tokenizeHttpAutolink(effects, ok, nok) { var self = this; return start function start(code) { /* istanbul ignore next - hooks. */ if ( (code !== 72 && code - 32 !== 72) || !previousHttp(self.previous) || previous$3(self.events) ) { return nok(code) } effects.enter('literalAutolink'); effects.enter('literalAutolinkHttp'); effects.consume(code); return t1 } function t1(code) { // `t` if (code === 84 || code - 32 === 84) { effects.consume(code); return t2 } return nok(code) } function t2(code) { // `t` if (code === 84 || code - 32 === 84) { effects.consume(code); return p } return nok(code) } function p(code) { // `p` if (code === 80 || code - 32 === 80) { effects.consume(code); return s } return nok(code) } function s(code) { // `s` if (code === 83 || code - 32 === 83) { effects.consume(code); return colon } return colon(code) } function colon(code) { // `:` if (code === 58) { effects.consume(code); return slash1 } return nok(code) } function slash1(code) { // `/` if (code === 47) { effects.consume(code); return slash2 } return nok(code) } function slash2(code) { // `/` if (code === 47) { effects.consume(code); return after } return nok(code) } function after(code) { return asciiControl_1(code) || unicodeWhitespace_1(code) || unicodePunctuation_1(code) ? nok(code) : effects.attempt(domain, effects.attempt(path, done), nok)(code) } function done(code) { effects.exit('literalAutolinkHttp'); effects.exit('literalAutolink'); return ok(code) } } function tokenizeWww(effects, ok, nok) { return start function start(code) { // Assume a `w`. effects.consume(code); return w2 } function w2(code) { // `w` if (code === 87 || code - 32 === 87) { effects.consume(code); return w3 } return nok(code) } function w3(code) { // `w` if (code === 87 || code - 32 === 87) { effects.consume(code); return dot } return nok(code) } function dot(code) { // `.` if (code === 46) { effects.consume(code); return after } return nok(code) } function after(code) { return code === null || markdownLineEnding_1(code) ? nok(code) : ok(code) } } function tokenizeDomain(effects, ok, nok) { var hasUnderscoreInLastSegment; var hasUnderscoreInLastLastSegment; return domain function domain(code) { // `&` if (code === 38) { return effects.check( namedCharacterReference, done, punctuationContinuation )(code) } if (code === 46 /* `.` */ || code === 95 /* `_` */) { return effects.check(punctuation, done, punctuationContinuation)(code) } // GH documents that only alphanumerics (other than `-`, `.`, and `_`) can // occur, which sounds like ASCII only, but they also support `www.點看.com`, // so that’s Unicode. // Instead of some new production for Unicode alphanumerics, markdown // already has that for Unicode punctuation and whitespace, so use those. if ( asciiControl_1(code) || unicodeWhitespace_1(code) || (code !== 45 /* `-` */ && unicodePunctuation_1(code)) ) { return done(code) } effects.consume(code); return domain } function punctuationContinuation(code) { // `.` if (code === 46) { hasUnderscoreInLastLastSegment = hasUnderscoreInLastSegment; hasUnderscoreInLastSegment = undefined; effects.consume(code); return domain } // `_` if (code === 95) hasUnderscoreInLastSegment = true; effects.consume(code); return domain } function done(code) { if (!hasUnderscoreInLastLastSegment && !hasUnderscoreInLastSegment) { return ok(code) } return nok(code) } } function tokenizePath(effects, ok) { var balance = 0; return inPath function inPath(code) { // `&` if (code === 38) { return effects.check( namedCharacterReference, ok, continuedPunctuation )(code) } // `(` if (code === 40) { balance++; } // `)` if (code === 41) { return effects.check( punctuation, parenAtPathEnd, continuedPunctuation )(code) } if (pathEnd(code)) { return ok(code) } if (trailingPunctuation(code)) { return effects.check(punctuation, ok, continuedPunctuation)(code) } effects.consume(code); return inPath } function continuedPunctuation(code) { effects.consume(code); return inPath } function parenAtPathEnd(code) { balance--; return balance < 0 ? ok(code) : continuedPunctuation(code) } } function tokenizeNamedCharacterReference(effects, ok, nok) { return start function start(code) { // Assume an ampersand. effects.consume(code); return inside } function inside(code) { if (asciiAlpha_1(code)) { effects.consume(code); return inside } // `;` if (code === 59) { effects.consume(code); return after } return nok(code) } function after(code) { // If the named character reference is followed by the end of the path, it’s // not continued punctuation. return pathEnd(code) ? ok(code) : nok(code) } } function tokenizePunctuation(effects, ok, nok) { return start function start(code) { // Always a valid trailing punctuation marker. effects.consume(code); return after } function after(code) { // Check the next. if (trailingPunctuation(code)) { effects.consume(code); return after } // If the punctuation marker is followed by the end of the path, it’s not // continued punctuation. return pathEnd(code) ? ok(code) : nok(code) } } function trailingPunctuation(code) { return ( // `!` code === 33 || // `"` code === 34 || // `'` code === 39 || // `)` code === 41 || // `*` code === 42 || // `,` code === 44 || // `.` code === 46 || // `:` code === 58 || // `;` code === 59 || // `<` code === 60 || // `?` code === 63 || // `_`. code === 95 || // `~` code === 126 ) } function pathEnd(code) { return ( // EOF. code === null || // CR, LF, CRLF, HT, VS. code < 0 || // Space. code === 32 || // `<` code === 60 ) } function gfmAtext(code) { return ( code === 43 /* `+` */ || code === 45 /* `-` */ || code === 46 /* `.` */ || code === 95 /* `_` */ || asciiAlphanumeric_1(code) ) } function previousWww(code) { return ( code === null || code < 0 || code === 32 /* ` ` */ || code === 40 /* `(` */ || code === 42 /* `*` */ || code === 95 /* `_` */ || code === 126 /* `~` */ ) } function previousHttp(code) { return code === null || !asciiAlpha_1(code) } function previousEmail(code) { return code !== 47 /* `/` */ && previousHttp(code) } function previous$3(events) { var index = events.length; while (index--) { if ( (events[index][1].type === 'labelLink' || events[index][1].type === 'labelImage') && !events[index][1]._balanced ) { return true } } } var syntax$4 = { text: text_1$3 }; var micromarkExtensionGfmAutolinkLiteral = syntax$4; function markdownLineEndingOrSpace(code) { return code < 0 || code === 32 } var markdownLineEndingOrSpace_1 = markdownLineEndingOrSpace; // Classify whether a character is unicode whitespace, unicode punctuation, or // anything else. // Used for attention (emphasis, strong), whose sequences can open or close // based on the class of surrounding characters. function classifyCharacter(code) { if ( code === null || markdownLineEndingOrSpace_1(code) || unicodeWhitespace_1(code) ) { return 1 } if (unicodePunctuation_1(code)) { return 2 } } var classifyCharacter_1 = classifyCharacter; function resolveAll(constructs, events, context) { var called = []; var index = -1; var resolve; while (++index < constructs.length) { resolve = constructs[index].resolveAll; if (resolve && called.indexOf(resolve) < 0) { events = resolve(events, context); called.push(resolve); } } return events } var resolveAll_1 = resolveAll; var assign = Object.assign; var assign_1 = assign; function shallow(object) { return assign_1({}, object) } var shallow_1 = shallow; var micromarkExtensionGfmStrikethrough = create$1; function create$1(options) { var settings = options || {}; var single = settings.singleTilde; var tokenizer = { tokenize: tokenizeStrikethrough, resolveAll: resolveAllStrikethrough }; if (single === null || single === undefined) { single = true; } return {text: {126: tokenizer}, insideSpan: {null: tokenizer}} // Take events and resolve strikethrough. function resolveAllStrikethrough(events, context) { var index = -1; var strikethrough; var text; var open; var nextEvents; // Walk through all events. while (++index < events.length) { // Find a token that can close. if ( events[index][0] === 'enter' && events[index][1].type === 'strikethroughSequenceTemporary' && events[index][1]._close ) { open = index; // Now walk back to find an opener. while (open--) { // Find a token that can open the closer. if ( events[open][0] === 'exit' && events[open][1].type === 'strikethroughSequenceTemporary' && events[open][1]._open && // If the sizes are the same: events[index][1].end.offset - events[index][1].start.offset === events[open][1].end.offset - events[open][1].start.offset ) { events[index][1].type = 'strikethroughSequence'; events[open][1].type = 'strikethroughSequence'; strikethrough = { type: 'strikethrough', start: shallow_1(events[open][1].start), end: shallow_1(events[index][1].end) }; text = { type: 'strikethroughText', start: shallow_1(events[open][1].end), end: shallow_1(events[index][1].start) }; // Opening. nextEvents = [ ['enter', strikethrough, context], ['enter', events[open][1], context], ['exit', events[open][1], context], ['enter', text, context] ]; // Between. chunkedSplice_1( nextEvents, nextEvents.length, 0, resolveAll_1( context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context ) ); // Closing. chunkedSplice_1(nextEvents, nextEvents.length, 0, [ ['exit', text, context], ['enter', events[index][1], context], ['exit', events[index][1], context], ['exit', strikethrough, context] ]); chunkedSplice_1(events, open - 1, index - open + 3, nextEvents); index = open + nextEvents.length - 2; break } } } } return removeRemainingSequences(events) } function removeRemainingSequences(events) { var index = -1; var length = events.length; while (++index < length) { if (events[index][1].type === 'strikethroughSequenceTemporary') { events[index][1].type = 'data'; } } return events } function tokenizeStrikethrough(effects, ok, nok) { var previous = this.previous; var events = this.events; var size = 0; return start function start(code) { if ( code !== 126 || (previous === 126 && events[events.length - 1][1].type !== 'characterEscape') ) { return nok(code) } effects.enter('strikethroughSequenceTemporary'); return more(code) } function more(code) { var before = classifyCharacter_1(previous); var token; var after; if (code === 126) { // If this is the third marker, exit. if (size > 1) return nok(code) effects.consume(code); size++; return more } if (size < 2 && !single) return nok(code) token = effects.exit('strikethroughSequenceTemporary'); after = classifyCharacter_1(code); token._open = !after || (after === 2 && before); token._close = !before || (before === 2 && after); return ok(code) } } } function markdownSpace(code) { return code === -2 || code === -1 || code === 32 } var markdownSpace_1 = markdownSpace; function spaceFactory(effects, ok, type, max) { var limit = max ? max - 1 : Infinity; var size = 0; return start function start(code) { if (markdownSpace_1(code)) { effects.enter(type); return prefix(code) } return ok(code) } function prefix(code) { if (markdownSpace_1(code) && size++ < limit) { effects.consume(code); return prefix } effects.exit(type); return ok(code) } } var factorySpace = spaceFactory; var flow$4 = { null: {tokenize: tokenizeTable, resolve: resolveTable, interruptible: true} }; var setextUnderlineMini = {tokenize: tokenizeSetextUnderlineMini, partial: true}; var nextPrefixedOrBlank = {tokenize: tokenizeNextPrefixedOrBlank, partial: true}; function resolveTable(events, context) { var length = events.length; var index = -1; var token; var inHead; var inDelimiterRow; var inRow; var cell; var content; var text; var contentStart; var contentEnd; var cellStart; while (++index < length) { token = events[index][1]; if (inRow) { if (token.type === 'temporaryTableCellContent') { contentStart = contentStart || index; contentEnd = index; } if ( // Combine separate content parts into one. (token.type === 'tableCellDivider' || token.type === 'tableRow') && contentEnd ) { content = { type: 'tableContent', start: events[contentStart][1].start, end: events[contentEnd][1].end }; text = { type: 'chunkText', start: content.start, end: content.end, contentType: 'text' }; events.splice( contentStart, contentEnd - contentStart + 1, ['enter', content, context], ['enter', text, context], ['exit', text, context], ['exit', content, context] ); index -= contentEnd - contentStart - 3; length = events.length; contentStart = undefined; contentEnd = undefined; } } if ( events[index][0] === 'exit' && cellStart && cellStart + 1 < index && (token.type === 'tableCellDivider' || (token.type === 'tableRow' && (cellStart + 3 < index || events[cellStart][1].type !== 'whitespace'))) ) { cell = { type: inDelimiterRow ? 'tableDelimiter' : inHead ? 'tableHeader' : 'tableData', start: events[cellStart][1].start, end: events[index][1].end }; events.splice(index + (token.type === 'tableCellDivider' ? 1 : 0), 0, [ 'exit', cell, context ]); events.splice(cellStart, 0, ['enter', cell, context]); index += 2; length = events.length; cellStart = index + 1; } if (token.type === 'tableRow') { inRow = events[index][0] === 'enter'; if (inRow) { cellStart = index + 1; } } if (token.type === 'tableDelimiterRow') { inDelimiterRow = events[index][0] === 'enter'; if (inDelimiterRow) { cellStart = index + 1; } } if (token.type === 'tableHead') { inHead = events[index][0] === 'enter'; } } return events } function tokenizeTable(effects, ok, nok) { var align = []; var tableHeaderCount = 0; var seenDelimiter; var hasDash; return start function start(code) { /* istanbul ignore if - used to be passed in beta micromark versions. */ if (code === null || code === -5 || code === -4 || code === -3) { return nok(code) } effects.enter('table')._align = align; effects.enter('tableHead'); effects.enter('tableRow'); // If we start with a pipe, we open a cell marker. if (code === 124) { return cellDividerHead(code) } tableHeaderCount++; effects.enter('temporaryTableCellContent'); // Can’t be space or eols at the start of a construct, so we’re in a cell. return inCellContentHead(code) } function cellDividerHead(code) { // Always a pipe. effects.enter('tableCellDivider'); effects.consume(code); effects.exit('tableCellDivider'); seenDelimiter = true; return cellBreakHead } function cellBreakHead(code) { // EOF, CR, LF, CRLF. if (code === null || code === -5 || code === -4 || code === -3) { return atRowEndHead(code) } // HT, VS, SP. if (code === -2 || code === -1 || code === 32) { effects.enter('whitespace'); effects.consume(code); return inWhitespaceHead } if (seenDelimiter) { seenDelimiter = undefined; tableHeaderCount++; } // `|` if (code === 124) { return cellDividerHead(code) } // Anything else is cell content. effects.enter('temporaryTableCellContent'); return inCellContentHead(code) } function inWhitespaceHead(code) { // HT, VS, SP. if (code === -2 || code === -1 || code === 32) { effects.consume(code); return inWhitespaceHead } effects.exit('whitespace'); return cellBreakHead(code) } function inCellContentHead(code) { // EOF, whitespace, pipe if (code === null || code < 0 || code === 32 || code === 124) { effects.exit('temporaryTableCellContent'); return cellBreakHead(code) } effects.consume(code); // `\` return code === 92 ? inCellContentEscapeHead : inCellContentHead } function inCellContentEscapeHead(code) { // `\` or `|` if (code === 92 || code === 124) { effects.consume(code); return inCellContentHead } // Anything else. return inCellContentHead(code) } function atRowEndHead(code) { if (code === null) { return nok(code) } effects.exit('tableRow'); effects.exit('tableHead'); // Always a line ending. effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); // If a setext heading, exit. return effects.check( setextUnderlineMini, nok, // Support an indent before the delimiter row. factorySpace(effects, rowStartDelimiter, 'linePrefix', 4) ) } function rowStartDelimiter(code) { // If there’s another space, or we’re at the EOL/EOF, exit. if (code === null || code < 0 || code === 32) { return nok(code) } effects.enter('tableDelimiterRow'); return atDelimiterRowBreak(code) } function atDelimiterRowBreak(code) { // EOF, CR, LF, CRLF. if (code === null || code === -5 || code === -4 || code === -3) { return rowEndDelimiter(code) } // HT, VS, SP. if (code === -2 || code === -1 || code === 32) { effects.enter('whitespace'); effects.consume(code); return inWhitespaceDelimiter } // `-` if (code === 45) { effects.enter('tableDelimiterFiller'); effects.consume(code); hasDash = true; align.push(null); return inFillerDelimiter } // `:` if (code === 58) { effects.enter('tableDelimiterAlignment'); effects.consume(code); effects.exit('tableDelimiterAlignment'); align.push('left'); return afterLeftAlignment } // If we start with a pipe, we open a cell marker. if (code === 124) { effects.enter('tableCellDivider'); effects.consume(code); effects.exit('tableCellDivider'); return atDelimiterRowBreak } return nok(code) } function inWhitespaceDelimiter(code) { // HT, VS, SP. if (code === -2 || code === -1 || code === 32) { effects.consume(code); return inWhitespaceDelimiter } effects.exit('whitespace'); return atDelimiterRowBreak(code) } function inFillerDelimiter(code) { // `-` if (code === 45) { effects.consume(code); return inFillerDelimiter } effects.exit('tableDelimiterFiller'); // `:` if (code === 58) { effects.enter('tableDelimiterAlignment'); effects.consume(code); effects.exit('tableDelimiterAlignment'); align[align.length - 1] = align[align.length - 1] === 'left' ? 'center' : 'right'; return afterRightAlignment } return atDelimiterRowBreak(code) } function afterLeftAlignment(code) { // `-` if (code === 45) { effects.enter('tableDelimiterFiller'); effects.consume(code); hasDash = true; return inFillerDelimiter } // Anything else is not ok. return nok(code) } function afterRightAlignment(code) { // EOF, CR, LF, CRLF. if (code === null || code === -5 || code === -4 || code === -3) { return rowEndDelimiter(code) } // HT, VS, SP. if (code === -2 || code === -1 || code === 32) { effects.enter('whitespace'); effects.consume(code); return inWhitespaceDelimiter } // `|` if (code === 124) { effects.enter('tableCellDivider'); effects.consume(code); effects.exit('tableCellDivider'); return atDelimiterRowBreak } return nok(code) } function rowEndDelimiter(code) { effects.exit('tableDelimiterRow'); // Exit if there was no dash at all, or if the header cell count is not the // delimiter cell count. if (!hasDash || tableHeaderCount !== align.length) { return nok(code) } if (code === null) { return tableClose(code) } return effects.check(nextPrefixedOrBlank, tableClose, tableContinue)(code) } function tableClose(code) { effects.exit('table'); return ok(code) } function tableContinue(code) { // Always a line ending. effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); // We checked that it’s not a prefixed or blank line, so we’re certain a // body is coming, though it may be indented. return factorySpace(effects, bodyStart, 'linePrefix', 4) } function bodyStart(code) { effects.enter('tableBody'); return rowStartBody(code) } function rowStartBody(code) { effects.enter('tableRow'); // If we start with a pipe, we open a cell marker. if (code === 124) { return cellDividerBody(code) } effects.enter('temporaryTableCellContent'); // Can’t be space or eols at the start of a construct, so we’re in a cell. return inCellContentBody(code) } function cellDividerBody(code) { // Always a pipe. effects.enter('tableCellDivider'); effects.consume(code); effects.exit('tableCellDivider'); return cellBreakBody } function cellBreakBody(code) { // EOF, CR, LF, CRLF. if (code === null || code === -5 || code === -4 || code === -3) { return atRowEndBody(code) } // HT, VS, SP. if (code === -2 || code === -1 || code === 32) { effects.enter('whitespace'); effects.consume(code); return inWhitespaceBody } // `|` if (code === 124) { return cellDividerBody(code) } // Anything else is cell content. effects.enter('temporaryTableCellContent'); return inCellContentBody(code) } function inWhitespaceBody(code) { // HT, VS, SP. if (code === -2 || code === -1 || code === 32) { effects.consume(code); return inWhitespaceBody } effects.exit('whitespace'); return cellBreakBody(code) } function inCellContentBody(code) { // EOF, whitespace, pipe if (code === null || code < 0 || code === 32 || code === 124) { effects.exit('temporaryTableCellContent'); return cellBreakBody(code) } effects.consume(code); // `\` return code === 92 ? inCellContentEscapeBody : inCellContentBody } function inCellContentEscapeBody(code) { // `\` or `|` if (code === 92 || code === 124) { effects.consume(code); return inCellContentBody } // Anything else. return inCellContentBody(code) } function atRowEndBody(code) { effects.exit('tableRow'); if (code === null) { return tableBodyClose(code) } return effects.check( nextPrefixedOrBlank, tableBodyClose, tableBodyContinue )(code) } function tableBodyClose(code) { effects.exit('tableBody'); return tableClose(code) } function tableBodyContinue(code) { // Always a line ending. effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); // Support an optional prefix, then start a body row. return factorySpace(effects, rowStartBody, 'linePrefix', 4) } } // Based on micromark, but that won’t work as we’re in a table, and that expects // content. // function tokenizeSetextUnderlineMini(effects, ok, nok) { return start function start(code) { // `-` if (code !== 45) { return nok(code) } effects.enter('setextUnderline'); return sequence(code) } function sequence(code) { if (code === 45) { effects.consume(code); return sequence } return whitespace(code) } function whitespace(code) { if (code === -2 || code === -1 || code === 32) { effects.consume(code); return whitespace } if (code === null || code === -5 || code === -4 || code === -3) { return ok(code) } return nok(code) } } function tokenizeNextPrefixedOrBlank(effects, ok, nok) { var size = 0; return start function start(code) { // This is a check, so we don’t care about tokens, but we open a bogus one // so we’re valid. effects.enter('check'); // EOL. effects.consume(code); return whitespace } function whitespace(code) { // VS or SP. if (code === -1 || code === 32) { effects.consume(code); size++; return size === 4 ? ok : whitespace } // EOF or whitespace if (code === null || code < 0) { return ok(code) } // Anything else. return nok(code) } } var syntax$3 = { flow: flow$4 }; var micromarkExtensionGfmTable = syntax$3; // Counts tabs based on their expanded size, and CR+LF as one character. function sizeChunks(chunks) { var index = -1; var size = 0; while (++index < chunks.length) { size += typeof chunks[index] === 'string' ? chunks[index].length : 1; } return size } var sizeChunks_1 = sizeChunks; function prefixSize(events, type) { var tail = events[events.length - 1]; if (!tail || tail[1].type !== type) return 0 return sizeChunks_1(tail[2].sliceStream(tail[1])) } var prefixSize_1 = prefixSize; var tasklistCheck = {tokenize: tokenizeTasklistCheck}; var text$5 = {91: tasklistCheck}; function tokenizeTasklistCheck(effects, ok, nok) { var self = this; return open function open(code) { if ( // Exit if not `[`. code !== 91 || // Exit if there’s stuff before. self.previous !== null || // Exit if not in the first content that is the first child of a list // item. !self._gfmTasklistFirstContentOfListItem ) { return nok(code) } effects.enter('taskListCheck'); effects.enter('taskListCheckMarker'); effects.consume(code); effects.exit('taskListCheckMarker'); return inside } function inside(code) { // Tab or space. if (code === -2 || code === 32) { effects.enter('taskListCheckValueUnchecked'); effects.consume(code); effects.exit('taskListCheckValueUnchecked'); return close } // Upper- and lower `x`. if (code === 88 || code === 120) { effects.enter('taskListCheckValueChecked'); effects.consume(code); effects.exit('taskListCheckValueChecked'); return close } return nok(code) } function close(code) { // `]` if (code === 93) { effects.enter('taskListCheckMarker'); effects.consume(code); effects.exit('taskListCheckMarker'); effects.exit('taskListCheck'); return effects.check({tokenize: spaceThenNonSpace}, ok, nok) } return nok(code) } } function spaceThenNonSpace(effects, ok, nok) { var self = this; return factorySpace(effects, after, 'whitespace') function after(code) { return prefixSize_1(self.events, 'whitespace') && code !== null && !markdownLineEndingOrSpace_1(code) ? ok(code) : nok(code) } } var syntax$2 = { text: text$5 }; var micromarkExtensionGfmTaskListItem = syntax$2; var syntax$1 = create; function create(options) { return combineExtensions_1([micromarkExtensionGfmAutolinkLiteral, micromarkExtensionGfmStrikethrough(options), micromarkExtensionGfmTable, micromarkExtensionGfmTaskListItem]) } var micromarkExtensionGfm = syntax$1; var ccount_1 = ccount; function ccount(source, character) { var value = String(source); var count = 0; var index; if (typeof character !== 'string') { throw new Error('Expected character') } index = value.indexOf(character); while (index !== -1) { count++; index = value.indexOf(character, index + character.length); } return count } var convert_1 = convert; function convert(test) { if (test == null) { return ok } if (typeof test === 'string') { return typeFactory(test) } if (typeof test === 'object') { return 'length' in test ? anyFactory(test) : allFactory(test) } if (typeof test === 'function') { return test } throw new Error('Expected function, string, or object as test') } // Utility assert each property in `test` is represented in `node`, and each // values are strictly equal. function allFactory(test) { return all function all(node) { var key; for (key in test) { if (node[key] !== test[key]) return false } return true } } function anyFactory(tests) { var checks = []; var index = -1; while (++index < tests.length) { checks[index] = convert(tests[index]); } return any function any() { var index = -1; while (++index < checks.length) { if (checks[index].apply(this, arguments)) { return true } } return false } } // Utility to convert a string into a function which checks a given node’s type // for said string. function typeFactory(test) { return type function type(node) { return Boolean(node && node.type === test) } } // Utility to return true. function ok() { return true } var color_1 = color; function color(d) { return '\u001B[33m' + d + '\u001B[39m' } var unistUtilVisitParents = visitParents; var CONTINUE = true; var SKIP = 'skip'; var EXIT = false; visitParents.CONTINUE = CONTINUE; visitParents.SKIP = SKIP; visitParents.EXIT = EXIT; function visitParents(tree, test, visitor, reverse) { var step; var is; if (typeof test === 'function' && typeof visitor !== 'function') { reverse = visitor; visitor = test; test = null; } is = convert_1(test); step = reverse ? -1 : 1; factory(tree, null, [])(); function factory(node, index, parents) { var value = typeof node === 'object' && node !== null ? node : {}; var name; if (typeof value.type === 'string') { name = typeof value.tagName === 'string' ? value.tagName : typeof value.name === 'string' ? value.name : undefined; visit.displayName = 'node (' + color_1(value.type + (name ? '<' + name + '>' : '')) + ')'; } return visit function visit() { var grandparents = parents.concat(node); var result = []; var subresult; var offset; if (!test || is(node, index, parents[parents.length - 1] || null)) { result = toResult(visitor(node, parents)); if (result[0] === EXIT) { return result } } if (node.children && result[0] !== SKIP) { offset = (reverse ? node.children.length : -1) + step; while (offset > -1 && offset < node.children.length) { subresult = factory(node.children[offset], offset, grandparents)(); if (subresult[0] === EXIT) { return subresult } offset = typeof subresult[1] === 'number' ? subresult[1] : offset + step; } } return result } } } function toResult(value) { if (value !== null && typeof value === 'object' && 'length' in value) { return value } if (typeof value === 'number') { return [CONTINUE, value] } return [value] } var escapeStringRegexp = string => { if (typeof string !== 'string') { throw new TypeError('Expected a string'); } // Escape characters with special meaning either inside or outside character sets. // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar. return string .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') .replace(/-/g, '\\x2d'); }; var mdastUtilFindAndReplace = findAndReplace; var splice = [].splice; function findAndReplace(tree, find, replace, options) { var settings; var schema; if (typeof find === 'string' || (find && typeof find.exec === 'function')) { schema = [[find, replace]]; } else { schema = find; options = replace; } settings = options || {}; search$1(tree, settings, handlerFactory(toPairs(schema))); return tree function handlerFactory(pairs) { var pair = pairs[0]; return handler function handler(node, parent) { var find = pair[0]; var replace = pair[1]; var nodes = []; var start = 0; var index = parent.children.indexOf(node); var position; var match; var subhandler; var value; find.lastIndex = 0; match = find.exec(node.value); while (match) { position = match.index; value = replace.apply( null, [].concat(match, {index: match.index, input: match.input}) ); if (value !== false) { if (start !== position) { nodes.push({type: 'text', value: node.value.slice(start, position)}); } if (typeof value === 'string' && value.length > 0) { value = {type: 'text', value: value}; } if (value) { nodes = [].concat(nodes, value); } start = position + match[0].length; } if (!find.global) { break } match = find.exec(node.value); } if (position === undefined) { nodes = [node]; index--; } else { if (start < node.value.length) { nodes.push({type: 'text', value: node.value.slice(start)}); } nodes.unshift(index, 1); splice.apply(parent.children, nodes); } if (pairs.length > 1) { subhandler = handlerFactory(pairs.slice(1)); position = -1; while (++position < nodes.length) { node = nodes[position]; if (node.type === 'text') { subhandler(node, parent); } else { search$1(node, settings, subhandler); } } } return index + nodes.length + 1 } } } function search$1(tree, settings, handler) { var ignored = convert_1(settings.ignore || []); var result = []; unistUtilVisitParents(tree, 'text', visitor); return result function visitor(node, parents) { var index = -1; var parent; var grandparent; while (++index < parents.length) { parent = parents[index]; if ( ignored( parent, grandparent ? grandparent.children.indexOf(parent) : undefined, grandparent ) ) { return } grandparent = parent; } return handler(node, grandparent) } } function toPairs(schema) { var result = []; var key; var index; if (typeof schema !== 'object') { throw new Error('Expected array or object as schema') } if ('length' in schema) { index = -1; while (++index < schema.length) { result.push([ toExpression(schema[index][0]), toFunction(schema[index][1]) ]); } } else { for (key in schema) { result.push([toExpression(key), toFunction(schema[key])]); } } return result } function toExpression(find) { return typeof find === 'string' ? new RegExp(escapeStringRegexp(find), 'g') : find } function toFunction(replace) { return typeof replace === 'function' ? replace : returner function returner() { return replace } } var transforms = [transformGfmAutolinkLiterals]; var enter$3 = { literalAutolink: enterLiteralAutolink, literalAutolinkEmail: enterLiteralAutolinkValue, literalAutolinkHttp: enterLiteralAutolinkValue, literalAutolinkWww: enterLiteralAutolinkValue }; var exit$5 = { literalAutolink: exitLiteralAutolink, literalAutolinkEmail: exitLiteralAutolinkEmail, literalAutolinkHttp: exitLiteralAutolinkHttp, literalAutolinkWww: exitLiteralAutolinkWww }; function enterLiteralAutolink(token) { this.enter({type: 'link', title: null, url: '', children: []}, token); } function enterLiteralAutolinkValue(token) { this.config.enter.autolinkProtocol.call(this, token); } function exitLiteralAutolinkHttp(token) { this.config.exit.autolinkProtocol.call(this, token); } function exitLiteralAutolinkWww(token) { this.config.exit.data.call(this, token); this.stack[this.stack.length - 1].url = 'http://' + this.sliceSerialize(token); } function exitLiteralAutolinkEmail(token) { this.config.exit.autolinkEmail.call(this, token); } function exitLiteralAutolink(token) { this.exit(token); } function transformGfmAutolinkLiterals(tree) { mdastUtilFindAndReplace( tree, [ [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/i, findUrl], [/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/, findEmail] ], {ignore: ['link', 'linkReference']} ); } function findUrl($0, protocol, domain, path, match) { var prefix = ''; var parts; var result; // Not an expected previous character. if (!previous$2(match)) { return false } // Treat `www` as part of the domain. if (/^w/i.test(protocol)) { domain = protocol + domain; protocol = ''; prefix = 'http://'; } if (!isCorrectDomain(domain)) { return false } parts = splitUrl(domain + path); if (!parts[0]) return false result = { type: 'link', title: null, url: prefix + protocol + parts[0], children: [{type: 'text', value: protocol + parts[0]}] }; if (parts[1]) { result = [result, {type: 'text', value: parts[1]}]; } return result } function findEmail($0, atext, label, match) { // Not an expected previous character. if (!previous$2(match, true) || /[_-]$/.test(label)) { return false } return { type: 'link', title: null, url: 'mailto:' + atext + '@' + label, children: [{type: 'text', value: atext + '@' + label}] } } function isCorrectDomain(domain) { var parts = domain.split('.'); if ( parts.length < 2 || (parts[parts.length - 1] && (/_/.test(parts[parts.length - 1]) || !/[a-zA-Z\d]/.test(parts[parts.length - 1]))) || (parts[parts.length - 2] && (/_/.test(parts[parts.length - 2]) || !/[a-zA-Z\d]/.test(parts[parts.length - 2]))) ) { return false } return true } function splitUrl(url) { var trail = /[!"&'),.:;<>?\]}]+$/.exec(url); var closingParenIndex; var openingParens; var closingParens; if (trail) { url = url.slice(0, trail.index); trail = trail[0]; closingParenIndex = trail.indexOf(')'); openingParens = ccount_1(url, '('); closingParens = ccount_1(url, ')'); while (closingParenIndex !== -1 && openingParens > closingParens) { url += trail.slice(0, closingParenIndex + 1); trail = trail.slice(closingParenIndex + 1); closingParenIndex = trail.indexOf(')'); closingParens++; } } return [url, trail] } function previous$2(match, email) { var code = match.input.charCodeAt(match.index - 1); return ( (code !== code || unicodeWhitespace_1(code) || unicodePunctuation_1(code)) && (!email || code !== 47) ) } var fromMarkdown$6 = { transforms: transforms, enter: enter$3, exit: exit$5 }; var canContainEols = ['delete']; var enter$2 = {strikethrough: enterStrikethrough}; var exit$4 = {strikethrough: exitStrikethrough}; function enterStrikethrough(token) { this.enter({type: 'delete', children: []}, token); } function exitStrikethrough(token) { this.exit(token); } var fromMarkdown$5 = { canContainEols: canContainEols, enter: enter$2, exit: exit$4 }; var enter$1 = { table: enterTable, tableData: enterCell, tableHeader: enterCell, tableRow: enterRow }; var exit_1 = { codeText: exitCodeText, table: exitTable, tableData: exit$3, tableHeader: exit$3, tableRow: exit$3 }; function enterTable(token) { this.enter({type: 'table', align: token._align, children: []}, token); this.setData('inTable', true); } function exitTable(token) { this.exit(token); this.setData('inTable'); } function enterRow(token) { this.enter({type: 'tableRow', children: []}, token); } function exit$3(token) { this.exit(token); } function enterCell(token) { this.enter({type: 'tableCell', children: []}, token); } // Overwrite the default code text data handler to unescape escaped pipes when // they are in tables. function exitCodeText(token) { var value = this.resume(); if (this.getData('inTable')) { value = value.replace(/\\([\\|])/g, replace); } this.stack[this.stack.length - 1].value = value; this.exit(token); } function replace($0, $1) { // Pipes work, backslashes don’t (but can’t escape pipes). return $1 === '|' ? $1 : $0 } var fromMarkdown$4 = { enter: enter$1, exit: exit_1 }; var exit$2 = { taskListCheckValueChecked: exitCheck, taskListCheckValueUnchecked: exitCheck, paragraph: exitParagraphWithTaskListItem }; function exitCheck(token) { // We’re always in a paragraph, in a list item. this.stack[this.stack.length - 2].checked = token.type === 'taskListCheckValueChecked'; } function exitParagraphWithTaskListItem(token) { var parent = this.stack[this.stack.length - 2]; var node = this.stack[this.stack.length - 1]; var siblings = parent.children; var head = node.children[0]; var index = -1; var firstParaghraph; if ( parent && parent.type === 'listItem' && typeof parent.checked === 'boolean' && head && head.type === 'text' ) { while (++index < siblings.length) { if (siblings[index].type === 'paragraph') { firstParaghraph = siblings[index]; break } } if (firstParaghraph === node) { // Must start with a space or a tab. head.value = head.value.slice(1); if (head.value.length === 0) { node.children.shift(); } else { head.position.start.column++; head.position.start.offset++; node.position.start = Object.assign({}, head.position.start); } } } this.exit(token); } var fromMarkdown$3 = { exit: exit$2 }; var own$5 = {}.hasOwnProperty; var fromMarkdown$2 = configure$3([ fromMarkdown$6, fromMarkdown$5, fromMarkdown$4, fromMarkdown$3 ]); function configure$3(extensions) { var config = {transforms: [], canContainEols: []}; var length = extensions.length; var index = -1; while (++index < length) { extension$1(config, extensions[index]); } return config } function extension$1(config, extension) { var key; var left; var right; for (key in extension) { left = own$5.call(config, key) ? config[key] : (config[key] = {}); right = extension[key]; if (key === 'canContainEols' || key === 'transforms') { config[key] = [].concat(left, right); } else { Object.assign(left, right); } } } var inConstruct = 'phrasing'; var notInConstruct = ['autolink', 'link', 'image', 'label']; var unsafe$4 = [ { character: '@', before: '[+\\-.\\w]', after: '[\\-.\\w]', inConstruct: inConstruct, notInConstruct: notInConstruct }, { character: '.', before: '[Ww]', after: '[\\-.\\w]', inConstruct: inConstruct, notInConstruct: notInConstruct }, { character: ':', before: '[ps]', after: '\\/', inConstruct: inConstruct, notInConstruct: notInConstruct } ]; var toMarkdown$7 = { unsafe: unsafe$4 }; var containerPhrasing$1 = phrasing$1; function phrasing$1(parent, context, safeOptions) { var children = parent.children || []; var results = []; var index = -1; var before = safeOptions.before; var after; var handle; var child; while (++index < children.length) { child = children[index]; if (index + 1 < children.length) { handle = context.handle.handlers[children[index + 1].type]; if (handle && handle.peek) handle = handle.peek; after = handle ? handle(children[index + 1], parent, context, { before: '', after: '' }).charAt(0) : ''; } else { after = safeOptions.after; } // In some cases, html (text) can be found in phrasing right after an eol. // When we’d serialize that, in most cases that would be seen as html // (flow). // As we can’t escape or so to prevent it from happening, we take a somewhat // reasonable approach: replace that eol with a space. // See: if ( results.length > 0 && (before === '\r' || before === '\n') && child.type === 'html' ) { results[results.length - 1] = results[results.length - 1].replace( /(\r?\n|\r)$/, ' ' ); before = ' '; } results.push( context.handle(child, parent, context, { before: before, after: after }) ); before = results[results.length - 1].slice(-1); } return results.join('') } var unsafe$3 = [{character: '~', inConstruct: 'phrasing'}]; var handlers$2 = {delete: handleDelete}; handleDelete.peek = peekDelete; function handleDelete(node, _, context) { var exit = context.enter('emphasis'); var value = containerPhrasing$1(node, context, {before: '~', after: '~'}); exit(); return '~~' + value + '~~' } function peekDelete() { return '~' } var toMarkdown$6 = { unsafe: unsafe$3, handlers: handlers$2 }; var inlineCode_1$1 = inlineCode$3; inlineCode$3.peek = inlineCodePeek$1; function inlineCode$3(node, parent, context) { var value = node.value || ''; var sequence = '`'; var index = -1; var pattern; var expression; var match; var position; // If there is a single grave accent on its own in the code, use a fence of // two. // If there are two in a row, use one. while (new RegExp('(^|[^`])' + sequence + '([^`]|$)').test(value)) { sequence += '`'; } // If this is not just spaces or eols (tabs don’t count), and either the // first or last character are a space, eol, or tick, then pad with spaces. if ( /[^ \r\n]/.test(value) && (/[ \r\n`]/.test(value.charAt(0)) || /[ \r\n`]/.test(value.charAt(value.length - 1))) ) { value = ' ' + value + ' '; } // We have a potential problem: certain characters after eols could result in // blocks being seen. // For example, if someone injected the string `'\n# b'`, then that would // result in an ATX heading. // We can’t escape characters in `inlineCode`, but because eols are // transformed to spaces when going from markdown to HTML anyway, we can swap // them out. while (++index < context.unsafe.length) { pattern = context.unsafe[index]; // Only look for `atBreak`s. // Btw: note that `atBreak` patterns will always start the regex at LF or // CR. if (!pattern.atBreak) continue expression = patternCompile_1$1(pattern); while ((match = expression.exec(value))) { position = match.index; // Support CRLF (patterns only look for one of the characters). if ( value.charCodeAt(position) === 10 /* `\n` */ && value.charCodeAt(position - 1) === 13 /* `\r` */ ) { position--; } value = value.slice(0, position) + ' ' + value.slice(match.index + 1); } } return sequence + value + sequence } function inlineCodePeek$1() { return '`' } /*! * repeat-string * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */ /** * Results cache */ var res = ''; var cache; /** * Expose `repeat` */ var repeatString = repeat; /** * Repeat the given `string` the specified `number` * of times. * * **Example:** * * ```js * var repeat = require('repeat-string'); * repeat('A', 5); * //=> AAAAA * ``` * * @param {String} `string` The string to repeat * @param {Number} `number` The number of times to repeat the string * @return {String} Repeated string * @api public */ function repeat(str, num) { if (typeof str !== 'string') { throw new TypeError('expected a string'); } // cover common, quick use cases if (num === 1) return str; if (num === 2) return str + str; var max = str.length * num; if (cache !== str || typeof cache === 'undefined') { cache = str; res = ''; } else if (res.length >= max) { return res.substr(0, max); } while (max > res.length && num > 1) { if (num & 1) { res += str; } num >>= 1; str += str; } res += str; res = res.substr(0, max); return res; } var markdownTable_1 = markdownTable; var trailingWhitespace = / +$/; // Characters. var space = ' '; var lineFeed = '\n'; var dash$1 = '-'; var colon$1 = ':'; var verticalBar = '|'; var x = 0; var C = 67; var L$1 = 76; var R = 82; var c = 99; var l$1 = 108; var r = 114; // Create a table from a matrix of strings. function markdownTable(table, options) { var settings = options || {}; var padding = settings.padding !== false; var start = settings.delimiterStart !== false; var end = settings.delimiterEnd !== false; var align = (settings.align || []).concat(); var alignDelimiters = settings.alignDelimiters !== false; var alignments = []; var stringLength = settings.stringLength || defaultStringLength; var rowIndex = -1; var rowLength = table.length; var cellMatrix = []; var sizeMatrix = []; var row = []; var sizes = []; var longestCellByColumn = []; var mostCellsPerRow = 0; var cells; var columnIndex; var columnLength; var largest; var size; var cell; var lines; var line; var before; var after; var code; // This is a superfluous loop if we don’t align delimiters, but otherwise we’d // do superfluous work when aligning, so optimize for aligning. while (++rowIndex < rowLength) { cells = table[rowIndex]; columnIndex = -1; columnLength = cells.length; row = []; sizes = []; if (columnLength > mostCellsPerRow) { mostCellsPerRow = columnLength; } while (++columnIndex < columnLength) { cell = serialize(cells[columnIndex]); if (alignDelimiters === true) { size = stringLength(cell); sizes[columnIndex] = size; largest = longestCellByColumn[columnIndex]; if (largest === undefined || size > largest) { longestCellByColumn[columnIndex] = size; } } row.push(cell); } cellMatrix[rowIndex] = row; sizeMatrix[rowIndex] = sizes; } // Figure out which alignments to use. columnIndex = -1; columnLength = mostCellsPerRow; if (typeof align === 'object' && 'length' in align) { while (++columnIndex < columnLength) { alignments[columnIndex] = toAlignment(align[columnIndex]); } } else { code = toAlignment(align); while (++columnIndex < columnLength) { alignments[columnIndex] = code; } } // Inject the alignment row. columnIndex = -1; columnLength = mostCellsPerRow; row = []; sizes = []; while (++columnIndex < columnLength) { code = alignments[columnIndex]; before = ''; after = ''; if (code === l$1) { before = colon$1; } else if (code === r) { after = colon$1; } else if (code === c) { before = colon$1; after = colon$1; } // There *must* be at least one hyphen-minus in each alignment cell. size = alignDelimiters ? Math.max( 1, longestCellByColumn[columnIndex] - before.length - after.length ) : 1; cell = before + repeatString(dash$1, size) + after; if (alignDelimiters === true) { size = before.length + size + after.length; if (size > longestCellByColumn[columnIndex]) { longestCellByColumn[columnIndex] = size; } sizes[columnIndex] = size; } row[columnIndex] = cell; } // Inject the alignment row. cellMatrix.splice(1, 0, row); sizeMatrix.splice(1, 0, sizes); rowIndex = -1; rowLength = cellMatrix.length; lines = []; while (++rowIndex < rowLength) { row = cellMatrix[rowIndex]; sizes = sizeMatrix[rowIndex]; columnIndex = -1; columnLength = mostCellsPerRow; line = []; while (++columnIndex < columnLength) { cell = row[columnIndex] || ''; before = ''; after = ''; if (alignDelimiters === true) { size = longestCellByColumn[columnIndex] - (sizes[columnIndex] || 0); code = alignments[columnIndex]; if (code === r) { before = repeatString(space, size); } else if (code === c) { if (size % 2 === 0) { before = repeatString(space, size / 2); after = before; } else { before = repeatString(space, size / 2 + 0.5); after = repeatString(space, size / 2 - 0.5); } } else { after = repeatString(space, size); } } if (start === true && columnIndex === 0) { line.push(verticalBar); } if ( padding === true && // Don’t add the opening space if we’re not aligning and the cell is // empty: there will be a closing space. !(alignDelimiters === false && cell === '') && (start === true || columnIndex !== 0) ) { line.push(space); } if (alignDelimiters === true) { line.push(before); } line.push(cell); if (alignDelimiters === true) { line.push(after); } if (padding === true) { line.push(space); } if (end === true || columnIndex !== columnLength - 1) { line.push(verticalBar); } } line = line.join(''); if (end === false) { line = line.replace(trailingWhitespace, ''); } lines.push(line); } return lines.join(lineFeed) } function serialize(value) { return value === null || value === undefined ? '' : String(value) } function defaultStringLength(value) { return value.length } function toAlignment(value) { var code = typeof value === 'string' ? value.charCodeAt(0) : x; return code === L$1 || code === l$1 ? l$1 : code === R || code === r ? r : code === C || code === c ? c : x } var toMarkdown_1$1 = toMarkdown$5; function toMarkdown$5(options) { var settings = options || {}; var padding = settings.tableCellPadding; var alignDelimiters = settings.tablePipeAlign; var stringLength = settings.stringLength; var around = padding ? ' ' : '|'; return { unsafe: [ {character: '\r', inConstruct: 'tableCell'}, {character: '\n', inConstruct: 'tableCell'}, // A pipe, when followed by a tab or space (padding), or a dash or colon // (unpadded delimiter row), could result in a table. {atBreak: true, character: '|', after: '[\t :-]'}, // A pipe in a cell must be encoded. {character: '|', inConstruct: 'tableCell'}, // A colon must be followed by a dash, in which case it could start a // delimiter row. {atBreak: true, character: ':', after: '-'}, // A delimiter row can also start with a dash, when followed by more // dashes, a colon, or a pipe. // This is a stricter version than the built in check for lists, thematic // breaks, and setex heading underlines though: // {atBreak: true, character: '-', after: '[:|-]'} ], handlers: { table: handleTable, tableRow: handleTableRow, tableCell: handleTableCell, inlineCode: inlineCodeWithTable } } function handleTable(node, _, context) { return serializeData(handleTableAsData(node, context), node.align) } // This function isn’t really used normally, because we handle rows at the // table level. // But, if someone passes in a table row, this ensures we make somewhat sense. function handleTableRow(node, _, context) { var row = handleTableRowAsData(node, context); // `markdown-table` will always add an align row var value = serializeData([row]); return value.slice(0, value.indexOf('\n')) } function handleTableCell(node, _, context) { var exit = context.enter('tableCell'); var value = containerPhrasing$1(node, context, {before: around, after: around}); exit(); return value } function serializeData(matrix, align) { return markdownTable_1(matrix, { align: align, alignDelimiters: alignDelimiters, padding: padding, stringLength: stringLength }) } function handleTableAsData(node, context) { var children = node.children; var index = -1; var length = children.length; var result = []; var subexit = context.enter('table'); while (++index < length) { result[index] = handleTableRowAsData(children[index], context); } subexit(); return result } function handleTableRowAsData(node, context) { var children = node.children; var index = -1; var length = children.length; var result = []; var subexit = context.enter('tableRow'); while (++index < length) { result[index] = handleTableCell(children[index], node, context); } subexit(); return result } function inlineCodeWithTable(node, parent, context) { var value = inlineCode_1$1(node, parent, context); if (context.stack.indexOf('tableCell') !== -1) { value = value.replace(/\|/g, '\\$&'); } return value } } var checkBullet_1$1 = checkBullet$1; function checkBullet$1(context) { var marker = context.options.bullet || '*'; if (marker !== '*' && marker !== '+' && marker !== '-') { throw new Error( 'Cannot serialize items with `' + marker + '` for `options.bullet`, expected `*`, `+`, or `-`' ) } return marker } var checkListItemIndent_1$1 = checkListItemIndent$1; function checkListItemIndent$1(context) { var style = context.options.listItemIndent || 'tab'; if (style === 1 || style === '1') { return 'one' } if (style !== 'tab' && style !== 'one' && style !== 'mixed') { throw new Error( 'Cannot serialize items with `' + style + '` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`' ) } return style } var containerFlow$1 = flow$3; function flow$3(parent, context) { var children = parent.children || []; var results = []; var index = -1; var child; while (++index < children.length) { child = children[index]; results.push( context.handle(child, parent, context, {before: '\n', after: '\n'}) ); if (index + 1 < children.length) { results.push(between(child, children[index + 1])); } } return results.join('') function between(left, right) { var index = -1; var result; while (++index < context.join.length) { result = context.join[index](left, right, parent, context); if (result === true || result === 1) { break } if (typeof result === 'number') { return repeatString('\n', 1 + Number(result)) } if (result === false) { return '\n\n\n\n' } } return '\n\n' } } var indentLines_1$1 = indentLines$1; var eol$1 = /\r?\n|\r/g; function indentLines$1(value, map) { var result = []; var start = 0; var line = 0; var match; while ((match = eol$1.exec(value))) { one(value.slice(start, match.index)); result.push(match[0]); start = match.index + match[0].length; line++; } one(value.slice(start)); return result.join('') function one(value) { result.push(map(value, line, !value)); } } var listItem_1 = listItem$3; function listItem$3(node, parent, context) { var bullet = checkBullet_1$1(context); var listItemIndent = checkListItemIndent_1$1(context); var size; var value; var exit; if (parent && parent.ordered) { bullet = (parent.start > -1 ? parent.start : 1) + (context.options.incrementListMarker === false ? 0 : parent.children.indexOf(node)) + '.'; } size = bullet.length + 1; if ( listItemIndent === 'tab' || (listItemIndent === 'mixed' && ((parent && parent.spread) || node.spread)) ) { size = Math.ceil(size / 4) * 4; } exit = context.enter('listItem'); value = indentLines_1$1(containerFlow$1(node, context), map); exit(); return value function map(line, index, blank) { if (index) { return (blank ? '' : repeatString(' ', size)) + line } return (blank ? bullet : bullet + repeatString(' ', size - bullet.length)) + line } } var unsafe$2 = [{atBreak: true, character: '-', after: '[:|-]'}]; var handlers$1 = { listItem: listItemWithTaskListItem$1 }; function listItemWithTaskListItem$1(node, parent, context) { var value = listItem_1(node, parent, context); var head = node.children[0]; if (typeof node.checked === 'boolean' && head && head.type === 'paragraph') { value = value.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, check); } return value function check($0) { return $0 + '[' + (node.checked ? 'x' : ' ') + '] ' } } var toMarkdown$4 = { unsafe: unsafe$2, handlers: handlers$1 }; var configure_1$1 = configure$2; function configure$2(base, extension) { var index = -1; var key; // First do subextensions. if (extension.extensions) { while (++index < extension.extensions.length) { configure$2(base, extension.extensions[index]); } } for (key in extension) { if (key === 'extensions') ; else if (key === 'unsafe' || key === 'join') { base[key] = base[key].concat(extension[key] || []); } else if (key === 'handlers') { base[key] = Object.assign(base[key], extension[key] || {}); } else { base.options[key] = extension[key]; } } return base } var toMarkdown_1 = toMarkdown$3; function toMarkdown$3(options) { var config = configure_1$1( {handlers: {}, join: [], unsafe: [], options: {}}, { extensions: [toMarkdown$7, toMarkdown$6, toMarkdown_1$1(options), toMarkdown$4] } ); return Object.assign(config.options, { handlers: config.handlers, join: config.join, unsafe: config.unsafe }) } var warningIssued$1; var remarkGfm = gfm; function gfm(options) { var data = this.data(); /* istanbul ignore next - old remark. */ if ( !warningIssued$1 && ((this.Parser && this.Parser.prototype && this.Parser.prototype.blockTokenizers) || (this.Compiler && this.Compiler.prototype && this.Compiler.prototype.visitors)) ) { warningIssued$1 = true; console.warn( '[remark-gfm] Warning: please upgrade to remark 13 to use this plugin' ); } add('micromarkExtensions', micromarkExtensionGfm(options)); add('fromMarkdownExtensions', fromMarkdown$2); add('toMarkdownExtensions', toMarkdown_1(options)); function add(field, value) { /* istanbul ignore if - other extensions. */ if (data[field]) data[field].push(value); else data[field] = [value]; } } var tokenize$1 = tokenizeMathFenced; var concrete = true; function tokenizeMathFenced(effects, ok, nok) { var self = this; var initialPrefix = prefixSize_1(this.events, 'linePrefix'); var sizeOpen = 0; return start function start(code) { /* istanbul ignore if - handled by mm */ if (code !== 36) throw new Error('expected `$`') effects.enter('mathFlow'); effects.enter('mathFlowFence'); effects.enter('mathFlowFenceSequence'); return sequenceOpen(code) } function sequenceOpen(code) { if (code === 36) { effects.consume(code); sizeOpen++; return sequenceOpen } effects.exit('mathFlowFenceSequence'); return sizeOpen < 2 ? nok(code) : factorySpace(effects, metaOpen, 'whitespace')(code) } function metaOpen(code) { if (code === null || code === -5 || code === -4 || code === -3) { return openAfter(code) } effects.enter('mathFlowFenceMeta'); effects.enter('chunkString', {contentType: 'string'}); return meta(code) } function meta(code) { if (code === null || code === -5 || code === -4 || code === -3) { effects.exit('chunkString'); effects.exit('mathFlowFenceMeta'); return openAfter(code) } if (code === 36) return nok(code) effects.consume(code); return meta } function openAfter(code) { effects.exit('mathFlowFence'); return self.interrupt ? ok(code) : content(code) } function content(code) { if (code === null) { return after(code) } if (code === -5 || code === -4 || code === -3) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return effects.attempt( {tokenize: tokenizeClosingFence, partial: true}, after, initialPrefix ? factorySpace(effects, content, 'linePrefix', initialPrefix + 1) : content ) } effects.enter('mathFlowValue'); return contentContinue(code) } function contentContinue(code) { if (code === null || code === -5 || code === -4 || code === -3) { effects.exit('mathFlowValue'); return content(code) } effects.consume(code); return contentContinue } function after(code) { effects.exit('mathFlow'); return ok(code) } function tokenizeClosingFence(effects, ok, nok) { var size = 0; return factorySpace(effects, closingPrefixAfter, 'linePrefix', 4) function closingPrefixAfter(code) { effects.enter('mathFlowFence'); effects.enter('mathFlowFenceSequence'); return closingSequence(code) } function closingSequence(code) { if (code === 36) { effects.consume(code); size++; return closingSequence } if (size < sizeOpen) return nok(code) effects.exit('mathFlowFenceSequence'); return factorySpace(effects, closingSequenceEnd, 'whitespace')(code) } function closingSequenceEnd(code) { if (code === null || code === -5 || code === -4 || code === -3) { effects.exit('mathFlowFence'); return ok(code) } return nok(code) } } } var tokenizeMathFlow = { tokenize: tokenize$1, concrete: concrete }; var tokenize = tokenizeMathText; var resolve = resolveMathText; var previous_1 = previous$1; function resolveMathText(events) { var tailExitIndex = events.length - 4; var headEnterIndex = 3; var index; var enter; // If we start and end with an EOL or a space. if ( (events[headEnterIndex][1].type === 'lineEnding' || events[headEnterIndex][1].type === 'space') && (events[tailExitIndex][1].type === 'lineEnding' || events[tailExitIndex][1].type === 'space') ) { index = headEnterIndex; // And we have data. while (++index < tailExitIndex) { if (events[index][1].type === 'mathTextData') { // Then we have padding. events[tailExitIndex][1].type = 'mathTextPadding'; events[headEnterIndex][1].type = 'mathTextPadding'; headEnterIndex += 2; tailExitIndex -= 2; break } } } // Merge adjacent spaces and data. index = headEnterIndex - 1; tailExitIndex++; while (++index <= tailExitIndex) { if (enter === undefined) { if (index !== tailExitIndex && events[index][1].type !== 'lineEnding') { enter = index; } } else if ( index === tailExitIndex || events[index][1].type === 'lineEnding' ) { events[enter][1].type = 'mathTextData'; if (index !== enter + 2) { events[enter][1].end = events[index - 1][1].end; events.splice(enter + 2, index - enter - 2); tailExitIndex -= index - enter - 2; index = enter + 2; } enter = undefined; } } return events } function previous$1(code) { // If there is a previous code, there will always be a tail. return ( code !== 36 || this.events[this.events.length - 1][1].type === 'characterEscape' ) } function tokenizeMathText(effects, ok, nok) { var self = this; var sizeOpen = 0; var size; var token; return start function start(code) { /* istanbul ignore if - handled by mm */ if (code !== 36) throw new Error('expected `$`') /* istanbul ignore if - handled by mm */ if (!previous$1.call(self, self.previous)) { throw new Error('expected correct previous') } effects.enter('mathText'); effects.enter('mathTextSequence'); return openingSequence(code) } function openingSequence(code) { if (code === 36) { effects.consume(code); sizeOpen++; return openingSequence } effects.exit('mathTextSequence'); return gap(code) } function gap(code) { // EOF. if (code === null) { return nok(code) } // Closing fence? // Could also be data. if (code === 36) { token = effects.enter('mathTextSequence'); size = 0; return closingSequence(code) } // Tabs don’t work, and virtual spaces don’t make sense. if (code === 32) { effects.enter('space'); effects.consume(code); effects.exit('space'); return gap } if (code === -5 || code === -4 || code === -3) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return gap } // Data. effects.enter('mathTextData'); return data(code) } // In code. function data(code) { if ( code === null || code === 32 || code === 36 || code === -5 || code === -4 || code === -3 ) { effects.exit('mathTextData'); return gap(code) } effects.consume(code); return data } // Closing fence. function closingSequence(code) { // More. if (code === 36) { effects.consume(code); size++; return closingSequence } // Done! if (size === sizeOpen) { effects.exit('mathTextSequence'); effects.exit('mathText'); return ok(code) } // More or less accents: mark as data. token.type = 'mathTextData'; return data(code) } } var tokenizeMathText_1 = { tokenize: tokenize, resolve: resolve, previous: previous_1 }; var flow$2 = {36: tokenizeMathFlow}; var text$4 = {36: tokenizeMathText_1}; var syntax = { flow: flow$2, text: text$4 }; var micromarkExtensionMath = syntax; var enter = { mathFlow: enterMathFlow, mathFlowFenceMeta: enterMathFlowMeta, mathText: enterMathText }; var exit$1 = { mathFlow: exitMathFlow, mathFlowFence: exitMathFlowFence, mathFlowFenceMeta: exitMathFlowMeta, mathFlowValue: exitMathData, mathText: exitMathText, mathTextData: exitMathData }; function enterMathFlow(token) { this.enter( { type: 'math', meta: null, value: '', data: { hName: 'div', hProperties: {className: ['math', 'math-display']}, hChildren: [{type: 'text', value: ''}] } }, token ); } function enterMathFlowMeta() { this.buffer(); } function exitMathFlowMeta() { var data = this.resume(); this.stack[this.stack.length - 1].meta = data; } function exitMathFlowFence() { // Exit if this is the closing fence. if (this.getData('mathFlowInside')) return this.buffer(); this.setData('mathFlowInside', true); } function exitMathFlow(token) { var data = this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ''); var node = this.exit(token); node.value = data; node.data.hChildren[0].value = data; this.setData('mathFlowInside'); } function enterMathText(token) { this.enter( { type: 'inlineMath', value: '', data: { hName: 'span', hProperties: {className: ['math', 'math-inline']}, hChildren: [{type: 'text', value: ''}] } }, token ); this.buffer(); } function exitMathText(token) { var data = this.resume(); var node = this.exit(token); node.value = data; node.data.hChildren[0].value = data; } function exitMathData(token) { this.config.enter.data.call(this, token); this.config.exit.data.call(this, token); } var fromMarkdown$1 = { enter: enter, exit: exit$1 }; var longestStreak_1 = longestStreak; // Get the count of the longest repeating streak of `character` in `value`. function longestStreak(value, character) { var count = 0; var maximum = 0; var expected; var index; if (typeof character !== 'string' || character.length !== 1) { throw new Error('Expected character') } value = String(value); index = value.indexOf(character); expected = index; while (index !== -1) { count++; if (index === expected) { if (count > maximum) { maximum = count; } } else { count = 1; } expected = index + 1; index = value.indexOf(character, expected); } return maximum } var unsafe$1 = [ {character: '\r', inConstruct: ['mathFlowMeta']}, {character: '\r', inConstruct: ['mathFlowMeta']}, {character: '$', inConstruct: ['mathFlowMeta', 'phrasing']}, {atBreak: true, character: '$', after: '\\$'} ]; var handlers = {math: math$1, inlineMath: inlineMath}; inlineMath.peek = inlineMathPeek; function math$1(node, _, context) { var raw = node.value || ''; var fence = repeatString('$', Math.max(longestStreak_1(raw, '$') + 1, 2)); var exit = context.enter('mathFlow'); var value = fence; var subexit; if (node.meta) { subexit = context.enter('mathFlowMeta'); value += safe_1$1(context, node.meta, {before: '$', after: ' ', encode: ['$']}); subexit(); } value += '\n'; if (raw) { value += raw + '\n'; } value += fence; exit(); return value } function inlineMath(node) { var value = node.value || ''; var size = 1; var pad = ''; var sequence; // If there is a single dollar sign on its own in the math, use a fence of // two. // If there are two in a row, use one. while ( new RegExp('(^|[^$])' + repeatString('\\$', size) + '([^$]|$)').test(value) ) { size++; } // If this is not just spaces or eols (tabs don’t count), and either the first // or last character are a space, eol, or dollar sign, then pad with spaces. if ( /[^ \r\n]/.test(value) && (/[ \r\n$]/.test(value.charAt(0)) || /[ \r\n$]/.test(value.charAt(value.length - 1))) ) { pad = ' '; } sequence = repeatString('$', size); return sequence + pad + value + pad + sequence } function inlineMathPeek() { return '$' } var toMarkdown$2 = { unsafe: unsafe$1, handlers: handlers }; var warningIssued; var remarkMath = math; function math() { var data = this.data(); /* istanbul ignore next - old remark. */ if ( !warningIssued && ((this.Parser && this.Parser.prototype && this.Parser.prototype.blockTokenizers) || (this.Compiler && this.Compiler.prototype && this.Compiler.prototype.visitors)) ) { warningIssued = true; console.warn( '[remark-math] Warning: please upgrade to remark 13 to use this plugin' ); } add('micromarkExtensions', micromarkExtensionMath); add('fromMarkdownExtensions', fromMarkdown$1); add('toMarkdownExtensions', toMarkdown$2); function add(field, value) { /* istanbul ignore if - other extensions. */ if (data[field]) data[field].push(value); else data[field] = [value]; } } var bail_1 = bail; function bail(err) { if (err) { throw err } } /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh * @license MIT */ var isBuffer = function isBuffer (obj) { return obj != null && obj.constructor != null && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) }; var hasOwn = Object.prototype.hasOwnProperty; var toStr = Object.prototype.toString; var defineProperty = Object.defineProperty; var gOPD = Object.getOwnPropertyDescriptor; var isArray = function isArray(arr) { if (typeof Array.isArray === 'function') { return Array.isArray(arr); } return toStr.call(arr) === '[object Array]'; }; var isPlainObject = function isPlainObject(obj) { if (!obj || toStr.call(obj) !== '[object Object]') { return false; } var hasOwnConstructor = hasOwn.call(obj, 'constructor'); var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); // Not own constructor property must be Object if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { return false; } // Own properties are enumerated firstly, so to speed up, // if last one is own, then all properties are own. var key; for (key in obj) { /**/ } return typeof key === 'undefined' || hasOwn.call(obj, key); }; // If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target var setProperty = function setProperty(target, options) { if (defineProperty && options.name === '__proto__') { defineProperty(target, options.name, { enumerable: true, configurable: true, value: options.newValue, writable: true }); } else { target[options.name] = options.newValue; } }; // Return undefined instead of __proto__ if '__proto__' is not an own property var getProperty = function getProperty(obj, name) { if (name === '__proto__') { if (!hasOwn.call(obj, name)) { return void 0; } else if (gOPD) { // In early versions of node, obj['__proto__'] is buggy when obj has // __proto__ as an own property. Object.getOwnPropertyDescriptor() works. return gOPD(obj, name).value; } } return obj[name]; }; var extend = function extend() { var options, name, src, copy, copyIsArray, clone; var target = arguments[0]; var i = 1; var length = arguments.length; var deep = false; // Handle a deep copy situation if (typeof target === 'boolean') { deep = target; target = arguments[1] || {}; // skip the boolean and the target i = 2; } if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { target = {}; } for (; i < length; ++i) { options = arguments[i]; // Only deal with non-null/undefined values if (options != null) { // Extend the base object for (name in options) { src = getProperty(target, name); copy = getProperty(options, name); // Prevent never-ending loop if (target !== copy) { // Recurse if we're merging plain objects or arrays if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { if (copyIsArray) { copyIsArray = false; clone = src && isArray(src) ? src : []; } else { clone = src && isPlainObject(src) ? src : {}; } // Never move original objects, clone them setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); // Don't bring in undefined values } else if (typeof copy !== 'undefined') { setProperty(target, { name: name, newValue: copy }); } } } } } // Return the modified object return target; }; var isPlainObj = value => { if (Object.prototype.toString.call(value) !== '[object Object]') { return false; } const prototype = Object.getPrototypeOf(value); return prototype === null || prototype === Object.prototype; }; var slice$2 = [].slice; var wrap_1 = wrap; // Wrap `fn`. // Can be sync or async; return a promise, receive a completion handler, return // new values and errors. function wrap(fn, callback) { var invoked; return wrapped function wrapped() { var params = slice$2.call(arguments, 0); var callback = fn.length > params.length; var result; if (callback) { params.push(done); } try { result = fn.apply(null, params); } catch (error) { // Well, this is quite the pickle. // `fn` received a callback and invoked it (thus continuing the pipeline), // but later also threw an error. // We’re not about to restart the pipeline again, so the only thing left // to do is to throw the thing instead. if (callback && invoked) { throw error } return done(error) } if (!callback) { if (result && typeof result.then === 'function') { result.then(then, done); } else if (result instanceof Error) { done(result); } else { then(result); } } } // Invoke `next`, only once. function done() { if (!invoked) { invoked = true; callback.apply(null, arguments); } } // Invoke `done` with one value. // Tracks if an error is passed, too. function then(value) { done(null, value); } } var trough_1 = trough; trough.wrap = wrap_1; var slice$1 = [].slice; // Create new middleware. function trough() { var fns = []; var middleware = {}; middleware.run = run; middleware.use = use; return middleware // Run `fns`. Last argument must be a completion handler. function run() { var index = -1; var input = slice$1.call(arguments, 0, -1); var done = arguments[arguments.length - 1]; if (typeof done !== 'function') { throw new Error('Expected function as last argument, not ' + done) } next.apply(null, [null].concat(input)); // Run the next `fn`, if any. function next(err) { var fn = fns[++index]; var params = slice$1.call(arguments, 0); var values = params.slice(1); var length = input.length; var pos = -1; if (err) { done(err); return } // Copy non-nully input into values. while (++pos < length) { if (values[pos] === null || values[pos] === undefined) { values[pos] = input[pos]; } } input = values; // Next or done. if (fn) { wrap_1(fn, next).apply(null, input); } else { done.apply(null, [null].concat(input)); } } } // Add `fn` to the list. function use(fn) { if (typeof fn !== 'function') { throw new Error('Expected `fn` to be a function, not ' + fn) } fns.push(fn); return middleware } } var own$4 = {}.hasOwnProperty; var unistUtilStringifyPosition = stringify$2; function stringify$2(value) { // Nothing. if (!value || typeof value !== 'object') { return '' } // Node. if (own$4.call(value, 'position') || own$4.call(value, 'type')) { return position(value.position) } // Position. if (own$4.call(value, 'start') || own$4.call(value, 'end')) { return position(value) } // Point. if (own$4.call(value, 'line') || own$4.call(value, 'column')) { return point(value) } // ? return '' } function point(point) { if (!point || typeof point !== 'object') { point = {}; } return index(point.line) + ':' + index(point.column) } function position(pos) { if (!pos || typeof pos !== 'object') { pos = {}; } return point(pos.start) + '-' + point(pos.end) } function index(value) { return value && typeof value === 'number' ? value : 1 } var vfileMessage = VMessage; // Inherit from `Error#`. function VMessagePrototype() {} VMessagePrototype.prototype = Error.prototype; VMessage.prototype = new VMessagePrototype(); // Message properties. var proto = VMessage.prototype; proto.file = ''; proto.name = ''; proto.reason = ''; proto.message = ''; proto.stack = ''; proto.fatal = null; proto.column = null; proto.line = null; // Construct a new VMessage. // // Note: We cannot invoke `Error` on the created context, as that adds readonly // `line` and `column` attributes on Safari 9, thus throwing and failing the // data. function VMessage(reason, position, origin) { var parts; var range; var location; if (typeof position === 'string') { origin = position; position = null; } parts = parseOrigin(origin); range = unistUtilStringifyPosition(position) || '1:1'; location = { start: {line: null, column: null}, end: {line: null, column: null} }; // Node. if (position && position.position) { position = position.position; } if (position) { // Position. if (position.start) { location = position; position = position.start; } else { // Point. location.start = position; } } if (reason.stack) { this.stack = reason.stack; reason = reason.message; } this.message = reason; this.name = range; this.reason = reason; this.line = position ? position.line : null; this.column = position ? position.column : null; this.location = location; this.source = parts[0]; this.ruleId = parts[1]; } function parseOrigin(origin) { var result = [null, null]; var index; if (typeof origin === 'string') { index = origin.indexOf(':'); if (index === -1) { result[1] = origin; } else { result[0] = origin.slice(0, index); result[1] = origin.slice(index + 1); } } return result } var minpath = require$$0__default["default"]; var minproc = process; var core = VFile; var own$3 = {}.hasOwnProperty; // Order of setting (least specific to most), we need this because otherwise // `{stem: 'a', path: '~/b.js'}` would throw, as a path is needed before a // stem can be set. var order$1 = ['history', 'path', 'basename', 'stem', 'extname', 'dirname']; VFile.prototype.toString = toString$1; // Access full path (`~/index.min.js`). Object.defineProperty(VFile.prototype, 'path', {get: getPath, set: setPath}); // Access parent path (`~`). Object.defineProperty(VFile.prototype, 'dirname', { get: getDirname, set: setDirname }); // Access basename (`index.min.js`). Object.defineProperty(VFile.prototype, 'basename', { get: getBasename, set: setBasename }); // Access extname (`.js`). Object.defineProperty(VFile.prototype, 'extname', { get: getExtname, set: setExtname }); // Access stem (`index.min`). Object.defineProperty(VFile.prototype, 'stem', {get: getStem, set: setStem}); // Construct a new file. function VFile(options) { var prop; var index; if (!options) { options = {}; } else if (typeof options === 'string' || isBuffer(options)) { options = {contents: options}; } else if ('message' in options && 'messages' in options) { return options } if (!(this instanceof VFile)) { return new VFile(options) } this.data = {}; this.messages = []; this.history = []; this.cwd = minproc.cwd(); // Set path related properties in the correct order. index = -1; while (++index < order$1.length) { prop = order$1[index]; if (own$3.call(options, prop)) { this[prop] = options[prop]; } } // Set non-path related properties. for (prop in options) { if (order$1.indexOf(prop) < 0) { this[prop] = options[prop]; } } } function getPath() { return this.history[this.history.length - 1] } function setPath(path) { assertNonEmpty(path, 'path'); if (this.path !== path) { this.history.push(path); } } function getDirname() { return typeof this.path === 'string' ? minpath.dirname(this.path) : undefined } function setDirname(dirname) { assertPath(this.path, 'dirname'); this.path = minpath.join(dirname || '', this.basename); } function getBasename() { return typeof this.path === 'string' ? minpath.basename(this.path) : undefined } function setBasename(basename) { assertNonEmpty(basename, 'basename'); assertPart(basename, 'basename'); this.path = minpath.join(this.dirname || '', basename); } function getExtname() { return typeof this.path === 'string' ? minpath.extname(this.path) : undefined } function setExtname(extname) { assertPart(extname, 'extname'); assertPath(this.path, 'extname'); if (extname) { if (extname.charCodeAt(0) !== 46 /* `.` */) { throw new Error('`extname` must start with `.`') } if (extname.indexOf('.', 1) > -1) { throw new Error('`extname` cannot contain multiple dots') } } this.path = minpath.join(this.dirname, this.stem + (extname || '')); } function getStem() { return typeof this.path === 'string' ? minpath.basename(this.path, this.extname) : undefined } function setStem(stem) { assertNonEmpty(stem, 'stem'); assertPart(stem, 'stem'); this.path = minpath.join(this.dirname || '', stem + (this.extname || '')); } // Get the value of the file. function toString$1(encoding) { return (this.contents || '').toString(encoding) } // Assert that `part` is not a path (i.e., does not contain `p.sep`). function assertPart(part, name) { if (part && part.indexOf(minpath.sep) > -1) { throw new Error( '`' + name + '` cannot be a path: did not expect `' + minpath.sep + '`' ) } } // Assert that `part` is not empty. function assertNonEmpty(part, name) { if (!part) { throw new Error('`' + name + '` cannot be empty') } } // Assert `path` exists. function assertPath(path, name) { if (!path) { throw new Error('Setting `' + name + '` requires `path` to be set too') } } var lib$1 = core; core.prototype.message = message; core.prototype.info = info; core.prototype.fail = fail; // Create a message with `reason` at `position`. // When an error is passed in as `reason`, copies the stack. function message(reason, position, origin) { var message = new vfileMessage(reason, position, origin); if (this.path) { message.name = this.path + ':' + message.name; message.file = this.path; } message.fatal = false; this.messages.push(message); return message } // Fail: creates a vmessage, associates it with the file, and throws it. function fail() { var message = this.message.apply(this, arguments); message.fatal = true; throw message } // Info: creates a vmessage, associates it with the file, and marks the fatality // as null. function info() { var message = this.message.apply(this, arguments); message.fatal = null; return message } var vfile = lib$1; // Expose a frozen processor. var unified_1 = unified().freeze(); var slice = [].slice; var own$2 = {}.hasOwnProperty; // Process pipeline. var pipeline = trough_1() .use(pipelineParse) .use(pipelineRun) .use(pipelineStringify); function pipelineParse(p, ctx) { ctx.tree = p.parse(ctx.file); } function pipelineRun(p, ctx, next) { p.run(ctx.tree, ctx.file, done); function done(error, tree, file) { if (error) { next(error); } else { ctx.tree = tree; ctx.file = file; next(); } } } function pipelineStringify(p, ctx) { var result = p.stringify(ctx.tree, ctx.file); if (result === undefined || result === null) ; else if (typeof result === 'string' || isBuffer(result)) { if ('value' in ctx.file) { ctx.file.value = result; } ctx.file.contents = result; } else { ctx.file.result = result; } } // Function to create the first processor. function unified() { var attachers = []; var transformers = trough_1(); var namespace = {}; var freezeIndex = -1; var frozen; // Data management. processor.data = data; // Lock. processor.freeze = freeze; // Plugins. processor.attachers = attachers; processor.use = use; // API. processor.parse = parse; processor.stringify = stringify; processor.run = run; processor.runSync = runSync; processor.process = process; processor.processSync = processSync; // Expose. return processor // Create a new processor based on the processor in the current scope. function processor() { var destination = unified(); var index = -1; while (++index < attachers.length) { destination.use.apply(null, attachers[index]); } destination.data(extend(true, {}, namespace)); return destination } // Freeze: used to signal a processor that has finished configuration. // // For example, take unified itself: it’s frozen. // Plugins should not be added to it. // Rather, it should be extended, by invoking it, before modifying it. // // In essence, always invoke this when exporting a processor. function freeze() { var values; var transformer; if (frozen) { return processor } while (++freezeIndex < attachers.length) { values = attachers[freezeIndex]; if (values[1] === false) { continue } if (values[1] === true) { values[1] = undefined; } transformer = values[0].apply(processor, values.slice(1)); if (typeof transformer === 'function') { transformers.use(transformer); } } frozen = true; freezeIndex = Infinity; return processor } // Data management. // Getter / setter for processor-specific informtion. function data(key, value) { if (typeof key === 'string') { // Set `key`. if (arguments.length === 2) { assertUnfrozen('data', frozen); namespace[key] = value; return processor } // Get `key`. return (own$2.call(namespace, key) && namespace[key]) || null } // Set space. if (key) { assertUnfrozen('data', frozen); namespace = key; return processor } // Get space. return namespace } // Plugin management. // // Pass it: // * an attacher and options, // * a preset, // * a list of presets, attachers, and arguments (list of attachers and // options). function use(value) { var settings; assertUnfrozen('use', frozen); if (value === null || value === undefined) ; else if (typeof value === 'function') { addPlugin.apply(null, arguments); } else if (typeof value === 'object') { if ('length' in value) { addList(value); } else { addPreset(value); } } else { throw new Error('Expected usable value, not `' + value + '`') } if (settings) { namespace.settings = extend(namespace.settings || {}, settings); } return processor function addPreset(result) { addList(result.plugins); if (result.settings) { settings = extend(settings || {}, result.settings); } } function add(value) { if (typeof value === 'function') { addPlugin(value); } else if (typeof value === 'object') { if ('length' in value) { addPlugin.apply(null, value); } else { addPreset(value); } } else { throw new Error('Expected usable value, not `' + value + '`') } } function addList(plugins) { var index = -1; if (plugins === null || plugins === undefined) ; else if (typeof plugins === 'object' && 'length' in plugins) { while (++index < plugins.length) { add(plugins[index]); } } else { throw new Error('Expected a list of plugins, not `' + plugins + '`') } } function addPlugin(plugin, value) { var entry = find(plugin); if (entry) { if (isPlainObj(entry[1]) && isPlainObj(value)) { value = extend(true, entry[1], value); } entry[1] = value; } else { attachers.push(slice.call(arguments)); } } } function find(plugin) { var index = -1; while (++index < attachers.length) { if (attachers[index][0] === plugin) { return attachers[index] } } } // Parse a file (in string or vfile representation) into a unist node using // the `Parser` on the processor. function parse(doc) { var file = vfile(doc); var Parser; freeze(); Parser = processor.Parser; assertParser('parse', Parser); if (newable(Parser, 'parse')) { return new Parser(String(file), file).parse() } return Parser(String(file), file) // eslint-disable-line new-cap } // Run transforms on a unist node representation of a file (in string or // vfile representation), async. function run(node, file, cb) { assertNode(node); freeze(); if (!cb && typeof file === 'function') { cb = file; file = null; } if (!cb) { return new Promise(executor) } executor(null, cb); function executor(resolve, reject) { transformers.run(node, vfile(file), done); function done(error, tree, file) { tree = tree || node; if (error) { reject(error); } else if (resolve) { resolve(tree); } else { cb(null, tree, file); } } } } // Run transforms on a unist node representation of a file (in string or // vfile representation), sync. function runSync(node, file) { var result; var complete; run(node, file, done); assertDone('runSync', 'run', complete); return result function done(error, tree) { complete = true; result = tree; bail_1(error); } } // Stringify a unist node representation of a file (in string or vfile // representation) into a string using the `Compiler` on the processor. function stringify(node, doc) { var file = vfile(doc); var Compiler; freeze(); Compiler = processor.Compiler; assertCompiler('stringify', Compiler); assertNode(node); if (newable(Compiler, 'compile')) { return new Compiler(node, file).compile() } return Compiler(node, file) // eslint-disable-line new-cap } // Parse a file (in string or vfile representation) into a unist node using // the `Parser` on the processor, then run transforms on that node, and // compile the resulting node using the `Compiler` on the processor, and // store that result on the vfile. function process(doc, cb) { freeze(); assertParser('process', processor.Parser); assertCompiler('process', processor.Compiler); if (!cb) { return new Promise(executor) } executor(null, cb); function executor(resolve, reject) { var file = vfile(doc); pipeline.run(processor, {file: file}, done); function done(error) { if (error) { reject(error); } else if (resolve) { resolve(file); } else { cb(null, file); } } } } // Process the given document (in string or vfile representation), sync. function processSync(doc) { var file; var complete; freeze(); assertParser('processSync', processor.Parser); assertCompiler('processSync', processor.Compiler); file = vfile(doc); process(file, done); assertDone('processSync', 'process', complete); return file function done(error) { complete = true; bail_1(error); } } } // Check if `value` is a constructor. function newable(value, name) { return ( typeof value === 'function' && value.prototype && // A function with keys in its prototype is probably a constructor. // Classes’ prototype methods are not enumerable, so we check if some value // exists in the prototype. (keys(value.prototype) || name in value.prototype) ) } // Check if `value` is an object with keys. function keys(value) { var key; for (key in value) { return true } return false } // Assert a parser is available. function assertParser(name, Parser) { if (typeof Parser !== 'function') { throw new Error('Cannot `' + name + '` without `Parser`') } } // Assert a compiler is available. function assertCompiler(name, Compiler) { if (typeof Compiler !== 'function') { throw new Error('Cannot `' + name + '` without `Compiler`') } } // Assert the processor is not frozen. function assertUnfrozen(name, frozen) { if (frozen) { throw new Error( 'Cannot invoke `' + name + '` on a frozen processor.\nCreate a new processor first, by invoking it: use `processor()` instead of `processor`.' ) } } // Assert `node` is a unist node. function assertNode(node) { if (!node || typeof node.type !== 'string') { throw new Error('Expected node, got `' + node + '`') } } // Assert that `complete` is `true`. function assertDone(name, asyncName, complete) { if (!complete) { throw new Error( '`' + name + '` finished async. Use `' + asyncName + '` instead' ) } } var mdastUtilToString = toString; // Get the text content of a node. // Prefer the node’s plain-text fields, otherwise serialize its children, // and if the given value is an array, serialize the nodes in it. function toString(node) { return ( (node && (node.value || node.alt || node.title || ('children' in node && all(node.children)) || ('length' in node && all(node)))) || '' ) } function all(values) { var result = []; var index = -1; while (++index < values.length) { result[index] = toString(values[index]); } return result.join('') } function normalizeIdentifier(value) { return ( value // Collapse Markdown whitespace. .replace(/[\t\n\r ]+/g, ' ') // Trim. .replace(/^ | $/g, '') // Some characters are considered “uppercase”, but if their lowercase // counterpart is uppercased will result in a different uppercase // character. // Hence, to get that form, we perform both lower- and uppercase. // Upper case makes sure keys will not interact with default prototypal // methods: no object method is uppercase. .toLowerCase() .toUpperCase() ) } var normalizeIdentifier_1 = normalizeIdentifier; function safeFromInt(value, base) { var code = parseInt(value, base); if ( // C0 except for HT, LF, FF, CR, space code < 9 || code === 11 || (code > 13 && code < 32) || // Control character (DEL) of the basic block and C1 controls. (code > 126 && code < 160) || // Lone high surrogates and low surrogates. (code > 55295 && code < 57344) || // Noncharacters. (code > 64975 && code < 65008) || (code & 65535) === 65535 || (code & 65535) === 65534 || // Out of range code > 1114111 ) { return '\uFFFD' } return fromCharCode_1(code) } var safeFromInt_1 = safeFromInt; var content$1 = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, '__esModule', {value: true}); var tokenize = initializeContent; function initializeContent(effects) { var contentStart = effects.attempt( this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial ); var previous; return contentStart function afterContentStartConstruct(code) { if (code === null) { effects.consume(code); return } effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return factorySpace(effects, contentStart, 'linePrefix') } function paragraphInitial(code) { effects.enter('paragraph'); return lineStart(code) } function lineStart(code) { var token = effects.enter('chunkText', { contentType: 'text', previous: previous }); if (previous) { previous.next = token; } previous = token; return data(code) } function data(code) { if (code === null) { effects.exit('chunkText'); effects.exit('paragraph'); effects.consume(code); return } if (markdownLineEnding_1(code)) { effects.consume(code); effects.exit('chunkText'); return lineStart } // Data. effects.consume(code); return data } } exports.tokenize = tokenize; }); var partialBlankLine = { tokenize: tokenizePartialBlankLine, partial: true }; function tokenizePartialBlankLine(effects, ok, nok) { return factorySpace(effects, afterWhitespace, 'linePrefix') function afterWhitespace(code) { return code === null || markdownLineEnding_1(code) ? ok(code) : nok(code) } } var partialBlankLine_1 = partialBlankLine; var document$1 = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, '__esModule', {value: true}); var tokenize = initializeDocument; var containerConstruct = { tokenize: tokenizeContainer }; var lazyFlowConstruct = { tokenize: tokenizeLazyFlow }; function initializeDocument(effects) { var self = this; var stack = []; var continued = 0; var inspectConstruct = { tokenize: tokenizeInspect, partial: true }; var inspectResult; var childFlow; var childToken; return start function start(code) { if (continued < stack.length) { self.containerState = stack[continued][1]; return effects.attempt( stack[continued][0].continuation, documentContinue, documentContinued )(code) } return documentContinued(code) } function documentContinue(code) { continued++; return start(code) } function documentContinued(code) { // If we’re in a concrete construct (such as when expecting another line of // HTML, or we resulted in lazy content), we can immediately start flow. if (inspectResult && inspectResult.flowContinue) { return flowStart(code) } self.interrupt = childFlow && childFlow.currentConstruct && childFlow.currentConstruct.interruptible; self.containerState = {}; return effects.attempt( containerConstruct, containerContinue, flowStart )(code) } function containerContinue(code) { stack.push([self.currentConstruct, self.containerState]); self.containerState = undefined; return documentContinued(code) } function flowStart(code) { if (code === null) { exitContainers(0, true); effects.consume(code); return } childFlow = childFlow || self.parser.flow(self.now()); effects.enter('chunkFlow', { contentType: 'flow', previous: childToken, _tokenizer: childFlow }); return flowContinue(code) } function flowContinue(code) { if (code === null) { continueFlow(effects.exit('chunkFlow')); return flowStart(code) } if (markdownLineEnding_1(code)) { effects.consume(code); continueFlow(effects.exit('chunkFlow')); return effects.check(inspectConstruct, documentAfterPeek) } effects.consume(code); return flowContinue } function documentAfterPeek(code) { exitContainers( inspectResult.continued, inspectResult && inspectResult.flowEnd ); continued = 0; return start(code) } function continueFlow(token) { if (childToken) childToken.next = token; childToken = token; childFlow.lazy = inspectResult && inspectResult.lazy; childFlow.defineSkip(token.start); childFlow.write(self.sliceStream(token)); } function exitContainers(size, end) { var index = stack.length; // Close the flow. if (childFlow && end) { childFlow.write([null]); childToken = childFlow = undefined; } // Exit open containers. while (index-- > size) { self.containerState = stack[index][1]; stack[index][0].exit.call(self, effects); } stack.length = size; } function tokenizeInspect(effects, ok) { var subcontinued = 0; inspectResult = {}; return inspectStart function inspectStart(code) { if (subcontinued < stack.length) { self.containerState = stack[subcontinued][1]; return effects.attempt( stack[subcontinued][0].continuation, inspectContinue, inspectLess )(code) } // If we’re continued but in a concrete flow, we can’t have more // containers. if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) { inspectResult.flowContinue = true; return inspectDone(code) } self.interrupt = childFlow.currentConstruct && childFlow.currentConstruct.interruptible; self.containerState = {}; return effects.attempt( containerConstruct, inspectFlowEnd, inspectDone )(code) } function inspectContinue(code) { subcontinued++; return self.containerState._closeFlow ? inspectFlowEnd(code) : inspectStart(code) } function inspectLess(code) { if (childFlow.currentConstruct && childFlow.currentConstruct.lazy) { // Maybe another container? self.containerState = {}; return effects.attempt( containerConstruct, inspectFlowEnd, // Maybe flow, or a blank line? effects.attempt( lazyFlowConstruct, inspectFlowEnd, effects.check(partialBlankLine_1, inspectFlowEnd, inspectLazy) ) )(code) } // Otherwise we’re interrupting. return inspectFlowEnd(code) } function inspectLazy(code) { // Act as if all containers are continued. subcontinued = stack.length; inspectResult.lazy = true; inspectResult.flowContinue = true; return inspectDone(code) } // We’re done with flow if we have more containers, or an interruption. function inspectFlowEnd(code) { inspectResult.flowEnd = true; return inspectDone(code) } function inspectDone(code) { inspectResult.continued = subcontinued; self.interrupt = self.containerState = undefined; return ok(code) } } } function tokenizeContainer(effects, ok, nok) { return factorySpace( effects, effects.attempt(this.parser.constructs.document, ok, nok), 'linePrefix', this.parser.constructs.disable.null.indexOf('codeIndented') > -1 ? undefined : 4 ) } function tokenizeLazyFlow(effects, ok, nok) { return factorySpace( effects, effects.lazy(this.parser.constructs.flow, ok, nok), 'linePrefix', this.parser.constructs.disable.null.indexOf('codeIndented') > -1 ? undefined : 4 ) } exports.tokenize = tokenize; }); function subtokenize(events) { var jumps = {}; var index = -1; var event; var lineIndex; var otherIndex; var otherEvent; var parameters; var subevents; var more; while (++index < events.length) { while (index in jumps) { index = jumps[index]; } event = events[index]; // Add a hook for the GFM tasklist extension, which needs to know if text // is in the first content of a list item. if ( index && event[1].type === 'chunkFlow' && events[index - 1][1].type === 'listItemPrefix' ) { subevents = event[1]._tokenizer.events; otherIndex = 0; if ( otherIndex < subevents.length && subevents[otherIndex][1].type === 'lineEndingBlank' ) { otherIndex += 2; } if ( otherIndex < subevents.length && subevents[otherIndex][1].type === 'content' ) { while (++otherIndex < subevents.length) { if (subevents[otherIndex][1].type === 'content') { break } if (subevents[otherIndex][1].type === 'chunkText') { subevents[otherIndex][1].isInFirstContentOfListItem = true; otherIndex++; } } } } // Enter. if (event[0] === 'enter') { if (event[1].contentType) { assign_1(jumps, subcontent(events, index)); index = jumps[index]; more = true; } } // Exit. else if (event[1]._container || event[1]._movePreviousLineEndings) { otherIndex = index; lineIndex = undefined; while (otherIndex--) { otherEvent = events[otherIndex]; if ( otherEvent[1].type === 'lineEnding' || otherEvent[1].type === 'lineEndingBlank' ) { if (otherEvent[0] === 'enter') { if (lineIndex) { events[lineIndex][1].type = 'lineEndingBlank'; } otherEvent[1].type = 'lineEnding'; lineIndex = otherIndex; } } else { break } } if (lineIndex) { // Fix position. event[1].end = shallow_1(events[lineIndex][1].start); // Switch container exit w/ line endings. parameters = events.slice(lineIndex, index); parameters.unshift(event); chunkedSplice_1(events, lineIndex, index - lineIndex + 1, parameters); } } } return !more } function subcontent(events, eventIndex) { var token = events[eventIndex][1]; var context = events[eventIndex][2]; var startPosition = eventIndex - 1; var startPositions = []; var tokenizer = token._tokenizer || context.parser[token.contentType](token.start); var childEvents = tokenizer.events; var jumps = []; var gaps = {}; var stream; var previous; var index; var entered; var end; var adjust; // Loop forward through the linked tokens to pass them in order to the // subtokenizer. while (token) { // Find the position of the event for this token. while (events[++startPosition][1] !== token) { // Empty. } startPositions.push(startPosition); if (!token._tokenizer) { stream = context.sliceStream(token); if (!token.next) { stream.push(null); } if (previous) { tokenizer.defineSkip(token.start); } if (token.isInFirstContentOfListItem) { tokenizer._gfmTasklistFirstContentOfListItem = true; } tokenizer.write(stream); if (token.isInFirstContentOfListItem) { tokenizer._gfmTasklistFirstContentOfListItem = undefined; } } // Unravel the next token. previous = token; token = token.next; } // Now, loop back through all events (and linked tokens), to figure out which // parts belong where. token = previous; index = childEvents.length; while (index--) { // Make sure we’ve at least seen something (final eol is part of the last // token). if (childEvents[index][0] === 'enter') { entered = true; } else if ( // Find a void token that includes a break. entered && childEvents[index][1].type === childEvents[index - 1][1].type && childEvents[index][1].start.line !== childEvents[index][1].end.line ) { add(childEvents.slice(index + 1, end)); // Help GC. token._tokenizer = token.next = undefined; token = token.previous; end = index + 1; } } // Help GC. tokenizer.events = token._tokenizer = token.next = undefined; // Do head: add(childEvents.slice(0, end)); index = -1; adjust = 0; while (++index < jumps.length) { gaps[adjust + jumps[index][0]] = adjust + jumps[index][1]; adjust += jumps[index][1] - jumps[index][0] - 1; } return gaps function add(slice) { var start = startPositions.pop(); jumps.unshift([start, start + slice.length - 1]); chunkedSplice_1(events, start, 2, slice); } } var subtokenize_1 = subtokenize; // No name because it must not be turned off. var content = { tokenize: tokenizeContent, resolve: resolveContent, interruptible: true, lazy: true }; var continuationConstruct = { tokenize: tokenizeContinuation, partial: true }; // Content is transparent: it’s parsed right now. That way, definitions are also // parsed right now: before text in paragraphs (specifically, media) are parsed. function resolveContent(events) { subtokenize_1(events); return events } function tokenizeContent(effects, ok) { var previous; return start function start(code) { effects.enter('content'); previous = effects.enter('chunkContent', { contentType: 'content' }); return data(code) } function data(code) { if (code === null) { return contentEnd(code) } if (markdownLineEnding_1(code)) { return effects.check( continuationConstruct, contentContinue, contentEnd )(code) } // Data. effects.consume(code); return data } function contentEnd(code) { effects.exit('chunkContent'); effects.exit('content'); return ok(code) } function contentContinue(code) { effects.consume(code); effects.exit('chunkContent'); previous = previous.next = effects.enter('chunkContent', { contentType: 'content', previous: previous }); return data } } function tokenizeContinuation(effects, ok, nok) { var self = this; return startLookahead function startLookahead(code) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return factorySpace(effects, prefixed, 'linePrefix') } function prefixed(code) { if (code === null || markdownLineEnding_1(code)) { return nok(code) } if ( self.parser.constructs.disable.null.indexOf('codeIndented') > -1 || prefixSize_1(self.events, 'linePrefix') < 4 ) { return effects.interrupt(self.parser.constructs.flow, nok, ok)(code) } return ok(code) } } var content_1 = content; var flow$1 = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, '__esModule', {value: true}); var tokenize = initializeFlow; function initializeFlow(effects) { var self = this; var initial = effects.attempt( // Try to parse a blank line. partialBlankLine_1, atBlankEnding, // Try to parse initial flow (essentially, only code). effects.attempt( this.parser.constructs.flowInitial, afterConstruct, factorySpace( effects, effects.attempt( this.parser.constructs.flow, afterConstruct, effects.attempt(content_1, afterConstruct) ), 'linePrefix' ) ) ); return initial function atBlankEnding(code) { if (code === null) { effects.consume(code); return } effects.enter('lineEndingBlank'); effects.consume(code); effects.exit('lineEndingBlank'); self.currentConstruct = undefined; return initial } function afterConstruct(code) { if (code === null) { effects.consume(code); return } effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); self.currentConstruct = undefined; return initial } } exports.tokenize = tokenize; }); var text_1$2 = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, '__esModule', {value: true}); var text = initializeFactory('text'); var string = initializeFactory('string'); var resolver = { resolveAll: createResolver() }; function initializeFactory(field) { return { tokenize: initializeText, resolveAll: createResolver( field === 'text' ? resolveAllLineSuffixes : undefined ) } function initializeText(effects) { var self = this; var constructs = this.parser.constructs[field]; var text = effects.attempt(constructs, start, notText); return start function start(code) { return atBreak(code) ? text(code) : notText(code) } function notText(code) { if (code === null) { effects.consume(code); return } effects.enter('data'); effects.consume(code); return data } function data(code) { if (atBreak(code)) { effects.exit('data'); return text(code) } // Data. effects.consume(code); return data } function atBreak(code) { var list = constructs[code]; var index = -1; if (code === null) { return true } if (list) { while (++index < list.length) { if ( !list[index].previous || list[index].previous.call(self, self.previous) ) { return true } } } } } } function createResolver(extraResolver) { return resolveAllText function resolveAllText(events, context) { var index = -1; var enter; // A rather boring computation (to merge adjacent `data` events) which // improves mm performance by 29%. while (++index <= events.length) { if (enter === undefined) { if (events[index] && events[index][1].type === 'data') { enter = index; index++; } } else if (!events[index] || events[index][1].type !== 'data') { // Don’t do anything if there is one data token. if (index !== enter + 2) { events[enter][1].end = events[index - 1][1].end; events.splice(enter + 2, index - enter - 2); index = enter + 2; } enter = undefined; } } return extraResolver ? extraResolver(events, context) : events } } // A rather ugly set of instructions which again looks at chunks in the input // stream. // The reason to do this here is that it is *much* faster to parse in reverse. // And that we can’t hook into `null` to split the line suffix before an EOF. // To do: figure out if we can make this into a clean utility, or even in core. // As it will be useful for GFMs literal autolink extension (and maybe even // tables?) function resolveAllLineSuffixes(events, context) { var eventIndex = -1; var chunks; var data; var chunk; var index; var bufferIndex; var size; var tabs; var token; while (++eventIndex <= events.length) { if ( (eventIndex === events.length || events[eventIndex][1].type === 'lineEnding') && events[eventIndex - 1][1].type === 'data' ) { data = events[eventIndex - 1][1]; chunks = context.sliceStream(data); index = chunks.length; bufferIndex = -1; size = 0; tabs = undefined; while (index--) { chunk = chunks[index]; if (typeof chunk === 'string') { bufferIndex = chunk.length; while (chunk.charCodeAt(bufferIndex - 1) === 32) { size++; bufferIndex--; } if (bufferIndex) break bufferIndex = -1; } // Number else if (chunk === -2) { tabs = true; size++; } else if (chunk === -1); else { // Replacement character, exit. index++; break } } if (size) { token = { type: eventIndex === events.length || tabs || size < 2 ? 'lineSuffix' : 'hardBreakTrailing', start: { line: data.end.line, column: data.end.column - size, offset: data.end.offset - size, _index: data.start._index + index, _bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex }, end: shallow_1(data.end) }; data.end = shallow_1(token.start); if (data.start.offset === data.end.offset) { assign_1(data, token); } else { events.splice( eventIndex, 0, ['enter', token, context], ['exit', token, context] ); eventIndex += 2; } } eventIndex++; } } return events } exports.resolver = resolver; exports.string = string; exports.text = text; }); function chunkedPush(list, items) { if (list.length) { chunkedSplice_1(list, list.length, 0, items); return list } return items } var chunkedPush_1 = chunkedPush; function serializeChunks(chunks) { var index = -1; var result = []; var chunk; var value; var atTab; while (++index < chunks.length) { chunk = chunks[index]; if (typeof chunk === 'string') { value = chunk; } else if (chunk === -5) { value = '\r'; } else if (chunk === -4) { value = '\n'; } else if (chunk === -3) { value = '\r' + '\n'; } else if (chunk === -2) { value = '\t'; } else if (chunk === -1) { if (atTab) continue value = ' '; } else { // Currently only replacement character. value = fromCharCode_1(chunk); } atTab = chunk === -2; result.push(value); } return result.join('') } var serializeChunks_1 = serializeChunks; function sliceChunks(chunks, token) { var startIndex = token.start._index; var startBufferIndex = token.start._bufferIndex; var endIndex = token.end._index; var endBufferIndex = token.end._bufferIndex; var view; if (startIndex === endIndex) { view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]; } else { view = chunks.slice(startIndex, endIndex); if (startBufferIndex > -1) { view[0] = view[0].slice(startBufferIndex); } if (endBufferIndex > 0) { view.push(chunks[endIndex].slice(0, endBufferIndex)); } } return view } var sliceChunks_1 = sliceChunks; // Create a tokenizer. // Tokenizers deal with one type of data (e.g., containers, flow, text). // The parser is the object dealing with it all. // `initialize` works like other constructs, except that only its `tokenize` // function is used, in which case it doesn’t receive an `ok` or `nok`. // `from` can be given to set the point before the first character, although // when further lines are indented, they must be set with `defineSkip`. function createTokenizer(parser, initialize, from) { var point = from ? shallow_1(from) : { line: 1, column: 1, offset: 0 }; var columnStart = {}; var resolveAllConstructs = []; var chunks = []; var stack = []; var effects = { consume: consume, enter: enter, exit: exit, attempt: constructFactory(onsuccessfulconstruct), check: constructFactory(onsuccessfulcheck), interrupt: constructFactory(onsuccessfulcheck, { interrupt: true }), lazy: constructFactory(onsuccessfulcheck, { lazy: true }) }; // State and tools for resolving and serializing. var context = { previous: null, events: [], parser: parser, sliceStream: sliceStream, sliceSerialize: sliceSerialize, now: now, defineSkip: skip, write: write }; // The state function. var state = initialize.tokenize.call(context, effects); // Track which character we expect to be consumed, to catch bugs. if (initialize.resolveAll) { resolveAllConstructs.push(initialize); } // Store where we are in the input stream. point._index = 0; point._bufferIndex = -1; return context function write(slice) { chunks = chunkedPush_1(chunks, slice); main(); // Exit if we’re not done, resolve might change stuff. if (chunks[chunks.length - 1] !== null) { return [] } addResult(initialize, 0); // Otherwise, resolve, and exit. context.events = resolveAll_1(resolveAllConstructs, context.events, context); return context.events } // // Tools. // function sliceSerialize(token) { return serializeChunks_1(sliceStream(token)) } function sliceStream(token) { return sliceChunks_1(chunks, token) } function now() { return shallow_1(point) } function skip(value) { columnStart[value.line] = value.column; accountForPotentialSkip(); } // // State management. // // Main loop (note that `_index` and `_bufferIndex` in `point` are modified by // `consume`). // Here is where we walk through the chunks, which either include strings of // several characters, or numerical character codes. // The reason to do this in a loop instead of a call is so the stack can // drain. function main() { var chunkIndex; var chunk; while (point._index < chunks.length) { chunk = chunks[point._index]; // If we’re in a buffer chunk, loop through it. if (typeof chunk === 'string') { chunkIndex = point._index; if (point._bufferIndex < 0) { point._bufferIndex = 0; } while ( point._index === chunkIndex && point._bufferIndex < chunk.length ) { go(chunk.charCodeAt(point._bufferIndex)); } } else { go(chunk); } } } // Deal with one code. function go(code) { state = state(code); } // Move a character forward. function consume(code) { if (markdownLineEnding_1(code)) { point.line++; point.column = 1; point.offset += code === -3 ? 2 : 1; accountForPotentialSkip(); } else if (code !== -1) { point.column++; point.offset++; } // Not in a string chunk. if (point._bufferIndex < 0) { point._index++; } else { point._bufferIndex++; // At end of string chunk. if (point._bufferIndex === chunks[point._index].length) { point._bufferIndex = -1; point._index++; } } // Expose the previous character. context.previous = code; // Mark as consumed. } // Start a token. function enter(type, fields) { var token = fields || {}; token.type = type; token.start = now(); context.events.push(['enter', token, context]); stack.push(token); return token } // Stop a token. function exit(type) { var token = stack.pop(); token.end = now(); context.events.push(['exit', token, context]); return token } // Use results. function onsuccessfulconstruct(construct, info) { addResult(construct, info.from); } // Discard results. function onsuccessfulcheck(construct, info) { info.restore(); } // Factory to attempt/check/interrupt. function constructFactory(onreturn, fields) { return hook // Handle either an object mapping codes to constructs, a list of // constructs, or a single construct. function hook(constructs, returnState, bogusState) { var listOfConstructs; var constructIndex; var currentConstruct; var info; return constructs.tokenize || 'length' in constructs ? handleListOfConstructs(miniflat_1(constructs)) : handleMapOfConstructs function handleMapOfConstructs(code) { if (code in constructs || null in constructs) { return handleListOfConstructs( constructs.null ? /* c8 ignore next */ miniflat_1(constructs[code]).concat(miniflat_1(constructs.null)) : constructs[code] )(code) } return bogusState(code) } function handleListOfConstructs(list) { listOfConstructs = list; constructIndex = 0; return handleConstruct(list[constructIndex]) } function handleConstruct(construct) { return start function start(code) { // To do: not nede to store if there is no bogus state, probably? // Currently doesn’t work because `inspect` in document does a check // w/o a bogus, which doesn’t make sense. But it does seem to help perf // by not storing. info = store(); currentConstruct = construct; if (!construct.partial) { context.currentConstruct = construct; } if ( construct.name && context.parser.constructs.disable.null.indexOf(construct.name) > -1 ) { return nok() } return construct.tokenize.call( fields ? assign_1({}, context, fields) : context, effects, ok, nok )(code) } } function ok(code) { onreturn(currentConstruct, info); return returnState } function nok(code) { info.restore(); if (++constructIndex < listOfConstructs.length) { return handleConstruct(listOfConstructs[constructIndex]) } return bogusState } } } function addResult(construct, from) { if (construct.resolveAll && resolveAllConstructs.indexOf(construct) < 0) { resolveAllConstructs.push(construct); } if (construct.resolve) { chunkedSplice_1( context.events, from, context.events.length - from, construct.resolve(context.events.slice(from), context) ); } if (construct.resolveTo) { context.events = construct.resolveTo(context.events, context); } } function store() { var startPoint = now(); var startPrevious = context.previous; var startCurrentConstruct = context.currentConstruct; var startEventsIndex = context.events.length; var startStack = Array.from(stack); return { restore: restore, from: startEventsIndex } function restore() { point = startPoint; context.previous = startPrevious; context.currentConstruct = startCurrentConstruct; context.events.length = startEventsIndex; stack = startStack; accountForPotentialSkip(); } } function accountForPotentialSkip() { if (point.line in columnStart && point.column < 2) { point.column = columnStart[point.line]; point.offset += columnStart[point.line] - 1; } } } var createTokenizer_1 = createTokenizer; // chunks (replacement characters, tabs, or line endings). function movePoint(point, offset) { point.column += offset; point.offset += offset; point._bufferIndex += offset; return point } var movePoint_1 = movePoint; var attention = { name: 'attention', tokenize: tokenizeAttention, resolveAll: resolveAllAttention }; function resolveAllAttention(events, context) { var index = -1; var open; var group; var text; var openingSequence; var closingSequence; var use; var nextEvents; var offset; // Walk through all events. // // Note: performance of this is fine on an mb of normal markdown, but it’s // a bottleneck for malicious stuff. while (++index < events.length) { // Find a token that can close. if ( events[index][0] === 'enter' && events[index][1].type === 'attentionSequence' && events[index][1]._close ) { open = index; // Now walk back to find an opener. while (open--) { // Find a token that can open the closer. if ( events[open][0] === 'exit' && events[open][1].type === 'attentionSequence' && events[open][1]._open && // If the markers are the same: context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index][1]).charCodeAt(0) ) { // If the opening can close or the closing can open, // and the close size *is not* a multiple of three, // but the sum of the opening and closing size *is* multiple of three, // then don’t match. if ( (events[open][1]._close || events[index][1]._open) && (events[index][1].end.offset - events[index][1].start.offset) % 3 && !( (events[open][1].end.offset - events[open][1].start.offset + events[index][1].end.offset - events[index][1].start.offset) % 3 ) ) { continue } // Number of markers to use from the sequence. use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1; openingSequence = { type: use > 1 ? 'strongSequence' : 'emphasisSequence', start: movePoint_1(shallow_1(events[open][1].end), -use), end: shallow_1(events[open][1].end) }; closingSequence = { type: use > 1 ? 'strongSequence' : 'emphasisSequence', start: shallow_1(events[index][1].start), end: movePoint_1(shallow_1(events[index][1].start), use) }; text = { type: use > 1 ? 'strongText' : 'emphasisText', start: shallow_1(events[open][1].end), end: shallow_1(events[index][1].start) }; group = { type: use > 1 ? 'strong' : 'emphasis', start: shallow_1(openingSequence.start), end: shallow_1(closingSequence.end) }; events[open][1].end = shallow_1(openingSequence.start); events[index][1].start = shallow_1(closingSequence.end); nextEvents = []; // If there are more markers in the opening, add them before. if (events[open][1].end.offset - events[open][1].start.offset) { nextEvents = chunkedPush_1(nextEvents, [ ['enter', events[open][1], context], ['exit', events[open][1], context] ]); } // Opening. nextEvents = chunkedPush_1(nextEvents, [ ['enter', group, context], ['enter', openingSequence, context], ['exit', openingSequence, context], ['enter', text, context] ]); // Between. nextEvents = chunkedPush_1( nextEvents, resolveAll_1( context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context ) ); // Closing. nextEvents = chunkedPush_1(nextEvents, [ ['exit', text, context], ['enter', closingSequence, context], ['exit', closingSequence, context], ['exit', group, context] ]); // If there are more markers in the closing, add them after. if (events[index][1].end.offset - events[index][1].start.offset) { offset = 2; nextEvents = chunkedPush_1(nextEvents, [ ['enter', events[index][1], context], ['exit', events[index][1], context] ]); } else { offset = 0; } chunkedSplice_1(events, open - 1, index - open + 3, nextEvents); index = open + nextEvents.length - offset - 2; break } } } } // Remove remaining sequences. index = -1; while (++index < events.length) { if (events[index][1].type === 'attentionSequence') { events[index][1].type = 'data'; } } return events } function tokenizeAttention(effects, ok) { var before = classifyCharacter_1(this.previous); var marker; return start function start(code) { effects.enter('attentionSequence'); marker = code; return sequence(code) } function sequence(code) { var token; var after; var open; var close; if (code === marker) { effects.consume(code); return sequence } token = effects.exit('attentionSequence'); after = classifyCharacter_1(code); open = !after || (after === 2 && before); close = !before || (before === 2 && after); token._open = marker === 42 ? open : open && (before || !close); token._close = marker === 42 ? close : close && (after || !open); return ok(code) } } var attention_1 = attention; var asciiAtext = regexCheck_1(/[#-'*+\--9=?A-Z^-~]/); var asciiAtext_1 = asciiAtext; var autolink = { name: 'autolink', tokenize: tokenizeAutolink }; function tokenizeAutolink(effects, ok, nok) { var size = 1; return start function start(code) { effects.enter('autolink'); effects.enter('autolinkMarker'); effects.consume(code); effects.exit('autolinkMarker'); effects.enter('autolinkProtocol'); return open } function open(code) { if (asciiAlpha_1(code)) { effects.consume(code); return schemeOrEmailAtext } return asciiAtext_1(code) ? emailAtext(code) : nok(code) } function schemeOrEmailAtext(code) { return code === 43 || code === 45 || code === 46 || asciiAlphanumeric_1(code) ? schemeInsideOrEmailAtext(code) : emailAtext(code) } function schemeInsideOrEmailAtext(code) { if (code === 58) { effects.consume(code); return urlInside } if ( (code === 43 || code === 45 || code === 46 || asciiAlphanumeric_1(code)) && size++ < 32 ) { effects.consume(code); return schemeInsideOrEmailAtext } return emailAtext(code) } function urlInside(code) { if (code === 62) { effects.exit('autolinkProtocol'); return end(code) } if (code === 32 || code === 60 || asciiControl_1(code)) { return nok(code) } effects.consume(code); return urlInside } function emailAtext(code) { if (code === 64) { effects.consume(code); size = 0; return emailAtSignOrDot } if (asciiAtext_1(code)) { effects.consume(code); return emailAtext } return nok(code) } function emailAtSignOrDot(code) { return asciiAlphanumeric_1(code) ? emailLabel(code) : nok(code) } function emailLabel(code) { if (code === 46) { effects.consume(code); size = 0; return emailAtSignOrDot } if (code === 62) { // Exit, then change the type. effects.exit('autolinkProtocol').type = 'autolinkEmail'; return end(code) } return emailValue(code) } function emailValue(code) { if ((code === 45 || asciiAlphanumeric_1(code)) && size++ < 63) { effects.consume(code); return code === 45 ? emailValue : emailLabel } return nok(code) } function end(code) { effects.enter('autolinkMarker'); effects.consume(code); effects.exit('autolinkMarker'); effects.exit('autolink'); return ok } } var autolink_1 = autolink; var blockQuote = { name: 'blockQuote', tokenize: tokenizeBlockQuoteStart, continuation: { tokenize: tokenizeBlockQuoteContinuation }, exit: exit }; function tokenizeBlockQuoteStart(effects, ok, nok) { var self = this; return start function start(code) { if (code === 62) { if (!self.containerState.open) { effects.enter('blockQuote', { _container: true }); self.containerState.open = true; } effects.enter('blockQuotePrefix'); effects.enter('blockQuoteMarker'); effects.consume(code); effects.exit('blockQuoteMarker'); return after } return nok(code) } function after(code) { if (markdownSpace_1(code)) { effects.enter('blockQuotePrefixWhitespace'); effects.consume(code); effects.exit('blockQuotePrefixWhitespace'); effects.exit('blockQuotePrefix'); return ok } effects.exit('blockQuotePrefix'); return ok(code) } } function tokenizeBlockQuoteContinuation(effects, ok, nok) { return factorySpace( effects, effects.attempt(blockQuote, ok, nok), 'linePrefix', this.parser.constructs.disable.null.indexOf('codeIndented') > -1 ? undefined : 4 ) } function exit(effects) { effects.exit('blockQuote'); } var blockQuote_1 = blockQuote; var asciiPunctuation = regexCheck_1(/[!-/:-@[-`{-~]/); var asciiPunctuation_1 = asciiPunctuation; var characterEscape$2 = { name: 'characterEscape', tokenize: tokenizeCharacterEscape }; function tokenizeCharacterEscape(effects, ok, nok) { return start function start(code) { effects.enter('characterEscape'); effects.enter('escapeMarker'); effects.consume(code); effects.exit('escapeMarker'); return open } function open(code) { if (asciiPunctuation_1(code)) { effects.enter('characterEscapeValue'); effects.consume(code); effects.exit('characterEscapeValue'); effects.exit('characterEscape'); return ok } return nok(code) } } var characterEscape_1 = characterEscape$2; var AEli = "Æ"; var AElig = "Æ"; var AM = "&"; var AMP = "&"; var Aacut = "Á"; var Aacute = "Á"; var Abreve = "Ă"; var Acir = "Â"; var Acirc = "Â"; var Acy = "А"; var Afr = "𝔄"; var Agrav = "À"; var Agrave = "À"; var Alpha = "Α"; var Amacr = "Ā"; var And = "⩓"; var Aogon = "Ą"; var Aopf = "𝔸"; var ApplyFunction = "⁡"; var Arin = "Å"; var Aring = "Å"; var Ascr = "𝒜"; var Assign = "≔"; var Atild = "Ã"; var Atilde = "Ã"; var Aum = "Ä"; var Auml = "Ä"; var Backslash = "∖"; var Barv = "⫧"; var Barwed = "⌆"; var Bcy = "Б"; var Because = "∵"; var Bernoullis = "ℬ"; var Beta = "Β"; var Bfr = "𝔅"; var Bopf = "𝔹"; var Breve = "˘"; var Bscr = "ℬ"; var Bumpeq = "≎"; var CHcy = "Ч"; var COP = "©"; var COPY = "©"; var Cacute = "Ć"; var Cap = "⋒"; var CapitalDifferentialD = "ⅅ"; var Cayleys = "ℭ"; var Ccaron = "Č"; var Ccedi = "Ç"; var Ccedil = "Ç"; var Ccirc = "Ĉ"; var Cconint = "∰"; var Cdot = "Ċ"; var Cedilla = "¸"; var CenterDot = "·"; var Cfr = "ℭ"; var Chi = "Χ"; var CircleDot = "⊙"; var CircleMinus = "⊖"; var CirclePlus = "⊕"; var CircleTimes = "⊗"; var ClockwiseContourIntegral = "∲"; var CloseCurlyDoubleQuote = "”"; var CloseCurlyQuote = "’"; var Colon = "∷"; var Colone = "⩴"; var Congruent = "≡"; var Conint = "∯"; var ContourIntegral = "∮"; var Copf = "ℂ"; var Coproduct = "∐"; var CounterClockwiseContourIntegral = "∳"; var Cross = "⨯"; var Cscr = "𝒞"; var Cup = "⋓"; var CupCap = "≍"; var DD = "ⅅ"; var DDotrahd = "⤑"; var DJcy = "Ђ"; var DScy = "Ѕ"; var DZcy = "Џ"; var Dagger = "‡"; var Darr = "↡"; var Dashv = "⫤"; var Dcaron = "Ď"; var Dcy = "Д"; var Del = "∇"; var Delta = "Δ"; var Dfr = "𝔇"; var DiacriticalAcute = "´"; var DiacriticalDot = "˙"; var DiacriticalDoubleAcute = "˝"; var DiacriticalGrave = "`"; var DiacriticalTilde = "˜"; var Diamond = "⋄"; var DifferentialD = "ⅆ"; var Dopf = "𝔻"; var Dot = "¨"; var DotDot = "⃜"; var DotEqual = "≐"; var DoubleContourIntegral = "∯"; var DoubleDot = "¨"; var DoubleDownArrow = "⇓"; var DoubleLeftArrow = "⇐"; var DoubleLeftRightArrow = "⇔"; var DoubleLeftTee = "⫤"; var DoubleLongLeftArrow = "⟸"; var DoubleLongLeftRightArrow = "⟺"; var DoubleLongRightArrow = "⟹"; var DoubleRightArrow = "⇒"; var DoubleRightTee = "⊨"; var DoubleUpArrow = "⇑"; var DoubleUpDownArrow = "⇕"; var DoubleVerticalBar = "∥"; var DownArrow = "↓"; var DownArrowBar = "⤓"; var DownArrowUpArrow = "⇵"; var DownBreve = "̑"; var DownLeftRightVector = "⥐"; var DownLeftTeeVector = "⥞"; var DownLeftVector = "↽"; var DownLeftVectorBar = "⥖"; var DownRightTeeVector = "⥟"; var DownRightVector = "⇁"; var DownRightVectorBar = "⥗"; var DownTee = "⊤"; var DownTeeArrow = "↧"; var Downarrow = "⇓"; var Dscr = "𝒟"; var Dstrok = "Đ"; var ENG = "Ŋ"; var ET = "Ð"; var ETH = "Ð"; var Eacut = "É"; var Eacute = "É"; var Ecaron = "Ě"; var Ecir = "Ê"; var Ecirc = "Ê"; var Ecy = "Э"; var Edot = "Ė"; var Efr = "𝔈"; var Egrav = "È"; var Egrave = "È"; var Element = "∈"; var Emacr = "Ē"; var EmptySmallSquare = "◻"; var EmptyVerySmallSquare = "▫"; var Eogon = "Ę"; var Eopf = "𝔼"; var Epsilon = "Ε"; var Equal = "⩵"; var EqualTilde = "≂"; var Equilibrium = "⇌"; var Escr = "ℰ"; var Esim = "⩳"; var Eta = "Η"; var Eum = "Ë"; var Euml = "Ë"; var Exists = "∃"; var ExponentialE = "ⅇ"; var Fcy = "Ф"; var Ffr = "𝔉"; var FilledSmallSquare = "◼"; var FilledVerySmallSquare = "▪"; var Fopf = "𝔽"; var ForAll = "∀"; var Fouriertrf = "ℱ"; var Fscr = "ℱ"; var GJcy = "Ѓ"; var G = ">"; var GT = ">"; var Gamma = "Γ"; var Gammad = "Ϝ"; var Gbreve = "Ğ"; var Gcedil = "Ģ"; var Gcirc = "Ĝ"; var Gcy = "Г"; var Gdot = "Ġ"; var Gfr = "𝔊"; var Gg = "⋙"; var Gopf = "𝔾"; var GreaterEqual = "≥"; var GreaterEqualLess = "⋛"; var GreaterFullEqual = "≧"; var GreaterGreater = "⪢"; var GreaterLess = "≷"; var GreaterSlantEqual = "⩾"; var GreaterTilde = "≳"; var Gscr = "𝒢"; var Gt = "≫"; var HARDcy = "Ъ"; var Hacek = "ˇ"; var Hat = "^"; var Hcirc = "Ĥ"; var Hfr = "ℌ"; var HilbertSpace = "ℋ"; var Hopf = "ℍ"; var HorizontalLine = "─"; var Hscr = "ℋ"; var Hstrok = "Ħ"; var HumpDownHump = "≎"; var HumpEqual = "≏"; var IEcy = "Е"; var IJlig = "IJ"; var IOcy = "Ё"; var Iacut = "Í"; var Iacute = "Í"; var Icir = "Î"; var Icirc = "Î"; var Icy = "И"; var Idot = "İ"; var Ifr = "ℑ"; var Igrav = "Ì"; var Igrave = "Ì"; var Im = "ℑ"; var Imacr = "Ī"; var ImaginaryI = "ⅈ"; var Implies = "⇒"; var Int = "∬"; var Integral = "∫"; var Intersection = "⋂"; var InvisibleComma = "⁣"; var InvisibleTimes = "⁢"; var Iogon = "Į"; var Iopf = "𝕀"; var Iota = "Ι"; var Iscr = "ℐ"; var Itilde = "Ĩ"; var Iukcy = "І"; var Ium = "Ï"; var Iuml = "Ï"; var Jcirc = "Ĵ"; var Jcy = "Й"; var Jfr = "𝔍"; var Jopf = "𝕁"; var Jscr = "𝒥"; var Jsercy = "Ј"; var Jukcy = "Є"; var KHcy = "Х"; var KJcy = "Ќ"; var Kappa = "Κ"; var Kcedil = "Ķ"; var Kcy = "К"; var Kfr = "𝔎"; var Kopf = "𝕂"; var Kscr = "𝒦"; var LJcy = "Љ"; var L = "<"; var LT = "<"; var Lacute = "Ĺ"; var Lambda = "Λ"; var Lang = "⟪"; var Laplacetrf = "ℒ"; var Larr = "↞"; var Lcaron = "Ľ"; var Lcedil = "Ļ"; var Lcy = "Л"; var LeftAngleBracket = "⟨"; var LeftArrow = "←"; var LeftArrowBar = "⇤"; var LeftArrowRightArrow = "⇆"; var LeftCeiling = "⌈"; var LeftDoubleBracket = "⟦"; var LeftDownTeeVector = "⥡"; var LeftDownVector = "⇃"; var LeftDownVectorBar = "⥙"; var LeftFloor = "⌊"; var LeftRightArrow = "↔"; var LeftRightVector = "⥎"; var LeftTee = "⊣"; var LeftTeeArrow = "↤"; var LeftTeeVector = "⥚"; var LeftTriangle = "⊲"; var LeftTriangleBar = "⧏"; var LeftTriangleEqual = "⊴"; var LeftUpDownVector = "⥑"; var LeftUpTeeVector = "⥠"; var LeftUpVector = "↿"; var LeftUpVectorBar = "⥘"; var LeftVector = "↼"; var LeftVectorBar = "⥒"; var Leftarrow = "⇐"; var Leftrightarrow = "⇔"; var LessEqualGreater = "⋚"; var LessFullEqual = "≦"; var LessGreater = "≶"; var LessLess = "⪡"; var LessSlantEqual = "⩽"; var LessTilde = "≲"; var Lfr = "𝔏"; var Ll = "⋘"; var Lleftarrow = "⇚"; var Lmidot = "Ŀ"; var LongLeftArrow = "⟵"; var LongLeftRightArrow = "⟷"; var LongRightArrow = "⟶"; var Longleftarrow = "⟸"; var Longleftrightarrow = "⟺"; var Longrightarrow = "⟹"; var Lopf = "𝕃"; var LowerLeftArrow = "↙"; var LowerRightArrow = "↘"; var Lscr = "ℒ"; var Lsh = "↰"; var Lstrok = "Ł"; var Lt = "≪"; var Mcy = "М"; var MediumSpace = " "; var Mellintrf = "ℳ"; var Mfr = "𝔐"; var MinusPlus = "∓"; var Mopf = "𝕄"; var Mscr = "ℳ"; var Mu = "Μ"; var NJcy = "Њ"; var Nacute = "Ń"; var Ncaron = "Ň"; var Ncedil = "Ņ"; var Ncy = "Н"; var NegativeMediumSpace = "​"; var NegativeThickSpace = "​"; var NegativeThinSpace = "​"; var NegativeVeryThinSpace = "​"; var NestedGreaterGreater = "≫"; var NestedLessLess = "≪"; var NewLine = "\n"; var Nfr = "𝔑"; var NoBreak = "⁠"; var NonBreakingSpace = " "; var Nopf = "ℕ"; var Not = "⫬"; var NotCongruent = "≢"; var NotCupCap = "≭"; var NotDoubleVerticalBar = "∦"; var NotElement = "∉"; var NotEqual = "≠"; var NotEqualTilde = "≂̸"; var NotExists = "∄"; var NotGreater = "≯"; var NotGreaterEqual = "≱"; var NotGreaterFullEqual = "≧̸"; var NotGreaterGreater = "≫̸"; var NotGreaterLess = "≹"; var NotGreaterSlantEqual = "⩾̸"; var NotGreaterTilde = "≵"; var NotHumpDownHump = "≎̸"; var NotHumpEqual = "≏̸"; var NotLeftTriangle = "⋪"; var NotLeftTriangleBar = "⧏̸"; var NotLeftTriangleEqual = "⋬"; var NotLess = "≮"; var NotLessEqual = "≰"; var NotLessGreater = "≸"; var NotLessLess = "≪̸"; var NotLessSlantEqual = "⩽̸"; var NotLessTilde = "≴"; var NotNestedGreaterGreater = "⪢̸"; var NotNestedLessLess = "⪡̸"; var NotPrecedes = "⊀"; var NotPrecedesEqual = "⪯̸"; var NotPrecedesSlantEqual = "⋠"; var NotReverseElement = "∌"; var NotRightTriangle = "⋫"; var NotRightTriangleBar = "⧐̸"; var NotRightTriangleEqual = "⋭"; var NotSquareSubset = "⊏̸"; var NotSquareSubsetEqual = "⋢"; var NotSquareSuperset = "⊐̸"; var NotSquareSupersetEqual = "⋣"; var NotSubset = "⊂⃒"; var NotSubsetEqual = "⊈"; var NotSucceeds = "⊁"; var NotSucceedsEqual = "⪰̸"; var NotSucceedsSlantEqual = "⋡"; var NotSucceedsTilde = "≿̸"; var NotSuperset = "⊃⃒"; var NotSupersetEqual = "⊉"; var NotTilde = "≁"; var NotTildeEqual = "≄"; var NotTildeFullEqual = "≇"; var NotTildeTilde = "≉"; var NotVerticalBar = "∤"; var Nscr = "𝒩"; var Ntild = "Ñ"; var Ntilde = "Ñ"; var Nu = "Ν"; var OElig = "Œ"; var Oacut = "Ó"; var Oacute = "Ó"; var Ocir = "Ô"; var Ocirc = "Ô"; var Ocy = "О"; var Odblac = "Ő"; var Ofr = "𝔒"; var Ograv = "Ò"; var Ograve = "Ò"; var Omacr = "Ō"; var Omega = "Ω"; var Omicron = "Ο"; var Oopf = "𝕆"; var OpenCurlyDoubleQuote = "“"; var OpenCurlyQuote = "‘"; var Or = "⩔"; var Oscr = "𝒪"; var Oslas = "Ø"; var Oslash = "Ø"; var Otild = "Õ"; var Otilde = "Õ"; var Otimes = "⨷"; var Oum = "Ö"; var Ouml = "Ö"; var OverBar = "‾"; var OverBrace = "⏞"; var OverBracket = "⎴"; var OverParenthesis = "⏜"; var PartialD = "∂"; var Pcy = "П"; var Pfr = "𝔓"; var Phi = "Φ"; var Pi = "Π"; var PlusMinus = "±"; var Poincareplane = "ℌ"; var Popf = "ℙ"; var Pr = "⪻"; var Precedes = "≺"; var PrecedesEqual = "⪯"; var PrecedesSlantEqual = "≼"; var PrecedesTilde = "≾"; var Prime = "″"; var Product = "∏"; var Proportion = "∷"; var Proportional = "∝"; var Pscr = "𝒫"; var Psi = "Ψ"; var QUO = "\""; var QUOT = "\""; var Qfr = "𝔔"; var Qopf = "ℚ"; var Qscr = "𝒬"; var RBarr = "⤐"; var RE = "®"; var REG = "®"; var Racute = "Ŕ"; var Rang = "⟫"; var Rarr = "↠"; var Rarrtl = "⤖"; var Rcaron = "Ř"; var Rcedil = "Ŗ"; var Rcy = "Р"; var Re = "ℜ"; var ReverseElement = "∋"; var ReverseEquilibrium = "⇋"; var ReverseUpEquilibrium = "⥯"; var Rfr = "ℜ"; var Rho = "Ρ"; var RightAngleBracket = "⟩"; var RightArrow = "→"; var RightArrowBar = "⇥"; var RightArrowLeftArrow = "⇄"; var RightCeiling = "⌉"; var RightDoubleBracket = "⟧"; var RightDownTeeVector = "⥝"; var RightDownVector = "⇂"; var RightDownVectorBar = "⥕"; var RightFloor = "⌋"; var RightTee = "⊢"; var RightTeeArrow = "↦"; var RightTeeVector = "⥛"; var RightTriangle = "⊳"; var RightTriangleBar = "⧐"; var RightTriangleEqual = "⊵"; var RightUpDownVector = "⥏"; var RightUpTeeVector = "⥜"; var RightUpVector = "↾"; var RightUpVectorBar = "⥔"; var RightVector = "⇀"; var RightVectorBar = "⥓"; var Rightarrow = "⇒"; var Ropf = "ℝ"; var RoundImplies = "⥰"; var Rrightarrow = "⇛"; var Rscr = "ℛ"; var Rsh = "↱"; var RuleDelayed = "⧴"; var SHCHcy = "Щ"; var SHcy = "Ш"; var SOFTcy = "Ь"; var Sacute = "Ś"; var Sc = "⪼"; var Scaron = "Š"; var Scedil = "Ş"; var Scirc = "Ŝ"; var Scy = "С"; var Sfr = "𝔖"; var ShortDownArrow = "↓"; var ShortLeftArrow = "←"; var ShortRightArrow = "→"; var ShortUpArrow = "↑"; var Sigma = "Σ"; var SmallCircle = "∘"; var Sopf = "𝕊"; var Sqrt = "√"; var Square = "□"; var SquareIntersection = "⊓"; var SquareSubset = "⊏"; var SquareSubsetEqual = "⊑"; var SquareSuperset = "⊐"; var SquareSupersetEqual = "⊒"; var SquareUnion = "⊔"; var Sscr = "𝒮"; var Star = "⋆"; var Sub = "⋐"; var Subset = "⋐"; var SubsetEqual = "⊆"; var Succeeds = "≻"; var SucceedsEqual = "⪰"; var SucceedsSlantEqual = "≽"; var SucceedsTilde = "≿"; var SuchThat = "∋"; var Sum = "∑"; var Sup = "⋑"; var Superset = "⊃"; var SupersetEqual = "⊇"; var Supset = "⋑"; var THOR = "Þ"; var THORN = "Þ"; var TRADE = "™"; var TSHcy = "Ћ"; var TScy = "Ц"; var Tab = "\t"; var Tau = "Τ"; var Tcaron = "Ť"; var Tcedil = "Ţ"; var Tcy = "Т"; var Tfr = "𝔗"; var Therefore = "∴"; var Theta = "Θ"; var ThickSpace = "  "; var ThinSpace = " "; var Tilde = "∼"; var TildeEqual = "≃"; var TildeFullEqual = "≅"; var TildeTilde = "≈"; var Topf = "𝕋"; var TripleDot = "⃛"; var Tscr = "𝒯"; var Tstrok = "Ŧ"; var Uacut = "Ú"; var Uacute = "Ú"; var Uarr = "↟"; var Uarrocir = "⥉"; var Ubrcy = "Ў"; var Ubreve = "Ŭ"; var Ucir = "Û"; var Ucirc = "Û"; var Ucy = "У"; var Udblac = "Ű"; var Ufr = "𝔘"; var Ugrav = "Ù"; var Ugrave = "Ù"; var Umacr = "Ū"; var UnderBar = "_"; var UnderBrace = "⏟"; var UnderBracket = "⎵"; var UnderParenthesis = "⏝"; var Union = "⋃"; var UnionPlus = "⊎"; var Uogon = "Ų"; var Uopf = "𝕌"; var UpArrow = "↑"; var UpArrowBar = "⤒"; var UpArrowDownArrow = "⇅"; var UpDownArrow = "↕"; var UpEquilibrium = "⥮"; var UpTee = "⊥"; var UpTeeArrow = "↥"; var Uparrow = "⇑"; var Updownarrow = "⇕"; var UpperLeftArrow = "↖"; var UpperRightArrow = "↗"; var Upsi = "ϒ"; var Upsilon = "Υ"; var Uring = "Ů"; var Uscr = "𝒰"; var Utilde = "Ũ"; var Uum = "Ü"; var Uuml = "Ü"; var VDash = "⊫"; var Vbar = "⫫"; var Vcy = "В"; var Vdash = "⊩"; var Vdashl = "⫦"; var Vee = "⋁"; var Verbar = "‖"; var Vert = "‖"; var VerticalBar = "∣"; var VerticalLine = "|"; var VerticalSeparator = "❘"; var VerticalTilde = "≀"; var VeryThinSpace = " "; var Vfr = "𝔙"; var Vopf = "𝕍"; var Vscr = "𝒱"; var Vvdash = "⊪"; var Wcirc = "Ŵ"; var Wedge = "⋀"; var Wfr = "𝔚"; var Wopf = "𝕎"; var Wscr = "𝒲"; var Xfr = "𝔛"; var Xi = "Ξ"; var Xopf = "𝕏"; var Xscr = "𝒳"; var YAcy = "Я"; var YIcy = "Ї"; var YUcy = "Ю"; var Yacut = "Ý"; var Yacute = "Ý"; var Ycirc = "Ŷ"; var Ycy = "Ы"; var Yfr = "𝔜"; var Yopf = "𝕐"; var Yscr = "𝒴"; var Yuml = "Ÿ"; var ZHcy = "Ж"; var Zacute = "Ź"; var Zcaron = "Ž"; var Zcy = "З"; var Zdot = "Ż"; var ZeroWidthSpace = "​"; var Zeta = "Ζ"; var Zfr = "ℨ"; var Zopf = "ℤ"; var Zscr = "𝒵"; var aacut = "á"; var aacute = "á"; var abreve = "ă"; var ac = "∾"; var acE = "∾̳"; var acd = "∿"; var acir = "â"; var acirc = "â"; var acut = "´"; var acute = "´"; var acy = "а"; var aeli = "æ"; var aelig = "æ"; var af = "⁡"; var afr = "𝔞"; var agrav = "à"; var agrave = "à"; var alefsym = "ℵ"; var aleph = "ℵ"; var alpha = "α"; var amacr = "ā"; var amalg = "⨿"; var am = "&"; var amp = "&"; var and = "∧"; var andand = "⩕"; var andd = "⩜"; var andslope = "⩘"; var andv = "⩚"; var ang = "∠"; var ange = "⦤"; var angle = "∠"; var angmsd = "∡"; var angmsdaa = "⦨"; var angmsdab = "⦩"; var angmsdac = "⦪"; var angmsdad = "⦫"; var angmsdae = "⦬"; var angmsdaf = "⦭"; var angmsdag = "⦮"; var angmsdah = "⦯"; var angrt = "∟"; var angrtvb = "⊾"; var angrtvbd = "⦝"; var angsph = "∢"; var angst = "Å"; var angzarr = "⍼"; var aogon = "ą"; var aopf = "𝕒"; var ap = "≈"; var apE = "⩰"; var apacir = "⩯"; var ape = "≊"; var apid = "≋"; var apos = "'"; var approx = "≈"; var approxeq = "≊"; var arin = "å"; var aring = "å"; var ascr = "𝒶"; var ast = "*"; var asymp = "≈"; var asympeq = "≍"; var atild = "ã"; var atilde = "ã"; var aum = "ä"; var auml = "ä"; var awconint = "∳"; var awint = "⨑"; var bNot = "⫭"; var backcong = "≌"; var backepsilon = "϶"; var backprime = "‵"; var backsim = "∽"; var backsimeq = "⋍"; var barvee = "⊽"; var barwed = "⌅"; var barwedge = "⌅"; var bbrk = "⎵"; var bbrktbrk = "⎶"; var bcong = "≌"; var bcy = "б"; var bdquo = "„"; var becaus = "∵"; var because = "∵"; var bemptyv = "⦰"; var bepsi = "϶"; var bernou = "ℬ"; var beta = "β"; var beth = "ℶ"; var between = "≬"; var bfr = "𝔟"; var bigcap = "⋂"; var bigcirc = "◯"; var bigcup = "⋃"; var bigodot = "⨀"; var bigoplus = "⨁"; var bigotimes = "⨂"; var bigsqcup = "⨆"; var bigstar = "★"; var bigtriangledown = "▽"; var bigtriangleup = "△"; var biguplus = "⨄"; var bigvee = "⋁"; var bigwedge = "⋀"; var bkarow = "⤍"; var blacklozenge = "⧫"; var blacksquare = "▪"; var blacktriangle = "▴"; var blacktriangledown = "▾"; var blacktriangleleft = "◂"; var blacktriangleright = "▸"; var blank = "␣"; var blk12 = "▒"; var blk14 = "░"; var blk34 = "▓"; var block = "█"; var bne = "=⃥"; var bnequiv = "≡⃥"; var bnot = "⌐"; var bopf = "𝕓"; var bot = "⊥"; var bottom = "⊥"; var bowtie = "⋈"; var boxDL = "╗"; var boxDR = "╔"; var boxDl = "╖"; var boxDr = "╓"; var boxH = "═"; var boxHD = "╦"; var boxHU = "╩"; var boxHd = "╤"; var boxHu = "╧"; var boxUL = "╝"; var boxUR = "╚"; var boxUl = "╜"; var boxUr = "╙"; var boxV = "║"; var boxVH = "╬"; var boxVL = "╣"; var boxVR = "╠"; var boxVh = "╫"; var boxVl = "╢"; var boxVr = "╟"; var boxbox = "⧉"; var boxdL = "╕"; var boxdR = "╒"; var boxdl = "┐"; var boxdr = "┌"; var boxh = "─"; var boxhD = "╥"; var boxhU = "╨"; var boxhd = "┬"; var boxhu = "┴"; var boxminus = "⊟"; var boxplus = "⊞"; var boxtimes = "⊠"; var boxuL = "╛"; var boxuR = "╘"; var boxul = "┘"; var boxur = "└"; var boxv = "│"; var boxvH = "╪"; var boxvL = "╡"; var boxvR = "╞"; var boxvh = "┼"; var boxvl = "┤"; var boxvr = "├"; var bprime = "‵"; var breve = "˘"; var brvba = "¦"; var brvbar = "¦"; var bscr = "𝒷"; var bsemi = "⁏"; var bsim = "∽"; var bsime = "⋍"; var bsol = "\\"; var bsolb = "⧅"; var bsolhsub = "⟈"; var bull = "•"; var bullet = "•"; var bump = "≎"; var bumpE = "⪮"; var bumpe = "≏"; var bumpeq = "≏"; var cacute = "ć"; var cap = "∩"; var capand = "⩄"; var capbrcup = "⩉"; var capcap = "⩋"; var capcup = "⩇"; var capdot = "⩀"; var caps = "∩︀"; var caret = "⁁"; var caron = "ˇ"; var ccaps = "⩍"; var ccaron = "č"; var ccedi = "ç"; var ccedil = "ç"; var ccirc = "ĉ"; var ccups = "⩌"; var ccupssm = "⩐"; var cdot = "ċ"; var cedi = "¸"; var cedil = "¸"; var cemptyv = "⦲"; var cen = "¢"; var cent = "¢"; var centerdot = "·"; var cfr = "𝔠"; var chcy = "ч"; var check = "✓"; var checkmark = "✓"; var chi = "χ"; var cir = "○"; var cirE = "⧃"; var circ = "ˆ"; var circeq = "≗"; var circlearrowleft = "↺"; var circlearrowright = "↻"; var circledR = "®"; var circledS = "Ⓢ"; var circledast = "⊛"; var circledcirc = "⊚"; var circleddash = "⊝"; var cire = "≗"; var cirfnint = "⨐"; var cirmid = "⫯"; var cirscir = "⧂"; var clubs = "♣"; var clubsuit = "♣"; var colon = ":"; var colone = "≔"; var coloneq = "≔"; var comma = ","; var commat = "@"; var comp = "∁"; var compfn = "∘"; var complement = "∁"; var complexes = "ℂ"; var cong = "≅"; var congdot = "⩭"; var conint = "∮"; var copf = "𝕔"; var coprod = "∐"; var cop = "©"; var copy = "©"; var copysr = "℗"; var crarr = "↵"; var cross = "✗"; var cscr = "𝒸"; var csub = "⫏"; var csube = "⫑"; var csup = "⫐"; var csupe = "⫒"; var ctdot = "⋯"; var cudarrl = "⤸"; var cudarrr = "⤵"; var cuepr = "⋞"; var cuesc = "⋟"; var cularr = "↶"; var cularrp = "⤽"; var cup = "∪"; var cupbrcap = "⩈"; var cupcap = "⩆"; var cupcup = "⩊"; var cupdot = "⊍"; var cupor = "⩅"; var cups = "∪︀"; var curarr = "↷"; var curarrm = "⤼"; var curlyeqprec = "⋞"; var curlyeqsucc = "⋟"; var curlyvee = "⋎"; var curlywedge = "⋏"; var curre = "¤"; var curren = "¤"; var curvearrowleft = "↶"; var curvearrowright = "↷"; var cuvee = "⋎"; var cuwed = "⋏"; var cwconint = "∲"; var cwint = "∱"; var cylcty = "⌭"; var dArr = "⇓"; var dHar = "⥥"; var dagger = "†"; var daleth = "ℸ"; var darr = "↓"; var dash = "‐"; var dashv = "⊣"; var dbkarow = "⤏"; var dblac = "˝"; var dcaron = "ď"; var dcy = "д"; var dd = "ⅆ"; var ddagger = "‡"; var ddarr = "⇊"; var ddotseq = "⩷"; var de = "°"; var deg = "°"; var delta = "δ"; var demptyv = "⦱"; var dfisht = "⥿"; var dfr = "𝔡"; var dharl = "⇃"; var dharr = "⇂"; var diam = "⋄"; var diamond = "⋄"; var diamondsuit = "♦"; var diams = "♦"; var die = "¨"; var digamma = "ϝ"; var disin = "⋲"; var div = "÷"; var divid = "÷"; var divide = "÷"; var divideontimes = "⋇"; var divonx = "⋇"; var djcy = "ђ"; var dlcorn = "⌞"; var dlcrop = "⌍"; var dollar = "$"; var dopf = "𝕕"; var dot = "˙"; var doteq = "≐"; var doteqdot = "≑"; var dotminus = "∸"; var dotplus = "∔"; var dotsquare = "⊡"; var doublebarwedge = "⌆"; var downarrow = "↓"; var downdownarrows = "⇊"; var downharpoonleft = "⇃"; var downharpoonright = "⇂"; var drbkarow = "⤐"; var drcorn = "⌟"; var drcrop = "⌌"; var dscr = "𝒹"; var dscy = "ѕ"; var dsol = "⧶"; var dstrok = "đ"; var dtdot = "⋱"; var dtri = "▿"; var dtrif = "▾"; var duarr = "⇵"; var duhar = "⥯"; var dwangle = "⦦"; var dzcy = "џ"; var dzigrarr = "⟿"; var eDDot = "⩷"; var eDot = "≑"; var eacut = "é"; var eacute = "é"; var easter = "⩮"; var ecaron = "ě"; var ecir = "ê"; var ecirc = "ê"; var ecolon = "≕"; var ecy = "э"; var edot = "ė"; var ee = "ⅇ"; var efDot = "≒"; var efr = "𝔢"; var eg = "⪚"; var egrav = "è"; var egrave = "è"; var egs = "⪖"; var egsdot = "⪘"; var el = "⪙"; var elinters = "⏧"; var ell = "ℓ"; var els = "⪕"; var elsdot = "⪗"; var emacr = "ē"; var empty = "∅"; var emptyset = "∅"; var emptyv = "∅"; var emsp13 = " "; var emsp14 = " "; var emsp = " "; var eng = "ŋ"; var ensp = " "; var eogon = "ę"; var eopf = "𝕖"; var epar = "⋕"; var eparsl = "⧣"; var eplus = "⩱"; var epsi = "ε"; var epsilon = "ε"; var epsiv = "ϵ"; var eqcirc = "≖"; var eqcolon = "≕"; var eqsim = "≂"; var eqslantgtr = "⪖"; var eqslantless = "⪕"; var equals = "="; var equest = "≟"; var equiv = "≡"; var equivDD = "⩸"; var eqvparsl = "⧥"; var erDot = "≓"; var erarr = "⥱"; var escr = "ℯ"; var esdot = "≐"; var esim = "≂"; var eta = "η"; var et = "ð"; var eth = "ð"; var eum = "ë"; var euml = "ë"; var euro = "€"; var excl = "!"; var exist = "∃"; var expectation = "ℰ"; var exponentiale = "ⅇ"; var fallingdotseq = "≒"; var fcy = "ф"; var female = "♀"; var ffilig = "ffi"; var fflig = "ff"; var ffllig = "ffl"; var ffr = "𝔣"; var filig = "fi"; var fjlig = "fj"; var flat = "♭"; var fllig = "fl"; var fltns = "▱"; var fnof = "ƒ"; var fopf = "𝕗"; var forall = "∀"; var fork = "⋔"; var forkv = "⫙"; var fpartint = "⨍"; var frac1 = "¼"; var frac12 = "½"; var frac13 = "⅓"; var frac14 = "¼"; var frac15 = "⅕"; var frac16 = "⅙"; var frac18 = "⅛"; var frac23 = "⅔"; var frac25 = "⅖"; var frac3 = "¾"; var frac34 = "¾"; var frac35 = "⅗"; var frac38 = "⅜"; var frac45 = "⅘"; var frac56 = "⅚"; var frac58 = "⅝"; var frac78 = "⅞"; var frasl = "⁄"; var frown = "⌢"; var fscr = "𝒻"; var gE = "≧"; var gEl = "⪌"; var gacute = "ǵ"; var gamma = "γ"; var gammad = "ϝ"; var gap = "⪆"; var gbreve = "ğ"; var gcirc = "ĝ"; var gcy = "г"; var gdot = "ġ"; var ge = "≥"; var gel = "⋛"; var geq = "≥"; var geqq = "≧"; var geqslant = "⩾"; var ges = "⩾"; var gescc = "⪩"; var gesdot = "⪀"; var gesdoto = "⪂"; var gesdotol = "⪄"; var gesl = "⋛︀"; var gesles = "⪔"; var gfr = "𝔤"; var gg = "≫"; var ggg = "⋙"; var gimel = "ℷ"; var gjcy = "ѓ"; var gl = "≷"; var glE = "⪒"; var gla = "⪥"; var glj = "⪤"; var gnE = "≩"; var gnap = "⪊"; var gnapprox = "⪊"; var gne = "⪈"; var gneq = "⪈"; var gneqq = "≩"; var gnsim = "⋧"; var gopf = "𝕘"; var grave = "`"; var gscr = "ℊ"; var gsim = "≳"; var gsime = "⪎"; var gsiml = "⪐"; var g = ">"; var gt = ">"; var gtcc = "⪧"; var gtcir = "⩺"; var gtdot = "⋗"; var gtlPar = "⦕"; var gtquest = "⩼"; var gtrapprox = "⪆"; var gtrarr = "⥸"; var gtrdot = "⋗"; var gtreqless = "⋛"; var gtreqqless = "⪌"; var gtrless = "≷"; var gtrsim = "≳"; var gvertneqq = "≩︀"; var gvnE = "≩︀"; var hArr = "⇔"; var hairsp = " "; var half = "½"; var hamilt = "ℋ"; var hardcy = "ъ"; var harr = "↔"; var harrcir = "⥈"; var harrw = "↭"; var hbar = "ℏ"; var hcirc = "ĥ"; var hearts = "♥"; var heartsuit = "♥"; var hellip = "…"; var hercon = "⊹"; var hfr = "𝔥"; var hksearow = "⤥"; var hkswarow = "⤦"; var hoarr = "⇿"; var homtht = "∻"; var hookleftarrow = "↩"; var hookrightarrow = "↪"; var hopf = "𝕙"; var horbar = "―"; var hscr = "𝒽"; var hslash = "ℏ"; var hstrok = "ħ"; var hybull = "⁃"; var hyphen = "‐"; var iacut = "í"; var iacute = "í"; var ic = "⁣"; var icir = "î"; var icirc = "î"; var icy = "и"; var iecy = "е"; var iexc = "¡"; var iexcl = "¡"; var iff = "⇔"; var ifr = "𝔦"; var igrav = "ì"; var igrave = "ì"; var ii = "ⅈ"; var iiiint = "⨌"; var iiint = "∭"; var iinfin = "⧜"; var iiota = "℩"; var ijlig = "ij"; var imacr = "ī"; var image$4 = "ℑ"; var imagline = "ℐ"; var imagpart = "ℑ"; var imath = "ı"; var imof = "⊷"; var imped = "Ƶ"; var incare = "℅"; var infin = "∞"; var infintie = "⧝"; var inodot = "ı"; var int = "∫"; var intcal = "⊺"; var integers = "ℤ"; var intercal = "⊺"; var intlarhk = "⨗"; var intprod = "⨼"; var iocy = "ё"; var iogon = "į"; var iopf = "𝕚"; var iota = "ι"; var iprod = "⨼"; var iques = "¿"; var iquest = "¿"; var iscr = "𝒾"; var isin = "∈"; var isinE = "⋹"; var isindot = "⋵"; var isins = "⋴"; var isinsv = "⋳"; var isinv = "∈"; var it = "⁢"; var itilde = "ĩ"; var iukcy = "і"; var ium = "ï"; var iuml = "ï"; var jcirc = "ĵ"; var jcy = "й"; var jfr = "𝔧"; var jmath = "ȷ"; var jopf = "𝕛"; var jscr = "𝒿"; var jsercy = "ј"; var jukcy = "є"; var kappa = "κ"; var kappav = "ϰ"; var kcedil = "ķ"; var kcy = "к"; var kfr = "𝔨"; var kgreen = "ĸ"; var khcy = "х"; var kjcy = "ќ"; var kopf = "𝕜"; var kscr = "𝓀"; var lAarr = "⇚"; var lArr = "⇐"; var lAtail = "⤛"; var lBarr = "⤎"; var lE = "≦"; var lEg = "⪋"; var lHar = "⥢"; var lacute = "ĺ"; var laemptyv = "⦴"; var lagran = "ℒ"; var lambda = "λ"; var lang = "⟨"; var langd = "⦑"; var langle = "⟨"; var lap = "⪅"; var laqu = "«"; var laquo = "«"; var larr = "←"; var larrb = "⇤"; var larrbfs = "⤟"; var larrfs = "⤝"; var larrhk = "↩"; var larrlp = "↫"; var larrpl = "⤹"; var larrsim = "⥳"; var larrtl = "↢"; var lat = "⪫"; var latail = "⤙"; var late = "⪭"; var lates = "⪭︀"; var lbarr = "⤌"; var lbbrk = "❲"; var lbrace = "{"; var lbrack = "["; var lbrke = "⦋"; var lbrksld = "⦏"; var lbrkslu = "⦍"; var lcaron = "ľ"; var lcedil = "ļ"; var lceil = "⌈"; var lcub = "{"; var lcy = "л"; var ldca = "⤶"; var ldquo = "“"; var ldquor = "„"; var ldrdhar = "⥧"; var ldrushar = "⥋"; var ldsh = "↲"; var le = "≤"; var leftarrow = "←"; var leftarrowtail = "↢"; var leftharpoondown = "↽"; var leftharpoonup = "↼"; var leftleftarrows = "⇇"; var leftrightarrow = "↔"; var leftrightarrows = "⇆"; var leftrightharpoons = "⇋"; var leftrightsquigarrow = "↭"; var leftthreetimes = "⋋"; var leg = "⋚"; var leq = "≤"; var leqq = "≦"; var leqslant = "⩽"; var les = "⩽"; var lescc = "⪨"; var lesdot = "⩿"; var lesdoto = "⪁"; var lesdotor = "⪃"; var lesg = "⋚︀"; var lesges = "⪓"; var lessapprox = "⪅"; var lessdot = "⋖"; var lesseqgtr = "⋚"; var lesseqqgtr = "⪋"; var lessgtr = "≶"; var lesssim = "≲"; var lfisht = "⥼"; var lfloor = "⌊"; var lfr = "𝔩"; var lg = "≶"; var lgE = "⪑"; var lhard = "↽"; var lharu = "↼"; var lharul = "⥪"; var lhblk = "▄"; var ljcy = "љ"; var ll = "≪"; var llarr = "⇇"; var llcorner = "⌞"; var llhard = "⥫"; var lltri = "◺"; var lmidot = "ŀ"; var lmoust = "⎰"; var lmoustache = "⎰"; var lnE = "≨"; var lnap = "⪉"; var lnapprox = "⪉"; var lne = "⪇"; var lneq = "⪇"; var lneqq = "≨"; var lnsim = "⋦"; var loang = "⟬"; var loarr = "⇽"; var lobrk = "⟦"; var longleftarrow = "⟵"; var longleftrightarrow = "⟷"; var longmapsto = "⟼"; var longrightarrow = "⟶"; var looparrowleft = "↫"; var looparrowright = "↬"; var lopar = "⦅"; var lopf = "𝕝"; var loplus = "⨭"; var lotimes = "⨴"; var lowast = "∗"; var lowbar = "_"; var loz = "◊"; var lozenge = "◊"; var lozf = "⧫"; var lpar = "("; var lparlt = "⦓"; var lrarr = "⇆"; var lrcorner = "⌟"; var lrhar = "⇋"; var lrhard = "⥭"; var lrm = "‎"; var lrtri = "⊿"; var lsaquo = "‹"; var lscr = "𝓁"; var lsh = "↰"; var lsim = "≲"; var lsime = "⪍"; var lsimg = "⪏"; var lsqb = "["; var lsquo = "‘"; var lsquor = "‚"; var lstrok = "ł"; var l = "<"; var lt = "<"; var ltcc = "⪦"; var ltcir = "⩹"; var ltdot = "⋖"; var lthree = "⋋"; var ltimes = "⋉"; var ltlarr = "⥶"; var ltquest = "⩻"; var ltrPar = "⦖"; var ltri = "◃"; var ltrie = "⊴"; var ltrif = "◂"; var lurdshar = "⥊"; var luruhar = "⥦"; var lvertneqq = "≨︀"; var lvnE = "≨︀"; var mDDot = "∺"; var mac = "¯"; var macr = "¯"; var male = "♂"; var malt = "✠"; var maltese = "✠"; var map$3 = "↦"; var mapsto = "↦"; var mapstodown = "↧"; var mapstoleft = "↤"; var mapstoup = "↥"; var marker = "▮"; var mcomma = "⨩"; var mcy = "м"; var mdash = "—"; var measuredangle = "∡"; var mfr = "𝔪"; var mho = "℧"; var micr = "µ"; var micro = "µ"; var mid = "∣"; var midast = "*"; var midcir = "⫰"; var middo = "·"; var middot = "·"; var minus = "−"; var minusb = "⊟"; var minusd = "∸"; var minusdu = "⨪"; var mlcp = "⫛"; var mldr = "…"; var mnplus = "∓"; var models = "⊧"; var mopf = "𝕞"; var mp = "∓"; var mscr = "𝓂"; var mstpos = "∾"; var mu = "μ"; var multimap = "⊸"; var mumap = "⊸"; var nGg = "⋙̸"; var nGt = "≫⃒"; var nGtv = "≫̸"; var nLeftarrow = "⇍"; var nLeftrightarrow = "⇎"; var nLl = "⋘̸"; var nLt = "≪⃒"; var nLtv = "≪̸"; var nRightarrow = "⇏"; var nVDash = "⊯"; var nVdash = "⊮"; var nabla = "∇"; var nacute = "ń"; var nang = "∠⃒"; var nap = "≉"; var napE = "⩰̸"; var napid = "≋̸"; var napos = "ʼn"; var napprox = "≉"; var natur = "♮"; var natural = "♮"; var naturals = "ℕ"; var nbs = " "; var nbsp = " "; var nbump = "≎̸"; var nbumpe = "≏̸"; var ncap = "⩃"; var ncaron = "ň"; var ncedil = "ņ"; var ncong = "≇"; var ncongdot = "⩭̸"; var ncup = "⩂"; var ncy = "н"; var ndash = "–"; var ne = "≠"; var neArr = "⇗"; var nearhk = "⤤"; var nearr = "↗"; var nearrow = "↗"; var nedot = "≐̸"; var nequiv = "≢"; var nesear = "⤨"; var nesim = "≂̸"; var nexist = "∄"; var nexists = "∄"; var nfr = "𝔫"; var ngE = "≧̸"; var nge = "≱"; var ngeq = "≱"; var ngeqq = "≧̸"; var ngeqslant = "⩾̸"; var nges = "⩾̸"; var ngsim = "≵"; var ngt = "≯"; var ngtr = "≯"; var nhArr = "⇎"; var nharr = "↮"; var nhpar = "⫲"; var ni = "∋"; var nis = "⋼"; var nisd = "⋺"; var niv = "∋"; var njcy = "њ"; var nlArr = "⇍"; var nlE = "≦̸"; var nlarr = "↚"; var nldr = "‥"; var nle = "≰"; var nleftarrow = "↚"; var nleftrightarrow = "↮"; var nleq = "≰"; var nleqq = "≦̸"; var nleqslant = "⩽̸"; var nles = "⩽̸"; var nless = "≮"; var nlsim = "≴"; var nlt = "≮"; var nltri = "⋪"; var nltrie = "⋬"; var nmid = "∤"; var nopf = "𝕟"; var no = "¬"; var not = "¬"; var notin = "∉"; var notinE = "⋹̸"; var notindot = "⋵̸"; var notinva = "∉"; var notinvb = "⋷"; var notinvc = "⋶"; var notni = "∌"; var notniva = "∌"; var notnivb = "⋾"; var notnivc = "⋽"; var npar = "∦"; var nparallel = "∦"; var nparsl = "⫽⃥"; var npart = "∂̸"; var npolint = "⨔"; var npr = "⊀"; var nprcue = "⋠"; var npre = "⪯̸"; var nprec = "⊀"; var npreceq = "⪯̸"; var nrArr = "⇏"; var nrarr = "↛"; var nrarrc = "⤳̸"; var nrarrw = "↝̸"; var nrightarrow = "↛"; var nrtri = "⋫"; var nrtrie = "⋭"; var nsc = "⊁"; var nsccue = "⋡"; var nsce = "⪰̸"; var nscr = "𝓃"; var nshortmid = "∤"; var nshortparallel = "∦"; var nsim = "≁"; var nsime = "≄"; var nsimeq = "≄"; var nsmid = "∤"; var nspar = "∦"; var nsqsube = "⋢"; var nsqsupe = "⋣"; var nsub = "⊄"; var nsubE = "⫅̸"; var nsube = "⊈"; var nsubset = "⊂⃒"; var nsubseteq = "⊈"; var nsubseteqq = "⫅̸"; var nsucc = "⊁"; var nsucceq = "⪰̸"; var nsup = "⊅"; var nsupE = "⫆̸"; var nsupe = "⊉"; var nsupset = "⊃⃒"; var nsupseteq = "⊉"; var nsupseteqq = "⫆̸"; var ntgl = "≹"; var ntild = "ñ"; var ntilde = "ñ"; var ntlg = "≸"; var ntriangleleft = "⋪"; var ntrianglelefteq = "⋬"; var ntriangleright = "⋫"; var ntrianglerighteq = "⋭"; var nu = "ν"; var num = "#"; var numero = "№"; var numsp = " "; var nvDash = "⊭"; var nvHarr = "⤄"; var nvap = "≍⃒"; var nvdash = "⊬"; var nvge = "≥⃒"; var nvgt = ">⃒"; var nvinfin = "⧞"; var nvlArr = "⤂"; var nvle = "≤⃒"; var nvlt = "<⃒"; var nvltrie = "⊴⃒"; var nvrArr = "⤃"; var nvrtrie = "⊵⃒"; var nvsim = "∼⃒"; var nwArr = "⇖"; var nwarhk = "⤣"; var nwarr = "↖"; var nwarrow = "↖"; var nwnear = "⤧"; var oS = "Ⓢ"; var oacut = "ó"; var oacute = "ó"; var oast = "⊛"; var ocir = "ô"; var ocirc = "ô"; var ocy = "о"; var odash = "⊝"; var odblac = "ő"; var odiv = "⨸"; var odot = "⊙"; var odsold = "⦼"; var oelig = "œ"; var ofcir = "⦿"; var ofr = "𝔬"; var ogon = "˛"; var ograv = "ò"; var ograve = "ò"; var ogt = "⧁"; var ohbar = "⦵"; var ohm = "Ω"; var oint = "∮"; var olarr = "↺"; var olcir = "⦾"; var olcross = "⦻"; var oline = "‾"; var olt = "⧀"; var omacr = "ō"; var omega = "ω"; var omicron = "ο"; var omid = "⦶"; var ominus = "⊖"; var oopf = "𝕠"; var opar = "⦷"; var operp = "⦹"; var oplus = "⊕"; var or = "∨"; var orarr = "↻"; var ord = "º"; var order = "ℴ"; var orderof = "ℴ"; var ordf = "ª"; var ordm = "º"; var origof = "⊶"; var oror = "⩖"; var orslope = "⩗"; var orv = "⩛"; var oscr = "ℴ"; var oslas = "ø"; var oslash = "ø"; var osol = "⊘"; var otild = "õ"; var otilde = "õ"; var otimes = "⊗"; var otimesas = "⨶"; var oum = "ö"; var ouml = "ö"; var ovbar = "⌽"; var par = "¶"; var para = "¶"; var parallel = "∥"; var parsim = "⫳"; var parsl = "⫽"; var part = "∂"; var pcy = "п"; var percnt = "%"; var period = "."; var permil = "‰"; var perp = "⊥"; var pertenk = "‱"; var pfr = "𝔭"; var phi = "φ"; var phiv = "ϕ"; var phmmat = "ℳ"; var phone = "☎"; var pi = "π"; var pitchfork = "⋔"; var piv = "ϖ"; var planck = "ℏ"; var planckh = "ℎ"; var plankv = "ℏ"; var plus = "+"; var plusacir = "⨣"; var plusb = "⊞"; var pluscir = "⨢"; var plusdo = "∔"; var plusdu = "⨥"; var pluse = "⩲"; var plusm = "±"; var plusmn = "±"; var plussim = "⨦"; var plustwo = "⨧"; var pm = "±"; var pointint = "⨕"; var popf = "𝕡"; var poun = "£"; var pound = "£"; var pr = "≺"; var prE = "⪳"; var prap = "⪷"; var prcue = "≼"; var pre = "⪯"; var prec = "≺"; var precapprox = "⪷"; var preccurlyeq = "≼"; var preceq = "⪯"; var precnapprox = "⪹"; var precneqq = "⪵"; var precnsim = "⋨"; var precsim = "≾"; var prime = "′"; var primes = "ℙ"; var prnE = "⪵"; var prnap = "⪹"; var prnsim = "⋨"; var prod = "∏"; var profalar = "⌮"; var profline = "⌒"; var profsurf = "⌓"; var prop = "∝"; var propto = "∝"; var prsim = "≾"; var prurel = "⊰"; var pscr = "𝓅"; var psi = "ψ"; var puncsp = " "; var qfr = "𝔮"; var qint = "⨌"; var qopf = "𝕢"; var qprime = "⁗"; var qscr = "𝓆"; var quaternions = "ℍ"; var quatint = "⨖"; var quest = "?"; var questeq = "≟"; var quo = "\""; var quot = "\""; var rAarr = "⇛"; var rArr = "⇒"; var rAtail = "⤜"; var rBarr = "⤏"; var rHar = "⥤"; var race = "∽̱"; var racute = "ŕ"; var radic = "√"; var raemptyv = "⦳"; var rang = "⟩"; var rangd = "⦒"; var range = "⦥"; var rangle = "⟩"; var raqu = "»"; var raquo = "»"; var rarr = "→"; var rarrap = "⥵"; var rarrb = "⇥"; var rarrbfs = "⤠"; var rarrc = "⤳"; var rarrfs = "⤞"; var rarrhk = "↪"; var rarrlp = "↬"; var rarrpl = "⥅"; var rarrsim = "⥴"; var rarrtl = "↣"; var rarrw = "↝"; var ratail = "⤚"; var ratio = "∶"; var rationals = "ℚ"; var rbarr = "⤍"; var rbbrk = "❳"; var rbrace = "}"; var rbrack = "]"; var rbrke = "⦌"; var rbrksld = "⦎"; var rbrkslu = "⦐"; var rcaron = "ř"; var rcedil = "ŗ"; var rceil = "⌉"; var rcub = "}"; var rcy = "р"; var rdca = "⤷"; var rdldhar = "⥩"; var rdquo = "”"; var rdquor = "”"; var rdsh = "↳"; var real = "ℜ"; var realine = "ℛ"; var realpart = "ℜ"; var reals = "ℝ"; var rect = "▭"; var re = "®"; var reg = "®"; var rfisht = "⥽"; var rfloor = "⌋"; var rfr = "𝔯"; var rhard = "⇁"; var rharu = "⇀"; var rharul = "⥬"; var rho = "ρ"; var rhov = "ϱ"; var rightarrow = "→"; var rightarrowtail = "↣"; var rightharpoondown = "⇁"; var rightharpoonup = "⇀"; var rightleftarrows = "⇄"; var rightleftharpoons = "⇌"; var rightrightarrows = "⇉"; var rightsquigarrow = "↝"; var rightthreetimes = "⋌"; var ring = "˚"; var risingdotseq = "≓"; var rlarr = "⇄"; var rlhar = "⇌"; var rlm = "‏"; var rmoust = "⎱"; var rmoustache = "⎱"; var rnmid = "⫮"; var roang = "⟭"; var roarr = "⇾"; var robrk = "⟧"; var ropar = "⦆"; var ropf = "𝕣"; var roplus = "⨮"; var rotimes = "⨵"; var rpar = ")"; var rpargt = "⦔"; var rppolint = "⨒"; var rrarr = "⇉"; var rsaquo = "›"; var rscr = "𝓇"; var rsh = "↱"; var rsqb = "]"; var rsquo = "’"; var rsquor = "’"; var rthree = "⋌"; var rtimes = "⋊"; var rtri = "▹"; var rtrie = "⊵"; var rtrif = "▸"; var rtriltri = "⧎"; var ruluhar = "⥨"; var rx = "℞"; var sacute = "ś"; var sbquo = "‚"; var sc = "≻"; var scE = "⪴"; var scap = "⪸"; var scaron = "š"; var sccue = "≽"; var sce = "⪰"; var scedil = "ş"; var scirc = "ŝ"; var scnE = "⪶"; var scnap = "⪺"; var scnsim = "⋩"; var scpolint = "⨓"; var scsim = "≿"; var scy = "с"; var sdot = "⋅"; var sdotb = "⊡"; var sdote = "⩦"; var seArr = "⇘"; var searhk = "⤥"; var searr = "↘"; var searrow = "↘"; var sec = "§"; var sect = "§"; var semi = ";"; var seswar = "⤩"; var setminus = "∖"; var setmn = "∖"; var sext = "✶"; var sfr = "𝔰"; var sfrown = "⌢"; var sharp = "♯"; var shchcy = "щ"; var shcy = "ш"; var shortmid = "∣"; var shortparallel = "∥"; var sh = "­"; var shy = "­"; var sigma = "σ"; var sigmaf = "ς"; var sigmav = "ς"; var sim = "∼"; var simdot = "⩪"; var sime = "≃"; var simeq = "≃"; var simg = "⪞"; var simgE = "⪠"; var siml = "⪝"; var simlE = "⪟"; var simne = "≆"; var simplus = "⨤"; var simrarr = "⥲"; var slarr = "←"; var smallsetminus = "∖"; var smashp = "⨳"; var smeparsl = "⧤"; var smid = "∣"; var smile = "⌣"; var smt = "⪪"; var smte = "⪬"; var smtes = "⪬︀"; var softcy = "ь"; var sol = "/"; var solb = "⧄"; var solbar = "⌿"; var sopf = "𝕤"; var spades = "♠"; var spadesuit = "♠"; var spar = "∥"; var sqcap = "⊓"; var sqcaps = "⊓︀"; var sqcup = "⊔"; var sqcups = "⊔︀"; var sqsub = "⊏"; var sqsube = "⊑"; var sqsubset = "⊏"; var sqsubseteq = "⊑"; var sqsup = "⊐"; var sqsupe = "⊒"; var sqsupset = "⊐"; var sqsupseteq = "⊒"; var squ = "□"; var square = "□"; var squarf = "▪"; var squf = "▪"; var srarr = "→"; var sscr = "𝓈"; var ssetmn = "∖"; var ssmile = "⌣"; var sstarf = "⋆"; var star = "☆"; var starf = "★"; var straightepsilon = "ϵ"; var straightphi = "ϕ"; var strns = "¯"; var sub = "⊂"; var subE = "⫅"; var subdot = "⪽"; var sube = "⊆"; var subedot = "⫃"; var submult = "⫁"; var subnE = "⫋"; var subne = "⊊"; var subplus = "⪿"; var subrarr = "⥹"; var subset = "⊂"; var subseteq = "⊆"; var subseteqq = "⫅"; var subsetneq = "⊊"; var subsetneqq = "⫋"; var subsim = "⫇"; var subsub = "⫕"; var subsup = "⫓"; var succ = "≻"; var succapprox = "⪸"; var succcurlyeq = "≽"; var succeq = "⪰"; var succnapprox = "⪺"; var succneqq = "⪶"; var succnsim = "⋩"; var succsim = "≿"; var sum = "∑"; var sung = "♪"; var sup = "⊃"; var sup1 = "¹"; var sup2 = "²"; var sup3 = "³"; var supE = "⫆"; var supdot = "⪾"; var supdsub = "⫘"; var supe = "⊇"; var supedot = "⫄"; var suphsol = "⟉"; var suphsub = "⫗"; var suplarr = "⥻"; var supmult = "⫂"; var supnE = "⫌"; var supne = "⊋"; var supplus = "⫀"; var supset = "⊃"; var supseteq = "⊇"; var supseteqq = "⫆"; var supsetneq = "⊋"; var supsetneqq = "⫌"; var supsim = "⫈"; var supsub = "⫔"; var supsup = "⫖"; var swArr = "⇙"; var swarhk = "⤦"; var swarr = "↙"; var swarrow = "↙"; var swnwar = "⤪"; var szli = "ß"; var szlig = "ß"; var target = "⌖"; var tau = "τ"; var tbrk = "⎴"; var tcaron = "ť"; var tcedil = "ţ"; var tcy = "т"; var tdot = "⃛"; var telrec = "⌕"; var tfr = "𝔱"; var there4 = "∴"; var therefore = "∴"; var theta = "θ"; var thetasym = "ϑ"; var thetav = "ϑ"; var thickapprox = "≈"; var thicksim = "∼"; var thinsp = " "; var thkap = "≈"; var thksim = "∼"; var thor = "þ"; var thorn = "þ"; var tilde = "˜"; var time = "×"; var times = "×"; var timesb = "⊠"; var timesbar = "⨱"; var timesd = "⨰"; var tint = "∭"; var toea = "⤨"; var top = "⊤"; var topbot = "⌶"; var topcir = "⫱"; var topf = "𝕥"; var topfork = "⫚"; var tosa = "⤩"; var tprime = "‴"; var trade = "™"; var triangle = "▵"; var triangledown = "▿"; var triangleleft = "◃"; var trianglelefteq = "⊴"; var triangleq = "≜"; var triangleright = "▹"; var trianglerighteq = "⊵"; var tridot = "◬"; var trie = "≜"; var triminus = "⨺"; var triplus = "⨹"; var trisb = "⧍"; var tritime = "⨻"; var trpezium = "⏢"; var tscr = "𝓉"; var tscy = "ц"; var tshcy = "ћ"; var tstrok = "ŧ"; var twixt = "≬"; var twoheadleftarrow = "↞"; var twoheadrightarrow = "↠"; var uArr = "⇑"; var uHar = "⥣"; var uacut = "ú"; var uacute = "ú"; var uarr = "↑"; var ubrcy = "ў"; var ubreve = "ŭ"; var ucir = "û"; var ucirc = "û"; var ucy = "у"; var udarr = "⇅"; var udblac = "ű"; var udhar = "⥮"; var ufisht = "⥾"; var ufr = "𝔲"; var ugrav = "ù"; var ugrave = "ù"; var uharl = "↿"; var uharr = "↾"; var uhblk = "▀"; var ulcorn = "⌜"; var ulcorner = "⌜"; var ulcrop = "⌏"; var ultri = "◸"; var umacr = "ū"; var um = "¨"; var uml = "¨"; var uogon = "ų"; var uopf = "𝕦"; var uparrow = "↑"; var updownarrow = "↕"; var upharpoonleft = "↿"; var upharpoonright = "↾"; var uplus = "⊎"; var upsi = "υ"; var upsih = "ϒ"; var upsilon = "υ"; var upuparrows = "⇈"; var urcorn = "⌝"; var urcorner = "⌝"; var urcrop = "⌎"; var uring = "ů"; var urtri = "◹"; var uscr = "𝓊"; var utdot = "⋰"; var utilde = "ũ"; var utri = "▵"; var utrif = "▴"; var uuarr = "⇈"; var uum = "ü"; var uuml = "ü"; var uwangle = "⦧"; var vArr = "⇕"; var vBar = "⫨"; var vBarv = "⫩"; var vDash = "⊨"; var vangrt = "⦜"; var varepsilon = "ϵ"; var varkappa = "ϰ"; var varnothing = "∅"; var varphi = "ϕ"; var varpi = "ϖ"; var varpropto = "∝"; var varr = "↕"; var varrho = "ϱ"; var varsigma = "ς"; var varsubsetneq = "⊊︀"; var varsubsetneqq = "⫋︀"; var varsupsetneq = "⊋︀"; var varsupsetneqq = "⫌︀"; var vartheta = "ϑ"; var vartriangleleft = "⊲"; var vartriangleright = "⊳"; var vcy = "в"; var vdash = "⊢"; var vee = "∨"; var veebar = "⊻"; var veeeq = "≚"; var vellip = "⋮"; var verbar = "|"; var vert = "|"; var vfr = "𝔳"; var vltri = "⊲"; var vnsub = "⊂⃒"; var vnsup = "⊃⃒"; var vopf = "𝕧"; var vprop = "∝"; var vrtri = "⊳"; var vscr = "𝓋"; var vsubnE = "⫋︀"; var vsubne = "⊊︀"; var vsupnE = "⫌︀"; var vsupne = "⊋︀"; var vzigzag = "⦚"; var wcirc = "ŵ"; var wedbar = "⩟"; var wedge = "∧"; var wedgeq = "≙"; var weierp = "℘"; var wfr = "𝔴"; var wopf = "𝕨"; var wp = "℘"; var wr = "≀"; var wreath = "≀"; var wscr = "𝓌"; var xcap = "⋂"; var xcirc = "◯"; var xcup = "⋃"; var xdtri = "▽"; var xfr = "𝔵"; var xhArr = "⟺"; var xharr = "⟷"; var xi = "ξ"; var xlArr = "⟸"; var xlarr = "⟵"; var xmap = "⟼"; var xnis = "⋻"; var xodot = "⨀"; var xopf = "𝕩"; var xoplus = "⨁"; var xotime = "⨂"; var xrArr = "⟹"; var xrarr = "⟶"; var xscr = "𝓍"; var xsqcup = "⨆"; var xuplus = "⨄"; var xutri = "△"; var xvee = "⋁"; var xwedge = "⋀"; var yacut = "ý"; var yacute = "ý"; var yacy = "я"; var ycirc = "ŷ"; var ycy = "ы"; var ye = "¥"; var yen = "¥"; var yfr = "𝔶"; var yicy = "ї"; var yopf = "𝕪"; var yscr = "𝓎"; var yucy = "ю"; var yum = "ÿ"; var yuml = "ÿ"; var zacute = "ź"; var zcaron = "ž"; var zcy = "з"; var zdot = "ż"; var zeetrf = "ℨ"; var zeta = "ζ"; var zfr = "𝔷"; var zhcy = "ж"; var zigrarr = "⇝"; var zopf = "𝕫"; var zscr = "𝓏"; var zwj = "‍"; var zwnj = "‌"; var characterEntities = { AEli: AEli, AElig: AElig, AM: AM, AMP: AMP, Aacut: Aacut, Aacute: Aacute, Abreve: Abreve, Acir: Acir, Acirc: Acirc, Acy: Acy, Afr: Afr, Agrav: Agrav, Agrave: Agrave, Alpha: Alpha, Amacr: Amacr, And: And, Aogon: Aogon, Aopf: Aopf, ApplyFunction: ApplyFunction, Arin: Arin, Aring: Aring, Ascr: Ascr, Assign: Assign, Atild: Atild, Atilde: Atilde, Aum: Aum, Auml: Auml, Backslash: Backslash, Barv: Barv, Barwed: Barwed, Bcy: Bcy, Because: Because, Bernoullis: Bernoullis, Beta: Beta, Bfr: Bfr, Bopf: Bopf, Breve: Breve, Bscr: Bscr, Bumpeq: Bumpeq, CHcy: CHcy, COP: COP, COPY: COPY, Cacute: Cacute, Cap: Cap, CapitalDifferentialD: CapitalDifferentialD, Cayleys: Cayleys, Ccaron: Ccaron, Ccedi: Ccedi, Ccedil: Ccedil, Ccirc: Ccirc, Cconint: Cconint, Cdot: Cdot, Cedilla: Cedilla, CenterDot: CenterDot, Cfr: Cfr, Chi: Chi, CircleDot: CircleDot, CircleMinus: CircleMinus, CirclePlus: CirclePlus, CircleTimes: CircleTimes, ClockwiseContourIntegral: ClockwiseContourIntegral, CloseCurlyDoubleQuote: CloseCurlyDoubleQuote, CloseCurlyQuote: CloseCurlyQuote, Colon: Colon, Colone: Colone, Congruent: Congruent, Conint: Conint, ContourIntegral: ContourIntegral, Copf: Copf, Coproduct: Coproduct, CounterClockwiseContourIntegral: CounterClockwiseContourIntegral, Cross: Cross, Cscr: Cscr, Cup: Cup, CupCap: CupCap, DD: DD, DDotrahd: DDotrahd, DJcy: DJcy, DScy: DScy, DZcy: DZcy, Dagger: Dagger, Darr: Darr, Dashv: Dashv, Dcaron: Dcaron, Dcy: Dcy, Del: Del, Delta: Delta, Dfr: Dfr, DiacriticalAcute: DiacriticalAcute, DiacriticalDot: DiacriticalDot, DiacriticalDoubleAcute: DiacriticalDoubleAcute, DiacriticalGrave: DiacriticalGrave, DiacriticalTilde: DiacriticalTilde, Diamond: Diamond, DifferentialD: DifferentialD, Dopf: Dopf, Dot: Dot, DotDot: DotDot, DotEqual: DotEqual, DoubleContourIntegral: DoubleContourIntegral, DoubleDot: DoubleDot, DoubleDownArrow: DoubleDownArrow, DoubleLeftArrow: DoubleLeftArrow, DoubleLeftRightArrow: DoubleLeftRightArrow, DoubleLeftTee: DoubleLeftTee, DoubleLongLeftArrow: DoubleLongLeftArrow, DoubleLongLeftRightArrow: DoubleLongLeftRightArrow, DoubleLongRightArrow: DoubleLongRightArrow, DoubleRightArrow: DoubleRightArrow, DoubleRightTee: DoubleRightTee, DoubleUpArrow: DoubleUpArrow, DoubleUpDownArrow: DoubleUpDownArrow, DoubleVerticalBar: DoubleVerticalBar, DownArrow: DownArrow, DownArrowBar: DownArrowBar, DownArrowUpArrow: DownArrowUpArrow, DownBreve: DownBreve, DownLeftRightVector: DownLeftRightVector, DownLeftTeeVector: DownLeftTeeVector, DownLeftVector: DownLeftVector, DownLeftVectorBar: DownLeftVectorBar, DownRightTeeVector: DownRightTeeVector, DownRightVector: DownRightVector, DownRightVectorBar: DownRightVectorBar, DownTee: DownTee, DownTeeArrow: DownTeeArrow, Downarrow: Downarrow, Dscr: Dscr, Dstrok: Dstrok, ENG: ENG, ET: ET, ETH: ETH, Eacut: Eacut, Eacute: Eacute, Ecaron: Ecaron, Ecir: Ecir, Ecirc: Ecirc, Ecy: Ecy, Edot: Edot, Efr: Efr, Egrav: Egrav, Egrave: Egrave, Element: Element, Emacr: Emacr, EmptySmallSquare: EmptySmallSquare, EmptyVerySmallSquare: EmptyVerySmallSquare, Eogon: Eogon, Eopf: Eopf, Epsilon: Epsilon, Equal: Equal, EqualTilde: EqualTilde, Equilibrium: Equilibrium, Escr: Escr, Esim: Esim, Eta: Eta, Eum: Eum, Euml: Euml, Exists: Exists, ExponentialE: ExponentialE, Fcy: Fcy, Ffr: Ffr, FilledSmallSquare: FilledSmallSquare, FilledVerySmallSquare: FilledVerySmallSquare, Fopf: Fopf, ForAll: ForAll, Fouriertrf: Fouriertrf, Fscr: Fscr, GJcy: GJcy, G: G, GT: GT, Gamma: Gamma, Gammad: Gammad, Gbreve: Gbreve, Gcedil: Gcedil, Gcirc: Gcirc, Gcy: Gcy, Gdot: Gdot, Gfr: Gfr, Gg: Gg, Gopf: Gopf, GreaterEqual: GreaterEqual, GreaterEqualLess: GreaterEqualLess, GreaterFullEqual: GreaterFullEqual, GreaterGreater: GreaterGreater, GreaterLess: GreaterLess, GreaterSlantEqual: GreaterSlantEqual, GreaterTilde: GreaterTilde, Gscr: Gscr, Gt: Gt, HARDcy: HARDcy, Hacek: Hacek, Hat: Hat, Hcirc: Hcirc, Hfr: Hfr, HilbertSpace: HilbertSpace, Hopf: Hopf, HorizontalLine: HorizontalLine, Hscr: Hscr, Hstrok: Hstrok, HumpDownHump: HumpDownHump, HumpEqual: HumpEqual, IEcy: IEcy, IJlig: IJlig, IOcy: IOcy, Iacut: Iacut, Iacute: Iacute, Icir: Icir, Icirc: Icirc, Icy: Icy, Idot: Idot, Ifr: Ifr, Igrav: Igrav, Igrave: Igrave, Im: Im, Imacr: Imacr, ImaginaryI: ImaginaryI, Implies: Implies, Int: Int, Integral: Integral, Intersection: Intersection, InvisibleComma: InvisibleComma, InvisibleTimes: InvisibleTimes, Iogon: Iogon, Iopf: Iopf, Iota: Iota, Iscr: Iscr, Itilde: Itilde, Iukcy: Iukcy, Ium: Ium, Iuml: Iuml, Jcirc: Jcirc, Jcy: Jcy, Jfr: Jfr, Jopf: Jopf, Jscr: Jscr, Jsercy: Jsercy, Jukcy: Jukcy, KHcy: KHcy, KJcy: KJcy, Kappa: Kappa, Kcedil: Kcedil, Kcy: Kcy, Kfr: Kfr, Kopf: Kopf, Kscr: Kscr, LJcy: LJcy, L: L, LT: LT, Lacute: Lacute, Lambda: Lambda, Lang: Lang, Laplacetrf: Laplacetrf, Larr: Larr, Lcaron: Lcaron, Lcedil: Lcedil, Lcy: Lcy, LeftAngleBracket: LeftAngleBracket, LeftArrow: LeftArrow, LeftArrowBar: LeftArrowBar, LeftArrowRightArrow: LeftArrowRightArrow, LeftCeiling: LeftCeiling, LeftDoubleBracket: LeftDoubleBracket, LeftDownTeeVector: LeftDownTeeVector, LeftDownVector: LeftDownVector, LeftDownVectorBar: LeftDownVectorBar, LeftFloor: LeftFloor, LeftRightArrow: LeftRightArrow, LeftRightVector: LeftRightVector, LeftTee: LeftTee, LeftTeeArrow: LeftTeeArrow, LeftTeeVector: LeftTeeVector, LeftTriangle: LeftTriangle, LeftTriangleBar: LeftTriangleBar, LeftTriangleEqual: LeftTriangleEqual, LeftUpDownVector: LeftUpDownVector, LeftUpTeeVector: LeftUpTeeVector, LeftUpVector: LeftUpVector, LeftUpVectorBar: LeftUpVectorBar, LeftVector: LeftVector, LeftVectorBar: LeftVectorBar, Leftarrow: Leftarrow, Leftrightarrow: Leftrightarrow, LessEqualGreater: LessEqualGreater, LessFullEqual: LessFullEqual, LessGreater: LessGreater, LessLess: LessLess, LessSlantEqual: LessSlantEqual, LessTilde: LessTilde, Lfr: Lfr, Ll: Ll, Lleftarrow: Lleftarrow, Lmidot: Lmidot, LongLeftArrow: LongLeftArrow, LongLeftRightArrow: LongLeftRightArrow, LongRightArrow: LongRightArrow, Longleftarrow: Longleftarrow, Longleftrightarrow: Longleftrightarrow, Longrightarrow: Longrightarrow, Lopf: Lopf, LowerLeftArrow: LowerLeftArrow, LowerRightArrow: LowerRightArrow, Lscr: Lscr, Lsh: Lsh, Lstrok: Lstrok, Lt: Lt, "Map": "⤅", Mcy: Mcy, MediumSpace: MediumSpace, Mellintrf: Mellintrf, Mfr: Mfr, MinusPlus: MinusPlus, Mopf: Mopf, Mscr: Mscr, Mu: Mu, NJcy: NJcy, Nacute: Nacute, Ncaron: Ncaron, Ncedil: Ncedil, Ncy: Ncy, NegativeMediumSpace: NegativeMediumSpace, NegativeThickSpace: NegativeThickSpace, NegativeThinSpace: NegativeThinSpace, NegativeVeryThinSpace: NegativeVeryThinSpace, NestedGreaterGreater: NestedGreaterGreater, NestedLessLess: NestedLessLess, NewLine: NewLine, Nfr: Nfr, NoBreak: NoBreak, NonBreakingSpace: NonBreakingSpace, Nopf: Nopf, Not: Not, NotCongruent: NotCongruent, NotCupCap: NotCupCap, NotDoubleVerticalBar: NotDoubleVerticalBar, NotElement: NotElement, NotEqual: NotEqual, NotEqualTilde: NotEqualTilde, NotExists: NotExists, NotGreater: NotGreater, NotGreaterEqual: NotGreaterEqual, NotGreaterFullEqual: NotGreaterFullEqual, NotGreaterGreater: NotGreaterGreater, NotGreaterLess: NotGreaterLess, NotGreaterSlantEqual: NotGreaterSlantEqual, NotGreaterTilde: NotGreaterTilde, NotHumpDownHump: NotHumpDownHump, NotHumpEqual: NotHumpEqual, NotLeftTriangle: NotLeftTriangle, NotLeftTriangleBar: NotLeftTriangleBar, NotLeftTriangleEqual: NotLeftTriangleEqual, NotLess: NotLess, NotLessEqual: NotLessEqual, NotLessGreater: NotLessGreater, NotLessLess: NotLessLess, NotLessSlantEqual: NotLessSlantEqual, NotLessTilde: NotLessTilde, NotNestedGreaterGreater: NotNestedGreaterGreater, NotNestedLessLess: NotNestedLessLess, NotPrecedes: NotPrecedes, NotPrecedesEqual: NotPrecedesEqual, NotPrecedesSlantEqual: NotPrecedesSlantEqual, NotReverseElement: NotReverseElement, NotRightTriangle: NotRightTriangle, NotRightTriangleBar: NotRightTriangleBar, NotRightTriangleEqual: NotRightTriangleEqual, NotSquareSubset: NotSquareSubset, NotSquareSubsetEqual: NotSquareSubsetEqual, NotSquareSuperset: NotSquareSuperset, NotSquareSupersetEqual: NotSquareSupersetEqual, NotSubset: NotSubset, NotSubsetEqual: NotSubsetEqual, NotSucceeds: NotSucceeds, NotSucceedsEqual: NotSucceedsEqual, NotSucceedsSlantEqual: NotSucceedsSlantEqual, NotSucceedsTilde: NotSucceedsTilde, NotSuperset: NotSuperset, NotSupersetEqual: NotSupersetEqual, NotTilde: NotTilde, NotTildeEqual: NotTildeEqual, NotTildeFullEqual: NotTildeFullEqual, NotTildeTilde: NotTildeTilde, NotVerticalBar: NotVerticalBar, Nscr: Nscr, Ntild: Ntild, Ntilde: Ntilde, Nu: Nu, OElig: OElig, Oacut: Oacut, Oacute: Oacute, Ocir: Ocir, Ocirc: Ocirc, Ocy: Ocy, Odblac: Odblac, Ofr: Ofr, Ograv: Ograv, Ograve: Ograve, Omacr: Omacr, Omega: Omega, Omicron: Omicron, Oopf: Oopf, OpenCurlyDoubleQuote: OpenCurlyDoubleQuote, OpenCurlyQuote: OpenCurlyQuote, Or: Or, Oscr: Oscr, Oslas: Oslas, Oslash: Oslash, Otild: Otild, Otilde: Otilde, Otimes: Otimes, Oum: Oum, Ouml: Ouml, OverBar: OverBar, OverBrace: OverBrace, OverBracket: OverBracket, OverParenthesis: OverParenthesis, PartialD: PartialD, Pcy: Pcy, Pfr: Pfr, Phi: Phi, Pi: Pi, PlusMinus: PlusMinus, Poincareplane: Poincareplane, Popf: Popf, Pr: Pr, Precedes: Precedes, PrecedesEqual: PrecedesEqual, PrecedesSlantEqual: PrecedesSlantEqual, PrecedesTilde: PrecedesTilde, Prime: Prime, Product: Product, Proportion: Proportion, Proportional: Proportional, Pscr: Pscr, Psi: Psi, QUO: QUO, QUOT: QUOT, Qfr: Qfr, Qopf: Qopf, Qscr: Qscr, RBarr: RBarr, RE: RE, REG: REG, Racute: Racute, Rang: Rang, Rarr: Rarr, Rarrtl: Rarrtl, Rcaron: Rcaron, Rcedil: Rcedil, Rcy: Rcy, Re: Re, ReverseElement: ReverseElement, ReverseEquilibrium: ReverseEquilibrium, ReverseUpEquilibrium: ReverseUpEquilibrium, Rfr: Rfr, Rho: Rho, RightAngleBracket: RightAngleBracket, RightArrow: RightArrow, RightArrowBar: RightArrowBar, RightArrowLeftArrow: RightArrowLeftArrow, RightCeiling: RightCeiling, RightDoubleBracket: RightDoubleBracket, RightDownTeeVector: RightDownTeeVector, RightDownVector: RightDownVector, RightDownVectorBar: RightDownVectorBar, RightFloor: RightFloor, RightTee: RightTee, RightTeeArrow: RightTeeArrow, RightTeeVector: RightTeeVector, RightTriangle: RightTriangle, RightTriangleBar: RightTriangleBar, RightTriangleEqual: RightTriangleEqual, RightUpDownVector: RightUpDownVector, RightUpTeeVector: RightUpTeeVector, RightUpVector: RightUpVector, RightUpVectorBar: RightUpVectorBar, RightVector: RightVector, RightVectorBar: RightVectorBar, Rightarrow: Rightarrow, Ropf: Ropf, RoundImplies: RoundImplies, Rrightarrow: Rrightarrow, Rscr: Rscr, Rsh: Rsh, RuleDelayed: RuleDelayed, SHCHcy: SHCHcy, SHcy: SHcy, SOFTcy: SOFTcy, Sacute: Sacute, Sc: Sc, Scaron: Scaron, Scedil: Scedil, Scirc: Scirc, Scy: Scy, Sfr: Sfr, ShortDownArrow: ShortDownArrow, ShortLeftArrow: ShortLeftArrow, ShortRightArrow: ShortRightArrow, ShortUpArrow: ShortUpArrow, Sigma: Sigma, SmallCircle: SmallCircle, Sopf: Sopf, Sqrt: Sqrt, Square: Square, SquareIntersection: SquareIntersection, SquareSubset: SquareSubset, SquareSubsetEqual: SquareSubsetEqual, SquareSuperset: SquareSuperset, SquareSupersetEqual: SquareSupersetEqual, SquareUnion: SquareUnion, Sscr: Sscr, Star: Star, Sub: Sub, Subset: Subset, SubsetEqual: SubsetEqual, Succeeds: Succeeds, SucceedsEqual: SucceedsEqual, SucceedsSlantEqual: SucceedsSlantEqual, SucceedsTilde: SucceedsTilde, SuchThat: SuchThat, Sum: Sum, Sup: Sup, Superset: Superset, SupersetEqual: SupersetEqual, Supset: Supset, THOR: THOR, THORN: THORN, TRADE: TRADE, TSHcy: TSHcy, TScy: TScy, Tab: Tab, Tau: Tau, Tcaron: Tcaron, Tcedil: Tcedil, Tcy: Tcy, Tfr: Tfr, Therefore: Therefore, Theta: Theta, ThickSpace: ThickSpace, ThinSpace: ThinSpace, Tilde: Tilde, TildeEqual: TildeEqual, TildeFullEqual: TildeFullEqual, TildeTilde: TildeTilde, Topf: Topf, TripleDot: TripleDot, Tscr: Tscr, Tstrok: Tstrok, Uacut: Uacut, Uacute: Uacute, Uarr: Uarr, Uarrocir: Uarrocir, Ubrcy: Ubrcy, Ubreve: Ubreve, Ucir: Ucir, Ucirc: Ucirc, Ucy: Ucy, Udblac: Udblac, Ufr: Ufr, Ugrav: Ugrav, Ugrave: Ugrave, Umacr: Umacr, UnderBar: UnderBar, UnderBrace: UnderBrace, UnderBracket: UnderBracket, UnderParenthesis: UnderParenthesis, Union: Union, UnionPlus: UnionPlus, Uogon: Uogon, Uopf: Uopf, UpArrow: UpArrow, UpArrowBar: UpArrowBar, UpArrowDownArrow: UpArrowDownArrow, UpDownArrow: UpDownArrow, UpEquilibrium: UpEquilibrium, UpTee: UpTee, UpTeeArrow: UpTeeArrow, Uparrow: Uparrow, Updownarrow: Updownarrow, UpperLeftArrow: UpperLeftArrow, UpperRightArrow: UpperRightArrow, Upsi: Upsi, Upsilon: Upsilon, Uring: Uring, Uscr: Uscr, Utilde: Utilde, Uum: Uum, Uuml: Uuml, VDash: VDash, Vbar: Vbar, Vcy: Vcy, Vdash: Vdash, Vdashl: Vdashl, Vee: Vee, Verbar: Verbar, Vert: Vert, VerticalBar: VerticalBar, VerticalLine: VerticalLine, VerticalSeparator: VerticalSeparator, VerticalTilde: VerticalTilde, VeryThinSpace: VeryThinSpace, Vfr: Vfr, Vopf: Vopf, Vscr: Vscr, Vvdash: Vvdash, Wcirc: Wcirc, Wedge: Wedge, Wfr: Wfr, Wopf: Wopf, Wscr: Wscr, Xfr: Xfr, Xi: Xi, Xopf: Xopf, Xscr: Xscr, YAcy: YAcy, YIcy: YIcy, YUcy: YUcy, Yacut: Yacut, Yacute: Yacute, Ycirc: Ycirc, Ycy: Ycy, Yfr: Yfr, Yopf: Yopf, Yscr: Yscr, Yuml: Yuml, ZHcy: ZHcy, Zacute: Zacute, Zcaron: Zcaron, Zcy: Zcy, Zdot: Zdot, ZeroWidthSpace: ZeroWidthSpace, Zeta: Zeta, Zfr: Zfr, Zopf: Zopf, Zscr: Zscr, aacut: aacut, aacute: aacute, abreve: abreve, ac: ac, acE: acE, acd: acd, acir: acir, acirc: acirc, acut: acut, acute: acute, acy: acy, aeli: aeli, aelig: aelig, af: af, afr: afr, agrav: agrav, agrave: agrave, alefsym: alefsym, aleph: aleph, alpha: alpha, amacr: amacr, amalg: amalg, am: am, amp: amp, and: and, andand: andand, andd: andd, andslope: andslope, andv: andv, ang: ang, ange: ange, angle: angle, angmsd: angmsd, angmsdaa: angmsdaa, angmsdab: angmsdab, angmsdac: angmsdac, angmsdad: angmsdad, angmsdae: angmsdae, angmsdaf: angmsdaf, angmsdag: angmsdag, angmsdah: angmsdah, angrt: angrt, angrtvb: angrtvb, angrtvbd: angrtvbd, angsph: angsph, angst: angst, angzarr: angzarr, aogon: aogon, aopf: aopf, ap: ap, apE: apE, apacir: apacir, ape: ape, apid: apid, apos: apos, approx: approx, approxeq: approxeq, arin: arin, aring: aring, ascr: ascr, ast: ast, asymp: asymp, asympeq: asympeq, atild: atild, atilde: atilde, aum: aum, auml: auml, awconint: awconint, awint: awint, bNot: bNot, backcong: backcong, backepsilon: backepsilon, backprime: backprime, backsim: backsim, backsimeq: backsimeq, barvee: barvee, barwed: barwed, barwedge: barwedge, bbrk: bbrk, bbrktbrk: bbrktbrk, bcong: bcong, bcy: bcy, bdquo: bdquo, becaus: becaus, because: because, bemptyv: bemptyv, bepsi: bepsi, bernou: bernou, beta: beta, beth: beth, between: between, bfr: bfr, bigcap: bigcap, bigcirc: bigcirc, bigcup: bigcup, bigodot: bigodot, bigoplus: bigoplus, bigotimes: bigotimes, bigsqcup: bigsqcup, bigstar: bigstar, bigtriangledown: bigtriangledown, bigtriangleup: bigtriangleup, biguplus: biguplus, bigvee: bigvee, bigwedge: bigwedge, bkarow: bkarow, blacklozenge: blacklozenge, blacksquare: blacksquare, blacktriangle: blacktriangle, blacktriangledown: blacktriangledown, blacktriangleleft: blacktriangleleft, blacktriangleright: blacktriangleright, blank: blank, blk12: blk12, blk14: blk14, blk34: blk34, block: block, bne: bne, bnequiv: bnequiv, bnot: bnot, bopf: bopf, bot: bot, bottom: bottom, bowtie: bowtie, boxDL: boxDL, boxDR: boxDR, boxDl: boxDl, boxDr: boxDr, boxH: boxH, boxHD: boxHD, boxHU: boxHU, boxHd: boxHd, boxHu: boxHu, boxUL: boxUL, boxUR: boxUR, boxUl: boxUl, boxUr: boxUr, boxV: boxV, boxVH: boxVH, boxVL: boxVL, boxVR: boxVR, boxVh: boxVh, boxVl: boxVl, boxVr: boxVr, boxbox: boxbox, boxdL: boxdL, boxdR: boxdR, boxdl: boxdl, boxdr: boxdr, boxh: boxh, boxhD: boxhD, boxhU: boxhU, boxhd: boxhd, boxhu: boxhu, boxminus: boxminus, boxplus: boxplus, boxtimes: boxtimes, boxuL: boxuL, boxuR: boxuR, boxul: boxul, boxur: boxur, boxv: boxv, boxvH: boxvH, boxvL: boxvL, boxvR: boxvR, boxvh: boxvh, boxvl: boxvl, boxvr: boxvr, bprime: bprime, breve: breve, brvba: brvba, brvbar: brvbar, bscr: bscr, bsemi: bsemi, bsim: bsim, bsime: bsime, bsol: bsol, bsolb: bsolb, bsolhsub: bsolhsub, bull: bull, bullet: bullet, bump: bump, bumpE: bumpE, bumpe: bumpe, bumpeq: bumpeq, cacute: cacute, cap: cap, capand: capand, capbrcup: capbrcup, capcap: capcap, capcup: capcup, capdot: capdot, caps: caps, caret: caret, caron: caron, ccaps: ccaps, ccaron: ccaron, ccedi: ccedi, ccedil: ccedil, ccirc: ccirc, ccups: ccups, ccupssm: ccupssm, cdot: cdot, cedi: cedi, cedil: cedil, cemptyv: cemptyv, cen: cen, cent: cent, centerdot: centerdot, cfr: cfr, chcy: chcy, check: check, checkmark: checkmark, chi: chi, cir: cir, cirE: cirE, circ: circ, circeq: circeq, circlearrowleft: circlearrowleft, circlearrowright: circlearrowright, circledR: circledR, circledS: circledS, circledast: circledast, circledcirc: circledcirc, circleddash: circleddash, cire: cire, cirfnint: cirfnint, cirmid: cirmid, cirscir: cirscir, clubs: clubs, clubsuit: clubsuit, colon: colon, colone: colone, coloneq: coloneq, comma: comma, commat: commat, comp: comp, compfn: compfn, complement: complement, complexes: complexes, cong: cong, congdot: congdot, conint: conint, copf: copf, coprod: coprod, cop: cop, copy: copy, copysr: copysr, crarr: crarr, cross: cross, cscr: cscr, csub: csub, csube: csube, csup: csup, csupe: csupe, ctdot: ctdot, cudarrl: cudarrl, cudarrr: cudarrr, cuepr: cuepr, cuesc: cuesc, cularr: cularr, cularrp: cularrp, cup: cup, cupbrcap: cupbrcap, cupcap: cupcap, cupcup: cupcup, cupdot: cupdot, cupor: cupor, cups: cups, curarr: curarr, curarrm: curarrm, curlyeqprec: curlyeqprec, curlyeqsucc: curlyeqsucc, curlyvee: curlyvee, curlywedge: curlywedge, curre: curre, curren: curren, curvearrowleft: curvearrowleft, curvearrowright: curvearrowright, cuvee: cuvee, cuwed: cuwed, cwconint: cwconint, cwint: cwint, cylcty: cylcty, dArr: dArr, dHar: dHar, dagger: dagger, daleth: daleth, darr: darr, dash: dash, dashv: dashv, dbkarow: dbkarow, dblac: dblac, dcaron: dcaron, dcy: dcy, dd: dd, ddagger: ddagger, ddarr: ddarr, ddotseq: ddotseq, de: de, deg: deg, delta: delta, demptyv: demptyv, dfisht: dfisht, dfr: dfr, dharl: dharl, dharr: dharr, diam: diam, diamond: diamond, diamondsuit: diamondsuit, diams: diams, die: die, digamma: digamma, disin: disin, div: div, divid: divid, divide: divide, divideontimes: divideontimes, divonx: divonx, djcy: djcy, dlcorn: dlcorn, dlcrop: dlcrop, dollar: dollar, dopf: dopf, dot: dot, doteq: doteq, doteqdot: doteqdot, dotminus: dotminus, dotplus: dotplus, dotsquare: dotsquare, doublebarwedge: doublebarwedge, downarrow: downarrow, downdownarrows: downdownarrows, downharpoonleft: downharpoonleft, downharpoonright: downharpoonright, drbkarow: drbkarow, drcorn: drcorn, drcrop: drcrop, dscr: dscr, dscy: dscy, dsol: dsol, dstrok: dstrok, dtdot: dtdot, dtri: dtri, dtrif: dtrif, duarr: duarr, duhar: duhar, dwangle: dwangle, dzcy: dzcy, dzigrarr: dzigrarr, eDDot: eDDot, eDot: eDot, eacut: eacut, eacute: eacute, easter: easter, ecaron: ecaron, ecir: ecir, ecirc: ecirc, ecolon: ecolon, ecy: ecy, edot: edot, ee: ee, efDot: efDot, efr: efr, eg: eg, egrav: egrav, egrave: egrave, egs: egs, egsdot: egsdot, el: el, elinters: elinters, ell: ell, els: els, elsdot: elsdot, emacr: emacr, empty: empty, emptyset: emptyset, emptyv: emptyv, emsp13: emsp13, emsp14: emsp14, emsp: emsp, eng: eng, ensp: ensp, eogon: eogon, eopf: eopf, epar: epar, eparsl: eparsl, eplus: eplus, epsi: epsi, epsilon: epsilon, epsiv: epsiv, eqcirc: eqcirc, eqcolon: eqcolon, eqsim: eqsim, eqslantgtr: eqslantgtr, eqslantless: eqslantless, equals: equals, equest: equest, equiv: equiv, equivDD: equivDD, eqvparsl: eqvparsl, erDot: erDot, erarr: erarr, escr: escr, esdot: esdot, esim: esim, eta: eta, et: et, eth: eth, eum: eum, euml: euml, euro: euro, excl: excl, exist: exist, expectation: expectation, exponentiale: exponentiale, fallingdotseq: fallingdotseq, fcy: fcy, female: female, ffilig: ffilig, fflig: fflig, ffllig: ffllig, ffr: ffr, filig: filig, fjlig: fjlig, flat: flat, fllig: fllig, fltns: fltns, fnof: fnof, fopf: fopf, forall: forall, fork: fork, forkv: forkv, fpartint: fpartint, frac1: frac1, frac12: frac12, frac13: frac13, frac14: frac14, frac15: frac15, frac16: frac16, frac18: frac18, frac23: frac23, frac25: frac25, frac3: frac3, frac34: frac34, frac35: frac35, frac38: frac38, frac45: frac45, frac56: frac56, frac58: frac58, frac78: frac78, frasl: frasl, frown: frown, fscr: fscr, gE: gE, gEl: gEl, gacute: gacute, gamma: gamma, gammad: gammad, gap: gap, gbreve: gbreve, gcirc: gcirc, gcy: gcy, gdot: gdot, ge: ge, gel: gel, geq: geq, geqq: geqq, geqslant: geqslant, ges: ges, gescc: gescc, gesdot: gesdot, gesdoto: gesdoto, gesdotol: gesdotol, gesl: gesl, gesles: gesles, gfr: gfr, gg: gg, ggg: ggg, gimel: gimel, gjcy: gjcy, gl: gl, glE: glE, gla: gla, glj: glj, gnE: gnE, gnap: gnap, gnapprox: gnapprox, gne: gne, gneq: gneq, gneqq: gneqq, gnsim: gnsim, gopf: gopf, grave: grave, gscr: gscr, gsim: gsim, gsime: gsime, gsiml: gsiml, g: g, gt: gt, gtcc: gtcc, gtcir: gtcir, gtdot: gtdot, gtlPar: gtlPar, gtquest: gtquest, gtrapprox: gtrapprox, gtrarr: gtrarr, gtrdot: gtrdot, gtreqless: gtreqless, gtreqqless: gtreqqless, gtrless: gtrless, gtrsim: gtrsim, gvertneqq: gvertneqq, gvnE: gvnE, hArr: hArr, hairsp: hairsp, half: half, hamilt: hamilt, hardcy: hardcy, harr: harr, harrcir: harrcir, harrw: harrw, hbar: hbar, hcirc: hcirc, hearts: hearts, heartsuit: heartsuit, hellip: hellip, hercon: hercon, hfr: hfr, hksearow: hksearow, hkswarow: hkswarow, hoarr: hoarr, homtht: homtht, hookleftarrow: hookleftarrow, hookrightarrow: hookrightarrow, hopf: hopf, horbar: horbar, hscr: hscr, hslash: hslash, hstrok: hstrok, hybull: hybull, hyphen: hyphen, iacut: iacut, iacute: iacute, ic: ic, icir: icir, icirc: icirc, icy: icy, iecy: iecy, iexc: iexc, iexcl: iexcl, iff: iff, ifr: ifr, igrav: igrav, igrave: igrave, ii: ii, iiiint: iiiint, iiint: iiint, iinfin: iinfin, iiota: iiota, ijlig: ijlig, imacr: imacr, image: image$4, imagline: imagline, imagpart: imagpart, imath: imath, imof: imof, imped: imped, "in": "∈", incare: incare, infin: infin, infintie: infintie, inodot: inodot, int: int, intcal: intcal, integers: integers, intercal: intercal, intlarhk: intlarhk, intprod: intprod, iocy: iocy, iogon: iogon, iopf: iopf, iota: iota, iprod: iprod, iques: iques, iquest: iquest, iscr: iscr, isin: isin, isinE: isinE, isindot: isindot, isins: isins, isinsv: isinsv, isinv: isinv, it: it, itilde: itilde, iukcy: iukcy, ium: ium, iuml: iuml, jcirc: jcirc, jcy: jcy, jfr: jfr, jmath: jmath, jopf: jopf, jscr: jscr, jsercy: jsercy, jukcy: jukcy, kappa: kappa, kappav: kappav, kcedil: kcedil, kcy: kcy, kfr: kfr, kgreen: kgreen, khcy: khcy, kjcy: kjcy, kopf: kopf, kscr: kscr, lAarr: lAarr, lArr: lArr, lAtail: lAtail, lBarr: lBarr, lE: lE, lEg: lEg, lHar: lHar, lacute: lacute, laemptyv: laemptyv, lagran: lagran, lambda: lambda, lang: lang, langd: langd, langle: langle, lap: lap, laqu: laqu, laquo: laquo, larr: larr, larrb: larrb, larrbfs: larrbfs, larrfs: larrfs, larrhk: larrhk, larrlp: larrlp, larrpl: larrpl, larrsim: larrsim, larrtl: larrtl, lat: lat, latail: latail, late: late, lates: lates, lbarr: lbarr, lbbrk: lbbrk, lbrace: lbrace, lbrack: lbrack, lbrke: lbrke, lbrksld: lbrksld, lbrkslu: lbrkslu, lcaron: lcaron, lcedil: lcedil, lceil: lceil, lcub: lcub, lcy: lcy, ldca: ldca, ldquo: ldquo, ldquor: ldquor, ldrdhar: ldrdhar, ldrushar: ldrushar, ldsh: ldsh, le: le, leftarrow: leftarrow, leftarrowtail: leftarrowtail, leftharpoondown: leftharpoondown, leftharpoonup: leftharpoonup, leftleftarrows: leftleftarrows, leftrightarrow: leftrightarrow, leftrightarrows: leftrightarrows, leftrightharpoons: leftrightharpoons, leftrightsquigarrow: leftrightsquigarrow, leftthreetimes: leftthreetimes, leg: leg, leq: leq, leqq: leqq, leqslant: leqslant, les: les, lescc: lescc, lesdot: lesdot, lesdoto: lesdoto, lesdotor: lesdotor, lesg: lesg, lesges: lesges, lessapprox: lessapprox, lessdot: lessdot, lesseqgtr: lesseqgtr, lesseqqgtr: lesseqqgtr, lessgtr: lessgtr, lesssim: lesssim, lfisht: lfisht, lfloor: lfloor, lfr: lfr, lg: lg, lgE: lgE, lhard: lhard, lharu: lharu, lharul: lharul, lhblk: lhblk, ljcy: ljcy, ll: ll, llarr: llarr, llcorner: llcorner, llhard: llhard, lltri: lltri, lmidot: lmidot, lmoust: lmoust, lmoustache: lmoustache, lnE: lnE, lnap: lnap, lnapprox: lnapprox, lne: lne, lneq: lneq, lneqq: lneqq, lnsim: lnsim, loang: loang, loarr: loarr, lobrk: lobrk, longleftarrow: longleftarrow, longleftrightarrow: longleftrightarrow, longmapsto: longmapsto, longrightarrow: longrightarrow, looparrowleft: looparrowleft, looparrowright: looparrowright, lopar: lopar, lopf: lopf, loplus: loplus, lotimes: lotimes, lowast: lowast, lowbar: lowbar, loz: loz, lozenge: lozenge, lozf: lozf, lpar: lpar, lparlt: lparlt, lrarr: lrarr, lrcorner: lrcorner, lrhar: lrhar, lrhard: lrhard, lrm: lrm, lrtri: lrtri, lsaquo: lsaquo, lscr: lscr, lsh: lsh, lsim: lsim, lsime: lsime, lsimg: lsimg, lsqb: lsqb, lsquo: lsquo, lsquor: lsquor, lstrok: lstrok, l: l, lt: lt, ltcc: ltcc, ltcir: ltcir, ltdot: ltdot, lthree: lthree, ltimes: ltimes, ltlarr: ltlarr, ltquest: ltquest, ltrPar: ltrPar, ltri: ltri, ltrie: ltrie, ltrif: ltrif, lurdshar: lurdshar, luruhar: luruhar, lvertneqq: lvertneqq, lvnE: lvnE, mDDot: mDDot, mac: mac, macr: macr, male: male, malt: malt, maltese: maltese, map: map$3, mapsto: mapsto, mapstodown: mapstodown, mapstoleft: mapstoleft, mapstoup: mapstoup, marker: marker, mcomma: mcomma, mcy: mcy, mdash: mdash, measuredangle: measuredangle, mfr: mfr, mho: mho, micr: micr, micro: micro, mid: mid, midast: midast, midcir: midcir, middo: middo, middot: middot, minus: minus, minusb: minusb, minusd: minusd, minusdu: minusdu, mlcp: mlcp, mldr: mldr, mnplus: mnplus, models: models, mopf: mopf, mp: mp, mscr: mscr, mstpos: mstpos, mu: mu, multimap: multimap, mumap: mumap, nGg: nGg, nGt: nGt, nGtv: nGtv, nLeftarrow: nLeftarrow, nLeftrightarrow: nLeftrightarrow, nLl: nLl, nLt: nLt, nLtv: nLtv, nRightarrow: nRightarrow, nVDash: nVDash, nVdash: nVdash, nabla: nabla, nacute: nacute, nang: nang, nap: nap, napE: napE, napid: napid, napos: napos, napprox: napprox, natur: natur, natural: natural, naturals: naturals, nbs: nbs, nbsp: nbsp, nbump: nbump, nbumpe: nbumpe, ncap: ncap, ncaron: ncaron, ncedil: ncedil, ncong: ncong, ncongdot: ncongdot, ncup: ncup, ncy: ncy, ndash: ndash, ne: ne, neArr: neArr, nearhk: nearhk, nearr: nearr, nearrow: nearrow, nedot: nedot, nequiv: nequiv, nesear: nesear, nesim: nesim, nexist: nexist, nexists: nexists, nfr: nfr, ngE: ngE, nge: nge, ngeq: ngeq, ngeqq: ngeqq, ngeqslant: ngeqslant, nges: nges, ngsim: ngsim, ngt: ngt, ngtr: ngtr, nhArr: nhArr, nharr: nharr, nhpar: nhpar, ni: ni, nis: nis, nisd: nisd, niv: niv, njcy: njcy, nlArr: nlArr, nlE: nlE, nlarr: nlarr, nldr: nldr, nle: nle, nleftarrow: nleftarrow, nleftrightarrow: nleftrightarrow, nleq: nleq, nleqq: nleqq, nleqslant: nleqslant, nles: nles, nless: nless, nlsim: nlsim, nlt: nlt, nltri: nltri, nltrie: nltrie, nmid: nmid, nopf: nopf, no: no, not: not, notin: notin, notinE: notinE, notindot: notindot, notinva: notinva, notinvb: notinvb, notinvc: notinvc, notni: notni, notniva: notniva, notnivb: notnivb, notnivc: notnivc, npar: npar, nparallel: nparallel, nparsl: nparsl, npart: npart, npolint: npolint, npr: npr, nprcue: nprcue, npre: npre, nprec: nprec, npreceq: npreceq, nrArr: nrArr, nrarr: nrarr, nrarrc: nrarrc, nrarrw: nrarrw, nrightarrow: nrightarrow, nrtri: nrtri, nrtrie: nrtrie, nsc: nsc, nsccue: nsccue, nsce: nsce, nscr: nscr, nshortmid: nshortmid, nshortparallel: nshortparallel, nsim: nsim, nsime: nsime, nsimeq: nsimeq, nsmid: nsmid, nspar: nspar, nsqsube: nsqsube, nsqsupe: nsqsupe, nsub: nsub, nsubE: nsubE, nsube: nsube, nsubset: nsubset, nsubseteq: nsubseteq, nsubseteqq: nsubseteqq, nsucc: nsucc, nsucceq: nsucceq, nsup: nsup, nsupE: nsupE, nsupe: nsupe, nsupset: nsupset, nsupseteq: nsupseteq, nsupseteqq: nsupseteqq, ntgl: ntgl, ntild: ntild, ntilde: ntilde, ntlg: ntlg, ntriangleleft: ntriangleleft, ntrianglelefteq: ntrianglelefteq, ntriangleright: ntriangleright, ntrianglerighteq: ntrianglerighteq, nu: nu, num: num, numero: numero, numsp: numsp, nvDash: nvDash, nvHarr: nvHarr, nvap: nvap, nvdash: nvdash, nvge: nvge, nvgt: nvgt, nvinfin: nvinfin, nvlArr: nvlArr, nvle: nvle, nvlt: nvlt, nvltrie: nvltrie, nvrArr: nvrArr, nvrtrie: nvrtrie, nvsim: nvsim, nwArr: nwArr, nwarhk: nwarhk, nwarr: nwarr, nwarrow: nwarrow, nwnear: nwnear, oS: oS, oacut: oacut, oacute: oacute, oast: oast, ocir: ocir, ocirc: ocirc, ocy: ocy, odash: odash, odblac: odblac, odiv: odiv, odot: odot, odsold: odsold, oelig: oelig, ofcir: ofcir, ofr: ofr, ogon: ogon, ograv: ograv, ograve: ograve, ogt: ogt, ohbar: ohbar, ohm: ohm, oint: oint, olarr: olarr, olcir: olcir, olcross: olcross, oline: oline, olt: olt, omacr: omacr, omega: omega, omicron: omicron, omid: omid, ominus: ominus, oopf: oopf, opar: opar, operp: operp, oplus: oplus, or: or, orarr: orarr, ord: ord, order: order, orderof: orderof, ordf: ordf, ordm: ordm, origof: origof, oror: oror, orslope: orslope, orv: orv, oscr: oscr, oslas: oslas, oslash: oslash, osol: osol, otild: otild, otilde: otilde, otimes: otimes, otimesas: otimesas, oum: oum, ouml: ouml, ovbar: ovbar, par: par, para: para, parallel: parallel, parsim: parsim, parsl: parsl, part: part, pcy: pcy, percnt: percnt, period: period, permil: permil, perp: perp, pertenk: pertenk, pfr: pfr, phi: phi, phiv: phiv, phmmat: phmmat, phone: phone, pi: pi, pitchfork: pitchfork, piv: piv, planck: planck, planckh: planckh, plankv: plankv, plus: plus, plusacir: plusacir, plusb: plusb, pluscir: pluscir, plusdo: plusdo, plusdu: plusdu, pluse: pluse, plusm: plusm, plusmn: plusmn, plussim: plussim, plustwo: plustwo, pm: pm, pointint: pointint, popf: popf, poun: poun, pound: pound, pr: pr, prE: prE, prap: prap, prcue: prcue, pre: pre, prec: prec, precapprox: precapprox, preccurlyeq: preccurlyeq, preceq: preceq, precnapprox: precnapprox, precneqq: precneqq, precnsim: precnsim, precsim: precsim, prime: prime, primes: primes, prnE: prnE, prnap: prnap, prnsim: prnsim, prod: prod, profalar: profalar, profline: profline, profsurf: profsurf, prop: prop, propto: propto, prsim: prsim, prurel: prurel, pscr: pscr, psi: psi, puncsp: puncsp, qfr: qfr, qint: qint, qopf: qopf, qprime: qprime, qscr: qscr, quaternions: quaternions, quatint: quatint, quest: quest, questeq: questeq, quo: quo, quot: quot, rAarr: rAarr, rArr: rArr, rAtail: rAtail, rBarr: rBarr, rHar: rHar, race: race, racute: racute, radic: radic, raemptyv: raemptyv, rang: rang, rangd: rangd, range: range, rangle: rangle, raqu: raqu, raquo: raquo, rarr: rarr, rarrap: rarrap, rarrb: rarrb, rarrbfs: rarrbfs, rarrc: rarrc, rarrfs: rarrfs, rarrhk: rarrhk, rarrlp: rarrlp, rarrpl: rarrpl, rarrsim: rarrsim, rarrtl: rarrtl, rarrw: rarrw, ratail: ratail, ratio: ratio, rationals: rationals, rbarr: rbarr, rbbrk: rbbrk, rbrace: rbrace, rbrack: rbrack, rbrke: rbrke, rbrksld: rbrksld, rbrkslu: rbrkslu, rcaron: rcaron, rcedil: rcedil, rceil: rceil, rcub: rcub, rcy: rcy, rdca: rdca, rdldhar: rdldhar, rdquo: rdquo, rdquor: rdquor, rdsh: rdsh, real: real, realine: realine, realpart: realpart, reals: reals, rect: rect, re: re, reg: reg, rfisht: rfisht, rfloor: rfloor, rfr: rfr, rhard: rhard, rharu: rharu, rharul: rharul, rho: rho, rhov: rhov, rightarrow: rightarrow, rightarrowtail: rightarrowtail, rightharpoondown: rightharpoondown, rightharpoonup: rightharpoonup, rightleftarrows: rightleftarrows, rightleftharpoons: rightleftharpoons, rightrightarrows: rightrightarrows, rightsquigarrow: rightsquigarrow, rightthreetimes: rightthreetimes, ring: ring, risingdotseq: risingdotseq, rlarr: rlarr, rlhar: rlhar, rlm: rlm, rmoust: rmoust, rmoustache: rmoustache, rnmid: rnmid, roang: roang, roarr: roarr, robrk: robrk, ropar: ropar, ropf: ropf, roplus: roplus, rotimes: rotimes, rpar: rpar, rpargt: rpargt, rppolint: rppolint, rrarr: rrarr, rsaquo: rsaquo, rscr: rscr, rsh: rsh, rsqb: rsqb, rsquo: rsquo, rsquor: rsquor, rthree: rthree, rtimes: rtimes, rtri: rtri, rtrie: rtrie, rtrif: rtrif, rtriltri: rtriltri, ruluhar: ruluhar, rx: rx, sacute: sacute, sbquo: sbquo, sc: sc, scE: scE, scap: scap, scaron: scaron, sccue: sccue, sce: sce, scedil: scedil, scirc: scirc, scnE: scnE, scnap: scnap, scnsim: scnsim, scpolint: scpolint, scsim: scsim, scy: scy, sdot: sdot, sdotb: sdotb, sdote: sdote, seArr: seArr, searhk: searhk, searr: searr, searrow: searrow, sec: sec, sect: sect, semi: semi, seswar: seswar, setminus: setminus, setmn: setmn, sext: sext, sfr: sfr, sfrown: sfrown, sharp: sharp, shchcy: shchcy, shcy: shcy, shortmid: shortmid, shortparallel: shortparallel, sh: sh, shy: shy, sigma: sigma, sigmaf: sigmaf, sigmav: sigmav, sim: sim, simdot: simdot, sime: sime, simeq: simeq, simg: simg, simgE: simgE, siml: siml, simlE: simlE, simne: simne, simplus: simplus, simrarr: simrarr, slarr: slarr, smallsetminus: smallsetminus, smashp: smashp, smeparsl: smeparsl, smid: smid, smile: smile, smt: smt, smte: smte, smtes: smtes, softcy: softcy, sol: sol, solb: solb, solbar: solbar, sopf: sopf, spades: spades, spadesuit: spadesuit, spar: spar, sqcap: sqcap, sqcaps: sqcaps, sqcup: sqcup, sqcups: sqcups, sqsub: sqsub, sqsube: sqsube, sqsubset: sqsubset, sqsubseteq: sqsubseteq, sqsup: sqsup, sqsupe: sqsupe, sqsupset: sqsupset, sqsupseteq: sqsupseteq, squ: squ, square: square, squarf: squarf, squf: squf, srarr: srarr, sscr: sscr, ssetmn: ssetmn, ssmile: ssmile, sstarf: sstarf, star: star, starf: starf, straightepsilon: straightepsilon, straightphi: straightphi, strns: strns, sub: sub, subE: subE, subdot: subdot, sube: sube, subedot: subedot, submult: submult, subnE: subnE, subne: subne, subplus: subplus, subrarr: subrarr, subset: subset, subseteq: subseteq, subseteqq: subseteqq, subsetneq: subsetneq, subsetneqq: subsetneqq, subsim: subsim, subsub: subsub, subsup: subsup, succ: succ, succapprox: succapprox, succcurlyeq: succcurlyeq, succeq: succeq, succnapprox: succnapprox, succneqq: succneqq, succnsim: succnsim, succsim: succsim, sum: sum, sung: sung, sup: sup, sup1: sup1, sup2: sup2, sup3: sup3, supE: supE, supdot: supdot, supdsub: supdsub, supe: supe, supedot: supedot, suphsol: suphsol, suphsub: suphsub, suplarr: suplarr, supmult: supmult, supnE: supnE, supne: supne, supplus: supplus, supset: supset, supseteq: supseteq, supseteqq: supseteqq, supsetneq: supsetneq, supsetneqq: supsetneqq, supsim: supsim, supsub: supsub, supsup: supsup, swArr: swArr, swarhk: swarhk, swarr: swarr, swarrow: swarrow, swnwar: swnwar, szli: szli, szlig: szlig, target: target, tau: tau, tbrk: tbrk, tcaron: tcaron, tcedil: tcedil, tcy: tcy, tdot: tdot, telrec: telrec, tfr: tfr, there4: there4, therefore: therefore, theta: theta, thetasym: thetasym, thetav: thetav, thickapprox: thickapprox, thicksim: thicksim, thinsp: thinsp, thkap: thkap, thksim: thksim, thor: thor, thorn: thorn, tilde: tilde, time: time, times: times, timesb: timesb, timesbar: timesbar, timesd: timesd, tint: tint, toea: toea, top: top, topbot: topbot, topcir: topcir, topf: topf, topfork: topfork, tosa: tosa, tprime: tprime, trade: trade, triangle: triangle, triangledown: triangledown, triangleleft: triangleleft, trianglelefteq: trianglelefteq, triangleq: triangleq, triangleright: triangleright, trianglerighteq: trianglerighteq, tridot: tridot, trie: trie, triminus: triminus, triplus: triplus, trisb: trisb, tritime: tritime, trpezium: trpezium, tscr: tscr, tscy: tscy, tshcy: tshcy, tstrok: tstrok, twixt: twixt, twoheadleftarrow: twoheadleftarrow, twoheadrightarrow: twoheadrightarrow, uArr: uArr, uHar: uHar, uacut: uacut, uacute: uacute, uarr: uarr, ubrcy: ubrcy, ubreve: ubreve, ucir: ucir, ucirc: ucirc, ucy: ucy, udarr: udarr, udblac: udblac, udhar: udhar, ufisht: ufisht, ufr: ufr, ugrav: ugrav, ugrave: ugrave, uharl: uharl, uharr: uharr, uhblk: uhblk, ulcorn: ulcorn, ulcorner: ulcorner, ulcrop: ulcrop, ultri: ultri, umacr: umacr, um: um, uml: uml, uogon: uogon, uopf: uopf, uparrow: uparrow, updownarrow: updownarrow, upharpoonleft: upharpoonleft, upharpoonright: upharpoonright, uplus: uplus, upsi: upsi, upsih: upsih, upsilon: upsilon, upuparrows: upuparrows, urcorn: urcorn, urcorner: urcorner, urcrop: urcrop, uring: uring, urtri: urtri, uscr: uscr, utdot: utdot, utilde: utilde, utri: utri, utrif: utrif, uuarr: uuarr, uum: uum, uuml: uuml, uwangle: uwangle, vArr: vArr, vBar: vBar, vBarv: vBarv, vDash: vDash, vangrt: vangrt, varepsilon: varepsilon, varkappa: varkappa, varnothing: varnothing, varphi: varphi, varpi: varpi, varpropto: varpropto, varr: varr, varrho: varrho, varsigma: varsigma, varsubsetneq: varsubsetneq, varsubsetneqq: varsubsetneqq, varsupsetneq: varsupsetneq, varsupsetneqq: varsupsetneqq, vartheta: vartheta, vartriangleleft: vartriangleleft, vartriangleright: vartriangleright, vcy: vcy, vdash: vdash, vee: vee, veebar: veebar, veeeq: veeeq, vellip: vellip, verbar: verbar, vert: vert, vfr: vfr, vltri: vltri, vnsub: vnsub, vnsup: vnsup, vopf: vopf, vprop: vprop, vrtri: vrtri, vscr: vscr, vsubnE: vsubnE, vsubne: vsubne, vsupnE: vsupnE, vsupne: vsupne, vzigzag: vzigzag, wcirc: wcirc, wedbar: wedbar, wedge: wedge, wedgeq: wedgeq, weierp: weierp, wfr: wfr, wopf: wopf, wp: wp, wr: wr, wreath: wreath, wscr: wscr, xcap: xcap, xcirc: xcirc, xcup: xcup, xdtri: xdtri, xfr: xfr, xhArr: xhArr, xharr: xharr, xi: xi, xlArr: xlArr, xlarr: xlarr, xmap: xmap, xnis: xnis, xodot: xodot, xopf: xopf, xoplus: xoplus, xotime: xotime, xrArr: xrArr, xrarr: xrarr, xscr: xscr, xsqcup: xsqcup, xuplus: xuplus, xutri: xutri, xvee: xvee, xwedge: xwedge, yacut: yacut, yacute: yacute, yacy: yacy, ycirc: ycirc, ycy: ycy, ye: ye, yen: yen, yfr: yfr, yicy: yicy, yopf: yopf, yscr: yscr, yucy: yucy, yum: yum, yuml: yuml, zacute: zacute, zcaron: zcaron, zcy: zcy, zdot: zdot, zeetrf: zeetrf, zeta: zeta, zfr: zfr, zhcy: zhcy, zigrarr: zigrarr, zopf: zopf, zscr: zscr, zwj: zwj, zwnj: zwnj }; var decodeEntity_1 = decodeEntity; var own$1 = {}.hasOwnProperty; function decodeEntity(characters) { return own$1.call(characterEntities, characters) ? characterEntities[characters] : false } var asciiDigit = regexCheck_1(/\d/); var asciiDigit_1 = asciiDigit; var asciiHexDigit = regexCheck_1(/[\dA-Fa-f]/); var asciiHexDigit_1 = asciiHexDigit; function _interopDefaultLegacy$1(e) { return e && typeof e === 'object' && 'default' in e ? e : {default: e} } var decodeEntity__default = /*#__PURE__*/ _interopDefaultLegacy$1(decodeEntity_1); var characterReference$2 = { name: 'characterReference', tokenize: tokenizeCharacterReference }; function tokenizeCharacterReference(effects, ok, nok) { var self = this; var size = 0; var max; var test; return start function start(code) { effects.enter('characterReference'); effects.enter('characterReferenceMarker'); effects.consume(code); effects.exit('characterReferenceMarker'); return open } function open(code) { if (code === 35) { effects.enter('characterReferenceMarkerNumeric'); effects.consume(code); effects.exit('characterReferenceMarkerNumeric'); return numeric } effects.enter('characterReferenceValue'); max = 31; test = asciiAlphanumeric_1; return value(code) } function numeric(code) { if (code === 88 || code === 120) { effects.enter('characterReferenceMarkerHexadecimal'); effects.consume(code); effects.exit('characterReferenceMarkerHexadecimal'); effects.enter('characterReferenceValue'); max = 6; test = asciiHexDigit_1; return value } effects.enter('characterReferenceValue'); max = 7; test = asciiDigit_1; return value(code) } function value(code) { var token; if (code === 59 && size) { token = effects.exit('characterReferenceValue'); if ( test === asciiAlphanumeric_1 && !decodeEntity__default['default'](self.sliceSerialize(token)) ) { return nok(code) } effects.enter('characterReferenceMarker'); effects.consume(code); effects.exit('characterReferenceMarker'); effects.exit('characterReference'); return ok } if (test(code) && size++ < max) { effects.consume(code); return value } return nok(code) } } var characterReference_1 = characterReference$2; var codeFenced = { name: 'codeFenced', tokenize: tokenizeCodeFenced, concrete: true }; function tokenizeCodeFenced(effects, ok, nok) { var self = this; var closingFenceConstruct = { tokenize: tokenizeClosingFence, partial: true }; var initialPrefix = prefixSize_1(this.events, 'linePrefix'); var sizeOpen = 0; var marker; return start function start(code) { effects.enter('codeFenced'); effects.enter('codeFencedFence'); effects.enter('codeFencedFenceSequence'); marker = code; return sequenceOpen(code) } function sequenceOpen(code) { if (code === marker) { effects.consume(code); sizeOpen++; return sequenceOpen } effects.exit('codeFencedFenceSequence'); return sizeOpen < 3 ? nok(code) : factorySpace(effects, infoOpen, 'whitespace')(code) } function infoOpen(code) { if (code === null || markdownLineEnding_1(code)) { return openAfter(code) } effects.enter('codeFencedFenceInfo'); effects.enter('chunkString', { contentType: 'string' }); return info(code) } function info(code) { if (code === null || markdownLineEndingOrSpace_1(code)) { effects.exit('chunkString'); effects.exit('codeFencedFenceInfo'); return factorySpace(effects, infoAfter, 'whitespace')(code) } if (code === 96 && code === marker) return nok(code) effects.consume(code); return info } function infoAfter(code) { if (code === null || markdownLineEnding_1(code)) { return openAfter(code) } effects.enter('codeFencedFenceMeta'); effects.enter('chunkString', { contentType: 'string' }); return meta(code) } function meta(code) { if (code === null || markdownLineEnding_1(code)) { effects.exit('chunkString'); effects.exit('codeFencedFenceMeta'); return openAfter(code) } if (code === 96 && code === marker) return nok(code) effects.consume(code); return meta } function openAfter(code) { effects.exit('codeFencedFence'); return self.interrupt ? ok(code) : content(code) } function content(code) { if (code === null) { return after(code) } if (markdownLineEnding_1(code)) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return effects.attempt( closingFenceConstruct, after, initialPrefix ? factorySpace(effects, content, 'linePrefix', initialPrefix + 1) : content ) } effects.enter('codeFlowValue'); return contentContinue(code) } function contentContinue(code) { if (code === null || markdownLineEnding_1(code)) { effects.exit('codeFlowValue'); return content(code) } effects.consume(code); return contentContinue } function after(code) { effects.exit('codeFenced'); return ok(code) } function tokenizeClosingFence(effects, ok, nok) { var size = 0; return factorySpace( effects, closingSequenceStart, 'linePrefix', this.parser.constructs.disable.null.indexOf('codeIndented') > -1 ? undefined : 4 ) function closingSequenceStart(code) { effects.enter('codeFencedFence'); effects.enter('codeFencedFenceSequence'); return closingSequence(code) } function closingSequence(code) { if (code === marker) { effects.consume(code); size++; return closingSequence } if (size < sizeOpen) return nok(code) effects.exit('codeFencedFenceSequence'); return factorySpace(effects, closingSequenceEnd, 'whitespace')(code) } function closingSequenceEnd(code) { if (code === null || markdownLineEnding_1(code)) { effects.exit('codeFencedFence'); return ok(code) } return nok(code) } } } var codeFenced_1 = codeFenced; var codeIndented = { name: 'codeIndented', tokenize: tokenizeCodeIndented, resolve: resolveCodeIndented }; var indentedContentConstruct = { tokenize: tokenizeIndentedContent, partial: true }; function resolveCodeIndented(events, context) { var code = { type: 'codeIndented', start: events[0][1].start, end: events[events.length - 1][1].end }; chunkedSplice_1(events, 0, 0, [['enter', code, context]]); chunkedSplice_1(events, events.length, 0, [['exit', code, context]]); return events } function tokenizeCodeIndented(effects, ok, nok) { return effects.attempt(indentedContentConstruct, afterPrefix, nok) function afterPrefix(code) { if (code === null) { return ok(code) } if (markdownLineEnding_1(code)) { return effects.attempt(indentedContentConstruct, afterPrefix, ok)(code) } effects.enter('codeFlowValue'); return content(code) } function content(code) { if (code === null || markdownLineEnding_1(code)) { effects.exit('codeFlowValue'); return afterPrefix(code) } effects.consume(code); return content } } function tokenizeIndentedContent(effects, ok, nok) { var self = this; return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1) function afterPrefix(code) { if (markdownLineEnding_1(code)) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1) } return prefixSize_1(self.events, 'linePrefix') < 4 ? nok(code) : ok(code) } } var codeIndented_1 = codeIndented; var codeText = { name: 'codeText', tokenize: tokenizeCodeText, resolve: resolveCodeText, previous: previous }; function resolveCodeText(events) { var tailExitIndex = events.length - 4; var headEnterIndex = 3; var index; var enter; // If we start and end with an EOL or a space. if ( (events[headEnterIndex][1].type === 'lineEnding' || events[headEnterIndex][1].type === 'space') && (events[tailExitIndex][1].type === 'lineEnding' || events[tailExitIndex][1].type === 'space') ) { index = headEnterIndex; // And we have data. while (++index < tailExitIndex) { if (events[index][1].type === 'codeTextData') { // Then we have padding. events[tailExitIndex][1].type = events[headEnterIndex][1].type = 'codeTextPadding'; headEnterIndex += 2; tailExitIndex -= 2; break } } } // Merge adjacent spaces and data. index = headEnterIndex - 1; tailExitIndex++; while (++index <= tailExitIndex) { if (enter === undefined) { if (index !== tailExitIndex && events[index][1].type !== 'lineEnding') { enter = index; } } else if ( index === tailExitIndex || events[index][1].type === 'lineEnding' ) { events[enter][1].type = 'codeTextData'; if (index !== enter + 2) { events[enter][1].end = events[index - 1][1].end; events.splice(enter + 2, index - enter - 2); tailExitIndex -= index - enter - 2; index = enter + 2; } enter = undefined; } } return events } function previous(code) { // If there is a previous code, there will always be a tail. return ( code !== 96 || this.events[this.events.length - 1][1].type === 'characterEscape' ) } function tokenizeCodeText(effects, ok, nok) { var sizeOpen = 0; var size; var token; return start function start(code) { effects.enter('codeText'); effects.enter('codeTextSequence'); return openingSequence(code) } function openingSequence(code) { if (code === 96) { effects.consume(code); sizeOpen++; return openingSequence } effects.exit('codeTextSequence'); return gap(code) } function gap(code) { // EOF. if (code === null) { return nok(code) } // Closing fence? // Could also be data. if (code === 96) { token = effects.enter('codeTextSequence'); size = 0; return closingSequence(code) } // Tabs don’t work, and virtual spaces don’t make sense. if (code === 32) { effects.enter('space'); effects.consume(code); effects.exit('space'); return gap } if (markdownLineEnding_1(code)) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return gap } // Data. effects.enter('codeTextData'); return data(code) } // In code. function data(code) { if ( code === null || code === 32 || code === 96 || markdownLineEnding_1(code) ) { effects.exit('codeTextData'); return gap(code) } effects.consume(code); return data } // Closing fence. function closingSequence(code) { // More. if (code === 96) { effects.consume(code); size++; return closingSequence } // Done! if (size === sizeOpen) { effects.exit('codeTextSequence'); effects.exit('codeText'); return ok(code) } // More or less accents: mark as data. token.type = 'codeTextData'; return data(code) } } var codeText_1 = codeText; // eslint-disable-next-line max-params function destinationFactory( effects, ok, nok, type, literalType, literalMarkerType, rawType, stringType, max ) { var limit = max || Infinity; var balance = 0; return start function start(code) { if (code === 60) { effects.enter(type); effects.enter(literalType); effects.enter(literalMarkerType); effects.consume(code); effects.exit(literalMarkerType); return destinationEnclosedBefore } if (asciiControl_1(code) || code === 41) { return nok(code) } effects.enter(type); effects.enter(rawType); effects.enter(stringType); effects.enter('chunkString', { contentType: 'string' }); return destinationRaw(code) } function destinationEnclosedBefore(code) { if (code === 62) { effects.enter(literalMarkerType); effects.consume(code); effects.exit(literalMarkerType); effects.exit(literalType); effects.exit(type); return ok } effects.enter(stringType); effects.enter('chunkString', { contentType: 'string' }); return destinationEnclosed(code) } function destinationEnclosed(code) { if (code === 62) { effects.exit('chunkString'); effects.exit(stringType); return destinationEnclosedBefore(code) } if (code === null || code === 60 || markdownLineEnding_1(code)) { return nok(code) } effects.consume(code); return code === 92 ? destinationEnclosedEscape : destinationEnclosed } function destinationEnclosedEscape(code) { if (code === 60 || code === 62 || code === 92) { effects.consume(code); return destinationEnclosed } return destinationEnclosed(code) } function destinationRaw(code) { if (code === 40) { if (++balance > limit) return nok(code) effects.consume(code); return destinationRaw } if (code === 41) { if (!balance--) { effects.exit('chunkString'); effects.exit(stringType); effects.exit(rawType); effects.exit(type); return ok(code) } effects.consume(code); return destinationRaw } if (code === null || markdownLineEndingOrSpace_1(code)) { if (balance) return nok(code) effects.exit('chunkString'); effects.exit(stringType); effects.exit(rawType); effects.exit(type); return ok(code) } if (asciiControl_1(code)) return nok(code) effects.consume(code); return code === 92 ? destinationRawEscape : destinationRaw } function destinationRawEscape(code) { if (code === 40 || code === 41 || code === 92) { effects.consume(code); return destinationRaw } return destinationRaw(code) } } var factoryDestination = destinationFactory; // eslint-disable-next-line max-params function labelFactory(effects, ok, nok, type, markerType, stringType) { var self = this; var size = 0; var data; return start function start(code) { effects.enter(type); effects.enter(markerType); effects.consume(code); effects.exit(markerType); effects.enter(stringType); return atBreak } function atBreak(code) { if ( code === null || code === 91 || (code === 93 && !data) || /* c8 ignore next */ (code === 94 && /* c8 ignore next */ !size && /* c8 ignore next */ '_hiddenFootnoteSupport' in self.parser.constructs) || size > 999 ) { return nok(code) } if (code === 93) { effects.exit(stringType); effects.enter(markerType); effects.consume(code); effects.exit(markerType); effects.exit(type); return ok } if (markdownLineEnding_1(code)) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return atBreak } effects.enter('chunkString', { contentType: 'string' }); return label(code) } function label(code) { if ( code === null || code === 91 || code === 93 || markdownLineEnding_1(code) || size++ > 999 ) { effects.exit('chunkString'); return atBreak(code) } effects.consume(code); data = data || !markdownSpace_1(code); return code === 92 ? labelEscape : label } function labelEscape(code) { if (code === 91 || code === 92 || code === 93) { effects.consume(code); size++; return label } return label(code) } } var factoryLabel = labelFactory; function whitespaceFactory(effects, ok) { var seen; return start function start(code) { if (markdownLineEnding_1(code)) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); seen = true; return start } if (markdownSpace_1(code)) { return factorySpace( effects, start, seen ? 'linePrefix' : 'lineSuffix' )(code) } return ok(code) } } var factoryWhitespace = whitespaceFactory; function titleFactory(effects, ok, nok, type, markerType, stringType) { var marker; return start function start(code) { effects.enter(type); effects.enter(markerType); effects.consume(code); effects.exit(markerType); marker = code === 40 ? 41 : code; return atFirstTitleBreak } function atFirstTitleBreak(code) { if (code === marker) { effects.enter(markerType); effects.consume(code); effects.exit(markerType); effects.exit(type); return ok } effects.enter(stringType); return atTitleBreak(code) } function atTitleBreak(code) { if (code === marker) { effects.exit(stringType); return atFirstTitleBreak(marker) } if (code === null) { return nok(code) } // Note: blank lines can’t exist in content. if (markdownLineEnding_1(code)) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return factorySpace(effects, atTitleBreak, 'linePrefix') } effects.enter('chunkString', { contentType: 'string' }); return title(code) } function title(code) { if (code === marker || code === null || markdownLineEnding_1(code)) { effects.exit('chunkString'); return atTitleBreak(code) } effects.consume(code); return code === 92 ? titleEscape : title } function titleEscape(code) { if (code === marker || code === 92) { effects.consume(code); return title } return title(code) } } var factoryTitle = titleFactory; var definition$4 = { name: 'definition', tokenize: tokenizeDefinition }; var titleConstruct = { tokenize: tokenizeTitle, partial: true }; function tokenizeDefinition(effects, ok, nok) { var self = this; var identifier; return start function start(code) { effects.enter('definition'); return factoryLabel.call( self, effects, labelAfter, nok, 'definitionLabel', 'definitionLabelMarker', 'definitionLabelString' )(code) } function labelAfter(code) { identifier = normalizeIdentifier_1( self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) ); if (code === 58) { effects.enter('definitionMarker'); effects.consume(code); effects.exit('definitionMarker'); // Note: blank lines can’t exist in content. return factoryWhitespace( effects, factoryDestination( effects, effects.attempt( titleConstruct, factorySpace(effects, after, 'whitespace'), factorySpace(effects, after, 'whitespace') ), nok, 'definitionDestination', 'definitionDestinationLiteral', 'definitionDestinationLiteralMarker', 'definitionDestinationRaw', 'definitionDestinationString' ) ) } return nok(code) } function after(code) { if (code === null || markdownLineEnding_1(code)) { effects.exit('definition'); if (self.parser.defined.indexOf(identifier) < 0) { self.parser.defined.push(identifier); } return ok(code) } return nok(code) } } function tokenizeTitle(effects, ok, nok) { return start function start(code) { return markdownLineEndingOrSpace_1(code) ? factoryWhitespace(effects, before)(code) : nok(code) } function before(code) { if (code === 34 || code === 39 || code === 40) { return factoryTitle( effects, factorySpace(effects, after, 'whitespace'), nok, 'definitionTitle', 'definitionTitleMarker', 'definitionTitleString' )(code) } return nok(code) } function after(code) { return code === null || markdownLineEnding_1(code) ? ok(code) : nok(code) } } var definition_1$2 = definition$4; var hardBreakEscape = { name: 'hardBreakEscape', tokenize: tokenizeHardBreakEscape }; function tokenizeHardBreakEscape(effects, ok, nok) { return start function start(code) { effects.enter('hardBreakEscape'); effects.enter('escapeMarker'); effects.consume(code); return open } function open(code) { if (markdownLineEnding_1(code)) { effects.exit('escapeMarker'); effects.exit('hardBreakEscape'); return ok(code) } return nok(code) } } var hardBreakEscape_1 = hardBreakEscape; var headingAtx = { name: 'headingAtx', tokenize: tokenizeHeadingAtx, resolve: resolveHeadingAtx }; function resolveHeadingAtx(events, context) { var contentEnd = events.length - 2; var contentStart = 3; var content; var text; // Prefix whitespace, part of the opening. if (events[contentStart][1].type === 'whitespace') { contentStart += 2; } // Suffix whitespace, part of the closing. if ( contentEnd - 2 > contentStart && events[contentEnd][1].type === 'whitespace' ) { contentEnd -= 2; } if ( events[contentEnd][1].type === 'atxHeadingSequence' && (contentStart === contentEnd - 1 || (contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === 'whitespace')) ) { contentEnd -= contentStart + 1 === contentEnd ? 2 : 4; } if (contentEnd > contentStart) { content = { type: 'atxHeadingText', start: events[contentStart][1].start, end: events[contentEnd][1].end }; text = { type: 'chunkText', start: events[contentStart][1].start, end: events[contentEnd][1].end, contentType: 'text' }; chunkedSplice_1(events, contentStart, contentEnd - contentStart + 1, [ ['enter', content, context], ['enter', text, context], ['exit', text, context], ['exit', content, context] ]); } return events } function tokenizeHeadingAtx(effects, ok, nok) { var self = this; var size = 0; return start function start(code) { effects.enter('atxHeading'); effects.enter('atxHeadingSequence'); return fenceOpenInside(code) } function fenceOpenInside(code) { if (code === 35 && size++ < 6) { effects.consume(code); return fenceOpenInside } if (code === null || markdownLineEndingOrSpace_1(code)) { effects.exit('atxHeadingSequence'); return self.interrupt ? ok(code) : headingBreak(code) } return nok(code) } function headingBreak(code) { if (code === 35) { effects.enter('atxHeadingSequence'); return sequence(code) } if (code === null || markdownLineEnding_1(code)) { effects.exit('atxHeading'); return ok(code) } if (markdownSpace_1(code)) { return factorySpace(effects, headingBreak, 'whitespace')(code) } effects.enter('atxHeadingText'); return data(code) } function sequence(code) { if (code === 35) { effects.consume(code); return sequence } effects.exit('atxHeadingSequence'); return headingBreak(code) } function data(code) { if (code === null || code === 35 || markdownLineEndingOrSpace_1(code)) { effects.exit('atxHeadingText'); return headingBreak(code) } effects.consume(code); return data } } var headingAtx_1 = headingAtx; // This module is copied from . var basics = [ 'address', 'article', 'aside', 'base', 'basefont', 'blockquote', 'body', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dialog', 'dir', 'div', 'dl', 'dt', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hr', 'html', 'iframe', 'legend', 'li', 'link', 'main', 'menu', 'menuitem', 'nav', 'noframes', 'ol', 'optgroup', 'option', 'p', 'param', 'section', 'source', 'summary', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul' ]; var htmlBlockNames = basics; // This module is copied from . var raws = ['pre', 'script', 'style', 'textarea']; var htmlRawNames = raws; var htmlFlow = { name: 'htmlFlow', tokenize: tokenizeHtmlFlow, resolveTo: resolveToHtmlFlow, concrete: true }; var nextBlankConstruct = { tokenize: tokenizeNextBlank, partial: true }; function resolveToHtmlFlow(events) { var index = events.length; while (index--) { if (events[index][0] === 'enter' && events[index][1].type === 'htmlFlow') { break } } if (index > 1 && events[index - 2][1].type === 'linePrefix') { // Add the prefix start to the HTML token. events[index][1].start = events[index - 2][1].start; // Add the prefix start to the HTML line token. events[index + 1][1].start = events[index - 2][1].start; // Remove the line prefix. events.splice(index - 2, 2); } return events } function tokenizeHtmlFlow(effects, ok, nok) { var self = this; var kind; var startTag; var buffer; var index; var marker; return start function start(code) { effects.enter('htmlFlow'); effects.enter('htmlFlowData'); effects.consume(code); return open } function open(code) { if (code === 33) { effects.consume(code); return declarationStart } if (code === 47) { effects.consume(code); return tagCloseStart } if (code === 63) { effects.consume(code); kind = 3; // While we’re in an instruction instead of a declaration, we’re on a `?` // right now, so we do need to search for `>`, similar to declarations. return self.interrupt ? ok : continuationDeclarationInside } if (asciiAlpha_1(code)) { effects.consume(code); buffer = fromCharCode_1(code); startTag = true; return tagName } return nok(code) } function declarationStart(code) { if (code === 45) { effects.consume(code); kind = 2; return commentOpenInside } if (code === 91) { effects.consume(code); kind = 5; buffer = 'CDATA['; index = 0; return cdataOpenInside } if (asciiAlpha_1(code)) { effects.consume(code); kind = 4; return self.interrupt ? ok : continuationDeclarationInside } return nok(code) } function commentOpenInside(code) { if (code === 45) { effects.consume(code); return self.interrupt ? ok : continuationDeclarationInside } return nok(code) } function cdataOpenInside(code) { if (code === buffer.charCodeAt(index++)) { effects.consume(code); return index === buffer.length ? self.interrupt ? ok : continuation : cdataOpenInside } return nok(code) } function tagCloseStart(code) { if (asciiAlpha_1(code)) { effects.consume(code); buffer = fromCharCode_1(code); return tagName } return nok(code) } function tagName(code) { if ( code === null || code === 47 || code === 62 || markdownLineEndingOrSpace_1(code) ) { if ( code !== 47 && startTag && htmlRawNames.indexOf(buffer.toLowerCase()) > -1 ) { kind = 1; return self.interrupt ? ok(code) : continuation(code) } if (htmlBlockNames.indexOf(buffer.toLowerCase()) > -1) { kind = 6; if (code === 47) { effects.consume(code); return basicSelfClosing } return self.interrupt ? ok(code) : continuation(code) } kind = 7; // Do not support complete HTML when interrupting. return self.interrupt ? nok(code) : startTag ? completeAttributeNameBefore(code) : completeClosingTagAfter(code) } if (code === 45 || asciiAlphanumeric_1(code)) { effects.consume(code); buffer += fromCharCode_1(code); return tagName } return nok(code) } function basicSelfClosing(code) { if (code === 62) { effects.consume(code); return self.interrupt ? ok : continuation } return nok(code) } function completeClosingTagAfter(code) { if (markdownSpace_1(code)) { effects.consume(code); return completeClosingTagAfter } return completeEnd(code) } function completeAttributeNameBefore(code) { if (code === 47) { effects.consume(code); return completeEnd } if (code === 58 || code === 95 || asciiAlpha_1(code)) { effects.consume(code); return completeAttributeName } if (markdownSpace_1(code)) { effects.consume(code); return completeAttributeNameBefore } return completeEnd(code) } function completeAttributeName(code) { if ( code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric_1(code) ) { effects.consume(code); return completeAttributeName } return completeAttributeNameAfter(code) } function completeAttributeNameAfter(code) { if (code === 61) { effects.consume(code); return completeAttributeValueBefore } if (markdownSpace_1(code)) { effects.consume(code); return completeAttributeNameAfter } return completeAttributeNameBefore(code) } function completeAttributeValueBefore(code) { if ( code === null || code === 60 || code === 61 || code === 62 || code === 96 ) { return nok(code) } if (code === 34 || code === 39) { effects.consume(code); marker = code; return completeAttributeValueQuoted } if (markdownSpace_1(code)) { effects.consume(code); return completeAttributeValueBefore } marker = undefined; return completeAttributeValueUnquoted(code) } function completeAttributeValueQuoted(code) { if (code === marker) { effects.consume(code); return completeAttributeValueQuotedAfter } if (code === null || markdownLineEnding_1(code)) { return nok(code) } effects.consume(code); return completeAttributeValueQuoted } function completeAttributeValueUnquoted(code) { if ( code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 62 || code === 96 || markdownLineEndingOrSpace_1(code) ) { return completeAttributeNameAfter(code) } effects.consume(code); return completeAttributeValueUnquoted } function completeAttributeValueQuotedAfter(code) { if (code === 47 || code === 62 || markdownSpace_1(code)) { return completeAttributeNameBefore(code) } return nok(code) } function completeEnd(code) { if (code === 62) { effects.consume(code); return completeAfter } return nok(code) } function completeAfter(code) { if (markdownSpace_1(code)) { effects.consume(code); return completeAfter } return code === null || markdownLineEnding_1(code) ? continuation(code) : nok(code) } function continuation(code) { if (code === 45 && kind === 2) { effects.consume(code); return continuationCommentInside } if (code === 60 && kind === 1) { effects.consume(code); return continuationRawTagOpen } if (code === 62 && kind === 4) { effects.consume(code); return continuationClose } if (code === 63 && kind === 3) { effects.consume(code); return continuationDeclarationInside } if (code === 93 && kind === 5) { effects.consume(code); return continuationCharacterDataInside } if (markdownLineEnding_1(code) && (kind === 6 || kind === 7)) { return effects.check( nextBlankConstruct, continuationClose, continuationAtLineEnding )(code) } if (code === null || markdownLineEnding_1(code)) { return continuationAtLineEnding(code) } effects.consume(code); return continuation } function continuationAtLineEnding(code) { effects.exit('htmlFlowData'); return htmlContinueStart(code) } function htmlContinueStart(code) { if (code === null) { return done(code) } if (markdownLineEnding_1(code)) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return htmlContinueStart } effects.enter('htmlFlowData'); return continuation(code) } function continuationCommentInside(code) { if (code === 45) { effects.consume(code); return continuationDeclarationInside } return continuation(code) } function continuationRawTagOpen(code) { if (code === 47) { effects.consume(code); buffer = ''; return continuationRawEndTag } return continuation(code) } function continuationRawEndTag(code) { if (code === 62 && htmlRawNames.indexOf(buffer.toLowerCase()) > -1) { effects.consume(code); return continuationClose } if (asciiAlpha_1(code) && buffer.length < 8) { effects.consume(code); buffer += fromCharCode_1(code); return continuationRawEndTag } return continuation(code) } function continuationCharacterDataInside(code) { if (code === 93) { effects.consume(code); return continuationDeclarationInside } return continuation(code) } function continuationDeclarationInside(code) { if (code === 62) { effects.consume(code); return continuationClose } return continuation(code) } function continuationClose(code) { if (code === null || markdownLineEnding_1(code)) { effects.exit('htmlFlowData'); return done(code) } effects.consume(code); return continuationClose } function done(code) { effects.exit('htmlFlow'); return ok(code) } } function tokenizeNextBlank(effects, ok, nok) { return start function start(code) { effects.exit('htmlFlowData'); effects.enter('lineEndingBlank'); effects.consume(code); effects.exit('lineEndingBlank'); return effects.attempt(partialBlankLine_1, ok, nok) } } var htmlFlow_1 = htmlFlow; var htmlText = { name: 'htmlText', tokenize: tokenizeHtmlText }; function tokenizeHtmlText(effects, ok, nok) { var self = this; var marker; var buffer; var index; var returnState; return start function start(code) { effects.enter('htmlText'); effects.enter('htmlTextData'); effects.consume(code); return open } function open(code) { if (code === 33) { effects.consume(code); return declarationOpen } if (code === 47) { effects.consume(code); return tagCloseStart } if (code === 63) { effects.consume(code); return instruction } if (asciiAlpha_1(code)) { effects.consume(code); return tagOpen } return nok(code) } function declarationOpen(code) { if (code === 45) { effects.consume(code); return commentOpen } if (code === 91) { effects.consume(code); buffer = 'CDATA['; index = 0; return cdataOpen } if (asciiAlpha_1(code)) { effects.consume(code); return declaration } return nok(code) } function commentOpen(code) { if (code === 45) { effects.consume(code); return commentStart } return nok(code) } function commentStart(code) { if (code === null || code === 62) { return nok(code) } if (code === 45) { effects.consume(code); return commentStartDash } return comment(code) } function commentStartDash(code) { if (code === null || code === 62) { return nok(code) } return comment(code) } function comment(code) { if (code === null) { return nok(code) } if (code === 45) { effects.consume(code); return commentClose } if (markdownLineEnding_1(code)) { returnState = comment; return atLineEnding(code) } effects.consume(code); return comment } function commentClose(code) { if (code === 45) { effects.consume(code); return end } return comment(code) } function cdataOpen(code) { if (code === buffer.charCodeAt(index++)) { effects.consume(code); return index === buffer.length ? cdata : cdataOpen } return nok(code) } function cdata(code) { if (code === null) { return nok(code) } if (code === 93) { effects.consume(code); return cdataClose } if (markdownLineEnding_1(code)) { returnState = cdata; return atLineEnding(code) } effects.consume(code); return cdata } function cdataClose(code) { if (code === 93) { effects.consume(code); return cdataEnd } return cdata(code) } function cdataEnd(code) { if (code === 62) { return end(code) } if (code === 93) { effects.consume(code); return cdataEnd } return cdata(code) } function declaration(code) { if (code === null || code === 62) { return end(code) } if (markdownLineEnding_1(code)) { returnState = declaration; return atLineEnding(code) } effects.consume(code); return declaration } function instruction(code) { if (code === null) { return nok(code) } if (code === 63) { effects.consume(code); return instructionClose } if (markdownLineEnding_1(code)) { returnState = instruction; return atLineEnding(code) } effects.consume(code); return instruction } function instructionClose(code) { return code === 62 ? end(code) : instruction(code) } function tagCloseStart(code) { if (asciiAlpha_1(code)) { effects.consume(code); return tagClose } return nok(code) } function tagClose(code) { if (code === 45 || asciiAlphanumeric_1(code)) { effects.consume(code); return tagClose } return tagCloseBetween(code) } function tagCloseBetween(code) { if (markdownLineEnding_1(code)) { returnState = tagCloseBetween; return atLineEnding(code) } if (markdownSpace_1(code)) { effects.consume(code); return tagCloseBetween } return end(code) } function tagOpen(code) { if (code === 45 || asciiAlphanumeric_1(code)) { effects.consume(code); return tagOpen } if (code === 47 || code === 62 || markdownLineEndingOrSpace_1(code)) { return tagOpenBetween(code) } return nok(code) } function tagOpenBetween(code) { if (code === 47) { effects.consume(code); return end } if (code === 58 || code === 95 || asciiAlpha_1(code)) { effects.consume(code); return tagOpenAttributeName } if (markdownLineEnding_1(code)) { returnState = tagOpenBetween; return atLineEnding(code) } if (markdownSpace_1(code)) { effects.consume(code); return tagOpenBetween } return end(code) } function tagOpenAttributeName(code) { if ( code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric_1(code) ) { effects.consume(code); return tagOpenAttributeName } return tagOpenAttributeNameAfter(code) } function tagOpenAttributeNameAfter(code) { if (code === 61) { effects.consume(code); return tagOpenAttributeValueBefore } if (markdownLineEnding_1(code)) { returnState = tagOpenAttributeNameAfter; return atLineEnding(code) } if (markdownSpace_1(code)) { effects.consume(code); return tagOpenAttributeNameAfter } return tagOpenBetween(code) } function tagOpenAttributeValueBefore(code) { if ( code === null || code === 60 || code === 61 || code === 62 || code === 96 ) { return nok(code) } if (code === 34 || code === 39) { effects.consume(code); marker = code; return tagOpenAttributeValueQuoted } if (markdownLineEnding_1(code)) { returnState = tagOpenAttributeValueBefore; return atLineEnding(code) } if (markdownSpace_1(code)) { effects.consume(code); return tagOpenAttributeValueBefore } effects.consume(code); marker = undefined; return tagOpenAttributeValueUnquoted } function tagOpenAttributeValueQuoted(code) { if (code === marker) { effects.consume(code); return tagOpenAttributeValueQuotedAfter } if (code === null) { return nok(code) } if (markdownLineEnding_1(code)) { returnState = tagOpenAttributeValueQuoted; return atLineEnding(code) } effects.consume(code); return tagOpenAttributeValueQuoted } function tagOpenAttributeValueQuotedAfter(code) { if (code === 62 || code === 47 || markdownLineEndingOrSpace_1(code)) { return tagOpenBetween(code) } return nok(code) } function tagOpenAttributeValueUnquoted(code) { if ( code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96 ) { return nok(code) } if (code === 62 || markdownLineEndingOrSpace_1(code)) { return tagOpenBetween(code) } effects.consume(code); return tagOpenAttributeValueUnquoted } // We can’t have blank lines in content, so no need to worry about empty // tokens. function atLineEnding(code) { effects.exit('htmlTextData'); effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return factorySpace( effects, afterPrefix, 'linePrefix', self.parser.constructs.disable.null.indexOf('codeIndented') > -1 ? undefined : 4 ) } function afterPrefix(code) { effects.enter('htmlTextData'); return returnState(code) } function end(code) { if (code === 62) { effects.consume(code); effects.exit('htmlTextData'); effects.exit('htmlText'); return ok } return nok(code) } } var htmlText_1 = htmlText; var labelEnd = { name: 'labelEnd', tokenize: tokenizeLabelEnd, resolveTo: resolveToLabelEnd, resolveAll: resolveAllLabelEnd }; var resourceConstruct = { tokenize: tokenizeResource }; var fullReferenceConstruct = { tokenize: tokenizeFullReference }; var collapsedReferenceConstruct = { tokenize: tokenizeCollapsedReference }; function resolveAllLabelEnd(events) { var index = -1; var token; while (++index < events.length) { token = events[index][1]; if ( !token._used && (token.type === 'labelImage' || token.type === 'labelLink' || token.type === 'labelEnd') ) { // Remove the marker. events.splice(index + 1, token.type === 'labelImage' ? 4 : 2); token.type = 'data'; index++; } } return events } function resolveToLabelEnd(events, context) { var index = events.length; var offset = 0; var group; var label; var text; var token; var open; var close; var media; // Find an opening. while (index--) { token = events[index][1]; if (open) { // If we see another link, or inactive link label, we’ve been here before. if ( token.type === 'link' || (token.type === 'labelLink' && token._inactive) ) { break } // Mark other link openings as inactive, as we can’t have links in // links. if (events[index][0] === 'enter' && token.type === 'labelLink') { token._inactive = true; } } else if (close) { if ( events[index][0] === 'enter' && (token.type === 'labelImage' || token.type === 'labelLink') && !token._balanced ) { open = index; if (token.type !== 'labelLink') { offset = 2; break } } } else if (token.type === 'labelEnd') { close = index; } } group = { type: events[open][1].type === 'labelLink' ? 'link' : 'image', start: shallow_1(events[open][1].start), end: shallow_1(events[events.length - 1][1].end) }; label = { type: 'label', start: shallow_1(events[open][1].start), end: shallow_1(events[close][1].end) }; text = { type: 'labelText', start: shallow_1(events[open + offset + 2][1].end), end: shallow_1(events[close - 2][1].start) }; media = [ ['enter', group, context], ['enter', label, context] ]; // Opening marker. media = chunkedPush_1(media, events.slice(open + 1, open + offset + 3)); // Text open. media = chunkedPush_1(media, [['enter', text, context]]); // Between. media = chunkedPush_1( media, resolveAll_1( context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context ) ); // Text close, marker close, label close. media = chunkedPush_1(media, [ ['exit', text, context], events[close - 2], events[close - 1], ['exit', label, context] ]); // Reference, resource, or so. media = chunkedPush_1(media, events.slice(close + 1)); // Media close. media = chunkedPush_1(media, [['exit', group, context]]); chunkedSplice_1(events, open, events.length, media); return events } function tokenizeLabelEnd(effects, ok, nok) { var self = this; var index = self.events.length; var labelStart; var defined; // Find an opening. while (index--) { if ( (self.events[index][1].type === 'labelImage' || self.events[index][1].type === 'labelLink') && !self.events[index][1]._balanced ) { labelStart = self.events[index][1]; break } } return start function start(code) { if (!labelStart) { return nok(code) } // It’s a balanced bracket, but contains a link. if (labelStart._inactive) return balanced(code) defined = self.parser.defined.indexOf( normalizeIdentifier_1( self.sliceSerialize({ start: labelStart.end, end: self.now() }) ) ) > -1; effects.enter('labelEnd'); effects.enter('labelMarker'); effects.consume(code); effects.exit('labelMarker'); effects.exit('labelEnd'); return afterLabelEnd } function afterLabelEnd(code) { // Resource: `[asd](fgh)`. if (code === 40) { return effects.attempt( resourceConstruct, ok, defined ? ok : balanced )(code) } // Collapsed (`[asd][]`) or full (`[asd][fgh]`) reference? if (code === 91) { return effects.attempt( fullReferenceConstruct, ok, defined ? effects.attempt(collapsedReferenceConstruct, ok, balanced) : balanced )(code) } // Shortcut reference: `[asd]`? return defined ? ok(code) : balanced(code) } function balanced(code) { labelStart._balanced = true; return nok(code) } } function tokenizeResource(effects, ok, nok) { return start function start(code) { effects.enter('resource'); effects.enter('resourceMarker'); effects.consume(code); effects.exit('resourceMarker'); return factoryWhitespace(effects, open) } function open(code) { if (code === 41) { return end(code) } return factoryDestination( effects, destinationAfter, nok, 'resourceDestination', 'resourceDestinationLiteral', 'resourceDestinationLiteralMarker', 'resourceDestinationRaw', 'resourceDestinationString', 3 )(code) } function destinationAfter(code) { return markdownLineEndingOrSpace_1(code) ? factoryWhitespace(effects, between)(code) : end(code) } function between(code) { if (code === 34 || code === 39 || code === 40) { return factoryTitle( effects, factoryWhitespace(effects, end), nok, 'resourceTitle', 'resourceTitleMarker', 'resourceTitleString' )(code) } return end(code) } function end(code) { if (code === 41) { effects.enter('resourceMarker'); effects.consume(code); effects.exit('resourceMarker'); effects.exit('resource'); return ok } return nok(code) } } function tokenizeFullReference(effects, ok, nok) { var self = this; return start function start(code) { return factoryLabel.call( self, effects, afterLabel, nok, 'reference', 'referenceMarker', 'referenceString' )(code) } function afterLabel(code) { return self.parser.defined.indexOf( normalizeIdentifier_1( self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) ) ) < 0 ? nok(code) : ok(code) } } function tokenizeCollapsedReference(effects, ok, nok) { return start function start(code) { effects.enter('reference'); effects.enter('referenceMarker'); effects.consume(code); effects.exit('referenceMarker'); return open } function open(code) { if (code === 93) { effects.enter('referenceMarker'); effects.consume(code); effects.exit('referenceMarker'); effects.exit('reference'); return ok } return nok(code) } } var labelEnd_1 = labelEnd; var labelStartImage = { name: 'labelStartImage', tokenize: tokenizeLabelStartImage, resolveAll: labelEnd_1.resolveAll }; function tokenizeLabelStartImage(effects, ok, nok) { var self = this; return start function start(code) { effects.enter('labelImage'); effects.enter('labelImageMarker'); effects.consume(code); effects.exit('labelImageMarker'); return open } function open(code) { if (code === 91) { effects.enter('labelMarker'); effects.consume(code); effects.exit('labelMarker'); effects.exit('labelImage'); return after } return nok(code) } function after(code) { /* c8 ignore next */ return code === 94 && /* c8 ignore next */ '_hiddenFootnoteSupport' in self.parser.constructs ? /* c8 ignore next */ nok(code) : ok(code) } } var labelStartImage_1 = labelStartImage; var labelStartLink = { name: 'labelStartLink', tokenize: tokenizeLabelStartLink, resolveAll: labelEnd_1.resolveAll }; function tokenizeLabelStartLink(effects, ok, nok) { var self = this; return start function start(code) { effects.enter('labelLink'); effects.enter('labelMarker'); effects.consume(code); effects.exit('labelMarker'); effects.exit('labelLink'); return after } function after(code) { /* c8 ignore next */ return code === 94 && /* c8 ignore next */ '_hiddenFootnoteSupport' in self.parser.constructs ? /* c8 ignore next */ nok(code) : ok(code) } } var labelStartLink_1 = labelStartLink; var lineEnding = { name: 'lineEnding', tokenize: tokenizeLineEnding }; function tokenizeLineEnding(effects, ok) { return start function start(code) { effects.enter('lineEnding'); effects.consume(code); effects.exit('lineEnding'); return factorySpace(effects, ok, 'linePrefix') } } var lineEnding_1 = lineEnding; var thematicBreak$4 = { name: 'thematicBreak', tokenize: tokenizeThematicBreak }; function tokenizeThematicBreak(effects, ok, nok) { var size = 0; var marker; return start function start(code) { effects.enter('thematicBreak'); marker = code; return atBreak(code) } function atBreak(code) { if (code === marker) { effects.enter('thematicBreakSequence'); return sequence(code) } if (markdownSpace_1(code)) { return factorySpace(effects, atBreak, 'whitespace')(code) } if (size < 3 || (code !== null && !markdownLineEnding_1(code))) { return nok(code) } effects.exit('thematicBreak'); return ok(code) } function sequence(code) { if (code === marker) { effects.consume(code); size++; return sequence } effects.exit('thematicBreakSequence'); return atBreak(code) } } var thematicBreak_1$2 = thematicBreak$4; var list$4 = { name: 'list', tokenize: tokenizeListStart, continuation: { tokenize: tokenizeListContinuation }, exit: tokenizeListEnd }; var listItemPrefixWhitespaceConstruct = { tokenize: tokenizeListItemPrefixWhitespace, partial: true }; var indentConstruct = { tokenize: tokenizeIndent, partial: true }; function tokenizeListStart(effects, ok, nok) { var self = this; var initialSize = prefixSize_1(self.events, 'linePrefix'); var size = 0; return start function start(code) { var kind = self.containerState.type || (code === 42 || code === 43 || code === 45 ? 'listUnordered' : 'listOrdered'); if ( kind === 'listUnordered' ? !self.containerState.marker || code === self.containerState.marker : asciiDigit_1(code) ) { if (!self.containerState.type) { self.containerState.type = kind; effects.enter(kind, { _container: true }); } if (kind === 'listUnordered') { effects.enter('listItemPrefix'); return code === 42 || code === 45 ? effects.check(thematicBreak_1$2, nok, atMarker)(code) : atMarker(code) } if (!self.interrupt || code === 49) { effects.enter('listItemPrefix'); effects.enter('listItemValue'); return inside(code) } } return nok(code) } function inside(code) { if (asciiDigit_1(code) && ++size < 10) { effects.consume(code); return inside } if ( (!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === 41 || code === 46) ) { effects.exit('listItemValue'); return atMarker(code) } return nok(code) } function atMarker(code) { effects.enter('listItemMarker'); effects.consume(code); effects.exit('listItemMarker'); self.containerState.marker = self.containerState.marker || code; return effects.check( partialBlankLine_1, // Can’t be empty when interrupting. self.interrupt ? nok : onBlank, effects.attempt( listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix ) ) } function onBlank(code) { self.containerState.initialBlankLine = true; initialSize++; return endOfPrefix(code) } function otherPrefix(code) { if (markdownSpace_1(code)) { effects.enter('listItemPrefixWhitespace'); effects.consume(code); effects.exit('listItemPrefixWhitespace'); return endOfPrefix } return nok(code) } function endOfPrefix(code) { self.containerState.size = initialSize + sizeChunks_1(self.sliceStream(effects.exit('listItemPrefix'))); return ok(code) } } function tokenizeListContinuation(effects, ok, nok) { var self = this; self.containerState._closeFlow = undefined; return effects.check(partialBlankLine_1, onBlank, notBlank) function onBlank(code) { self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine; // We have a blank line. // Still, try to consume at most the items size. return factorySpace( effects, ok, 'listItemIndent', self.containerState.size + 1 )(code) } function notBlank(code) { if (self.containerState.furtherBlankLines || !markdownSpace_1(code)) { self.containerState.furtherBlankLines = self.containerState.initialBlankLine = undefined; return notInCurrentItem(code) } self.containerState.furtherBlankLines = self.containerState.initialBlankLine = undefined; return effects.attempt(indentConstruct, ok, notInCurrentItem)(code) } function notInCurrentItem(code) { // While we do continue, we signal that the flow should be closed. self.containerState._closeFlow = true; // As we’re closing flow, we’re no longer interrupting. self.interrupt = undefined; return factorySpace( effects, effects.attempt(list$4, ok, nok), 'linePrefix', self.parser.constructs.disable.null.indexOf('codeIndented') > -1 ? undefined : 4 )(code) } } function tokenizeIndent(effects, ok, nok) { var self = this; return factorySpace( effects, afterPrefix, 'listItemIndent', self.containerState.size + 1 ) function afterPrefix(code) { return prefixSize_1(self.events, 'listItemIndent') === self.containerState.size ? ok(code) : nok(code) } } function tokenizeListEnd(effects) { effects.exit(this.containerState.type); } function tokenizeListItemPrefixWhitespace(effects, ok, nok) { var self = this; return factorySpace( effects, afterPrefix, 'listItemPrefixWhitespace', self.parser.constructs.disable.null.indexOf('codeIndented') > -1 ? undefined : 4 + 1 ) function afterPrefix(code) { return markdownSpace_1(code) || !prefixSize_1(self.events, 'listItemPrefixWhitespace') ? nok(code) : ok(code) } } var list_1$2 = list$4; var setextUnderline = { name: 'setextUnderline', tokenize: tokenizeSetextUnderline, resolveTo: resolveToSetextUnderline }; function resolveToSetextUnderline(events, context) { var index = events.length; var content; var text; var definition; var heading; // Find the opening of the content. // It’ll always exist: we don’t tokenize if it isn’t there. while (index--) { if (events[index][0] === 'enter') { if (events[index][1].type === 'content') { content = index; break } if (events[index][1].type === 'paragraph') { text = index; } } // Exit else { if (events[index][1].type === 'content') { // Remove the content end (if needed we’ll add it later) events.splice(index, 1); } if (!definition && events[index][1].type === 'definition') { definition = index; } } } heading = { type: 'setextHeading', start: shallow_1(events[text][1].start), end: shallow_1(events[events.length - 1][1].end) }; // Change the paragraph to setext heading text. events[text][1].type = 'setextHeadingText'; // If we have definitions in the content, we’ll keep on having content, // but we need move it. if (definition) { events.splice(text, 0, ['enter', heading, context]); events.splice(definition + 1, 0, ['exit', events[content][1], context]); events[content][1].end = shallow_1(events[definition][1].end); } else { events[content][1] = heading; } // Add the heading exit at the end. events.push(['exit', heading, context]); return events } function tokenizeSetextUnderline(effects, ok, nok) { var self = this; var index = self.events.length; var marker; var paragraph; // Find an opening. while (index--) { // Skip enter/exit of line ending, line prefix, and content. // We can now either have a definition or a paragraph. if ( self.events[index][1].type !== 'lineEnding' && self.events[index][1].type !== 'linePrefix' && self.events[index][1].type !== 'content' ) { paragraph = self.events[index][1].type === 'paragraph'; break } } return start function start(code) { if (!self.lazy && (self.interrupt || paragraph)) { effects.enter('setextHeadingLine'); effects.enter('setextHeadingLineSequence'); marker = code; return closingSequence(code) } return nok(code) } function closingSequence(code) { if (code === marker) { effects.consume(code); return closingSequence } effects.exit('setextHeadingLineSequence'); return factorySpace(effects, closingSequenceEnd, 'lineSuffix')(code) } function closingSequenceEnd(code) { if (code === null || markdownLineEnding_1(code)) { effects.exit('setextHeadingLine'); return ok(code) } return nok(code) } } var setextUnderline_1 = setextUnderline; var constructs = createCommonjsModule(function (module, exports) { Object.defineProperty(exports, '__esModule', {value: true}); var document = { 42: list_1$2, // Asterisk 43: list_1$2, // Plus sign 45: list_1$2, // Dash 48: list_1$2, // 0 49: list_1$2, // 1 50: list_1$2, // 2 51: list_1$2, // 3 52: list_1$2, // 4 53: list_1$2, // 5 54: list_1$2, // 6 55: list_1$2, // 7 56: list_1$2, // 8 57: list_1$2, // 9 62: blockQuote_1 // Greater than }; var contentInitial = { 91: definition_1$2 // Left square bracket }; var flowInitial = { '-2': codeIndented_1, // Horizontal tab '-1': codeIndented_1, // Virtual space 32: codeIndented_1 // Space }; var flow = { 35: headingAtx_1, // Number sign 42: thematicBreak_1$2, // Asterisk 45: [setextUnderline_1, thematicBreak_1$2], // Dash 60: htmlFlow_1, // Less than 61: setextUnderline_1, // Equals to 95: thematicBreak_1$2, // Underscore 96: codeFenced_1, // Grave accent 126: codeFenced_1 // Tilde }; var string = { 38: characterReference_1, // Ampersand 92: characterEscape_1 // Backslash }; var text = { '-5': lineEnding_1, // Carriage return '-4': lineEnding_1, // Line feed '-3': lineEnding_1, // Carriage return + line feed 33: labelStartImage_1, // Exclamation mark 38: characterReference_1, // Ampersand 42: attention_1, // Asterisk 60: [autolink_1, htmlText_1], // Less than 91: labelStartLink_1, // Left square bracket 92: [hardBreakEscape_1, characterEscape_1], // Backslash 93: labelEnd_1, // Right square bracket 95: attention_1, // Underscore 96: codeText_1 // Grave accent }; var insideSpan = { null: [attention_1, text_1$2.resolver] }; var disable = { null: [] }; exports.contentInitial = contentInitial; exports.disable = disable; exports.document = document; exports.flow = flow; exports.flowInitial = flowInitial; exports.insideSpan = insideSpan; exports.string = string; exports.text = text; }); function parse$1(options) { var settings = options || {}; var parser = { defined: [], constructs: combineExtensions_1( [constructs].concat(miniflat_1(settings.extensions)) ), content: create(content$1), document: create(document$1), flow: create(flow$1), string: create(text_1$2.string), text: create(text_1$2.text) }; return parser function create(initializer) { return creator function creator(from) { return createTokenizer_1(parser, initializer, from) } } } var parse_1 = parse$1; var search = /[\0\t\n\r]/g; function preprocess() { var start = true; var column = 1; var buffer = ''; var atCarriageReturn; return preprocessor function preprocessor(value, encoding, end) { var chunks = []; var match; var next; var startPosition; var endPosition; var code; value = buffer + value.toString(encoding); startPosition = 0; buffer = ''; if (start) { if (value.charCodeAt(0) === 65279) { startPosition++; } start = undefined; } while (startPosition < value.length) { search.lastIndex = startPosition; match = search.exec(value); endPosition = match ? match.index : value.length; code = value.charCodeAt(endPosition); if (!match) { buffer = value.slice(startPosition); break } if (code === 10 && startPosition === endPosition && atCarriageReturn) { chunks.push(-3); atCarriageReturn = undefined; } else { if (atCarriageReturn) { chunks.push(-5); atCarriageReturn = undefined; } if (startPosition < endPosition) { chunks.push(value.slice(startPosition, endPosition)); column += endPosition - startPosition; } if (code === 0) { chunks.push(65533); column++; } else if (code === 9) { next = Math.ceil(column / 4) * 4; chunks.push(-2); while (column++ < next) chunks.push(-1); } else if (code === 10) { chunks.push(-4); column = 1; } // Must be carriage return. else { atCarriageReturn = true; column = 1; } } startPosition = endPosition + 1; } if (end) { if (atCarriageReturn) chunks.push(-5); if (buffer) chunks.push(buffer); chunks.push(null); } return chunks } } var preprocess_1 = preprocess; function postprocess(events) { while (!subtokenize_1(events)) { // Empty } return events } var postprocess_1 = postprocess; var dist = fromMarkdown; // These three are compiled away in the `dist/` function fromMarkdown(value, encoding, options) { if (typeof encoding !== 'string') { options = encoding; encoding = undefined; } return compiler(options)( postprocess_1( parse_1(options).document().write(preprocess_1()(value, encoding, true)) ) ) } // Note this compiler only understand complete buffering, not streaming. function compiler(options) { var settings = options || {}; var config = configure$1( { transforms: [], canContainEols: [ 'emphasis', 'fragment', 'heading', 'paragraph', 'strong' ], enter: { autolink: opener(link), autolinkProtocol: onenterdata, autolinkEmail: onenterdata, atxHeading: opener(heading), blockQuote: opener(blockQuote), characterEscape: onenterdata, characterReference: onenterdata, codeFenced: opener(codeFlow), codeFencedFenceInfo: buffer, codeFencedFenceMeta: buffer, codeIndented: opener(codeFlow, buffer), codeText: opener(codeText, buffer), codeTextData: onenterdata, data: onenterdata, codeFlowValue: onenterdata, definition: opener(definition), definitionDestinationString: buffer, definitionLabelString: buffer, definitionTitleString: buffer, emphasis: opener(emphasis), hardBreakEscape: opener(hardBreak), hardBreakTrailing: opener(hardBreak), htmlFlow: opener(html, buffer), htmlFlowData: onenterdata, htmlText: opener(html, buffer), htmlTextData: onenterdata, image: opener(image), label: buffer, link: opener(link), listItem: opener(listItem), listItemValue: onenterlistitemvalue, listOrdered: opener(list, onenterlistordered), listUnordered: opener(list), paragraph: opener(paragraph), reference: onenterreference, referenceString: buffer, resourceDestinationString: buffer, resourceTitleString: buffer, setextHeading: opener(heading), strong: opener(strong), thematicBreak: opener(thematicBreak) }, exit: { atxHeading: closer(), atxHeadingSequence: onexitatxheadingsequence, autolink: closer(), autolinkEmail: onexitautolinkemail, autolinkProtocol: onexitautolinkprotocol, blockQuote: closer(), characterEscapeValue: onexitdata, characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, characterReferenceMarkerNumeric: onexitcharacterreferencemarker, characterReferenceValue: onexitcharacterreferencevalue, codeFenced: closer(onexitcodefenced), codeFencedFence: onexitcodefencedfence, codeFencedFenceInfo: onexitcodefencedfenceinfo, codeFencedFenceMeta: onexitcodefencedfencemeta, codeFlowValue: onexitdata, codeIndented: closer(onexitcodeindented), codeText: closer(onexitcodetext), codeTextData: onexitdata, data: onexitdata, definition: closer(), definitionDestinationString: onexitdefinitiondestinationstring, definitionLabelString: onexitdefinitionlabelstring, definitionTitleString: onexitdefinitiontitlestring, emphasis: closer(), hardBreakEscape: closer(onexithardbreak), hardBreakTrailing: closer(onexithardbreak), htmlFlow: closer(onexithtmlflow), htmlFlowData: onexitdata, htmlText: closer(onexithtmltext), htmlTextData: onexitdata, image: closer(onexitimage), label: onexitlabel, labelText: onexitlabeltext, lineEnding: onexitlineending, link: closer(onexitlink), listItem: closer(), listOrdered: closer(), listUnordered: closer(), paragraph: closer(), referenceString: onexitreferencestring, resourceDestinationString: onexitresourcedestinationstring, resourceTitleString: onexitresourcetitlestring, resource: onexitresource, setextHeading: closer(onexitsetextheading), setextHeadingLineSequence: onexitsetextheadinglinesequence, setextHeadingText: onexitsetextheadingtext, strong: closer(), thematicBreak: closer() } }, settings.mdastExtensions || [] ); var data = {}; return compile function compile(events) { var tree = {type: 'root', children: []}; var stack = [tree]; var tokenStack = []; var listStack = []; var index = -1; var handler; var listStart; var context = { stack: stack, tokenStack: tokenStack, config: config, enter: enter, exit: exit, buffer: buffer, resume: resume, setData: setData, getData: getData }; while (++index < events.length) { // We preprocess lists to add `listItem` tokens, and to infer whether // items the list itself are spread out. if ( events[index][1].type === 'listOrdered' || events[index][1].type === 'listUnordered' ) { if (events[index][0] === 'enter') { listStack.push(index); } else { listStart = listStack.pop(index); index = prepareList(events, listStart, index); } } } index = -1; while (++index < events.length) { handler = config[events[index][0]]; if (hasOwnProperty_1.call(handler, events[index][1].type)) { handler[events[index][1].type].call( assign_1({sliceSerialize: events[index][2].sliceSerialize}, context), events[index][1] ); } } if (tokenStack.length) { throw new Error( 'Cannot close document, a token (`' + tokenStack[tokenStack.length - 1].type + '`, ' + unistUtilStringifyPosition({ start: tokenStack[tokenStack.length - 1].start, end: tokenStack[tokenStack.length - 1].end }) + ') is still open' ) } // Figure out `root` position. tree.position = { start: point( events.length ? events[0][1].start : {line: 1, column: 1, offset: 0} ), end: point( events.length ? events[events.length - 2][1].end : {line: 1, column: 1, offset: 0} ) }; index = -1; while (++index < config.transforms.length) { tree = config.transforms[index](tree) || tree; } return tree } function prepareList(events, start, length) { var index = start - 1; var containerBalance = -1; var listSpread = false; var listItem; var tailIndex; var lineIndex; var tailEvent; var event; var firstBlankLineIndex; var atMarker; while (++index <= length) { event = events[index]; if ( event[1].type === 'listUnordered' || event[1].type === 'listOrdered' || event[1].type === 'blockQuote' ) { if (event[0] === 'enter') { containerBalance++; } else { containerBalance--; } atMarker = undefined; } else if (event[1].type === 'lineEndingBlank') { if (event[0] === 'enter') { if ( listItem && !atMarker && !containerBalance && !firstBlankLineIndex ) { firstBlankLineIndex = index; } atMarker = undefined; } } else if ( event[1].type === 'linePrefix' || event[1].type === 'listItemValue' || event[1].type === 'listItemMarker' || event[1].type === 'listItemPrefix' || event[1].type === 'listItemPrefixWhitespace' ) ; else { atMarker = undefined; } if ( (!containerBalance && event[0] === 'enter' && event[1].type === 'listItemPrefix') || (containerBalance === -1 && event[0] === 'exit' && (event[1].type === 'listUnordered' || event[1].type === 'listOrdered')) ) { if (listItem) { tailIndex = index; lineIndex = undefined; while (tailIndex--) { tailEvent = events[tailIndex]; if ( tailEvent[1].type === 'lineEnding' || tailEvent[1].type === 'lineEndingBlank' ) { if (tailEvent[0] === 'exit') continue if (lineIndex) { events[lineIndex][1].type = 'lineEndingBlank'; listSpread = true; } tailEvent[1].type = 'lineEnding'; lineIndex = tailIndex; } else if ( tailEvent[1].type === 'linePrefix' || tailEvent[1].type === 'blockQuotePrefix' || tailEvent[1].type === 'blockQuotePrefixWhitespace' || tailEvent[1].type === 'blockQuoteMarker' || tailEvent[1].type === 'listItemIndent' ) ; else { break } } if ( firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex) ) { listItem._spread = true; } // Fix position. listItem.end = point( lineIndex ? events[lineIndex][1].start : event[1].end ); events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]); index++; length++; } // Create a new list item. if (event[1].type === 'listItemPrefix') { listItem = { type: 'listItem', _spread: false, start: point(event[1].start) }; events.splice(index, 0, ['enter', listItem, event[2]]); index++; length++; firstBlankLineIndex = undefined; atMarker = true; } } } events[start][1]._spread = listSpread; return length } function setData(key, value) { data[key] = value; } function getData(key) { return data[key] } function point(d) { return {line: d.line, column: d.column, offset: d.offset} } function opener(create, and) { return open function open(token) { enter.call(this, create(token), token); if (and) and.call(this, token); } } function buffer() { this.stack.push({type: 'fragment', children: []}); } function enter(node, token) { this.stack[this.stack.length - 1].children.push(node); this.stack.push(node); this.tokenStack.push(token); node.position = {start: point(token.start)}; return node } function closer(and) { return close function close(token) { if (and) and.call(this, token); exit.call(this, token); } } function exit(token) { var node = this.stack.pop(); var open = this.tokenStack.pop(); if (!open) { throw new Error( 'Cannot close `' + token.type + '` (' + unistUtilStringifyPosition({start: token.start, end: token.end}) + '): it’s not open' ) } else if (open.type !== token.type) { throw new Error( 'Cannot close `' + token.type + '` (' + unistUtilStringifyPosition({start: token.start, end: token.end}) + '): a different token (`' + open.type + '`, ' + unistUtilStringifyPosition({start: open.start, end: open.end}) + ') is open' ) } node.position.end = point(token.end); return node } function resume() { return mdastUtilToString(this.stack.pop()) } // // Handlers. // function onenterlistordered() { setData('expectingFirstListItemValue', true); } function onenterlistitemvalue(token) { if (getData('expectingFirstListItemValue')) { this.stack[this.stack.length - 2].start = parseInt( this.sliceSerialize(token), 10 ); setData('expectingFirstListItemValue'); } } function onexitcodefencedfenceinfo() { var data = this.resume(); this.stack[this.stack.length - 1].lang = data; } function onexitcodefencedfencemeta() { var data = this.resume(); this.stack[this.stack.length - 1].meta = data; } function onexitcodefencedfence() { // Exit if this is the closing fence. if (getData('flowCodeInside')) return this.buffer(); setData('flowCodeInside', true); } function onexitcodefenced() { var data = this.resume(); this.stack[this.stack.length - 1].value = data.replace( /^(\r?\n|\r)|(\r?\n|\r)$/g, '' ); setData('flowCodeInside'); } function onexitcodeindented() { var data = this.resume(); this.stack[this.stack.length - 1].value = data; } function onexitdefinitionlabelstring(token) { // Discard label, use the source content instead. var label = this.resume(); this.stack[this.stack.length - 1].label = label; this.stack[this.stack.length - 1].identifier = normalizeIdentifier_1( this.sliceSerialize(token) ).toLowerCase(); } function onexitdefinitiontitlestring() { var data = this.resume(); this.stack[this.stack.length - 1].title = data; } function onexitdefinitiondestinationstring() { var data = this.resume(); this.stack[this.stack.length - 1].url = data; } function onexitatxheadingsequence(token) { if (!this.stack[this.stack.length - 1].depth) { this.stack[this.stack.length - 1].depth = this.sliceSerialize( token ).length; } } function onexitsetextheadingtext() { setData('setextHeadingSlurpLineEnding', true); } function onexitsetextheadinglinesequence(token) { this.stack[this.stack.length - 1].depth = this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2; } function onexitsetextheading() { setData('setextHeadingSlurpLineEnding'); } function onenterdata(token) { var siblings = this.stack[this.stack.length - 1].children; var tail = siblings[siblings.length - 1]; if (!tail || tail.type !== 'text') { // Add a new text node. tail = text(); tail.position = {start: point(token.start)}; this.stack[this.stack.length - 1].children.push(tail); } this.stack.push(tail); } function onexitdata(token) { var tail = this.stack.pop(); tail.value += this.sliceSerialize(token); tail.position.end = point(token.end); } function onexitlineending(token) { var context = this.stack[this.stack.length - 1]; // If we’re at a hard break, include the line ending in there. if (getData('atHardBreak')) { context.children[context.children.length - 1].position.end = point( token.end ); setData('atHardBreak'); return } if ( !getData('setextHeadingSlurpLineEnding') && config.canContainEols.indexOf(context.type) > -1 ) { onenterdata.call(this, token); onexitdata.call(this, token); } } function onexithardbreak() { setData('atHardBreak', true); } function onexithtmlflow() { var data = this.resume(); this.stack[this.stack.length - 1].value = data; } function onexithtmltext() { var data = this.resume(); this.stack[this.stack.length - 1].value = data; } function onexitcodetext() { var data = this.resume(); this.stack[this.stack.length - 1].value = data; } function onexitlink() { var context = this.stack[this.stack.length - 1]; // To do: clean. if (getData('inReference')) { context.type += 'Reference'; context.referenceType = getData('referenceType') || 'shortcut'; delete context.url; delete context.title; } else { delete context.identifier; delete context.label; delete context.referenceType; } setData('referenceType'); } function onexitimage() { var context = this.stack[this.stack.length - 1]; // To do: clean. if (getData('inReference')) { context.type += 'Reference'; context.referenceType = getData('referenceType') || 'shortcut'; delete context.url; delete context.title; } else { delete context.identifier; delete context.label; delete context.referenceType; } setData('referenceType'); } function onexitlabeltext(token) { this.stack[this.stack.length - 2].identifier = normalizeIdentifier_1( this.sliceSerialize(token) ).toLowerCase(); } function onexitlabel() { var fragment = this.stack[this.stack.length - 1]; var value = this.resume(); this.stack[this.stack.length - 1].label = value; // Assume a reference. setData('inReference', true); if (this.stack[this.stack.length - 1].type === 'link') { this.stack[this.stack.length - 1].children = fragment.children; } else { this.stack[this.stack.length - 1].alt = value; } } function onexitresourcedestinationstring() { var data = this.resume(); this.stack[this.stack.length - 1].url = data; } function onexitresourcetitlestring() { var data = this.resume(); this.stack[this.stack.length - 1].title = data; } function onexitresource() { setData('inReference'); } function onenterreference() { setData('referenceType', 'collapsed'); } function onexitreferencestring(token) { var label = this.resume(); this.stack[this.stack.length - 1].label = label; this.stack[this.stack.length - 1].identifier = normalizeIdentifier_1( this.sliceSerialize(token) ).toLowerCase(); setData('referenceType', 'full'); } function onexitcharacterreferencemarker(token) { setData('characterReferenceType', token.type); } function onexitcharacterreferencevalue(token) { var data = this.sliceSerialize(token); var type = getData('characterReferenceType'); var value; var tail; if (type) { value = safeFromInt_1( data, type === 'characterReferenceMarkerNumeric' ? 10 : 16 ); setData('characterReferenceType'); } else { value = decodeEntity_1(data); } tail = this.stack.pop(); tail.value += value; tail.position.end = point(token.end); } function onexitautolinkprotocol(token) { onexitdata.call(this, token); this.stack[this.stack.length - 1].url = this.sliceSerialize(token); } function onexitautolinkemail(token) { onexitdata.call(this, token); this.stack[this.stack.length - 1].url = 'mailto:' + this.sliceSerialize(token); } // // Creaters. // function blockQuote() { return {type: 'blockquote', children: []} } function codeFlow() { return {type: 'code', lang: null, meta: null, value: ''} } function codeText() { return {type: 'inlineCode', value: ''} } function definition() { return { type: 'definition', identifier: '', label: null, title: null, url: '' } } function emphasis() { return {type: 'emphasis', children: []} } function heading() { return {type: 'heading', depth: undefined, children: []} } function hardBreak() { return {type: 'break'} } function html() { return {type: 'html', value: ''} } function image() { return {type: 'image', title: null, url: '', alt: null} } function link() { return {type: 'link', title: null, url: '', children: []} } function list(token) { return { type: 'list', ordered: token.type === 'listOrdered', start: null, spread: token._spread, children: [] } } function listItem(token) { return { type: 'listItem', spread: token._spread, checked: null, children: [] } } function paragraph() { return {type: 'paragraph', children: []} } function strong() { return {type: 'strong', children: []} } function text() { return {type: 'text', value: ''} } function thematicBreak() { return {type: 'thematicBreak'} } } function configure$1(config, extensions) { var index = -1; while (++index < extensions.length) { extension(config, extensions[index]); } return config } function extension(config, extension) { var key; var left; for (key in extension) { left = hasOwnProperty_1.call(config, key) ? config[key] : (config[key] = {}); if (key === 'canContainEols' || key === 'transforms') { config[key] = [].concat(left, extension[key]); } else { Object.assign(left, extension[key]); } } } var mdastUtilFromMarkdown = dist; var remarkParse = parse; function parse(options) { var self = this; this.Parser = parse; function parse(doc) { return mdastUtilFromMarkdown( doc, Object.assign({}, self.data('settings'), options, { // Note: these options are not in the readme. // The goal is for them to be set by plugins on `data` instead of being // passed by users. extensions: self.data('micromarkExtensions') || [], mdastExtensions: self.data('fromMarkdownExtensions') || [] }) ) } } var zwitch = factory; var noop = Function.prototype; var own = {}.hasOwnProperty; // Handle values based on a property. function factory(key, options) { var settings = options || {}; function one(value) { var fn = one.invalid; var handlers = one.handlers; if (value && own.call(value, key)) { fn = own.call(handlers, value[key]) ? handlers[value[key]] : one.unknown; } return (fn || noop).apply(this, arguments) } one.handlers = settings.handlers || {}; one.invalid = settings.invalid; one.unknown = settings.unknown; return one } var blockquote_1$1 = blockquote$3; function blockquote$3(node, _, context) { var exit = context.enter('blockquote'); var value = indentLines_1$1(containerFlow$1(node, context), map$2); exit(); return value } function map$2(line, index, blank) { return '>' + (blank ? '' : ' ') + line } var _break$3 = hardBreak$3; function hardBreak$3(node, _, context, safe) { var index = -1; while (++index < context.unsafe.length) { // If we can’t put eols in this construct (setext headings, tables), use a // space instead. if ( context.unsafe[index].character === '\n' && patternInScope_1$1(context.stack, context.unsafe[index]) ) { return /[ \t]/.test(safe.before) ? '' : ' ' } } return '\\\n' } var formatCodeAsIndented_1$1 = formatCodeAsIndented$1; function formatCodeAsIndented$1(node, context) { return ( !context.options.fences && node.value && // If there’s no info… !node.lang && // And there’s a non-whitespace character… /[^ \r\n]/.test(node.value) && // And the value doesn’t start or end in a blank… !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(node.value) ) } var checkFence_1$1 = checkFence$1; function checkFence$1(context) { var marker = context.options.fence || '`'; if (marker !== '`' && marker !== '~') { throw new Error( 'Cannot serialize code with `' + marker + '` for `options.fence`, expected `` ` `` or `~`' ) } return marker } var code_1$1 = code$3; function code$3(node, _, context) { var marker = checkFence_1$1(context); var raw = node.value || ''; var suffix = marker === '`' ? 'GraveAccent' : 'Tilde'; var value; var sequence; var exit; var subexit; if (formatCodeAsIndented_1$1(node, context)) { exit = context.enter('codeIndented'); value = indentLines_1$1(raw, map$1); } else { sequence = repeatString(marker, Math.max(longestStreak_1(raw, marker) + 1, 3)); exit = context.enter('codeFenced'); value = sequence; if (node.lang) { subexit = context.enter('codeFencedLang' + suffix); value += safe_1$1(context, node.lang, { before: '`', after: ' ', encode: ['`'] }); subexit(); } if (node.lang && node.meta) { subexit = context.enter('codeFencedMeta' + suffix); value += ' ' + safe_1$1(context, node.meta, { before: ' ', after: '\n', encode: ['`'] }); subexit(); } value += '\n'; if (raw) { value += raw + '\n'; } value += sequence; } exit(); return value } function map$1(line, _, blank) { return (blank ? '' : ' ') + line } var association_1$1 = association$1; var characterEscape$1 = /\\([!-/:-@[-`{-~])/g; var characterReference$1 = /&(#(\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; // The `label` of an association is the string value: character escapes and // references work, and casing is intact. // The `identifier` is used to match one association to another: controversially, // character escapes and references don’t work in this matching: `©` does // not match `©`, and `\+` does not match `+`. // But casing is ignored (and whitespace) is trimmed and collapsed: ` A\nb` // matches `a b`. // So, we do prefer the label when figuring out how we’re going to serialize: // it has whitespace, casing, and we can ignore most useless character escapes // and all character references. function association$1(node) { if (node.label || !node.identifier) { return node.label || '' } return node.identifier .replace(characterEscape$1, '$1') .replace(characterReference$1, decodeIfPossible$1) } function decodeIfPossible$1($0, $1) { return decodeEntity_1($1) || $0 } var checkQuote_1$1 = checkQuote$1; function checkQuote$1(context) { var marker = context.options.quote || '"'; if (marker !== '"' && marker !== "'") { throw new Error( 'Cannot serialize title with `' + marker + '` for `options.quote`, expected `"`, or `\'`' ) } return marker } var definition_1$1 = definition$3; function definition$3(node, _, context) { var marker = checkQuote_1$1(context); var suffix = marker === '"' ? 'Quote' : 'Apostrophe'; var exit = context.enter('definition'); var subexit = context.enter('label'); var value = '[' + safe_1$1(context, association_1$1(node), {before: '[', after: ']'}) + ']: '; subexit(); if ( // If there’s no url, or… !node.url || // If there’s whitespace, enclosed is prettier. /[ \t\r\n]/.test(node.url) ) { subexit = context.enter('destinationLiteral'); value += '<' + safe_1$1(context, node.url, {before: '<', after: '>'}) + '>'; } else { // No whitespace, raw is prettier. subexit = context.enter('destinationRaw'); value += safe_1$1(context, node.url, {before: ' ', after: ' '}); } subexit(); if (node.title) { subexit = context.enter('title' + suffix); value += ' ' + marker + safe_1$1(context, node.title, {before: marker, after: marker}) + marker; subexit(); } exit(); return value } var checkEmphasis_1$1 = checkEmphasis$1; function checkEmphasis$1(context) { var marker = context.options.emphasis || '*'; if (marker !== '*' && marker !== '_') { throw new Error( 'Cannot serialize emphasis with `' + marker + '` for `options.emphasis`, expected `*`, or `_`' ) } return marker } var emphasis_1$1 = emphasis$3; emphasis$3.peek = emphasisPeek$1; // To do: there are cases where emphasis cannot “form” depending on the // previous or next character of sequences. // There’s no way around that though, except for injecting zero-width stuff. // Do we need to safeguard against that? function emphasis$3(node, _, context) { var marker = checkEmphasis_1$1(context); var exit = context.enter('emphasis'); var value = containerPhrasing$1(node, context, {before: marker, after: marker}); exit(); return marker + value + marker } function emphasisPeek$1(node, _, context) { return context.options.emphasis || '*' } var formatHeadingAsSetext_1$1 = formatHeadingAsSetext$1; function formatHeadingAsSetext$1(node, context) { return ( context.options.setext && (!node.depth || node.depth < 3) && mdastUtilToString(node) ) } var heading_1$1 = heading$3; function heading$3(node, _, context) { var rank = Math.max(Math.min(6, node.depth || 1), 1); var exit; var subexit; var value; var sequence; if (formatHeadingAsSetext_1$1(node, context)) { exit = context.enter('headingSetext'); subexit = context.enter('phrasing'); value = containerPhrasing$1(node, context, {before: '\n', after: '\n'}); subexit(); exit(); return ( value + '\n' + repeatString( rank === 1 ? '=' : '-', // The whole size… value.length - // Minus the position of the character after the last EOL (or // 0 if there is none)… (Math.max(value.lastIndexOf('\r'), value.lastIndexOf('\n')) + 1) ) ) } sequence = repeatString('#', rank); exit = context.enter('headingAtx'); subexit = context.enter('phrasing'); value = containerPhrasing$1(node, context, {before: '# ', after: '\n'}); value = value ? sequence + ' ' + value : sequence; if (context.options.closeAtx) { value += ' ' + sequence; } subexit(); exit(); return value } var html_1$1 = html$3; html$3.peek = htmlPeek$1; function html$3(node) { return node.value || '' } function htmlPeek$1() { return '<' } var image_1$1 = image$3; image$3.peek = imagePeek$1; function image$3(node, _, context) { var quote = checkQuote_1$1(context); var suffix = quote === '"' ? 'Quote' : 'Apostrophe'; var exit = context.enter('image'); var subexit = context.enter('label'); var value = '![' + safe_1$1(context, node.alt, {before: '[', after: ']'}) + ']('; subexit(); if ( // If there’s no url but there is a title… (!node.url && node.title) || // Or if there’s markdown whitespace or an eol, enclose. /[ \t\r\n]/.test(node.url) ) { subexit = context.enter('destinationLiteral'); value += '<' + safe_1$1(context, node.url, {before: '<', after: '>'}) + '>'; } else { // No whitespace, raw is prettier. subexit = context.enter('destinationRaw'); value += safe_1$1(context, node.url, { before: '(', after: node.title ? ' ' : ')' }); } subexit(); if (node.title) { subexit = context.enter('title' + suffix); value += ' ' + quote + safe_1$1(context, node.title, {before: quote, after: quote}) + quote; subexit(); } value += ')'; exit(); return value } function imagePeek$1() { return '!' } var imageReference_1$1 = imageReference$3; imageReference$3.peek = imageReferencePeek$1; function imageReference$3(node, _, context) { var type = node.referenceType; var exit = context.enter('imageReference'); var subexit = context.enter('label'); var alt = safe_1$1(context, node.alt, {before: '[', after: ']'}); var value = '![' + alt + ']'; var reference; var stack; subexit(); // Hide the fact that we’re in phrasing, because escapes don’t work. stack = context.stack; context.stack = []; subexit = context.enter('reference'); reference = safe_1$1(context, association_1$1(node), {before: '[', after: ']'}); subexit(); context.stack = stack; exit(); if (type === 'full' || !alt || alt !== reference) { value += '[' + reference + ']'; } else if (type !== 'shortcut') { value += '[]'; } return value } function imageReferencePeek$1() { return '!' } var formatLinkAsAutolink_1$1 = formatLinkAsAutolink$1; function formatLinkAsAutolink$1(node, context) { var raw = mdastUtilToString(node); return ( !context.options.resourceLink && // If there’s a url… node.url && // And there’s a no title… !node.title && // And the content of `node` is a single text node… node.children && node.children.length === 1 && node.children[0].type === 'text' && // And if the url is the same as the content… (raw === node.url || 'mailto:' + raw === node.url) && // And that starts w/ a protocol… /^[a-z][a-z+.-]+:/i.test(node.url) && // And that doesn’t contain ASCII control codes (character escapes and // references don’t work) or angle brackets… !/[\0- <>\u007F]/.test(node.url) ) } var link_1$1 = link$3; link$3.peek = linkPeek$1; function link$3(node, _, context) { var quote = checkQuote_1$1(context); var suffix = quote === '"' ? 'Quote' : 'Apostrophe'; var exit; var subexit; var value; var stack; if (formatLinkAsAutolink_1$1(node, context)) { // Hide the fact that we’re in phrasing, because escapes don’t work. stack = context.stack; context.stack = []; exit = context.enter('autolink'); value = '<' + containerPhrasing$1(node, context, {before: '<', after: '>'}) + '>'; exit(); context.stack = stack; return value } exit = context.enter('link'); subexit = context.enter('label'); value = '[' + containerPhrasing$1(node, context, {before: '[', after: ']'}) + ']('; subexit(); if ( // If there’s no url but there is a title… (!node.url && node.title) || // Or if there’s markdown whitespace or an eol, enclose. /[ \t\r\n]/.test(node.url) ) { subexit = context.enter('destinationLiteral'); value += '<' + safe_1$1(context, node.url, {before: '<', after: '>'}) + '>'; } else { // No whitespace, raw is prettier. subexit = context.enter('destinationRaw'); value += safe_1$1(context, node.url, { before: '(', after: node.title ? ' ' : ')' }); } subexit(); if (node.title) { subexit = context.enter('title' + suffix); value += ' ' + quote + safe_1$1(context, node.title, {before: quote, after: quote}) + quote; subexit(); } value += ')'; exit(); return value } function linkPeek$1(node, _, context) { return formatLinkAsAutolink_1$1(node, context) ? '<' : '[' } var linkReference_1$1 = linkReference$3; linkReference$3.peek = linkReferencePeek$1; function linkReference$3(node, _, context) { var type = node.referenceType; var exit = context.enter('linkReference'); var subexit = context.enter('label'); var text = containerPhrasing$1(node, context, {before: '[', after: ']'}); var value = '[' + text + ']'; var reference; var stack; subexit(); // Hide the fact that we’re in phrasing, because escapes don’t work. stack = context.stack; context.stack = []; subexit = context.enter('reference'); reference = safe_1$1(context, association_1$1(node), {before: '[', after: ']'}); subexit(); context.stack = stack; exit(); if (type === 'full' || !text || text !== reference) { value += '[' + reference + ']'; } else if (type !== 'shortcut') { value += '[]'; } return value } function linkReferencePeek$1() { return '[' } var list_1$1 = list$3; function list$3(node, _, context) { var exit = context.enter('list'); var value = containerFlow$1(node, context); exit(); return value } var paragraph_1$1 = paragraph$3; function paragraph$3(node, _, context) { var exit = context.enter('paragraph'); var subexit = context.enter('phrasing'); var value = containerPhrasing$1(node, context, {before: '\n', after: '\n'}); subexit(); exit(); return value } var root_1$1 = root$3; function root$3(node, _, context) { return containerFlow$1(node, context) } var checkStrong_1$1 = checkStrong$1; function checkStrong$1(context) { var marker = context.options.strong || '*'; if (marker !== '*' && marker !== '_') { throw new Error( 'Cannot serialize strong with `' + marker + '` for `options.strong`, expected `*`, or `_`' ) } return marker } var strong_1$1 = strong$3; strong$3.peek = strongPeek$1; // To do: there are cases where emphasis cannot “form” depending on the // previous or next character of sequences. // There’s no way around that though, except for injecting zero-width stuff. // Do we need to safeguard against that? function strong$3(node, _, context) { var marker = checkStrong_1$1(context); var exit = context.enter('strong'); var value = containerPhrasing$1(node, context, {before: marker, after: marker}); exit(); return marker + marker + value + marker + marker } function strongPeek$1(node, _, context) { return context.options.strong || '*' } var text_1$1 = text$3; function text$3(node, parent, context, safeOptions) { return safe_1$1(context, node.value, safeOptions) } var checkRuleRepeat$1 = checkRule$3; function checkRule$3(context) { var repetition = context.options.ruleRepetition || 3; if (repetition < 3) { throw new Error( 'Cannot serialize rules with repetition `' + repetition + '` for `options.ruleRepetition`, expected `3` or more' ) } return repetition } var checkRule_1$1 = checkRule$2; function checkRule$2(context) { var marker = context.options.rule || '*'; if (marker !== '*' && marker !== '-' && marker !== '_') { throw new Error( 'Cannot serialize rules with `' + marker + '` for `options.rule`, expected `*`, `-`, or `_`' ) } return marker } var thematicBreak_1$1 = thematicBreak$3; function thematicBreak$3(node, parent, context) { var value = repeatString( checkRule_1$1(context) + (context.options.ruleSpaces ? ' ' : ''), checkRuleRepeat$1(context) ); return context.options.ruleSpaces ? value.slice(0, -1) : value } var blockquote$2 = blockquote_1$1; var _break$2 = _break$3; var code$2 = code_1$1; var definition$2 = definition_1$1; var emphasis$2 = emphasis_1$1; var hardBreak$2 = _break$3; var heading$2 = heading_1$1; var html$2 = html_1$1; var image$2 = image_1$1; var imageReference$2 = imageReference_1$1; var inlineCode$2 = inlineCode_1$1; var link$2 = link_1$1; var linkReference$2 = linkReference_1$1; var list$2 = list_1$1; var listItem$2 = listItem_1; var paragraph$2 = paragraph_1$1; var root$2 = root_1$1; var strong$2 = strong_1$1; var text$2 = text_1$1; var thematicBreak$2 = thematicBreak_1$1; var handle$1 = { blockquote: blockquote$2, break: _break$2, code: code$2, definition: definition$2, emphasis: emphasis$2, hardBreak: hardBreak$2, heading: heading$2, html: html$2, image: image$2, imageReference: imageReference$2, inlineCode: inlineCode$2, link: link$2, linkReference: linkReference$2, list: list$2, listItem: listItem$2, paragraph: paragraph$2, root: root$2, strong: strong$2, text: text$2, thematicBreak: thematicBreak$2 }; var join$1 = [joinDefaults$1]; function joinDefaults$1(left, right, parent, context) { if ( // Two lists with the same marker. (right.type === 'list' && right.type === left.type && Boolean(left.ordered) === Boolean(right.ordered)) || // Indented code after list or another indented code. (right.type === 'code' && formatCodeAsIndented_1$1(right, context) && (left.type === 'list' || (left.type === right.type && formatCodeAsIndented_1$1(left, context)))) ) { return false } // Join children of a list or an item. // In which case, `parent` has a `spread` field. if (typeof parent.spread === 'boolean') { if ( left.type === 'paragraph' && // Two paragraphs. (left.type === right.type || right.type === 'definition' || // Paragraph followed by a setext heading. (right.type === 'heading' && formatHeadingAsSetext_1$1(right, context))) ) { return } return parent.spread ? 1 : 0 } } var unsafe = [ { character: '\t', inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde'] }, { character: '\r', inConstruct: [ 'codeFencedLangGraveAccent', 'codeFencedLangTilde', 'codeFencedMetaGraveAccent', 'codeFencedMetaTilde', 'destinationLiteral', 'headingAtx' ] }, { character: '\n', inConstruct: [ 'codeFencedLangGraveAccent', 'codeFencedLangTilde', 'codeFencedMetaGraveAccent', 'codeFencedMetaTilde', 'destinationLiteral', 'headingAtx' ] }, { character: ' ', inConstruct: ['codeFencedLangGraveAccent', 'codeFencedLangTilde'] }, // An exclamation mark can start an image, if it is followed by a link or // a link reference. {character: '!', after: '\\[', inConstruct: 'phrasing'}, // A quote can break out of a title. {character: '"', inConstruct: 'titleQuote'}, // A number sign could start an ATX heading if it starts a line. {atBreak: true, character: '#'}, {character: '#', inConstruct: 'headingAtx', after: '(?:[\r\n]|$)'}, // Dollar sign and percentage are not used in markdown. // An ampersand could start a character reference. {character: '&', after: '[#A-Za-z]', inConstruct: 'phrasing'}, // An apostrophe can break out of a title. {character: "'", inConstruct: 'titleApostrophe'}, // A left paren could break out of a destination raw. {character: '(', inConstruct: 'destinationRaw'}, {before: '\\]', character: '(', inConstruct: 'phrasing'}, // A right paren could start a list item or break out of a destination // raw. {atBreak: true, before: '\\d+', character: ')'}, {character: ')', inConstruct: 'destinationRaw'}, // An asterisk can start thematic breaks, list items, emphasis, strong. {atBreak: true, character: '*'}, {character: '*', inConstruct: 'phrasing'}, // A plus sign could start a list item. {atBreak: true, character: '+'}, // A dash can start thematic breaks, list items, and setext heading // underlines. {atBreak: true, character: '-'}, // A dot could start a list item. {atBreak: true, before: '\\d+', character: '.', after: '(?:[ \t\r\n]|$)'}, // Slash, colon, and semicolon are not used in markdown for constructs. // A less than can start html (flow or text) or an autolink. // HTML could start with an exclamation mark (declaration, cdata, comment), // slash (closing tag), question mark (instruction), or a letter (tag). // An autolink also starts with a letter. // Finally, it could break out of a destination literal. {atBreak: true, character: '<', after: '[!/?A-Za-z]'}, {character: '<', after: '[!/?A-Za-z]', inConstruct: 'phrasing'}, {character: '<', inConstruct: 'destinationLiteral'}, // An equals to can start setext heading underlines. {atBreak: true, character: '='}, // A greater than can start block quotes and it can break out of a // destination literal. {atBreak: true, character: '>'}, {character: '>', inConstruct: 'destinationLiteral'}, // Question mark and at sign are not used in markdown for constructs. // A left bracket can start definitions, references, labels, {atBreak: true, character: '['}, {character: '[', inConstruct: ['phrasing', 'label', 'reference']}, // A backslash can start an escape (when followed by punctuation) or a // hard break (when followed by an eol). // Note: typical escapes are handled in `safe`! {character: '\\', after: '[\\r\\n]', inConstruct: 'phrasing'}, // A right bracket can exit labels. { character: ']', inConstruct: ['label', 'reference'] }, // Caret is not used in markdown for constructs. // An underscore can start emphasis, strong, or a thematic break. {atBreak: true, character: '_'}, {before: '[^A-Za-z]', character: '_', inConstruct: 'phrasing'}, {character: '_', after: '[^A-Za-z]', inConstruct: 'phrasing'}, // A grave accent can start code (fenced or text), or it can break out of // a grave accent code fence. {atBreak: true, character: '`'}, { character: '`', inConstruct: [ 'codeFencedLangGraveAccent', 'codeFencedMetaGraveAccent', 'phrasing' ] }, // Left brace, vertical bar, right brace are not used in markdown for // constructs. // A tilde can start code (fenced). {atBreak: true, character: '~'} ]; var lib = toMarkdown$1; function toMarkdown$1(tree, options) { var settings = options || {}; var context = { enter: enter, stack: [], unsafe: [], join: [], handlers: {}, options: {} }; var result; configure_1$1(context, { unsafe: unsafe, join: join$1, handlers: handle$1 }); configure_1$1(context, settings); if (context.options.tightDefinitions) { context.join = [joinDefinition$1].concat(context.join); } context.handle = zwitch('type', { invalid: invalid$1, unknown: unknown$1, handlers: context.handlers }); result = context.handle(tree, null, context, {before: '\n', after: '\n'}); if ( result && result.charCodeAt(result.length - 1) !== 10 && result.charCodeAt(result.length - 1) !== 13 ) { result += '\n'; } return result function enter(name) { context.stack.push(name); return exit function exit() { context.stack.pop(); } } } function invalid$1(value) { throw new Error('Cannot handle value `' + value + '`, expected node') } function unknown$1(node) { throw new Error('Cannot handle unknown node `' + node.type + '`') } function joinDefinition$1(left, right) { // No blank line between adjacent definitions. if (left.type === 'definition' && left.type === right.type) { return 0 } } var mdastUtilToMarkdown = lib; var remarkStringify = stringify$1; function stringify$1(options) { var self = this; this.Compiler = compile; function compile(tree) { return mdastUtilToMarkdown( tree, Object.assign({}, self.data('settings'), options, { // Note: this option is not in the readme. // The goal is for it to be set by plugins on `data` instead of being // passed by users. extensions: self.data('toMarkdownExtensions') || [] }) ) } } var remark = unified_1().use(remarkParse).use(remarkStringify).freeze(); var configure_1 = configure; function configure(base, extension) { var index = -1; var key; // First do subextensions. if (extension.extensions) { while (++index < extension.extensions.length) { configure(base, extension.extensions[index]); } } for (key in extension) { if (key === 'extensions') ; else if (key === 'unsafe' || key === 'join') { base[key] = base[key].concat(extension[key] || []); } else if (key === 'handlers') { base[key] = Object.assign(base[key], extension[key] || {}); } else { base.options[key] = extension[key]; } } return base } var containerFlow = flow; function flow(parent, context) { var children = parent.children || []; var results = []; var index = -1; var child; while (++index < children.length) { child = children[index]; results.push( context.handle(child, parent, context, {before: '\n', after: '\n'}) ); if (index + 1 < children.length) { results.push(between(child, children[index + 1])); } } return results.join('') function between(left, right) { var index = -1; var result; while (++index < context.join.length) { result = context.join[index](left, right, parent, context); if (result === true || result === 1) { break } if (typeof result === 'number') { return repeatString('\n', 1 + Number(result)) } if (result === false) { // return '\n\n\n\n' return '\n\n' } } return '\n\n' } } var indentLines_1 = indentLines; var eol = /\r?\n|\r/g; function indentLines(value, map) { var result = []; var start = 0; var line = 0; var match; while ((match = eol.exec(value))) { one(value.slice(start, match.index)); result.push(match[0]); start = match.index + match[0].length; line++; } one(value.slice(start)); return result.join('') function one(value) { result.push(map(value, line, !value)); } } var blockquote_1 = blockquote$1; function blockquote$1(node, _, context) { var exit = context.enter('blockquote'); var value = indentLines_1(containerFlow(node, context), map); exit(); return value } function map(line, index, blank) { return '>' + (blank ? '' : ' ') + line } var patternInScope_1 = patternInScope; function patternInScope(stack, pattern) { return ( listInScope(stack, pattern.inConstruct, true) && !listInScope(stack, pattern.notInConstruct) ) } function listInScope(stack, list, none) { var index; if (!list) { return none } if (typeof list === 'string') { list = [list]; } index = -1; while (++index < list.length) { if (stack.indexOf(list[index]) !== -1) { return true } } return false } var _break$1 = hardBreak$1; function hardBreak$1(node, _, context, safe) { let index = -1; while (++index < context.unsafe.length) { // If we can’t put eols in this construct (setext headings, tables), use a // space instead. if ( context.unsafe[index].character === '\n' && patternInScope_1(context.stack, context.unsafe[index]) ) { return /[ \t]/.test(safe.before) ? '' : ' ' } } return '\\\n' } var formatCodeAsIndented_1 = formatCodeAsIndented; function formatCodeAsIndented(node, context) { return ( !context.options.fences && node.value && // If there’s no info… !node.lang && // And there’s a non-whitespace character… /[^ \r\n]/.test(node.value) && // And the value doesn’t start or end in a blank… !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(node.value) ) } var checkFence_1 = checkFence; function checkFence(context) { var marker = context.options.fence || '`'; if (marker !== '`' && marker !== '~') { throw new Error( 'Cannot serialize code with `' + marker + '` for `options.fence`, expected `` ` `` or `~`' ) } return marker } var patternCompile_1 = patternCompile; function patternCompile(pattern) { var before; var after; if (!pattern._compiled) { before = pattern.before ? '(?:' + pattern.before + ')' : ''; after = pattern.after ? '(?:' + pattern.after + ')' : ''; if (pattern.atBreak) { before = '[\\r\\n][\\t ]*' + before; } pattern._compiled = new RegExp( (before ? '(' + before + ')' : '') + (/[|\\{}()[\]^$+*?.-]/.test(pattern.character) ? '\\' : '') + pattern.character + (after || ''), 'g' ); } return pattern._compiled } var safe_1 = safe; function safe(context, input, config) { var value = (config.before || '') + (input || '') + (config.after || ''); var positions = []; var result = []; var infos = {}; var index = -1; var before; var after; var position; var pattern; var expression; var match; var start; var end; while (++index < context.unsafe.length) { pattern = context.unsafe[index]; if (!patternInScope_1(context.stack, pattern)) { continue } expression = patternCompile_1(pattern); while ((match = expression.exec(value))) { before = 'before' in pattern || pattern.atBreak; after = 'after' in pattern; position = match.index + (before ? match[1].length : 0); if (positions.indexOf(position) === -1) { positions.push(position); infos[position] = {before: before, after: after}; } else { if (infos[position].before && !before) { infos[position].before = false; } if (infos[position].after && !after) { infos[position].after = false; } } } } positions.sort(numerical); start = config.before ? config.before.length : 0; end = value.length - (config.after ? config.after.length : 0); index = -1; while (++index < positions.length) { position = positions[index]; if ( // Character before or after matched: position < start || position >= end ) { continue } // If this character is supposed to be escaped because it has a condition on // the next character, and the next character is definitly being escaped, // then skip this escape. if ( position + 1 < end && positions[index + 1] === position + 1 && infos[position].after && !infos[position + 1].before && !infos[position + 1].after ) { continue } if (start !== position) { // If we have to use a character reference, an ampersand would be more // correct, but as backslashes only care about punctuation, either will // do the trick result.push(escapeBackslashes(value.slice(start, position), '\\')); } start = position; if ( /[!-/:-@[-`{-~]/.test(value.charAt(position)) && (!config.encode || config.encode.indexOf(value.charAt(position)) === -1) ) ; else { // Character reference. result.push( '&#x' + value.charCodeAt(position).toString(16).toUpperCase() + ';' ); start++; } } result.push(escapeBackslashes(value.slice(start, end), config.after)); return result.join('') } function numerical(a, b) { return a - b } function escapeBackslashes(value, after) { var expression = /\\(?=[!-/:-@[-`{-~])/g; var positions = []; var results = []; var index = -1; var start = 0; var whole = value + after; var match; while ((match = expression.exec(whole))) { positions.push(match.index); } while (++index < positions.length) { if (start !== positions[index]) { results.push(value.slice(start, positions[index])); } results.push('\\'); start = positions[index]; } results.push(value.slice(start)); return results.join('') } var code_1 = code$1; function code$1(node, _, context) { const marker = checkFence_1(context); const raw = node.value || ''; const suffix = marker === '`' ? 'GraveAccent' : 'Tilde'; let value; let sequence; let exit; let subexit; if (formatCodeAsIndented_1(node, context)) { exit = context.enter('codeIndented'); // value = indentLines(raw, map) value = raw; } else { sequence = repeatString(marker, Math.max(longestStreak_1(raw, marker) + 1, 3)); exit = context.enter('codeFenced'); value = sequence; if (node.lang) { subexit = context.enter('codeFencedLang' + suffix); value += safe_1(context, node.lang, { before: '`', after: ' ', encode: ['`'] }); subexit(); } if (node.lang && node.meta) { subexit = context.enter('codeFencedMeta' + suffix); value += ' ' + safe_1(context, node.meta, { before: ' ', after: '\n', encode: ['`'] }); subexit(); } value += '\n'; if (raw) { value += raw + '\n'; } value += sequence; } exit(); return value } var association_1 = association; var characterEscape = /\\([!-/:-@[-`{-~])/g; var characterReference = /&(#(\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; // The `label` of an association is the string value: character escapes and // references work, and casing is intact. // The `identifier` is used to match one association to another: controversially, // character escapes and references don’t work in this matching: `©` does // not match `©`, and `\+` does not match `+`. // But casing is ignored (and whitespace) is trimmed and collapsed: ` A\nb` // matches `a b`. // So, we do prefer the label when figuring out how we’re going to serialize: // it has whitespace, casing, and we can ignore most useless character escapes // and all character references. function association(node) { if (node.label || !node.identifier) { return node.label || '' } return node.identifier .replace(characterEscape, '$1') .replace(characterReference, decodeIfPossible) } function decodeIfPossible($0, $1) { return decodeEntity_1($1) || $0 } var checkQuote_1 = checkQuote; function checkQuote(context) { var marker = context.options.quote || '"'; if (marker !== '"' && marker !== "'") { throw new Error( 'Cannot serialize title with `' + marker + '` for `options.quote`, expected `"`, or `\'`' ) } return marker } var definition_1 = definition$1; function definition$1(node, _, context) { var marker = checkQuote_1(context); var suffix = marker === '"' ? 'Quote' : 'Apostrophe'; var exit = context.enter('definition'); var subexit = context.enter('label'); var value = '[' + safe_1(context, association_1(node), {before: '[', after: ']'}) + ']: '; subexit(); if ( // If there’s no url, or… !node.url || // If there’s whitespace, enclosed is prettier. /[ \t\r\n]/.test(node.url) ) { subexit = context.enter('destinationLiteral'); value += '<' + safe_1(context, node.url, {before: '<', after: '>'}) + '>'; } else { // No whitespace, raw is prettier. subexit = context.enter('destinationRaw'); value += safe_1(context, node.url, {before: ' ', after: ' '}); } subexit(); if (node.title) { subexit = context.enter('title' + suffix); value += ' ' + marker + safe_1(context, node.title, {before: marker, after: marker}) + marker; subexit(); } exit(); return value } var checkEmphasis_1 = checkEmphasis; function checkEmphasis(context) { var marker = context.options.emphasis || '*'; if (marker !== '*' && marker !== '_') { throw new Error( 'Cannot serialize emphasis with `' + marker + '` for `options.emphasis`, expected `*`, or `_`' ) } return marker } var containerPhrasing = phrasing; function phrasing(parent, context, safeOptions) { var children = parent.children || []; var results = []; var index = -1; var before = safeOptions.before; var after; var handle; var child; while (++index < children.length) { child = children[index]; if (index + 1 < children.length) { handle = context.handle.handlers[children[index + 1].type]; if (handle && handle.peek) handle = handle.peek; after = handle ? handle(children[index + 1], parent, context, { before: '', after: '' }).charAt(0) : ''; } else { after = safeOptions.after; } // In some cases, html (text) can be found in phrasing right after an eol. // When we’d serialize that, in most cases that would be seen as html // (flow). // As we can’t escape or so to prevent it from happening, we take a somewhat // reasonable approach: replace that eol with a space. // See: if ( results.length > 0 && (before === '\r' || before === '\n') && child.type === 'html' ) { results[results.length - 1] = results[results.length - 1].replace( /(\r?\n|\r)$/, ' ' ); before = ' '; } results.push( context.handle(child, parent, context, { before: before, after: after }) ); before = results[results.length - 1].slice(-1); } return results.join('') } var emphasis_1 = emphasis$1; emphasis$1.peek = emphasisPeek; // To do: there are cases where emphasis cannot “form” depending on the // previous or next character of sequences. // There’s no way around that though, except for injecting zero-width stuff. // Do we need to safeguard against that? function emphasis$1(node, _, context) { var marker = checkEmphasis_1(context); var exit = context.enter('emphasis'); var value = containerPhrasing(node, context, {before: marker, after: marker}); exit(); return marker + value + marker } function emphasisPeek(node, _, context) { return context.options.emphasis || '*' } var formatHeadingAsSetext_1 = formatHeadingAsSetext; function formatHeadingAsSetext(node, context) { return ( context.options.setext && (!node.depth || node.depth < 3) && mdastUtilToString(node) ) } var heading_1 = heading$1; function heading$1(node, _, context) { var rank = Math.max(Math.min(6, node.depth || 1), 1); var exit; var subexit; var value; var sequence; if (formatHeadingAsSetext_1(node, context)) { exit = context.enter('headingSetext'); subexit = context.enter('phrasing'); value = containerPhrasing(node, context, {before: '\n', after: '\n'}); subexit(); exit(); return ( value + '\n' + repeatString( rank === 1 ? '=' : '-', // The whole size… value.length - // Minus the position of the character after the last EOL (or // 0 if there is none)… (Math.max(value.lastIndexOf('\r'), value.lastIndexOf('\n')) + 1) ) ) } sequence = repeatString('#', rank); exit = context.enter('headingAtx'); subexit = context.enter('phrasing'); value = containerPhrasing(node, context, {before: '# ', after: '\n'}); value = value ? sequence + ' ' + value : sequence; if (context.options.closeAtx) { value += ' ' + sequence; } subexit(); exit(); return value } var html_1 = html$1; html$1.peek = htmlPeek; function html$1(node) { return node.value || '' } function htmlPeek() { return '<' } var image_1 = image$1; image$1.peek = imagePeek; function image$1(node, _, context) { var quote = checkQuote_1(context); var suffix = quote === '"' ? 'Quote' : 'Apostrophe'; var exit = context.enter('image'); var subexit = context.enter('label'); var value = '![' + safe_1(context, node.alt, {before: '[', after: ']'}) + ']('; subexit(); if ( // If there’s no url but there is a title… (!node.url && node.title) || // Or if there’s markdown whitespace or an eol, enclose. /[ \t\r\n]/.test(node.url) ) { subexit = context.enter('destinationLiteral'); value += '<' + safe_1(context, node.url, {before: '<', after: '>'}) + '>'; } else { // No whitespace, raw is prettier. subexit = context.enter('destinationRaw'); value += safe_1(context, node.url, { before: '(', after: node.title ? ' ' : ')' }); } subexit(); if (node.title) { subexit = context.enter('title' + suffix); value += ' ' + quote + safe_1(context, node.title, {before: quote, after: quote}) + quote; subexit(); } value += ')'; exit(); return value } function imagePeek() { return '!' } var imageReference_1 = imageReference$1; imageReference$1.peek = imageReferencePeek; function imageReference$1(node, _, context) { var type = node.referenceType; var exit = context.enter('imageReference'); var subexit = context.enter('label'); var alt = safe_1(context, node.alt, {before: '[', after: ']'}); var value = '![' + alt + ']'; var reference; var stack; subexit(); // Hide the fact that we’re in phrasing, because escapes don’t work. stack = context.stack; context.stack = []; subexit = context.enter('reference'); reference = safe_1(context, association_1(node), {before: '[', after: ']'}); subexit(); context.stack = stack; exit(); if (type === 'full' || !alt || alt !== reference) { value += '[' + reference + ']'; } else if (type !== 'shortcut') { value += '[]'; } return value } function imageReferencePeek() { return '!' } var inlineCode_1 = inlineCode$1; inlineCode$1.peek = inlineCodePeek; function inlineCode$1(node, parent, context) { var value = node.value || ''; var sequence = '`'; var index = -1; var pattern; var expression; var match; var position; // If there is a single grave accent on its own in the code, use a fence of // two. // If there are two in a row, use one. while (new RegExp('(^|[^`])' + sequence + '([^`]|$)').test(value)) { sequence += '`'; } // If this is not just spaces or eols (tabs don’t count), and either the // first or last character are a space, eol, or tick, then pad with spaces. if ( /[^ \r\n]/.test(value) && (/[ \r\n`]/.test(value.charAt(0)) || /[ \r\n`]/.test(value.charAt(value.length - 1))) ) { value = ' ' + value + ' '; } // We have a potential problem: certain characters after eols could result in // blocks being seen. // For example, if someone injected the string `'\n# b'`, then that would // result in an ATX heading. // We can’t escape characters in `inlineCode`, but because eols are // transformed to spaces when going from markdown to HTML anyway, we can swap // them out. while (++index < context.unsafe.length) { pattern = context.unsafe[index]; // Only look for `atBreak`s. // Btw: note that `atBreak` patterns will always start the regex at LF or // CR. if (!pattern.atBreak) continue expression = patternCompile_1(pattern); while ((match = expression.exec(value))) { position = match.index; // Support CRLF (patterns only look for one of the characters). if ( value.charCodeAt(position) === 10 /* `\n` */ && value.charCodeAt(position - 1) === 13 /* `\r` */ ) { position--; } value = value.slice(0, position) + ' ' + value.slice(match.index + 1); } } return sequence + value + sequence } function inlineCodePeek() { return '`' } var formatLinkAsAutolink_1 = formatLinkAsAutolink; function formatLinkAsAutolink(node, context) { var raw = mdastUtilToString(node); return ( !context.options.resourceLink && // If there’s a url… node.url && // And there’s a no title… !node.title && // And the content of `node` is a single text node… node.children && node.children.length === 1 && node.children[0].type === 'text' && // And if the url is the same as the content… (raw === node.url || 'mailto:' + raw === node.url) && // And that starts w/ a protocol… /^[a-z][a-z+.-]+:/i.test(node.url) && // And that doesn’t contain ASCII control codes (character escapes and // references don’t work) or angle brackets… !/[\0- <>\u007F]/.test(node.url) ) } var link_1 = link$1; link$1.peek = linkPeek; function link$1(node, _, context) { var quote = checkQuote_1(context); var suffix = quote === '"' ? 'Quote' : 'Apostrophe'; var exit; var subexit; var value; var stack; if (formatLinkAsAutolink_1(node, context)) { // Hide the fact that we’re in phrasing, because escapes don’t work. stack = context.stack; context.stack = []; exit = context.enter('autolink'); value = '<' + containerPhrasing(node, context, {before: '<', after: '>'}) + '>'; exit(); context.stack = stack; return value } exit = context.enter('link'); subexit = context.enter('label'); value = '[' + containerPhrasing(node, context, {before: '[', after: ']'}) + ']('; subexit(); if ( // If there’s no url but there is a title… (!node.url && node.title) || // Or if there’s markdown whitespace or an eol, enclose. /[ \t\r\n]/.test(node.url) ) { subexit = context.enter('destinationLiteral'); value += '<' + safe_1(context, node.url, {before: '<', after: '>'}) + '>'; } else { // No whitespace, raw is prettier. subexit = context.enter('destinationRaw'); value += safe_1(context, node.url, { before: '(', after: node.title ? ' ' : ')' }); } subexit(); if (node.title) { subexit = context.enter('title' + suffix); value += ' ' + quote + safe_1(context, node.title, {before: quote, after: quote}) + quote; subexit(); } value += ')'; exit(); return value } function linkPeek(node, _, context) { return formatLinkAsAutolink_1(node, context) ? '<' : '[' } var linkReference_1 = linkReference$1; linkReference$1.peek = linkReferencePeek; function linkReference$1(node, _, context) { var type = node.referenceType; var exit = context.enter('linkReference'); var subexit = context.enter('label'); var text = containerPhrasing(node, context, {before: '[', after: ']'}); var value = '[' + text + ']'; var reference; var stack; subexit(); // Hide the fact that we’re in phrasing, because escapes don’t work. stack = context.stack; context.stack = []; subexit = context.enter('reference'); reference = safe_1(context, association_1(node), {before: '[', after: ']'}); subexit(); context.stack = stack; exit(); if (type === 'full' || !text || text !== reference) { value += '[' + reference + ']'; } else if (type !== 'shortcut') { value += '[]'; } return value } function linkReferencePeek() { return '[' } var list_1 = list$1; function list$1(node, _, context) { var exit = context.enter('list'); var value = containerFlow(node, context); exit(); return value } var checkBullet_1 = checkBullet; function checkBullet(context) { var marker = context.options.bullet || '*'; if (marker !== '*' && marker !== '+' && marker !== '-') { throw new Error( 'Cannot serialize items with `' + marker + '` for `options.bullet`, expected `*`, `+`, or `-`' ) } return marker } var checkListItemIndent_1 = checkListItemIndent; function checkListItemIndent(context) { var style = context.options.listItemIndent || 'tab'; if (style === 1 || style === '1') { return 'one' } if (style !== 'tab' && style !== 'one' && style !== 'mixed') { throw new Error( 'Cannot serialize items with `' + style + '` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`' ) } return style } var defaultListItem = listItem$1; function listItem$1(node, parent, context) { var bullet = checkBullet_1(context); var listItemIndent = checkListItemIndent_1(context); var size; var value; var exit; if (parent && parent.ordered) { bullet = (parent.start > -1 ? parent.start : 1) + (context.options.incrementListMarker === false ? 0 : parent.children.indexOf(node)) + '.'; } size = bullet.length + 1; let separator = ' '; if ( listItemIndent === 'tab' || (listItemIndent === 'mixed' && ((parent && parent.spread) || node.spread)) ) { separator = '\t'; size = bullet.length; } exit = context.enter('listItem'); value = indentLines_1(containerFlow(node, context), map); exit(); return value function map(line, index, blank) { if (index) { return (blank ? '' : repeatString(separator, size)) + line } return (blank ? bullet : bullet + ' ') + line } } function listItemWithTaskListItemPatch(node, parent, context) { var value = defaultListItem(node, parent, context); var head = node.children[0]; if (typeof node.checked === 'boolean' && head && head.type === 'paragraph') { value = value.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, check); } return value function check($0) { return $0 + '[' + (node.checked ? 'x' : ' ') + '] ' } } var listItemWithTaskListItem = listItemWithTaskListItemPatch; var paragraph_1 = paragraph$1; function paragraph$1(node, _, context) { var exit = context.enter('paragraph'); var subexit = context.enter('phrasing'); var value = containerPhrasing(node, context, {before: '\n', after: '\n'}); subexit(); exit(); return value } var root_1 = root$1; function root$1(node, _, context) { return containerFlow(node, context) } var checkStrong_1 = checkStrong; function checkStrong(context) { var marker = context.options.strong || '*'; if (marker !== '*' && marker !== '_') { throw new Error( 'Cannot serialize strong with `' + marker + '` for `options.strong`, expected `*`, or `_`' ) } return marker } var strong_1 = strong$1; strong$1.peek = strongPeek; // To do: there are cases where emphasis cannot “form” depending on the // previous or next character of sequences. // There’s no way around that though, except for injecting zero-width stuff. // Do we need to safeguard against that? function strong$1(node, _, context) { var marker = checkStrong_1(context); var exit = context.enter('strong'); var value = containerPhrasing(node, context, {before: marker, after: marker}); exit(); return marker + marker + value + marker + marker } function strongPeek(node, _, context) { return context.options.strong || '*' } var text_1 = text$1; function text$1(node, parent, context, safeOptions) { return safe_1(context, node.value, safeOptions) } var checkRuleRepeat = checkRule$1; function checkRule$1(context) { var repetition = context.options.ruleRepetition || 3; if (repetition < 3) { throw new Error( 'Cannot serialize rules with repetition `' + repetition + '` for `options.ruleRepetition`, expected `3` or more' ) } return repetition } var checkRule_1 = checkRule; function checkRule(context) { var marker = context.options.rule || '*'; if (marker !== '*' && marker !== '-' && marker !== '_') { throw new Error( 'Cannot serialize rules with `' + marker + '` for `options.rule`, expected `*`, `-`, or `_`' ) } return marker } var thematicBreak_1 = thematicBreak$1; function thematicBreak$1(node, parent, context) { var value = repeatString( checkRule_1(context) + (context.options.ruleSpaces ? ' ' : ''), checkRuleRepeat(context) ); return context.options.ruleSpaces ? value.slice(0, -1) : value } var blockquote = blockquote_1; var _break = _break$1; var code = code_1; var definition = definition_1; var emphasis = emphasis_1; var hardBreak = _break$1; var heading = heading_1; var html = html_1; var image = image_1; var imageReference = imageReference_1; var inlineCode = inlineCode_1; var link = link_1; var linkReference = linkReference_1; var list = list_1; var listItem = listItemWithTaskListItem; var paragraph = paragraph_1; var root = root_1; var strong = strong_1; var text = text_1; var thematicBreak = thematicBreak_1; var handle = { blockquote: blockquote, break: _break, code: code, definition: definition, emphasis: emphasis, hardBreak: hardBreak, heading: heading, html: html, image: image, imageReference: imageReference, inlineCode: inlineCode, link: link, linkReference: linkReference, list: list, listItem: listItem, paragraph: paragraph, root: root, strong: strong, text: text, thematicBreak: thematicBreak }; var join = [joinDefaults]; function joinDefaults(left, right, parent, context) { if ( // Two lists with the same marker. (right.type === 'list' && right.type === left.type && Boolean(left.ordered) === Boolean(right.ordered)) || // Indented code after list or another indented code. (right.type === 'code' && formatCodeAsIndented_1(right, context) && (left.type === 'list' || (left.type === right.type && formatCodeAsIndented_1(left, context)))) ) { return false } // Join children of a list or an item. // In which case, `parent` has a `spread` field. if (typeof parent.spread === 'boolean') { if ( left.type === 'paragraph' && // Two paragraphs. (left.type === right.type || right.type === 'definition' || // Paragraph followed by a setext heading. (right.type === 'heading' && formatHeadingAsSetext_1(right, context))) ) { return } return parent.spread ? 1 : 0 } } var mdastUtilToMarkdownPatch = toMarkdown; var defaultUnsafe = []; function toMarkdown (tree, options) { var settings = options || {}; var context = { enter: enter, stack: [], unsafe: [], join: [], handlers: {}, options: {} }; var result; configure_1(context, { unsafe: defaultUnsafe, join: join, handlers: handle }); configure_1(context, settings); if (context.options.tightDefinitions) { context.join = [joinDefinition].concat(context.join); } context.handle = zwitch('type', { invalid: invalid, unknown: unknown, handlers: context.handlers }); result = context.handle(tree, null, context, { before: '\n', after: '\n' }); if ( result && result.charCodeAt(result.length - 1) !== 10 && result.charCodeAt(result.length - 1) !== 13 ) { result += '\n'; } return result function enter (name) { context.stack.push(name); return exit function exit () { context.stack.pop(); } } } function invalid (value) { throw new Error('Cannot handle value `' + value + '`, expected node') } function unknown (node) { throw new Error('Cannot handle unknown node `' + node.type + '`') } function joinDefinition (left, right) { // No blank line between adjacent definitions. if (left.type === 'definition' && left.type === right.type) { return 0 } } function prettifier(content, userOptions, frontMatterData) { var options = __assign(__assign({}, DEFAULT_OPTIONS), userOptions); var processor = remark(); if (options.createHeaderIfNotPresent || options.updateHeader) { processor = processor .use(remarkFrontmatter) .use(metadataWriter, options, __assign({ today: moment(), tags: [] }, frontMatterData)); } var stringifyOptions = Object.assign({}, options); if (!stringifyOptions.newlinesAroundHeadings) { stringifyOptions.join = [ //@ts-ignore function (left, right) { if (left.type === 'heading' || right.type === 'heading') { return 0; } return 1; }, ]; } //https://github.com/cristianvasquez/obsidian-prettify/issues/19 stringifyOptions.handlers = { listItem: listItemWithTaskListItem }; processor = processor .use(remarkGfm) .use(wikiLinkPlugin) .use(remarkMath) // @ts-ignore .use(stringify, stringifyOptions); return processor.process(content); } function stringify(options) { var self = this; this.Compiler = compile; function compile(tree) { return mdastUtilToMarkdownPatch(tree, Object.assign({}, self.data('settings'), options, { extensions: self.data('toMarkdownExtensions') || [] })); } } var DEFAULT_SETTINGS = { bullet: "-", emphasis: "_", rule: "-", createHeaderIfNotPresent: true, newHeaderTemplate: NEW_HEADER_TEMPLATE, updateHeader: true, updateHeaderTemplate: UPDATE_HEADER_TEMPLATE, listItemIndent: "one", newlinesAroundHeadings: true, }; var MarkdownPrettifier = /** @class */ (function (_super) { __extends(MarkdownPrettifier, _super); function MarkdownPrettifier() { return _super !== null && _super.apply(this, arguments) || this; } MarkdownPrettifier.prototype.onInit = function () { }; MarkdownPrettifier.prototype.loadSettings = function () { return __awaiter(this, void 0, void 0, function () { var _a, _b, _c, _d; return __generator(this, function (_e) { switch (_e.label) { case 0: _a = this; _c = (_b = Object).assign; _d = [DEFAULT_SETTINGS]; return [4 /*yield*/, this.loadData()]; case 1: _a.settings = _c.apply(_b, _d.concat([_e.sent()])); return [2 /*return*/]; } }); }); }; MarkdownPrettifier.prototype.saveSettings = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.saveData(this.settings)]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }; MarkdownPrettifier.prototype.onload = function () { return __awaiter(this, void 0, void 0, function () { var _this = this; return __generator(this, function (_a) { switch (_a.label) { case 0: console.log("Loading Markdown-Prettifier"); return [4 /*yield*/, this.loadSettings()]; case 1: _a.sent(); this.addSettingTab(new MarkdownPrettifierSettingsTab(this.app, this)); this.addCommand({ id: "markdown-prettifier-run", name: "Run", callback: function () { return _this.runPrettifier(); }, hotkeys: [ { modifiers: ["Mod", "Alt"], key: "l", }, ], }); this.addCommand({ id: "markdown-prettifier-update-fields", name: "Run with Hashtag janitor", callback: function () { return _this.updateMatters(); }, hotkeys: [ { modifiers: ["Mod", "Alt"], key: "o", }, ], }); return [2 /*return*/]; } }); }); }; MarkdownPrettifier.prototype.onunload = function () { console.log("Unload Markdown-Prettifier"); }; MarkdownPrettifier.prototype.runPrettifier = function () { var view = this.app.workspace.activeLeaf.view; if (view instanceof obsidian.MarkdownView) { // Do work here var editor_1 = view.editor; // Remember the cursor var cursor_1 = Object.assign({}, editor_1.getCursor()); var text_1 = editor_1.getDoc().getValue(); prettifier(text_1, this.settings, { today: moment(), tags: [] }) .then(function (data) { var output = String(data); try { // Calculate difference of lines and provide feedback var n_before = output.split(/\r\n|\r|\n/).length; var n_after = String(text_1).split(/\r\n|\r|\n/).length; var lines_changed = n_before - n_after; if (lines_changed != 0) { new obsidian.Notice("Prettifier: " + lines_changed + " lines."); } // Update the cursor if (cursor_1.line) { cursor_1.line = cursor_1.line + lines_changed; } } catch (err) { console.error(err); } editor_1.setValue(output); editor_1.setCursor(cursor_1); }).catch(function (err) { console.error(err); if (err.message) { new obsidian.Notice(err.message); } }); } }; MarkdownPrettifier.prototype.updateMatters = function () { var view = this.app.workspace.activeLeaf.view; if (view instanceof obsidian.MarkdownView) { // Do work here var editor_2 = view.editor; // Remember the cursor var cursor_2 = editor_2.getCursor(); var text = editor_2.getDoc().getValue(); var frontMatterData = { today: moment(), tags: new Templates().findHashtags(text), }; prettifier(text, this.settings, frontMatterData) .then(function (data) { editor_2.setValue(String(data)); editor_2.setCursor(cursor_2); new obsidian.Notice("Updated tags"); }) .catch(function (err) { console.error(err); if (err.message) { new obsidian.Notice(err.message); } }); } }; return MarkdownPrettifier; }(obsidian.Plugin)); var MarkdownPrettifierSettingsTab = /** @class */ (function (_super) { __extends(MarkdownPrettifierSettingsTab, _super); function MarkdownPrettifierSettingsTab(app, plugin) { var _this = _super.call(this, app, plugin) || this; _this.newHeaderExample = document.createElement('b'); _this.newHeaderIsValid = document.createElement('b'); _this.updateHeaderExample = document.createElement('b'); _this.updateHeaderIsValid = document.createElement('b'); _this.plugin = plugin; return _this; } MarkdownPrettifierSettingsTab.prototype.display = function () { var _this = this; var containerEl = this.containerEl; containerEl.empty(); var settings = this.plugin.settings; this.containerEl.createEl("h3", { text: "Prettyfication Settings", }); // ('*', '+', or '-', default: '*'). Marker to use to for bullets of items in unordered lists new obsidian.Setting(containerEl) .setName("bullet") .setDesc("Marker to use to for bullets of items in unordered lists") .addDropdown(function (dropdown) { dropdown.addOption("*", "* item"); dropdown.addOption("+", "+ item"); dropdown.addOption("-", "- item"); dropdown.setValue(String(settings.bullet)) .onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: this.plugin.settings.bullet = value; return [4 /*yield*/, this.plugin.saveSettings()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }); }); new obsidian.Setting(containerEl) .setName("List indent") .setDesc("Whether to use small or big spaces to indent lists") .addDropdown(function (dropdown) { dropdown.addOption('one', "space"); // dropdown.addOption('mixed', "mixed"); dropdown.addOption('tab', "tab"); dropdown.setValue(String(_this.plugin.settings.listItemIndent)) .onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: this.plugin.settings.listItemIndent = value; return [4 /*yield*/, this.plugin.saveSettings()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }); }); // ('*' or '_', default: '*'). Marker to use to serialize emphasis new obsidian.Setting(containerEl) .setName("emphasis") .setDesc("Marker to use to serialize emphasis") .addDropdown(function (dropdown) { dropdown.setValue(_this.plugin.settings.emphasis); dropdown.addOption("*", "*emphasis*"); dropdown.addOption("_", "_emphasis_"); dropdown.setValue(String(settings.emphasis)).onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: this.plugin.settings.emphasis = value; return [4 /*yield*/, this.plugin.saveSettings()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }); }); // ('*', '-', or '_', default: '*'). Marker to use for thematic breaks new obsidian.Setting(containerEl) .setName("thematic rule") .setDesc("Marker to use for thematic breaks") .addDropdown(function (dropdown) { dropdown.setValue(_this.plugin.settings.rule); dropdown.addOption("*", "***"); dropdown.addOption("-", "---"); dropdown.addOption("_", "___"); dropdown.setValue(String(settings.rule)).onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: this.plugin.settings.rule = value; return [4 /*yield*/, this.plugin.saveSettings()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }); }); new obsidian.Setting(containerEl) .setName('Newlines around headings') .setDesc('Add empty lines around each heading') .addToggle(function (toggle) { toggle.setValue(_this.plugin.settings.newlinesAroundHeadings); toggle.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: this.plugin.settings.newlinesAroundHeadings = value; return [4 /*yield*/, this.plugin.saveSettings()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }); }); this.containerEl.createEl("h3", { text: "Add new Header Settings", }); new obsidian.Setting(this.containerEl) .setName("Add a new header") .setDesc("Adds a new header if there isn't") .addToggle(function (toggle) { toggle.setValue(_this.plugin.settings.createHeaderIfNotPresent); toggle.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: this.plugin.settings.createHeaderIfNotPresent = value; return [4 /*yield*/, this.plugin.saveSettings()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }); }); new obsidian.Setting(containerEl) .setName('New Header template') .setDesc(this.checkNewTemplate()) .addTextArea(function (text) { text .setValue(_this.plugin.settings.newHeaderTemplate || '') .onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { var example; return __generator(this, function (_a) { switch (_a.label) { case 0: this.plugin.settings.newHeaderTemplate = value; example = this.applyTemplate(this.plugin.settings.newHeaderTemplate); this.newHeaderExample.innerText = example.text; this.newHeaderIsValid.innerText = example.valid ? "is valid YAML" : "is NOT valid YAML"; if (!example.valid) return [3 /*break*/, 2]; return [4 /*yield*/, this.plugin.saveSettings()]; case 1: _a.sent(); _a.label = 2; case 2: return [2 /*return*/]; } }); }); }); text.inputEl.rows = 8; text.inputEl.cols = 40; }); this.containerEl.createEl("h3", { text: "Update Header Settings", }); new obsidian.Setting(this.containerEl) .setName("Update header") .setDesc(this.updateTemplateHelp()) .addToggle(function (toggle) { toggle.setValue(_this.plugin.settings.updateHeader); toggle.onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: this.plugin.settings.updateHeader = value; return [4 /*yield*/, this.plugin.saveSettings()]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }); }); new obsidian.Setting(containerEl) .setName('Update Header template') .setDesc(this.checkUpdateTemplate()) .addTextArea(function (text) { text .setValue(_this.plugin.settings.updateHeaderTemplate || '') .onChange(function (value) { return __awaiter(_this, void 0, void 0, function () { var example; return __generator(this, function (_a) { switch (_a.label) { case 0: this.plugin.settings.updateHeaderTemplate = value; example = this.applyTemplate(this.plugin.settings.updateHeaderTemplate); this.updateHeaderExample.innerText = example.text; this.updateHeaderIsValid.innerText = example.valid ? "is valid YAML" : "is NOT valid YAML"; if (!example.valid) return [3 /*break*/, 2]; return [4 /*yield*/, this.plugin.saveSettings()]; case 1: _a.sent(); _a.label = 2; case 2: return [2 /*return*/]; } }); }); }); text.inputEl.rows = 8; text.inputEl.cols = 40; }); }; MarkdownPrettifierSettingsTab.prototype.updateTemplateHelp = function () { var descEl = document.createDocumentFragment(); descEl.appendText('If there is a header, they will be updated with the data defined in the template'); descEl.appendChild(document.createElement('br')); descEl.appendText('useful to update the "modified date" value'); return descEl; }; MarkdownPrettifierSettingsTab.prototype.checkNewTemplate = function () { var descEl = document.createDocumentFragment(); descEl.appendText('Newly created headers will use this template. This needs to be YAML'); descEl.appendChild(document.createElement('br')); this.formattingDescription(descEl); var example = this.applyTemplate(this.plugin.settings.newHeaderTemplate); this.newHeaderExample.innerText = example.text; this.newHeaderIsValid.innerText = example.valid ? "is valid YAML" : "is NOT valid YAML"; descEl.appendText('Your current header '); descEl.appendChild(this.newHeaderIsValid); descEl.appendText(' and the syntax looks like this:'); descEl.appendChild(document.createElement('br')); descEl.appendChild(this.newHeaderExample); return descEl; }; MarkdownPrettifierSettingsTab.prototype.checkUpdateTemplate = function () { var descEl = document.createDocumentFragment(); var example = this.applyTemplate(this.plugin.settings.updateHeaderTemplate); this.updateHeaderExample.innerText = example.text; this.updateHeaderIsValid.innerText = example.valid ? "is valid YAML" : "is NOT valid YAML"; descEl.appendText('Your current header '); descEl.appendChild(this.updateHeaderIsValid); descEl.appendText(' and the syntax looks like this:'); descEl.appendChild(document.createElement('br')); descEl.appendChild(this.updateHeaderExample); return descEl; }; MarkdownPrettifierSettingsTab.prototype.applyTemplate = function (template) { var templateLib = new Templates(); var text = templateLib.replaceUUID(template); text = templateLib.replaceDates(text, moment()); return { text: text, valid: templateLib.isValidYaml(text) }; }; MarkdownPrettifierSettingsTab.prototype.formattingDescription = function (descEl) { descEl.appendText('you can use {{UUID}} to generate unique IDs, {{date}} for dates, or things like {{date:YYY-MM-DD}}.'); descEl.appendChild(document.createElement('br')); descEl.appendText('For more syntax, refer to '); this.addMomentDocsLink(descEl); }; MarkdownPrettifierSettingsTab.prototype.addMomentDocsLink = function (descEl) { var a = document.createElement('a'); a.href = 'https://momentjs.com/docs/#/displaying/format/'; a.text = 'format reference'; a.target = '_blank'; descEl.appendChild(a); descEl.appendChild(document.createElement('br')); }; return MarkdownPrettifierSettingsTab; }(obsidian.PluginSettingTab)); module.exports = MarkdownPrettifier;