|
@@ -48,24 +48,29 @@
|
|
return arr2;
|
|
return arr2;
|
|
}
|
|
}
|
|
|
|
|
|
- function _createForOfIteratorHelperLoose(o) {
|
|
|
|
- var i = 0;
|
|
|
|
|
|
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
|
+ var it;
|
|
|
|
|
|
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
|
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
|
- if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) return function () {
|
|
|
|
- if (i >= o.length) return {
|
|
|
|
- done: true
|
|
|
|
- };
|
|
|
|
- return {
|
|
|
|
- done: false,
|
|
|
|
- value: o[i++]
|
|
|
|
|
|
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
|
|
+ if (it) o = it;
|
|
|
|
+ var i = 0;
|
|
|
|
+ return function () {
|
|
|
|
+ if (i >= o.length) return {
|
|
|
|
+ done: true
|
|
|
|
+ };
|
|
|
|
+ return {
|
|
|
|
+ done: false,
|
|
|
|
+ value: o[i++]
|
|
|
|
+ };
|
|
};
|
|
};
|
|
- };
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
}
|
|
}
|
|
|
|
|
|
- i = o[Symbol.iterator]();
|
|
|
|
- return i.next.bind(i);
|
|
|
|
|
|
+ it = o[Symbol.iterator]();
|
|
|
|
+ return it.next.bind(it);
|
|
}
|
|
}
|
|
|
|
|
|
function createCommonjsModule(fn, module) {
|
|
function createCommonjsModule(fn, module) {
|
|
@@ -585,11 +590,12 @@
|
|
var raw = cap[0];
|
|
var raw = cap[0];
|
|
var bull = cap[2];
|
|
var bull = cap[2];
|
|
var isordered = bull.length > 1;
|
|
var isordered = bull.length > 1;
|
|
|
|
+ var isparen = bull[bull.length - 1] === ')';
|
|
var list = {
|
|
var list = {
|
|
type: 'list',
|
|
type: 'list',
|
|
raw: raw,
|
|
raw: raw,
|
|
ordered: isordered,
|
|
ordered: isordered,
|
|
- start: isordered ? +bull : '',
|
|
|
|
|
|
+ start: isordered ? +bull.slice(0, -1) : '',
|
|
loose: false,
|
|
loose: false,
|
|
items: []
|
|
items: []
|
|
}; // Get each top-level item.
|
|
}; // Get each top-level item.
|
|
@@ -611,7 +617,7 @@
|
|
// so it is seen as the next token.
|
|
// so it is seen as the next token.
|
|
|
|
|
|
space = item.length;
|
|
space = item.length;
|
|
- item = item.replace(/^ *([*+-]|\d+\.) */, ''); // Outdent whatever the
|
|
|
|
|
|
+ item = item.replace(/^ *([*+-]|\d+[.)]) */, ''); // Outdent whatever the
|
|
// list item contains. Hacky.
|
|
// list item contains. Hacky.
|
|
|
|
|
|
if (~item.indexOf('\n ')) {
|
|
if (~item.indexOf('\n ')) {
|
|
@@ -624,7 +630,7 @@
|
|
if (i !== l - 1) {
|
|
if (i !== l - 1) {
|
|
b = this.rules.block.bullet.exec(itemMatch[i + 1])[0];
|
|
b = this.rules.block.bullet.exec(itemMatch[i + 1])[0];
|
|
|
|
|
|
- if (bull.length > 1 ? b.length === 1 : b.length > 1 || this.options.smartLists && b !== bull) {
|
|
|
|
|
|
+ if (isordered ? b.length === 1 || !isparen && b[b.length - 1] === ')' : b.length > 1 || this.options.smartLists && b !== bull) {
|
|
addBack = itemMatch.slice(i + 1).join('\n');
|
|
addBack = itemMatch.slice(i + 1).join('\n');
|
|
list.raw = list.raw.substring(0, list.raw.length - addBack.length);
|
|
list.raw = list.raw.substring(0, list.raw.length - addBack.length);
|
|
i = l - 1;
|
|
i = l - 1;
|
|
@@ -879,27 +885,57 @@
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- _proto.strong = function strong(src) {
|
|
|
|
- var cap = this.rules.inline.strong.exec(src);
|
|
|
|
|
|
+ _proto.strong = function strong(src, maskedSrc, prevChar) {
|
|
|
|
+ if (prevChar === void 0) {
|
|
|
|
+ prevChar = '';
|
|
|
|
+ }
|
|
|
|
|
|
- if (cap) {
|
|
|
|
- return {
|
|
|
|
- type: 'strong',
|
|
|
|
- raw: cap[0],
|
|
|
|
- text: cap[4] || cap[3] || cap[2] || cap[1]
|
|
|
|
- };
|
|
|
|
|
|
+ var match = this.rules.inline.strong.start.exec(src);
|
|
|
|
+
|
|
|
|
+ if (match && (!match[1] || match[1] && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar)))) {
|
|
|
|
+ maskedSrc = maskedSrc.slice(-1 * src.length);
|
|
|
|
+ var endReg = match[0] === '**' ? this.rules.inline.strong.endAst : this.rules.inline.strong.endUnd;
|
|
|
|
+ endReg.lastIndex = 0;
|
|
|
|
+ var cap;
|
|
|
|
+
|
|
|
|
+ while ((match = endReg.exec(maskedSrc)) != null) {
|
|
|
|
+ cap = this.rules.inline.strong.middle.exec(maskedSrc.slice(0, match.index + 3));
|
|
|
|
+
|
|
|
|
+ if (cap) {
|
|
|
|
+ return {
|
|
|
|
+ type: 'strong',
|
|
|
|
+ raw: src.slice(0, cap[0].length),
|
|
|
|
+ text: src.slice(2, cap[0].length - 2)
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- _proto.em = function em(src) {
|
|
|
|
- var cap = this.rules.inline.em.exec(src);
|
|
|
|
|
|
+ _proto.em = function em(src, maskedSrc, prevChar) {
|
|
|
|
+ if (prevChar === void 0) {
|
|
|
|
+ prevChar = '';
|
|
|
|
+ }
|
|
|
|
|
|
- if (cap) {
|
|
|
|
- return {
|
|
|
|
- type: 'em',
|
|
|
|
- raw: cap[0],
|
|
|
|
- text: cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]
|
|
|
|
- };
|
|
|
|
|
|
+ var match = this.rules.inline.em.start.exec(src);
|
|
|
|
+
|
|
|
|
+ if (match && (!match[1] || match[1] && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar)))) {
|
|
|
|
+ maskedSrc = maskedSrc.slice(-1 * src.length);
|
|
|
|
+ var endReg = match[0] === '*' ? this.rules.inline.em.endAst : this.rules.inline.em.endUnd;
|
|
|
|
+ endReg.lastIndex = 0;
|
|
|
|
+ var cap;
|
|
|
|
+
|
|
|
|
+ while ((match = endReg.exec(maskedSrc)) != null) {
|
|
|
|
+ cap = this.rules.inline.em.middle.exec(maskedSrc.slice(0, match.index + 2));
|
|
|
|
+
|
|
|
|
+ if (cap) {
|
|
|
|
+ return {
|
|
|
|
+ type: 'em',
|
|
|
|
+ raw: src.slice(0, cap[0].length),
|
|
|
|
+ text: src.slice(1, cap[0].length - 1)
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -1057,9 +1093,9 @@
|
|
html: '^ {0,3}(?:' // optional indentation
|
|
html: '^ {0,3}(?:' // optional indentation
|
|
+ '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
+ '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
- + '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
|
|
|
|
- + '|<![A-Z][\\s\\S]*?>\\n*' // (4)
|
|
|
|
- + '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
|
|
|
|
|
|
+ + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
|
|
+ + '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
|
|
+ + '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
|
|
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
|
|
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
|
|
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
|
|
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
|
|
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
|
|
@@ -1076,12 +1112,12 @@
|
|
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
|
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
block.def = edit$1(block.def).replace('label', block._label).replace('title', block._title).getRegex();
|
|
block.def = edit$1(block.def).replace('label', block._label).replace('title', block._title).getRegex();
|
|
- block.bullet = /(?:[*+-]|\d{1,9}\.)/;
|
|
|
|
|
|
+ block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
|
|
block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
|
|
block.item = edit$1(block.item, 'gm').replace(/bull/g, block.bullet).getRegex();
|
|
block.item = edit$1(block.item, 'gm').replace(/bull/g, block.bullet).getRegex();
|
|
block.list = edit$1(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
|
|
block.list = edit$1(block.list).replace(/bull/g, block.bullet).replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))').replace('def', '\\n+(?=' + block.def.source + ')').getRegex();
|
|
block._tag = '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|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + '|track|ul';
|
|
block._tag = '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|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' + '|track|ul';
|
|
- block._comment = /<!--(?!-?>)[\s\S]*?-->/;
|
|
|
|
|
|
+ block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
block.html = edit$1(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
block.html = edit$1(block.html, 'i').replace('comment', block._comment).replace('tag', block._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
block.paragraph = edit$1(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
block.paragraph = edit$1(block._paragraph).replace('hr', block.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
.replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
.replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
@@ -1099,11 +1135,11 @@
|
|
|
|
|
|
block.gfm = merge$1({}, block.normal, {
|
|
block.gfm = merge$1({}, block.normal, {
|
|
nptable: '^ *([^|\\n ].*\\|.*)\\n' // Header
|
|
nptable: '^ *([^|\\n ].*\\|.*)\\n' // Header
|
|
- + ' *([-:]+ *\\|[-| :]*)' // Align
|
|
|
|
|
|
+ + ' {0,3}([-:]+ *\\|[-| :]*)' // Align
|
|
+ '(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)',
|
|
+ '(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)',
|
|
// Cells
|
|
// Cells
|
|
table: '^ *\\|(.+)\\n' // Header
|
|
table: '^ *\\|(.+)\\n' // Header
|
|
- + ' *\\|?( *[-:]+[-| :]*)' // Align
|
|
|
|
|
|
+ + ' {0,3}\\|?( *[-:]+[-| :]*)' // Align
|
|
+ '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
+ '(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
|
|
|
|
});
|
|
});
|
|
@@ -1143,29 +1179,61 @@
|
|
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
|
|
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
|
|
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
|
|
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
|
|
- strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
|
|
|
|
- em: /^_([^\s_])_(?!_)|^_([^\s_<][\s\S]*?[^\s_])_(?!_|[^\s,punctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\s,punctuation])|^\*([^\s*<\[])\*(?!\*)|^\*([^\s<"][\s\S]*?[^\s\[\*])\*(?![\]`punctuation])|^\*([^\s*"<\[][\s\S]*[^\s])\*(?!\*)/,
|
|
|
|
|
|
+ reflinkSearch: 'reflink|nolink(?!\\()',
|
|
|
|
+ strong: {
|
|
|
|
+ start: /^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,
|
|
|
|
+ // (1) returns if starts w/ punctuation
|
|
|
|
+ middle: /^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,
|
|
|
|
+ endAst: /[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,
|
|
|
|
+ // last char can't be punct, or final * must also be followed by punct (or endline)
|
|
|
|
+ endUnd: /[^\s]__(?!_)(?:(?=[punctuation\s])|$)/ // last char can't be a space, and final _ must preceed punct or \s (or endline)
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ em: {
|
|
|
|
+ start: /^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,
|
|
|
|
+ // (1) returns if starts w/ punctuation
|
|
|
|
+ middle: /^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,
|
|
|
|
+ endAst: /[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,
|
|
|
|
+ // last char can't be punct, or final * must also be followed by punct (or endline)
|
|
|
|
+ endUnd: /[^\s]_(?!_)(?:(?=[punctuation\s])|$)/ // last char can't be a space, and final _ must preceed punct or \s (or endline)
|
|
|
|
+
|
|
|
|
+ },
|
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
del: noopTest$1,
|
|
del: noopTest$1,
|
|
- text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/
|
|
|
|
|
|
+ text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
|
|
+ punctuation: /^([\s*punctuation])/
|
|
}; // list of punctuation marks from common mark spec
|
|
}; // list of punctuation marks from common mark spec
|
|
- // without ` and ] to workaround Rule 17 (inline code blocks/links)
|
|
|
|
- // without , to work around example 393
|
|
|
|
-
|
|
|
|
- inline._punctuation = '!"#$%&\'()*+\\-./:;<=>?@\\[^_{|}~';
|
|
|
|
- inline.em = edit$1(inline.em).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
|
|
|
|
+ // without * and _ to workaround cases with double emphasis
|
|
|
|
+
|
|
|
|
+ inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
|
|
|
+ inline.punctuation = edit$1(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex(); // sequences em should skip over [title](link), `code`, <html>
|
|
|
|
+
|
|
|
|
+ inline._blockSkip = '\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>';
|
|
|
|
+ inline._overlapSkip = '__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*';
|
|
|
|
+ inline._comment = edit$1(block._comment).replace('(?:-->|$)', '-->').getRegex();
|
|
|
|
+ inline.em.start = edit$1(inline.em.start).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
|
|
+ inline.em.middle = edit$1(inline.em.middle).replace(/punctuation/g, inline._punctuation).replace(/overlapSkip/g, inline._overlapSkip).getRegex();
|
|
|
|
+ inline.em.endAst = edit$1(inline.em.endAst, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
|
|
|
|
+ inline.em.endUnd = edit$1(inline.em.endUnd, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
|
|
|
|
+ inline.strong.start = edit$1(inline.strong.start).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
|
|
+ inline.strong.middle = edit$1(inline.strong.middle).replace(/punctuation/g, inline._punctuation).replace(/blockSkip/g, inline._blockSkip).getRegex();
|
|
|
|
+ inline.strong.endAst = edit$1(inline.strong.endAst, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
|
|
|
|
+ inline.strong.endUnd = edit$1(inline.strong.endUnd, 'g').replace(/punctuation/g, inline._punctuation).getRegex();
|
|
|
|
+ inline.blockSkip = edit$1(inline._blockSkip, 'g').getRegex();
|
|
|
|
+ inline.overlapSkip = edit$1(inline._overlapSkip, 'g').getRegex();
|
|
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
|
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
|
inline.autolink = edit$1(inline.autolink).replace('scheme', inline._scheme).replace('email', inline._email).getRegex();
|
|
inline.autolink = edit$1(inline.autolink).replace('scheme', inline._scheme).replace('email', inline._email).getRegex();
|
|
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
- inline.tag = edit$1(inline.tag).replace('comment', block._comment).replace('attribute', inline._attribute).getRegex();
|
|
|
|
|
|
+ inline.tag = edit$1(inline.tag).replace('comment', inline._comment).replace('attribute', inline._attribute).getRegex();
|
|
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
inline._href = /<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/;
|
|
inline._href = /<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/;
|
|
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
inline.link = edit$1(inline.link).replace('label', inline._label).replace('href', inline._href).replace('title', inline._title).getRegex();
|
|
inline.link = edit$1(inline.link).replace('label', inline._label).replace('href', inline._href).replace('title', inline._title).getRegex();
|
|
inline.reflink = edit$1(inline.reflink).replace('label', inline._label).getRegex();
|
|
inline.reflink = edit$1(inline.reflink).replace('label', inline._label).getRegex();
|
|
|
|
+ inline.reflinkSearch = edit$1(inline.reflinkSearch, 'g').replace('reflink', inline.reflink).replace('nolink', inline.nolink).getRegex();
|
|
/**
|
|
/**
|
|
* Normal Inline Grammar
|
|
* Normal Inline Grammar
|
|
*/
|
|
*/
|
|
@@ -1176,8 +1244,18 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
inline.pedantic = merge$1({}, inline.normal, {
|
|
inline.pedantic = merge$1({}, inline.normal, {
|
|
- strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
|
|
- em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
|
|
|
|
|
|
+ strong: {
|
|
|
|
+ start: /^__|\*\*/,
|
|
|
|
+ middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
|
|
+ endAst: /\*\*(?!\*)/g,
|
|
|
|
+ endUnd: /__(?!_)/g
|
|
|
|
+ },
|
|
|
|
+ em: {
|
|
|
|
+ start: /^_|\*/,
|
|
|
|
+ middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,
|
|
|
|
+ endAst: /\*(?!\*)/g,
|
|
|
|
+ endUnd: /_(?!_)/g
|
|
|
|
+ },
|
|
link: edit$1(/^!?\[(label)\]\((.*?)\)/).replace('label', inline._label).getRegex(),
|
|
link: edit$1(/^!?\[(label)\]\((.*?)\)/).replace('label', inline._label).getRegex(),
|
|
reflink: edit$1(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline._label).getRegex()
|
|
reflink: edit$1(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', inline._label).getRegex()
|
|
});
|
|
});
|
|
@@ -1191,7 +1269,7 @@
|
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
del: /^~+(?=\S)([\s\S]*?\S)~+/,
|
|
del: /^~+(?=\S)([\s\S]*?\S)~+/,
|
|
- text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
|
|
|
|
|
|
+ text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
|
|
});
|
|
});
|
|
inline.gfm.url = edit$1(inline.gfm.url, 'i').replace('email', inline.gfm._extended_email).getRegex();
|
|
inline.gfm.url = edit$1(inline.gfm.url, 'i').replace('email', inline.gfm._extended_email).getRegex();
|
|
/**
|
|
/**
|
|
@@ -1543,7 +1621,7 @@
|
|
*/
|
|
*/
|
|
;
|
|
;
|
|
|
|
|
|
- _proto.inlineTokens = function inlineTokens(src, tokens, inLink, inRawBlock) {
|
|
|
|
|
|
+ _proto.inlineTokens = function inlineTokens(src, tokens, inLink, inRawBlock, prevChar) {
|
|
if (tokens === void 0) {
|
|
if (tokens === void 0) {
|
|
tokens = [];
|
|
tokens = [];
|
|
}
|
|
}
|
|
@@ -1556,7 +1634,31 @@
|
|
inRawBlock = false;
|
|
inRawBlock = false;
|
|
}
|
|
}
|
|
|
|
|
|
- var token;
|
|
|
|
|
|
+ if (prevChar === void 0) {
|
|
|
|
+ prevChar = '';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var token; // String with links masked to avoid interference with em and strong
|
|
|
|
+
|
|
|
|
+ var maskedSrc = src;
|
|
|
|
+ var match; // Mask out reflinks
|
|
|
|
+
|
|
|
|
+ if (this.tokens.links) {
|
|
|
|
+ var links = Object.keys(this.tokens.links);
|
|
|
|
+
|
|
|
|
+ if (links.length > 0) {
|
|
|
|
+ while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
|
|
+ if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
|
|
|
|
+ maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } // Mask out other blocks
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
|
|
+ maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
|
|
+ }
|
|
|
|
|
|
while (src) {
|
|
while (src) {
|
|
// escape
|
|
// escape
|
|
@@ -1600,7 +1702,7 @@
|
|
} // strong
|
|
} // strong
|
|
|
|
|
|
|
|
|
|
- if (token = this.tokenizer.strong(src)) {
|
|
|
|
|
|
+ if (token = this.tokenizer.strong(src, maskedSrc, prevChar)) {
|
|
src = src.substring(token.raw.length);
|
|
src = src.substring(token.raw.length);
|
|
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
tokens.push(token);
|
|
tokens.push(token);
|
|
@@ -1608,7 +1710,7 @@
|
|
} // em
|
|
} // em
|
|
|
|
|
|
|
|
|
|
- if (token = this.tokenizer.em(src)) {
|
|
|
|
|
|
+ if (token = this.tokenizer.em(src, maskedSrc, prevChar)) {
|
|
src = src.substring(token.raw.length);
|
|
src = src.substring(token.raw.length);
|
|
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
token.tokens = this.inlineTokens(token.text, [], inLink, inRawBlock);
|
|
tokens.push(token);
|
|
tokens.push(token);
|
|
@@ -1654,6 +1756,7 @@
|
|
|
|
|
|
if (token = this.tokenizer.inlineText(src, inRawBlock, smartypants)) {
|
|
if (token = this.tokenizer.inlineText(src, inRawBlock, smartypants)) {
|
|
src = src.substring(token.raw.length);
|
|
src = src.substring(token.raw.length);
|
|
|
|
+ prevChar = token.raw.slice(-1);
|
|
tokens.push(token);
|
|
tokens.push(token);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -1891,29 +1994,53 @@
|
|
function Slugger() {
|
|
function Slugger() {
|
|
this.seen = {};
|
|
this.seen = {};
|
|
}
|
|
}
|
|
- /**
|
|
|
|
- * Convert string to unique id
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
|
|
|
|
var _proto = Slugger.prototype;
|
|
var _proto = Slugger.prototype;
|
|
|
|
|
|
- _proto.slug = function slug(value) {
|
|
|
|
- var slug = value.toLowerCase().trim() // remove html tags
|
|
|
|
|
|
+ _proto.serialize = function serialize(value) {
|
|
|
|
+ return value.toLowerCase().trim() // remove html tags
|
|
.replace(/<[!\/a-z].*?>/ig, '') // remove unwanted chars
|
|
.replace(/<[!\/a-z].*?>/ig, '') // remove unwanted chars
|
|
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '').replace(/\s/g, '-');
|
|
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '').replace(/\s/g, '-');
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * Finds the next safe (unique) slug to use
|
|
|
|
+ */
|
|
|
|
+ ;
|
|
|
|
+
|
|
|
|
+ _proto.getNextSafeSlug = function getNextSafeSlug(originalSlug, isDryRun) {
|
|
|
|
+ var slug = originalSlug;
|
|
|
|
+ var occurenceAccumulator = 0;
|
|
|
|
|
|
if (this.seen.hasOwnProperty(slug)) {
|
|
if (this.seen.hasOwnProperty(slug)) {
|
|
- var originalSlug = slug;
|
|
|
|
|
|
+ occurenceAccumulator = this.seen[originalSlug];
|
|
|
|
|
|
do {
|
|
do {
|
|
- this.seen[originalSlug]++;
|
|
|
|
- slug = originalSlug + '-' + this.seen[originalSlug];
|
|
|
|
|
|
+ occurenceAccumulator++;
|
|
|
|
+ slug = originalSlug + '-' + occurenceAccumulator;
|
|
} while (this.seen.hasOwnProperty(slug));
|
|
} while (this.seen.hasOwnProperty(slug));
|
|
}
|
|
}
|
|
|
|
|
|
- this.seen[slug] = 0;
|
|
|
|
|
|
+ if (!isDryRun) {
|
|
|
|
+ this.seen[originalSlug] = occurenceAccumulator;
|
|
|
|
+ this.seen[slug] = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
return slug;
|
|
return slug;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * Convert string to unique id
|
|
|
|
+ * @param {object} options
|
|
|
|
+ * @param {boolean} options.dryrun Generates the next unique slug without updating the internal accumulator.
|
|
|
|
+ */
|
|
|
|
+ ;
|
|
|
|
+
|
|
|
|
+ _proto.slug = function slug(value, options) {
|
|
|
|
+ if (options === void 0) {
|
|
|
|
+ options = {};
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var slug = this.serialize(value);
|
|
|
|
+ return this.getNextSafeSlug(slug, options.dryrun);
|
|
};
|
|
};
|
|
|
|
|
|
return Slugger;
|
|
return Slugger;
|