From 8bb2ecf5448d9d49582479ba1cc1f27d82584154 Mon Sep 17 00:00:00 2001
From: Tony Brix ' + text + ' An error occurred: An error occurred: An error occurred: "+e+"\n' + quote + '
\n';
- };
+ }
html(html) {
return html;
- };
+ }
heading(text, level, raw, slugger) {
if (this.options.headerIds) {
@@ -1024,21 +1477,21 @@ var Renderer_1 = class Renderer {
}
// ignore IDs
return '
\n' : '
\n';
- };
+ }
list(body, ordered, start) {
const type = ordered ? 'ol' : 'ul',
startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
return '<' + type + startatt + '>\n' + body + '' + type + '>\n';
- };
+ }
listitem(text) {
return '\n' + content + ' \n';
- };
+ }
tablecell(content, flags) {
const type = flags.header ? 'th' : 'td';
@@ -1073,28 +1526,28 @@ var Renderer_1 = class Renderer {
? '<' + type + ' align="' + flags.align + '">'
: '<' + type + '>';
return tag + content + '' + type + '>\n';
- };
+ }
// span level renderer
strong(text) {
return '' + text + '';
- };
+ }
em(text) {
return '' + text + '';
- };
+ }
codespan(text) {
return '' + text + '
';
- };
+ }
br() {
return this.options.xhtml ? '
' : '
';
- };
+ }
del(text) {
return '' + text + '';
- };
+ }
link(href, title, text) {
href = cleanUrl$1(this.options.sanitize, this.options.baseUrl, href);
@@ -1107,7 +1560,7 @@ var Renderer_1 = class Renderer {
}
out += '>' + text + '';
return out;
- };
+ }
image(href, title, text) {
href = cleanUrl$1(this.options.sanitize, this.options.baseUrl, href);
@@ -1121,337 +1574,10 @@ var Renderer_1 = class Renderer {
}
out += this.options.xhtml ? '/>' : '>';
return out;
- };
+ }
text(text) {
return text;
- };
-};
-
-/**
- * Slugger generates header id
- */
-var Slugger_1 = class Slugger {
- constructor() {
- this.seen = {};
- }
-
- /**
- * Convert string to unique id
- */
- slug(value) {
- let slug = value
- .toLowerCase()
- .trim()
- // remove html tags
- .replace(/<[!\/a-z].*?>/ig, '')
- // remove unwanted chars
- .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
- .replace(/\s/g, '-');
-
- if (this.seen.hasOwnProperty(slug)) {
- const originalSlug = slug;
- do {
- this.seen[originalSlug]++;
- slug = originalSlug + '-' + this.seen[originalSlug];
- } while (this.seen.hasOwnProperty(slug));
- }
- this.seen[slug] = 0;
-
- return slug;
- };
-};
-
-const { defaults: defaults$3 } = defaults;
-const { inline: inline$1 } = rules;
-const {
- findClosingBracket: findClosingBracket$1,
- escape: escape$3
-} = helpers;
-
-/**
- * Inline Lexer & Compiler
- */
-var InlineLexer_1 = class InlineLexer {
- constructor(links, options) {
- this.options = options || defaults$3;
- this.links = links;
- this.rules = inline$1.normal;
- this.options.renderer = this.options.renderer || new Renderer_1();
- this.renderer = this.options.renderer;
- this.renderer.options = this.options;
-
- if (!this.links) {
- throw new Error('Tokens array requires a `links` property.');
- }
-
- if (this.options.pedantic) {
- this.rules = inline$1.pedantic;
- } else if (this.options.gfm) {
- if (this.options.breaks) {
- this.rules = inline$1.breaks;
- } else {
- this.rules = inline$1.gfm;
- }
- }
- }
-
- /**
- * Expose Inline Rules
- */
- static get rules() {
- return inline$1;
- }
-
- /**
- * Static Lexing/Compiling Method
- */
- static output(src, links, options) {
- const inline = new InlineLexer(links, options);
- return inline.output(src);
- }
-
- /**
- * Lexing/Compiling
- */
- output(src) {
- let out = '',
- link,
- text,
- href,
- title,
- cap,
- prevCapZero;
-
- while (src) {
- // escape
- if (cap = this.rules.escape.exec(src)) {
- src = src.substring(cap[0].length);
- out += escape$3(cap[1]);
- continue;
- }
-
- // tag
- if (cap = this.rules.tag.exec(src)) {
- if (!this.inLink && /^/i.test(cap[0])) {
- this.inLink = false;
- }
- if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
- this.inRawBlock = true;
- } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
- this.inRawBlock = false;
- }
-
- src = src.substring(cap[0].length);
- out += this.renderer.html(this.options.sanitize
- ? (this.options.sanitizer
- ? this.options.sanitizer(cap[0])
- : escape$3(cap[0]))
- : cap[0]);
- continue;
- }
-
- // link
- if (cap = this.rules.link.exec(src)) {
- const lastParenIndex = findClosingBracket$1(cap[2], '()');
- if (lastParenIndex > -1) {
- const start = cap[0].indexOf('!') === 0 ? 5 : 4;
- const linkLen = start + cap[1].length + lastParenIndex;
- cap[2] = cap[2].substring(0, lastParenIndex);
- cap[0] = cap[0].substring(0, linkLen).trim();
- cap[3] = '';
- }
- src = src.substring(cap[0].length);
- this.inLink = true;
- href = cap[2];
- if (this.options.pedantic) {
- link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
-
- if (link) {
- href = link[1];
- title = link[3];
- } else {
- title = '';
- }
- } else {
- title = cap[3] ? cap[3].slice(1, -1) : '';
- }
- href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
- out += this.outputLink(cap, {
- href: InlineLexer.escapes(href),
- title: InlineLexer.escapes(title)
- });
- this.inLink = false;
- continue;
- }
-
- // reflink, nolink
- if ((cap = this.rules.reflink.exec(src))
- || (cap = this.rules.nolink.exec(src))) {
- src = src.substring(cap[0].length);
- link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
- link = this.links[link.toLowerCase()];
- if (!link || !link.href) {
- out += cap[0].charAt(0);
- src = cap[0].substring(1) + src;
- continue;
- }
- this.inLink = true;
- out += this.outputLink(cap, link);
- this.inLink = false;
- continue;
- }
-
- // strong
- if (cap = this.rules.strong.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
- continue;
- }
-
- // em
- if (cap = this.rules.em.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
- continue;
- }
-
- // code
- if (cap = this.rules.code.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.codespan(escape$3(cap[2].trim(), true));
- continue;
- }
-
- // br
- if (cap = this.rules.br.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.br();
- continue;
- }
-
- // del (gfm)
- if (cap = this.rules.del.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.del(this.output(cap[1]));
- continue;
- }
-
- // autolink
- if (cap = this.rules.autolink.exec(src)) {
- src = src.substring(cap[0].length);
- if (cap[2] === '@') {
- text = escape$3(this.mangle(cap[1]));
- href = 'mailto:' + text;
- } else {
- text = escape$3(cap[1]);
- href = text;
- }
- out += this.renderer.link(href, null, text);
- continue;
- }
-
- // url (gfm)
- if (!this.inLink && (cap = this.rules.url.exec(src))) {
- if (cap[2] === '@') {
- text = escape$3(cap[0]);
- href = 'mailto:' + text;
- } else {
- // do extended autolink path validation
- do {
- prevCapZero = cap[0];
- cap[0] = this.rules._backpedal.exec(cap[0])[0];
- } while (prevCapZero !== cap[0]);
- text = escape$3(cap[0]);
- if (cap[1] === 'www.') {
- href = 'http://' + text;
- } else {
- href = text;
- }
- }
- src = src.substring(cap[0].length);
- out += this.renderer.link(href, null, text);
- continue;
- }
-
- // text
- if (cap = this.rules.text.exec(src)) {
- src = src.substring(cap[0].length);
- if (this.inRawBlock) {
- out += this.renderer.text(this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$3(cap[0])) : cap[0]);
- } else {
- out += this.renderer.text(escape$3(this.smartypants(cap[0])));
- }
- continue;
- }
-
- if (src) {
- throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
- }
- }
-
- return out;
- }
-
- static escapes(text) {
- return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
- }
-
- /**
- * Compile Link
- */
- outputLink(cap, link) {
- const href = link.href,
- title = link.title ? escape$3(link.title) : null;
-
- return cap[0].charAt(0) !== '!'
- ? this.renderer.link(href, title, this.output(cap[1]))
- : this.renderer.image(href, title, escape$3(cap[1]));
- }
-
- /**
- * Smartypants Transformations
- */
- smartypants(text) {
- if (!this.options.smartypants) return text;
- return text
- // em-dashes
- .replace(/---/g, '\u2014')
- // en-dashes
- .replace(/--/g, '\u2013')
- // opening singles
- .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
- // closing singles & apostrophes
- .replace(/'/g, '\u2019')
- // opening doubles
- .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
- // closing doubles
- .replace(/"/g, '\u201d')
- // ellipses
- .replace(/\.{3}/g, '\u2026');
- }
-
- /**
- * Mangle Links
- */
- mangle(text) {
- if (!this.options.mangle) return text;
- const l = text.length;
- let out = '',
- i = 0,
- ch;
-
- for (; i < l; i++) {
- ch = text.charCodeAt(i);
- if (Math.random() > 0.5) {
- ch = 'x' + ch.toString(16);
- }
- out += '' + ch + ';';
- }
-
- return out;
}
};
@@ -1498,9 +1624,42 @@ var TextRenderer_1 = class TextRenderer {
}
};
-const { defaults: defaults$4 } = defaults;
+/**
+ * Slugger generates header id
+ */
+var Slugger_1 = class Slugger {
+ constructor() {
+ this.seen = {};
+ }
+
+ /**
+ * Convert string to unique id
+ */
+ slug(value) {
+ let slug = value
+ .toLowerCase()
+ .trim()
+ // remove html tags
+ .replace(/<[!\/a-z].*?>/ig, '')
+ // remove unwanted chars
+ .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
+ .replace(/\s/g, '-');
+
+ if (this.seen.hasOwnProperty(slug)) {
+ const originalSlug = slug;
+ do {
+ this.seen[originalSlug]++;
+ slug = originalSlug + '-' + this.seen[originalSlug];
+ } while (this.seen.hasOwnProperty(slug));
+ }
+ this.seen[slug] = 0;
+
+ return slug;
+ }
+};
+
+const { defaults: defaults$3 } = defaults;
const {
- merge: merge$2,
unescape: unescape$1
} = helpers;
@@ -1509,11 +1668,10 @@ const {
*/
var Parser_1 = class Parser {
constructor(options) {
- this.tokens = [];
- this.token = null;
- this.options = options || defaults$4;
+ this.options = options || defaults$3;
this.options.renderer = this.options.renderer || new Renderer_1();
this.renderer = this.options.renderer;
+ this.textRenderer = new TextRenderer_1();
this.renderer.options = this.options;
this.slugger = new Slugger_1();
}
@@ -1524,192 +1682,233 @@ var Parser_1 = class Parser {
static parse(tokens, options) {
const parser = new Parser(options);
return parser.parse(tokens);
- };
+ }
/**
* Parse Loop
*/
- parse(tokens) {
- this.inline = new InlineLexer_1(tokens.links, this.options);
- // use an InlineLexer with a TextRenderer to extract pure text
- this.inlineText = new InlineLexer_1(
- tokens.links,
- merge$2({}, this.options, { renderer: new TextRenderer_1() })
- );
- this.tokens = tokens.reverse();
+ parse(tokens, top = true) {
+ let out = '',
+ body,
+ token;
- let out = '';
- while (this.next()) {
- out += this.tok();
+ const l = tokens.length;
+ for (let i = 0; i < l; i++) {
+ token = tokens[i];
+ switch (token.type) {
+ case 'space': {
+ continue;
+ }
+ case 'hr': {
+ out += this.renderer.hr();
+ continue;
+ }
+ case 'heading': {
+ out += this.renderer.heading(
+ this.parseInline(token.tokens),
+ token.depth,
+ unescape$1(this.parseInline(token.tokens, this.textRenderer)),
+ this.slugger);
+ continue;
+ }
+ case 'code': {
+ out += this.renderer.code(token.text,
+ token.lang,
+ token.escaped);
+ continue;
+ }
+ case 'table': {
+ let header = '',
+ i,
+ row,
+ cell,
+ j,
+ l2,
+ l3;
+
+ // header
+ cell = '';
+ l2 = token.header.length;
+ for (i = 0; i < l2; i++) {
+ cell += this.renderer.tablecell(
+ this.parseInline(token.tokens.header[i]),
+ { header: true, align: token.align[i] }
+ );
+ }
+ header += this.renderer.tablerow(cell);
+
+ body = '';
+ l2 = token.cells.length;
+ for (i = 0; i < l2; i++) {
+ row = token.tokens.cells[i];
+
+ cell = '';
+ l3 = row.length;
+ for (j = 0; j < l3; j++) {
+ cell += this.renderer.tablecell(
+ this.parseInline(row[j]),
+ { header: false, align: token.align[j] }
+ );
+ }
+
+ body += this.renderer.tablerow(cell);
+ }
+ out += this.renderer.table(header, body);
+ continue;
+ }
+ case 'blockquote': {
+ body = this.parse(token.tokens);
+ out += this.renderer.blockquote(body);
+ continue;
+ }
+ case 'list': {
+ const ordered = token.ordered,
+ start = token.start,
+ loose = token.loose,
+ l2 = token.items.length;
+ let itemBody;
+
+ body = '';
+ for (let j = 0; j < l2; j++) {
+ const item = token.items[j];
+ const checked = item.checked;
+ const task = item.task;
+
+ itemBody = '';
+ if (item.task) {
+ const checkbox = this.renderer.checkbox(checked);
+ if (loose) {
+ if (item.tokens[0].type === 'text') {
+ item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
+ if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
+ item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
+ }
+ } else {
+ item.tokens.unshift({
+ type: 'text',
+ text: checkbox
+ });
+ }
+ } else {
+ itemBody += checkbox;
+ }
+ }
+
+ itemBody += this.parse(item.tokens, loose);
+ body += this.renderer.listitem(itemBody, task, checked);
+ }
+
+ out += this.renderer.list(body, ordered, start);
+ continue;
+ }
+ case 'html': {
+ // TODO parse inline content if parameter markdown=1
+ out += this.renderer.html(token.text);
+ continue;
+ }
+ case 'paragraph': {
+ out += this.renderer.paragraph(this.parseInline(token.tokens));
+ continue;
+ }
+ case 'text': {
+ body = token.tokens ? this.parseInline(token.tokens) : token.text;
+ while (i + 1 < l && tokens[i + 1].type === 'text') {
+ token = tokens[++i];
+ body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
+ }
+ out += top ? this.renderer.paragraph(body) : body;
+ continue;
+ }
+ default: {
+ const errMsg = 'Token with "' + token.type + '" type was not found.';
+ if (this.options.silent) {
+ console.error(errMsg);
+ } else {
+ throw new Error(errMsg);
+ }
+ }
+ }
}
return out;
- };
+ }
/**
- * Next Token
+ * Parse Inline Tokens
*/
- next() {
- this.token = this.tokens.pop();
- return this.token;
- };
+ parseInline(tokens, renderer) {
+ renderer = renderer || this.renderer;
+ let out = '',
+ i,
+ token;
- /**
- * Preview Next Token
- */
- peek() {
- return this.tokens[this.tokens.length - 1] || 0;
- };
-
- /**
- * Parse Text Tokens
- */
- parseText() {
- let body = this.token.text;
-
- while (this.peek().type === 'text') {
- body += '\n' + this.next().text;
- }
-
- return this.inline.output(body);
- };
-
- /**
- * Parse Current Token
- */
- tok() {
- let body = '';
- switch (this.token.type) {
- case 'space': {
- return '';
- }
- case 'hr': {
- return this.renderer.hr();
- }
- case 'heading': {
- return this.renderer.heading(
- this.inline.output(this.token.text),
- this.token.depth,
- unescape$1(this.inlineText.output(this.token.text)),
- this.slugger);
- }
- case 'code': {
- return this.renderer.code(this.token.text,
- this.token.lang,
- this.token.escaped);
- }
- case 'table': {
- let header = '',
- i,
- row,
- cell,
- j;
-
- // header
- cell = '';
- for (i = 0; i < this.token.header.length; i++) {
- cell += this.renderer.tablecell(
- this.inline.output(this.token.header[i]),
- { header: true, align: this.token.align[i] }
- );
+ const l = tokens.length;
+ for (i = 0; i < l; i++) {
+ token = tokens[i];
+ switch (token.type) {
+ case 'escape': {
+ out += token.text;
+ break;
}
- header += this.renderer.tablerow(cell);
-
- for (i = 0; i < this.token.cells.length; i++) {
- row = this.token.cells[i];
-
- cell = '';
- for (j = 0; j < row.length; j++) {
- cell += this.renderer.tablecell(
- this.inline.output(row[j]),
- { header: false, align: this.token.align[j] }
- );
- }
-
- body += this.renderer.tablerow(cell);
+ case 'html': {
+ out += renderer.html(token.text);
+ break;
}
- return this.renderer.table(header, body);
- }
- case 'blockquote_start': {
- body = '';
-
- while (this.next().type !== 'blockquote_end') {
- body += this.tok();
+ case 'link': {
+ out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
+ break;
}
-
- return this.renderer.blockquote(body);
- }
- case 'list_start': {
- body = '';
- const ordered = this.token.ordered,
- start = this.token.start;
-
- while (this.next().type !== 'list_end') {
- body += this.tok();
+ case 'image': {
+ out += renderer.image(token.href, token.title, token.text);
+ break;
}
-
- return this.renderer.list(body, ordered, start);
- }
- case 'list_item_start': {
- body = '';
- const loose = this.token.loose;
- const checked = this.token.checked;
- const task = this.token.task;
-
- if (this.token.task) {
- if (loose) {
- if (this.peek().type === 'text') {
- const nextToken = this.peek();
- nextToken.text = this.renderer.checkbox(checked) + ' ' + nextToken.text;
- } else {
- this.tokens.push({
- type: 'text',
- text: this.renderer.checkbox(checked)
- });
- }
+ case 'strong': {
+ out += renderer.strong(this.parseInline(token.tokens, renderer));
+ break;
+ }
+ case 'em': {
+ out += renderer.em(this.parseInline(token.tokens, renderer));
+ break;
+ }
+ case 'codespan': {
+ out += renderer.codespan(token.text);
+ break;
+ }
+ case 'br': {
+ out += renderer.br();
+ break;
+ }
+ case 'del': {
+ out += renderer.del(this.parseInline(token.tokens, renderer));
+ break;
+ }
+ case 'text': {
+ out += renderer.text(token.text);
+ break;
+ }
+ default: {
+ const errMsg = 'Inline token with "' + this.token.type + '" type was not found.';
+ if (this.options.silent) {
+ console.error(errMsg);
} else {
- body += this.renderer.checkbox(checked);
+ throw new Error(errMsg);
}
}
-
- while (this.next().type !== 'list_item_end') {
- body += !loose && this.token.type === 'text'
- ? this.parseText()
- : this.tok();
- }
- return this.renderer.listitem(body, task, checked);
- }
- case 'html': {
- // TODO parse inline content if parameter markdown=1
- return this.renderer.html(this.token.text);
- }
- case 'paragraph': {
- return this.renderer.paragraph(this.inline.output(this.token.text));
- }
- case 'text': {
- return this.renderer.paragraph(this.parseText());
- }
- default: {
- const errMsg = 'Token with "' + this.token.type + '" type was not found.';
- if (this.options.silent) {
- console.log(errMsg);
- } else {
- throw new Error(errMsg);
- }
}
}
- };
+ return out;
+ }
};
const {
- merge: merge$3,
+ merge: merge$2,
checkSanitizeDeprecation: checkSanitizeDeprecation$1,
- escape: escape$4
+ escape: escape$3
} = helpers;
const {
getDefaults,
changeDefaults,
- defaults: defaults$5
+ defaults: defaults$4
} = defaults;
/**
@@ -1731,7 +1930,7 @@ function marked(src, opt, callback) {
opt = null;
}
- opt = merge$3({}, marked.defaults, opt || {});
+ opt = merge$2({}, marked.defaults, opt || {});
checkSanitizeDeprecation$1(opt);
const highlight = opt.highlight;
let tokens,
@@ -1795,14 +1994,14 @@ function marked(src, opt, callback) {
return;
}
try {
- opt = merge$3({}, marked.defaults, opt || {});
+ opt = merge$2({}, marked.defaults, opt || {});
checkSanitizeDeprecation$1(opt);
return Parser_1.parse(Lexer_1.lex(src, opt), opt);
} catch (e) {
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
if ((opt || marked.defaults).silent) {
return ''
- + escape$4(e.message + '', true)
+ + escape$3(e.message + '', true)
+ '
';
}
throw e;
@@ -1815,14 +2014,14 @@ function marked(src, opt, callback) {
marked.options =
marked.setOptions = function(opt) {
- merge$3(marked.defaults, opt);
+ merge$2(marked.defaults, opt);
changeDefaults(marked.defaults);
return marked;
};
marked.getDefaults = getDefaults;
-marked.defaults = defaults$5;
+marked.defaults = defaults$4;
/**
* Expose
@@ -1837,9 +2036,6 @@ marked.TextRenderer = TextRenderer_1;
marked.Lexer = Lexer_1;
marked.lexer = Lexer_1.lex;
-marked.InlineLexer = InlineLexer_1;
-marked.inlineLexer = InlineLexer_1.output;
-
marked.Slugger = Slugger_1;
marked.parse = marked;
diff --git a/lib/marked.js b/lib/marked.js
index af3f9123..2809bbdb 100644
--- a/lib/marked.js
+++ b/lib/marked.js
@@ -510,10 +510,12 @@
};
var defaults$1 = defaults.defaults;
- var block$1 = rules.block;
+ var block$1 = rules.block,
+ inline$1 = rules.inline;
var rtrim$1 = helpers.rtrim,
splitCells$1 = helpers.splitCells,
- escape$1 = helpers.escape;
+ escape$1 = helpers.escape,
+ findClosingBracket$1 = helpers.findClosingBracket;
/**
* Block Lexer
*/
@@ -523,12 +525,22 @@
this.tokens = [];
this.tokens.links = Object.create(null);
this.options = options || defaults$1;
- this.rules = block$1.normal;
+ this.rules = {
+ block: block$1.normal,
+ inline: inline$1.normal
+ };
if (this.options.pedantic) {
- this.rules = block$1.pedantic;
+ this.rules.block = block$1.pedantic;
+ this.rules.inline = inline$1.pedantic;
} else if (this.options.gfm) {
- this.rules = block$1.gfm;
+ this.rules.block = block$1.gfm;
+
+ if (this.options.breaks) {
+ this.rules.inline = inline$1.breaks;
+ } else {
+ this.rules.inline = inline$1.gfm;
+ }
}
}
/**
@@ -542,48 +554,57 @@
Lexer.lex = function lex(src, options) {
var lexer = new Lexer(options);
return lexer.lex(src);
- };
-
- var _proto = Lexer.prototype;
-
+ }
/**
* Preprocessing
*/
+ ;
+
+ var _proto = Lexer.prototype;
+
_proto.lex = function lex(src) {
src = src.replace(/\r\n|\r/g, '\n').replace(/\t/g, ' ');
- return this.token(src, true);
- };
-
+ this.blockTokens(this.tokens, src, true);
+ this.inlineTokens(this.tokens);
+ return this.tokens;
+ }
/**
* Lexing
*/
- _proto.token = function token(src, top) {
+ ;
+
+ _proto.blockTokens = function blockTokens(tokens, src, top) {
src = src.replace(/^ +$/gm, '');
- var next, loose, cap, bull, b, item, listStart, listItems, t, space, i, tag, l, isordered, istask, ischecked;
+ var next, loose, cap, bull, b, item, list, space, i, tag, l, isordered, istask, ischecked, raw;
while (src) {
// newline
- if (cap = this.rules.newline.exec(src)) {
+ if (cap = this.rules.block.newline.exec(src)) {
src = src.substring(cap[0].length);
+ raw = cap[0];
if (cap[0].length > 1) {
- this.tokens.push({
- type: 'space'
+ tokens.push({
+ type: 'space',
+ raw: raw
});
}
} // code
- if (cap = this.rules.code.exec(src)) {
- var lastToken = this.tokens[this.tokens.length - 1];
- src = src.substring(cap[0].length); // An indented code block cannot interrupt a paragraph.
+ if (cap = this.rules.block.code.exec(src)) {
+ var lastToken = tokens[tokens.length - 1];
+ src = src.substring(cap[0].length);
+ raw = cap[0]; // An indented code block cannot interrupt a paragraph.
if (lastToken && lastToken.type === 'paragraph') {
lastToken.text += '\n' + cap[0].trimRight();
+ lastToken.raw += '\n' + raw;
} else {
cap = cap[0].replace(/^ {4}/gm, '');
- this.tokens.push({
+ tokens.push({
type: 'code',
+ raw: raw,
codeBlockStyle: 'indented',
text: !this.options.pedantic ? rtrim$1(cap, '\n') : cap
});
@@ -593,10 +614,12 @@
} // fences
- if (cap = this.rules.fences.exec(src)) {
+ if (cap = this.rules.block.fences.exec(src)) {
src = src.substring(cap[0].length);
- this.tokens.push({
+ raw = cap[0];
+ tokens.push({
type: 'code',
+ raw: raw,
lang: cap[2] ? cap[2].trim() : cap[2],
text: cap[3] || ''
});
@@ -604,10 +627,12 @@
} // heading
- if (cap = this.rules.heading.exec(src)) {
+ if (cap = this.rules.block.heading.exec(src)) {
src = src.substring(cap[0].length);
- this.tokens.push({
+ raw = cap[0];
+ tokens.push({
type: 'heading',
+ raw: raw,
depth: cap[1].length,
text: cap[2]
});
@@ -615,7 +640,7 @@
} // table no leading pipe (gfm)
- if (cap = this.rules.nptable.exec(src)) {
+ if (cap = this.rules.block.nptable.exec(src)) {
item = {
type: 'table',
header: splitCells$1(cap[1].replace(/^ *| *\| *$/g, '')),
@@ -625,8 +650,11 @@
if (item.header.length === item.align.length) {
src = src.substring(cap[0].length);
+ raw = cap[0];
+ item.raw = raw;
+ l = item.align.length;
- for (i = 0; i < item.align.length; i++) {
+ for (i = 0; i < l; i++) {
if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = 'right';
} else if (/^ *:-+: *$/.test(item.align[i])) {
@@ -638,62 +666,64 @@
}
}
- for (i = 0; i < item.cells.length; i++) {
+ l = item.cells.length;
+
+ for (i = 0; i < l; i++) {
item.cells[i] = splitCells$1(item.cells[i], item.header.length);
}
- this.tokens.push(item);
+ tokens.push(item);
continue;
}
} // hr
- if (cap = this.rules.hr.exec(src)) {
+ if (cap = this.rules.block.hr.exec(src)) {
src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'hr'
+ raw = cap[0];
+ tokens.push({
+ type: 'hr',
+ raw: raw
});
continue;
} // blockquote
- if (cap = this.rules.blockquote.exec(src)) {
+ if (cap = this.rules.block.blockquote.exec(src)) {
src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'blockquote_start'
- });
- cap = cap[0].replace(/^ *> ?/gm, ''); // Pass `top` to keep the current
- // "toplevel" state. This is exactly
- // how markdown.pl works.
-
- this.token(cap, top);
- this.tokens.push({
- type: 'blockquote_end'
+ raw = cap[0];
+ cap = cap[0].replace(/^ *> ?/gm, '');
+ tokens.push({
+ type: 'blockquote',
+ raw: raw,
+ tokens: this.blockTokens([], cap, top)
});
continue;
} // list
- if (cap = this.rules.list.exec(src)) {
+ if (cap = this.rules.block.list.exec(src)) {
src = src.substring(cap[0].length);
+ raw = cap[0];
bull = cap[2];
isordered = bull.length > 1;
- listStart = {
- type: 'list_start',
+ list = {
+ type: 'list',
+ raw: raw,
ordered: isordered,
start: isordered ? +bull : '',
- loose: false
+ loose: false,
+ items: []
};
- this.tokens.push(listStart); // Get each top-level item.
+ tokens.push(list); // Get each top-level item.
- cap = cap[0].match(this.rules.item);
- listItems = [];
+ cap = cap[0].match(this.rules.block.item);
next = false;
l = cap.length;
- i = 0;
- for (; i < l; i++) {
- item = cap[i]; // Remove the list item's bullet
+ for (i = 0; i < l; i++) {
+ item = cap[i];
+ raw = item.trim(); // Remove the list item's bullet
// so it is seen as the next token.
space = item.length;
@@ -711,7 +741,9 @@
b = block$1.bullet.exec(cap[i + 1])[0];
if (bull.length > 1 ? b.length === 1 : b.length > 1 || this.options.smartLists && b !== bull) {
- src = cap.slice(i + 1).join('\n') + src;
+ var addBack = cap.slice(i + 1).join('\n');
+ src = addBack + src;
+ list.raw = list.raw.substring(list.raw.length - addBack.length);
i = l - 1;
}
} // Determine whether item is loose or not.
@@ -727,7 +759,7 @@
}
if (loose) {
- listStart.loose = true;
+ list.loose = true;
} // Check for task list items
@@ -739,41 +771,25 @@
item = item.replace(/^\[[ xX]\] +/, '');
}
- t = {
- type: 'list_item_start',
+ list.items.push({
+ raw: raw,
task: istask,
checked: ischecked,
- loose: loose
- };
- listItems.push(t);
- this.tokens.push(t); // Recurse.
-
- this.token(item, false);
- this.tokens.push({
- type: 'list_item_end'
+ loose: loose,
+ tokens: this.blockTokens([], item, false)
});
}
- if (listStart.loose) {
- l = listItems.length;
- i = 0;
-
- for (; i < l; i++) {
- listItems[i].loose = true;
- }
- }
-
- this.tokens.push({
- type: 'list_end'
- });
continue;
} // html
- if (cap = this.rules.html.exec(src)) {
+ if (cap = this.rules.block.html.exec(src)) {
src = src.substring(cap[0].length);
- this.tokens.push({
+ raw = cap[0];
+ tokens.push({
type: this.options.sanitize ? 'paragraph' : 'html',
+ raw: raw,
pre: !this.options.sanitizer && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$1(cap[0]) : cap[0]
});
@@ -781,7 +797,7 @@
} // def
- if (top && (cap = this.rules.def.exec(src))) {
+ if (top && (cap = this.rules.block.def.exec(src))) {
src = src.substring(cap[0].length);
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
@@ -797,7 +813,7 @@
} // table (gfm)
- if (cap = this.rules.table.exec(src)) {
+ if (cap = this.rules.block.table.exec(src)) {
item = {
type: 'table',
header: splitCells$1(cap[1].replace(/^ *| *\| *$/g, '')),
@@ -807,8 +823,10 @@
if (item.header.length === item.align.length) {
src = src.substring(cap[0].length);
+ item.raw = cap[0];
+ l = item.align.length;
- for (i = 0; i < item.align.length; i++) {
+ for (i = 0; i < l; i++) {
if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = 'right';
} else if (/^ *:-+: *$/.test(item.align[i])) {
@@ -820,20 +838,24 @@
}
}
- for (i = 0; i < item.cells.length; i++) {
+ l = item.cells.length;
+
+ for (i = 0; i < l; i++) {
item.cells[i] = splitCells$1(item.cells[i].replace(/^ *\| *| *\| *$/g, ''), item.header.length);
}
- this.tokens.push(item);
+ tokens.push(item);
continue;
}
} // lheading
- if (cap = this.rules.lheading.exec(src)) {
+ if (cap = this.rules.block.lheading.exec(src)) {
src = src.substring(cap[0].length);
- this.tokens.push({
+ raw = cap[0];
+ tokens.push({
type: 'heading',
+ raw: raw,
depth: cap[2].charAt(0) === '=' ? 1 : 2,
text: cap[1]
});
@@ -841,38 +863,490 @@
} // top-level paragraph
- if (top && (cap = this.rules.paragraph.exec(src))) {
+ if (top && (cap = this.rules.block.paragraph.exec(src))) {
src = src.substring(cap[0].length);
- this.tokens.push({
+ raw = cap[0];
+ tokens.push({
type: 'paragraph',
+ raw: raw,
text: cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1]
});
continue;
} // text
- if (cap = this.rules.text.exec(src)) {
+ if (cap = this.rules.block.text.exec(src)) {
// Top-level should never reach here.
src = src.substring(cap[0].length);
- this.tokens.push({
+ raw = cap[0];
+ tokens.push({
type: 'text',
+ raw: raw,
text: cap[0]
});
continue;
}
if (src) {
- throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
+ var errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
+
+ if (this.options.silent) {
+ console.error(errMsg);
+ } else {
+ throw new Error(errMsg);
+ }
}
}
- return this.tokens;
+ return tokens;
+ };
+
+ _proto.inlineTokens = function inlineTokens(tokens) {
+ var i, j, k, l2, row, token;
+ var l = tokens.length;
+
+ for (i = 0; i < l; i++) {
+ token = tokens[i];
+
+ switch (token.type) {
+ case 'paragraph':
+ case 'text':
+ case 'heading':
+ {
+ token.tokens = [];
+ this.inlineOutput(token.text, token.tokens);
+ break;
+ }
+
+ case 'table':
+ {
+ token.tokens = {
+ header: [],
+ cells: []
+ }; // header
+
+ l2 = token.header.length;
+
+ for (j = 0; j < l2; j++) {
+ token.tokens.header[j] = [];
+ this.inlineOutput(token.header[j], token.tokens.header[j]);
+ } // cells
+
+
+ l2 = token.cells.length;
+
+ for (j = 0; j < l2; j++) {
+ row = token.cells[j];
+ token.tokens.cells[j] = [];
+
+ for (k = 0; k < row.length; k++) {
+ token.tokens.cells[j][k] = [];
+ this.inlineOutput(row[k], token.tokens.cells[j][k]);
+ }
+ }
+
+ break;
+ }
+
+ case 'blockquote':
+ {
+ this.inlineTokens(token.tokens);
+ break;
+ }
+
+ case 'list':
+ {
+ l2 = token.items.length;
+
+ for (j = 0; j < l2; j++) {
+ this.inlineTokens(token.items[j].tokens);
+ }
+
+ break;
+ }
+ }
+ }
+
+ return tokens;
+ }
+ /**
+ * Lexing/Compiling
+ */
+ ;
+
+ _proto.inlineOutput = function inlineOutput(src, tokens) {
+ var out = '',
+ link,
+ text,
+ newTokens,
+ href,
+ title,
+ cap,
+ prevCapZero,
+ raw;
+
+ while (src) {
+ // escape
+ if (cap = this.rules.inline.escape.exec(src)) {
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+ text = escape$1(cap[1]);
+ out += text;
+ tokens.push({
+ type: 'escape',
+ raw: raw,
+ text: text
+ });
+ continue;
+ } // tag
+
+
+ if (cap = this.rules.inline.tag.exec(src)) {
+ if (!this.inLink && /^/i.test(cap[0])) {
+ this.inLink = false;
+ }
+
+ if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
+ this.inRawBlock = true;
+ } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
+ this.inRawBlock = false;
+ }
+
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+ text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$1(cap[0]) : cap[0];
+ tokens.push({
+ type: this.options.sanitize ? 'text' : 'html',
+ raw: raw,
+ text: text
+ });
+ out += text;
+ continue;
+ } // link
+
+
+ if (cap = this.rules.inline.link.exec(src)) {
+ var lastParenIndex = findClosingBracket$1(cap[2], '()');
+
+ if (lastParenIndex > -1) {
+ var start = cap[0].indexOf('!') === 0 ? 5 : 4;
+ var linkLen = start + cap[1].length + lastParenIndex;
+ cap[2] = cap[2].substring(0, lastParenIndex);
+ cap[0] = cap[0].substring(0, linkLen).trim();
+ cap[3] = '';
+ }
+
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+ this.inLink = true;
+ href = cap[2];
+
+ if (this.options.pedantic) {
+ link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
+
+ if (link) {
+ href = link[1];
+ title = link[3];
+ } else {
+ title = '';
+ }
+ } else {
+ title = cap[3] ? cap[3].slice(1, -1) : '';
+ }
+
+ href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
+ out += this.outputLink(cap, {
+ href: this.escapes(href),
+ title: this.escapes(title)
+ }, tokens, raw);
+ this.inLink = false;
+ continue;
+ } // reflink, nolink
+
+
+ if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+ link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
+ link = this.tokens.links[link.toLowerCase()];
+
+ if (!link || !link.href) {
+ text = cap[0].charAt(0);
+ out += text;
+ tokens.push({
+ type: 'text',
+ raw: text,
+ text: text
+ });
+ src = cap[0].substring(1) + src;
+ continue;
+ }
+
+ this.inLink = true;
+ out += this.outputLink(cap, link, tokens, raw);
+ this.inLink = false;
+ continue;
+ } // strong
+
+
+ if (cap = this.rules.inline.strong.exec(src)) {
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+ newTokens = tokens ? [] : null;
+ text = this.inlineOutput(cap[4] || cap[3] || cap[2] || cap[1], newTokens);
+ tokens.push({
+ type: 'strong',
+ raw: raw,
+ text: text,
+ tokens: newTokens
+ });
+ out += text;
+ continue;
+ } // em
+
+
+ if (cap = this.rules.inline.em.exec(src)) {
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+ newTokens = tokens ? [] : null;
+ text = this.inlineOutput(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1], newTokens);
+ tokens.push({
+ type: 'em',
+ raw: raw,
+ text: text,
+ tokens: newTokens
+ });
+ out += text;
+ continue;
+ } // code
+
+
+ if (cap = this.rules.inline.code.exec(src)) {
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+ text = escape$1(cap[2].trim(), true);
+ tokens.push({
+ type: 'codespan',
+ raw: raw,
+ text: text
+ });
+ out += text;
+ continue;
+ } // br
+
+
+ if (cap = this.rules.inline.br.exec(src)) {
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+ tokens.push({
+ type: 'br',
+ raw: raw
+ });
+ out += '\n';
+ continue;
+ } // del (gfm)
+
+
+ if (cap = this.rules.inline.del.exec(src)) {
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+ newTokens = tokens ? [] : null;
+ text = this.inlineOutput(cap[1], newTokens);
+ tokens.push({
+ type: 'del',
+ raw: raw,
+ text: text,
+ tokens: newTokens
+ });
+ out += text;
+ continue;
+ } // autolink
+
+
+ if (cap = this.rules.inline.autolink.exec(src)) {
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+
+ if (cap[2] === '@') {
+ text = escape$1(this.options.mangle ? this.mangle(cap[1]) : cap[1]);
+ href = 'mailto:' + text;
+ } else {
+ text = escape$1(cap[1]);
+ href = text;
+ }
+
+ tokens.push({
+ type: 'link',
+ raw: raw,
+ text: text,
+ href: href,
+ tokens: [{
+ type: 'text',
+ raw: text,
+ text: text
+ }]
+ });
+ out += text;
+ continue;
+ } // url (gfm)
+
+
+ if (!this.inLink && (cap = this.rules.inline.url.exec(src))) {
+ if (cap[2] === '@') {
+ text = escape$1(this.options.mangle ? this.mangle(cap[0]) : cap[0]);
+ href = 'mailto:' + text;
+ } else {
+ // do extended autolink path validation
+ do {
+ prevCapZero = cap[0];
+ cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
+ } while (prevCapZero !== cap[0]);
+
+ text = escape$1(cap[0]);
+
+ if (cap[1] === 'www.') {
+ href = 'http://' + text;
+ } else {
+ href = text;
+ }
+ }
+
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+ tokens.push({
+ type: 'link',
+ raw: raw,
+ text: text,
+ href: href,
+ tokens: [{
+ type: 'text',
+ raw: text,
+ text: text
+ }]
+ });
+ out += text;
+ continue;
+ } // text
+
+
+ if (cap = this.rules.inline.text.exec(src)) {
+ src = src.substring(cap[0].length);
+ raw = cap[0];
+
+ if (this.inRawBlock) {
+ text = this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$1(cap[0]) : cap[0];
+ } else {
+ text = escape$1(this.options.smartypants ? this.smartypants(cap[0]) : cap[0]);
+ }
+
+ tokens.push({
+ type: 'text',
+ raw: raw,
+ text: text
+ });
+ out += text;
+ continue;
+ }
+
+ if (src) {
+ var errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
+
+ if (this.options.silent) {
+ console.error(errMsg);
+ } else {
+ throw new Error(errMsg);
+ }
+ }
+ }
+
+ return out;
+ };
+
+ _proto.escapes = function escapes(text) {
+ return text ? text.replace(inline$1._escapes, '$1') : text;
+ }
+ /**
+ * tokenize Link
+ */
+ ;
+
+ _proto.outputLink = function outputLink(cap, link, tokens, raw) {
+ var href = link.href;
+ var title = link.title ? escape$1(link.title) : null;
+ var newTokens = tokens ? [] : null;
+
+ if (cap[0].charAt(0) !== '!') {
+ var text = this.inlineOutput(cap[1], newTokens);
+ tokens.push({
+ type: 'link',
+ raw: raw,
+ text: text,
+ href: href,
+ title: title,
+ tokens: newTokens
+ });
+ return text;
+ } else {
+ var _text = escape$1(cap[1]);
+
+ tokens.push({
+ type: 'image',
+ raw: raw,
+ text: _text,
+ href: href,
+ title: title
+ });
+ return _text;
+ }
+ }
+ /**
+ * Smartypants Transformations
+ */
+ ;
+
+ _proto.smartypants = function smartypants(text) {
+ return text // em-dashes
+ .replace(/---/g, "\u2014") // en-dashes
+ .replace(/--/g, "\u2013") // opening singles
+ .replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018") // closing singles & apostrophes
+ .replace(/'/g, "\u2019") // opening doubles
+ .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C") // closing doubles
+ .replace(/"/g, "\u201D") // ellipses
+ .replace(/\.{3}/g, "\u2026");
+ }
+ /**
+ * Mangle Links
+ */
+ ;
+
+ _proto.mangle = function mangle(text) {
+ var out = '',
+ i,
+ ch;
+ var l = text.length;
+
+ for (i = 0; i < l; i++) {
+ ch = text.charCodeAt(i);
+
+ if (Math.random() > 0.5) {
+ ch = 'x' + ch.toString(16);
+ }
+
+ out += '' + ch + ';';
+ }
+
+ return out;
};
_createClass(Lexer, null, [{
key: "rules",
get: function get() {
- return block$1;
+ return {
+ block: block$1,
+ inline: inline$1
+ };
}
}]);
@@ -964,9 +1438,9 @@
var type = flags.header ? 'th' : 'td';
var tag = flags.align ? '<' + type + ' align="' + flags.align + '">' : '<' + type + '>';
return tag + content + '' + type + '>\n';
- };
+ } // span level renderer
+ ;
- // span level renderer
_proto.strong = function strong(text) {
return '' + text + '';
};
@@ -1028,345 +1502,6 @@
return Renderer;
}();
- /**
- * Slugger generates header id
- */
- var Slugger_1 = /*#__PURE__*/function () {
- function Slugger() {
- this.seen = {};
- }
- /**
- * Convert string to unique id
- */
-
-
- var _proto = Slugger.prototype;
-
- _proto.slug = function slug(value) {
- var slug = value.toLowerCase().trim() // remove html tags
- .replace(/<[!\/a-z].*?>/ig, '') // remove unwanted chars
- .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '').replace(/\s/g, '-');
-
- if (this.seen.hasOwnProperty(slug)) {
- var originalSlug = slug;
-
- do {
- this.seen[originalSlug]++;
- slug = originalSlug + '-' + this.seen[originalSlug];
- } while (this.seen.hasOwnProperty(slug));
- }
-
- this.seen[slug] = 0;
- return slug;
- };
-
- return Slugger;
- }();
-
- var defaults$3 = defaults.defaults;
- var inline$1 = rules.inline;
- var findClosingBracket$1 = helpers.findClosingBracket,
- escape$3 = helpers.escape;
- /**
- * Inline Lexer & Compiler
- */
-
- var InlineLexer_1 = /*#__PURE__*/function () {
- function InlineLexer(links, options) {
- this.options = options || defaults$3;
- this.links = links;
- this.rules = inline$1.normal;
- this.options.renderer = this.options.renderer || new Renderer_1();
- this.renderer = this.options.renderer;
- this.renderer.options = this.options;
-
- if (!this.links) {
- throw new Error('Tokens array requires a `links` property.');
- }
-
- if (this.options.pedantic) {
- this.rules = inline$1.pedantic;
- } else if (this.options.gfm) {
- if (this.options.breaks) {
- this.rules = inline$1.breaks;
- } else {
- this.rules = inline$1.gfm;
- }
- }
- }
- /**
- * Expose Inline Rules
- */
-
-
- /**
- * Static Lexing/Compiling Method
- */
- InlineLexer.output = function output(src, links, options) {
- var inline = new InlineLexer(links, options);
- return inline.output(src);
- }
- /**
- * Lexing/Compiling
- */
- ;
-
- var _proto = InlineLexer.prototype;
-
- _proto.output = function output(src) {
- var out = '',
- link,
- text,
- href,
- title,
- cap,
- prevCapZero;
-
- while (src) {
- // escape
- if (cap = this.rules.escape.exec(src)) {
- src = src.substring(cap[0].length);
- out += escape$3(cap[1]);
- continue;
- } // tag
-
-
- if (cap = this.rules.tag.exec(src)) {
- if (!this.inLink && /^/i.test(cap[0])) {
- this.inLink = false;
- }
-
- if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
- this.inRawBlock = true;
- } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
- this.inRawBlock = false;
- }
-
- src = src.substring(cap[0].length);
- out += this.renderer.html(this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$3(cap[0]) : cap[0]);
- continue;
- } // link
-
-
- if (cap = this.rules.link.exec(src)) {
- var lastParenIndex = findClosingBracket$1(cap[2], '()');
-
- if (lastParenIndex > -1) {
- var start = cap[0].indexOf('!') === 0 ? 5 : 4;
- var linkLen = start + cap[1].length + lastParenIndex;
- cap[2] = cap[2].substring(0, lastParenIndex);
- cap[0] = cap[0].substring(0, linkLen).trim();
- cap[3] = '';
- }
-
- src = src.substring(cap[0].length);
- this.inLink = true;
- href = cap[2];
-
- if (this.options.pedantic) {
- link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
-
- if (link) {
- href = link[1];
- title = link[3];
- } else {
- title = '';
- }
- } else {
- title = cap[3] ? cap[3].slice(1, -1) : '';
- }
-
- href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
- out += this.outputLink(cap, {
- href: InlineLexer.escapes(href),
- title: InlineLexer.escapes(title)
- });
- this.inLink = false;
- continue;
- } // reflink, nolink
-
-
- if ((cap = this.rules.reflink.exec(src)) || (cap = this.rules.nolink.exec(src))) {
- src = src.substring(cap[0].length);
- link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
- link = this.links[link.toLowerCase()];
-
- if (!link || !link.href) {
- out += cap[0].charAt(0);
- src = cap[0].substring(1) + src;
- continue;
- }
-
- this.inLink = true;
- out += this.outputLink(cap, link);
- this.inLink = false;
- continue;
- } // strong
-
-
- if (cap = this.rules.strong.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
- continue;
- } // em
-
-
- if (cap = this.rules.em.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
- continue;
- } // code
-
-
- if (cap = this.rules.code.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.codespan(escape$3(cap[2].trim(), true));
- continue;
- } // br
-
-
- if (cap = this.rules.br.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.br();
- continue;
- } // del (gfm)
-
-
- if (cap = this.rules.del.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.del(this.output(cap[1]));
- continue;
- } // autolink
-
-
- if (cap = this.rules.autolink.exec(src)) {
- src = src.substring(cap[0].length);
-
- if (cap[2] === '@') {
- text = escape$3(this.mangle(cap[1]));
- href = 'mailto:' + text;
- } else {
- text = escape$3(cap[1]);
- href = text;
- }
-
- out += this.renderer.link(href, null, text);
- continue;
- } // url (gfm)
-
-
- if (!this.inLink && (cap = this.rules.url.exec(src))) {
- if (cap[2] === '@') {
- text = escape$3(cap[0]);
- href = 'mailto:' + text;
- } else {
- // do extended autolink path validation
- do {
- prevCapZero = cap[0];
- cap[0] = this.rules._backpedal.exec(cap[0])[0];
- } while (prevCapZero !== cap[0]);
-
- text = escape$3(cap[0]);
-
- if (cap[1] === 'www.') {
- href = 'http://' + text;
- } else {
- href = text;
- }
- }
-
- src = src.substring(cap[0].length);
- out += this.renderer.link(href, null, text);
- continue;
- } // text
-
-
- if (cap = this.rules.text.exec(src)) {
- src = src.substring(cap[0].length);
-
- if (this.inRawBlock) {
- out += this.renderer.text(this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape$3(cap[0]) : cap[0]);
- } else {
- out += this.renderer.text(escape$3(this.smartypants(cap[0])));
- }
-
- continue;
- }
-
- if (src) {
- throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
- }
- }
-
- return out;
- };
-
- InlineLexer.escapes = function escapes(text) {
- return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
- }
- /**
- * Compile Link
- */
- ;
-
- _proto.outputLink = function outputLink(cap, link) {
- var href = link.href,
- title = link.title ? escape$3(link.title) : null;
- return cap[0].charAt(0) !== '!' ? this.renderer.link(href, title, this.output(cap[1])) : this.renderer.image(href, title, escape$3(cap[1]));
- }
- /**
- * Smartypants Transformations
- */
- ;
-
- _proto.smartypants = function smartypants(text) {
- if (!this.options.smartypants) return text;
- return text // em-dashes
- .replace(/---/g, "\u2014") // en-dashes
- .replace(/--/g, "\u2013") // opening singles
- .replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018") // closing singles & apostrophes
- .replace(/'/g, "\u2019") // opening doubles
- .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201C") // closing doubles
- .replace(/"/g, "\u201D") // ellipses
- .replace(/\.{3}/g, "\u2026");
- }
- /**
- * Mangle Links
- */
- ;
-
- _proto.mangle = function mangle(text) {
- if (!this.options.mangle) return text;
- var l = text.length;
- var out = '',
- i = 0,
- ch;
-
- for (; i < l; i++) {
- ch = text.charCodeAt(i);
-
- if (Math.random() > 0.5) {
- ch = 'x' + ch.toString(16);
- }
-
- out += '' + ch + ';';
- }
-
- return out;
- };
-
- _createClass(InlineLexer, null, [{
- key: "rules",
- get: function get() {
- return inline$1;
- }
- }]);
-
- return InlineLexer;
- }();
-
/**
* TextRenderer
* returns only the textual part of the token
@@ -1416,20 +1551,53 @@
return TextRenderer;
}();
- var defaults$4 = defaults.defaults;
- var merge$2 = helpers.merge,
- unescape$1 = helpers.unescape;
+ /**
+ * Slugger generates header id
+ */
+ var Slugger_1 = /*#__PURE__*/function () {
+ function Slugger() {
+ this.seen = {};
+ }
+ /**
+ * Convert string to unique id
+ */
+
+
+ var _proto = Slugger.prototype;
+
+ _proto.slug = function slug(value) {
+ var slug = value.toLowerCase().trim() // remove html tags
+ .replace(/<[!\/a-z].*?>/ig, '') // remove unwanted chars
+ .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '').replace(/\s/g, '-');
+
+ if (this.seen.hasOwnProperty(slug)) {
+ var originalSlug = slug;
+
+ do {
+ this.seen[originalSlug]++;
+ slug = originalSlug + '-' + this.seen[originalSlug];
+ } while (this.seen.hasOwnProperty(slug));
+ }
+
+ this.seen[slug] = 0;
+ return slug;
+ };
+
+ return Slugger;
+ }();
+
+ var defaults$3 = defaults.defaults;
+ var unescape$1 = helpers.unescape;
/**
* Parsing & Compiling
*/
var Parser_1 = /*#__PURE__*/function () {
function Parser(options) {
- this.tokens = [];
- this.token = null;
- this.options = options || defaults$4;
+ this.options = options || defaults$3;
this.options.renderer = this.options.renderer || new Renderer_1();
this.renderer = this.options.renderer;
+ this.textRenderer = new TextRenderer_1();
this.renderer.options = this.options;
this.slugger = new Slugger_1();
}
@@ -1441,212 +1609,288 @@
Parser.parse = function parse(tokens, options) {
var parser = new Parser(options);
return parser.parse(tokens);
- };
-
- var _proto = Parser.prototype;
-
+ }
/**
* Parse Loop
*/
- _proto.parse = function parse(tokens) {
- this.inline = new InlineLexer_1(tokens.links, this.options); // use an InlineLexer with a TextRenderer to extract pure text
+ ;
- this.inlineText = new InlineLexer_1(tokens.links, merge$2({}, this.options, {
- renderer: new TextRenderer_1()
- }));
- this.tokens = tokens.reverse();
- var out = '';
+ var _proto = Parser.prototype;
- while (this.next()) {
- out += this.tok();
+ _proto.parse = function parse(tokens, top) {
+ if (top === void 0) {
+ top = true;
+ }
+
+ var out = '',
+ body,
+ token;
+ var l = tokens.length;
+
+ for (var i = 0; i < l; i++) {
+ token = tokens[i];
+
+ switch (token.type) {
+ case 'space':
+ {
+ continue;
+ }
+
+ case 'hr':
+ {
+ out += this.renderer.hr();
+ continue;
+ }
+
+ case 'heading':
+ {
+ out += this.renderer.heading(this.parseInline(token.tokens), token.depth, unescape$1(this.parseInline(token.tokens, this.textRenderer)), this.slugger);
+ continue;
+ }
+
+ case 'code':
+ {
+ out += this.renderer.code(token.text, token.lang, token.escaped);
+ continue;
+ }
+
+ case 'table':
+ {
+ var header = '',
+ _i = void 0,
+ row = void 0,
+ cell = void 0,
+ j = void 0,
+ l2 = void 0,
+ l3 = void 0; // header
+
+
+ cell = '';
+ l2 = token.header.length;
+
+ for (_i = 0; _i < l2; _i++) {
+ cell += this.renderer.tablecell(this.parseInline(token.tokens.header[_i]), {
+ header: true,
+ align: token.align[_i]
+ });
+ }
+
+ header += this.renderer.tablerow(cell);
+ body = '';
+ l2 = token.cells.length;
+
+ for (_i = 0; _i < l2; _i++) {
+ row = token.tokens.cells[_i];
+ cell = '';
+ l3 = row.length;
+
+ for (j = 0; j < l3; j++) {
+ cell += this.renderer.tablecell(this.parseInline(row[j]), {
+ header: false,
+ align: token.align[j]
+ });
+ }
+
+ body += this.renderer.tablerow(cell);
+ }
+
+ out += this.renderer.table(header, body);
+ continue;
+ }
+
+ case 'blockquote':
+ {
+ body = this.parse(token.tokens);
+ out += this.renderer.blockquote(body);
+ continue;
+ }
+
+ case 'list':
+ {
+ var ordered = token.ordered,
+ start = token.start,
+ loose = token.loose,
+ _l = token.items.length;
+ var itemBody = void 0;
+ body = '';
+
+ for (var _j = 0; _j < _l; _j++) {
+ var item = token.items[_j];
+ var checked = item.checked;
+ var task = item.task;
+ itemBody = '';
+
+ if (item.task) {
+ var checkbox = this.renderer.checkbox(checked);
+
+ if (loose) {
+ if (item.tokens[0].type === 'text') {
+ item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
+
+ if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
+ item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
+ }
+ } else {
+ item.tokens.unshift({
+ type: 'text',
+ text: checkbox
+ });
+ }
+ } else {
+ itemBody += checkbox;
+ }
+ }
+
+ itemBody += this.parse(item.tokens, loose);
+ body += this.renderer.listitem(itemBody, task, checked);
+ }
+
+ out += this.renderer.list(body, ordered, start);
+ continue;
+ }
+
+ case 'html':
+ {
+ // TODO parse inline content if parameter markdown=1
+ out += this.renderer.html(token.text);
+ continue;
+ }
+
+ case 'paragraph':
+ {
+ out += this.renderer.paragraph(this.parseInline(token.tokens));
+ continue;
+ }
+
+ case 'text':
+ {
+ body = token.tokens ? this.parseInline(token.tokens) : token.text;
+
+ while (i + 1 < l && tokens[i + 1].type === 'text') {
+ token = tokens[++i];
+ body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
+ }
+
+ out += top ? this.renderer.paragraph(body) : body;
+ continue;
+ }
+
+ default:
+ {
+ var errMsg = 'Token with "' + token.type + '" type was not found.';
+
+ if (this.options.silent) {
+ console.error(errMsg);
+ } else {
+ throw new Error(errMsg);
+ }
+ }
+ }
+ }
+
+ return out;
+ }
+ /**
+ * Parse Inline Tokens
+ */
+ ;
+
+ _proto.parseInline = function parseInline(tokens, renderer) {
+ renderer = renderer || this.renderer;
+ var out = '',
+ i,
+ token;
+ var l = tokens.length;
+
+ for (i = 0; i < l; i++) {
+ token = tokens[i];
+
+ switch (token.type) {
+ case 'escape':
+ {
+ out += token.text;
+ break;
+ }
+
+ case 'html':
+ {
+ out += renderer.html(token.text);
+ break;
+ }
+
+ case 'link':
+ {
+ out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
+ break;
+ }
+
+ case 'image':
+ {
+ out += renderer.image(token.href, token.title, token.text);
+ break;
+ }
+
+ case 'strong':
+ {
+ out += renderer.strong(this.parseInline(token.tokens, renderer));
+ break;
+ }
+
+ case 'em':
+ {
+ out += renderer.em(this.parseInline(token.tokens, renderer));
+ break;
+ }
+
+ case 'codespan':
+ {
+ out += renderer.codespan(token.text);
+ break;
+ }
+
+ case 'br':
+ {
+ out += renderer.br();
+ break;
+ }
+
+ case 'del':
+ {
+ out += renderer.del(this.parseInline(token.tokens, renderer));
+ break;
+ }
+
+ case 'text':
+ {
+ out += renderer.text(token.text);
+ break;
+ }
+
+ default:
+ {
+ var errMsg = 'Inline token with "' + this.token.type + '" type was not found.';
+
+ if (this.options.silent) {
+ console.error(errMsg);
+ } else {
+ throw new Error(errMsg);
+ }
+ }
+ }
}
return out;
};
- /**
- * Next Token
- */
- _proto.next = function next() {
- this.token = this.tokens.pop();
- return this.token;
- };
-
- /**
- * Preview Next Token
- */
- _proto.peek = function peek() {
- return this.tokens[this.tokens.length - 1] || 0;
- };
-
- /**
- * Parse Text Tokens
- */
- _proto.parseText = function parseText() {
- var body = this.token.text;
-
- while (this.peek().type === 'text') {
- body += '\n' + this.next().text;
- }
-
- return this.inline.output(body);
- };
-
- /**
- * Parse Current Token
- */
- _proto.tok = function tok() {
- var body = '';
-
- switch (this.token.type) {
- case 'space':
- {
- return '';
- }
-
- case 'hr':
- {
- return this.renderer.hr();
- }
-
- case 'heading':
- {
- return this.renderer.heading(this.inline.output(this.token.text), this.token.depth, unescape$1(this.inlineText.output(this.token.text)), this.slugger);
- }
-
- case 'code':
- {
- return this.renderer.code(this.token.text, this.token.lang, this.token.escaped);
- }
-
- case 'table':
- {
- var header = '',
- i,
- row,
- cell,
- j; // header
-
- cell = '';
-
- for (i = 0; i < this.token.header.length; i++) {
- cell += this.renderer.tablecell(this.inline.output(this.token.header[i]), {
- header: true,
- align: this.token.align[i]
- });
- }
-
- header += this.renderer.tablerow(cell);
-
- for (i = 0; i < this.token.cells.length; i++) {
- row = this.token.cells[i];
- cell = '';
-
- for (j = 0; j < row.length; j++) {
- cell += this.renderer.tablecell(this.inline.output(row[j]), {
- header: false,
- align: this.token.align[j]
- });
- }
-
- body += this.renderer.tablerow(cell);
- }
-
- return this.renderer.table(header, body);
- }
-
- case 'blockquote_start':
- {
- body = '';
-
- while (this.next().type !== 'blockquote_end') {
- body += this.tok();
- }
-
- return this.renderer.blockquote(body);
- }
-
- case 'list_start':
- {
- body = '';
- var ordered = this.token.ordered,
- start = this.token.start;
-
- while (this.next().type !== 'list_end') {
- body += this.tok();
- }
-
- return this.renderer.list(body, ordered, start);
- }
-
- case 'list_item_start':
- {
- body = '';
- var loose = this.token.loose;
- var checked = this.token.checked;
- var task = this.token.task;
-
- if (this.token.task) {
- if (loose) {
- if (this.peek().type === 'text') {
- var nextToken = this.peek();
- nextToken.text = this.renderer.checkbox(checked) + ' ' + nextToken.text;
- } else {
- this.tokens.push({
- type: 'text',
- text: this.renderer.checkbox(checked)
- });
- }
- } else {
- body += this.renderer.checkbox(checked);
- }
- }
-
- while (this.next().type !== 'list_item_end') {
- body += !loose && this.token.type === 'text' ? this.parseText() : this.tok();
- }
-
- return this.renderer.listitem(body, task, checked);
- }
-
- case 'html':
- {
- // TODO parse inline content if parameter markdown=1
- return this.renderer.html(this.token.text);
- }
-
- case 'paragraph':
- {
- return this.renderer.paragraph(this.inline.output(this.token.text));
- }
-
- case 'text':
- {
- return this.renderer.paragraph(this.parseText());
- }
-
- default:
- {
- var errMsg = 'Token with "' + this.token.type + '" type was not found.';
-
- if (this.options.silent) {
- console.log(errMsg);
- } else {
- throw new Error(errMsg);
- }
- }
- }
- };
-
return Parser;
}();
- var merge$3 = helpers.merge,
+ var merge$2 = helpers.merge,
checkSanitizeDeprecation$1 = helpers.checkSanitizeDeprecation,
- escape$4 = helpers.escape;
+ escape$3 = helpers.escape;
var getDefaults = defaults.getDefaults,
changeDefaults = defaults.changeDefaults,
- defaults$5 = defaults.defaults;
+ defaults$4 = defaults.defaults;
/**
* Marked
*/
@@ -1668,7 +1912,7 @@
opt = null;
}
- opt = merge$3({}, marked.defaults, opt || {});
+ opt = merge$2({}, marked.defaults, opt || {});
checkSanitizeDeprecation$1(opt);
var highlight = opt.highlight;
var tokens,
@@ -1743,14 +1987,14 @@
}
try {
- opt = merge$3({}, marked.defaults, opt || {});
+ opt = merge$2({}, marked.defaults, opt || {});
checkSanitizeDeprecation$1(opt);
return Parser_1.parse(Lexer_1.lex(src, opt), opt);
} catch (e) {
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
if ((opt || marked.defaults).silent) {
- return '' + escape$4(e.message + '', true) + '
';
+ return '' + escape$3(e.message + '', true) + '
';
}
throw e;
@@ -1762,13 +2006,13 @@
marked.options = marked.setOptions = function (opt) {
- merge$3(marked.defaults, opt);
+ merge$2(marked.defaults, opt);
changeDefaults(marked.defaults);
return marked;
};
marked.getDefaults = getDefaults;
- marked.defaults = defaults$5;
+ marked.defaults = defaults$4;
/**
* Expose
*/
@@ -1779,8 +2023,6 @@
marked.TextRenderer = TextRenderer_1;
marked.Lexer = Lexer_1;
marked.lexer = Lexer_1.lex;
- marked.InlineLexer = InlineLexer_1;
- marked.inlineLexer = InlineLexer_1.output;
marked.Slugger = Slugger_1;
marked.parse = marked;
var marked_1 = marked;
diff --git a/marked.min.js b/marked.min.js
index 7c4f6a08..9586cd0c 100644
--- a/marked.min.js
+++ b/marked.min.js
@@ -3,4 +3,4 @@
* Copyright (c) 2011-2020, Christopher Jeffrey. (MIT Licensed)
* https://github.com/markedjs/marked
*/
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).marked=t()}(this,function(){"use strict";function r(e,t){for(var n=0;n'+(n?e:N(e,!0))+"
\n":"
"},t.blockquote=function(e){return""+(n?e:N(e,!0))+"
\n"+e+"
\n"},t.html=function(e){return e},t.heading=function(e,t,n,r){return this.options.headerIds?"
\n":"
\n"},t.list=function(e,t,n){var r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+""+r+">\n"},t.listitem=function(e){return"\n\n"+e+"\n"+(t=t&&""+t+"")+"
\n"},t.tablerow=function(e){return"\n"+e+" \n"},t.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' align="'+t.align+'">':"<"+n+">")+e+""+n+">\n"},t.strong=function(e){return""+e+""},t.em=function(e){return""+e+""},t.codespan=function(e){return""+e+"
"},t.br=function(){return this.options.xhtml?"
":"
"},t.del=function(e){return""+e+""},t.link=function(e,t,n){if(null===(e=F(this.options.sanitize,this.options.baseUrl,e)))return n;var r='"+n+""},t.image=function(e,t,n){if(null===(e=F(this.options.sanitize,this.options.baseUrl,e)))return n;var r='":">"},t.text=function(e){return e},e}(),G=function(){function e(){this.seen={}}return e.prototype.slug=function(e){var t=e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(t))for(var n=t;this.seen[n]++,t=n+"-"+this.seen[n],this.seen.hasOwnProperty(t););return this.seen[t]=0,t},e}(),M=s.defaults,V=D.inline,H=A,J=y,K=function(){function u(e,t){if(this.options=t||M,this.links=e,this.rules=V.normal,this.options.renderer=this.options.renderer||new X,this.renderer=this.options.renderer,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.pedantic?this.rules=V.pedantic:this.options.gfm&&(this.options.breaks?this.rules=V.breaks:this.rules=V.gfm)}u.output=function(e,t,n){return new u(t,n).output(e)};var e=u.prototype;return e.output=function(e){for(var t,n,r,s,i,l,a="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),a+=J(i[1]);else if(i=this.rules.tag.exec(e))!this.inLink&&/^/i.test(i[0])&&(this.inLink=!1),!this.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(i[0])?this.inRawBlock=!0:this.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(i[0])&&(this.inRawBlock=!1),e=e.substring(i[0].length),a+=this.renderer.html(this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):J(i[0]):i[0]);else if(i=this.rules.link.exec(e)){var o=H(i[2],"()");if(-1
"+se(e.message+"",!0)+"";throw e}}return oe.options=oe.setOptions=function(e){return ne(oe.defaults,e),le(oe.defaults),oe},oe.getDefaults=ie,oe.defaults=ae,oe.Parser=te,oe.parser=te.parse,oe.Renderer=X,oe.TextRenderer=Q,oe.Lexer=B,oe.lexer=B.lex,oe.InlineLexer=K,oe.inlineLexer=K.output,oe.Slugger=G,oe.parse=oe}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).marked=t()}(this,function(){"use strict";function r(e,t){for(var n=0;n
'+(n?e:N(e,!0))+"
\n":""+(n?e:N(e,!0))+"
"},t.blockquote=function(e){return"\n"+e+"\n"},t.html=function(e){return e},t.heading=function(e,t,n,r){return this.options.headerIds?"
"+e+"
\n"},t.table=function(e,t){return""+e+"
"},t.br=function(){return this.options.xhtml?""+re(e.message+"",!0)+"";throw e}}return ae.options=ae.setOptions=function(e){return te(ae.defaults,e),ie(ae.defaults),ae},ae.getDefaults=se,ae.defaults=le,ae.Parser=J,ae.parser=J.parse,ae.Renderer=X,ae.TextRenderer=G,ae.Lexer=B,ae.lexer=B.lex,ae.InlineLexer=ee,ae.inlineLexer=ee.lex,ae.Slugger=M,ae.parse=ae}); \ No newline at end of file