mirror of
https://github.com/markedjs/marked.git
synced 2026-12-01 16:56:16 +01:00
🗜️ build [skip ci]
This commit is contained in:
+12
-11
@@ -1478,7 +1478,8 @@ var Lexer_1 = class Lexer {
|
||||
let token, i, l, lastToken, cutSrc, lastParagraphClipped;
|
||||
|
||||
while (src) {
|
||||
if (this.options?.extensions?.block
|
||||
if (this.options.extensions
|
||||
&& this.options.extensions.block
|
||||
&& this.options.extensions.block.some((extTokenizer) => {
|
||||
if (token = extTokenizer.call(this, src, tokens)) {
|
||||
src = src.substring(token.raw.length);
|
||||
@@ -1596,7 +1597,7 @@ var Lexer_1 = class Lexer {
|
||||
// top-level paragraph
|
||||
// prevent paragraph consuming extensions by clipping 'src' to extension start
|
||||
cutSrc = src;
|
||||
if (this.options.extensions?.startBlock) {
|
||||
if (this.options.extensions && this.options.extensions.startBlock) {
|
||||
let startIndex = Infinity;
|
||||
const tempSrc = src.slice(1);
|
||||
let tempStart;
|
||||
@@ -1749,7 +1750,8 @@ var Lexer_1 = class Lexer {
|
||||
keepPrevChar = false;
|
||||
|
||||
// extensions
|
||||
if (this.options?.extensions?.inline
|
||||
if (this.options.extensions
|
||||
&& this.options.extensions.inline
|
||||
&& this.options.extensions.inline.some((extTokenizer) => {
|
||||
if (token = extTokenizer.call(this, src, tokens)) {
|
||||
src = src.substring(token.raw.length);
|
||||
@@ -1856,7 +1858,7 @@ var Lexer_1 = class Lexer {
|
||||
// text
|
||||
// prevent inlineText consuming extensions by clipping 'src' to extension start
|
||||
cutSrc = src;
|
||||
if (this.options.extensions?.startInline) {
|
||||
if (this.options.extensions && this.options.extensions.startInline) {
|
||||
let startIndex = Infinity;
|
||||
const tempSrc = src.slice(1);
|
||||
let tempStart;
|
||||
@@ -2228,7 +2230,7 @@ var Parser_1 = class Parser {
|
||||
token = tokens[i];
|
||||
|
||||
// Run any renderer extensions
|
||||
if (this.options.extensions?.renderers?.[token.type]) {
|
||||
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
||||
ret = this.options.extensions.renderers[token.type].call(this, token);
|
||||
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
|
||||
out += ret || '';
|
||||
@@ -2384,7 +2386,7 @@ var Parser_1 = class Parser {
|
||||
token = tokens[i];
|
||||
|
||||
// Run any renderer extensions
|
||||
if (this.options.extensions?.renderers?.[token.type]) {
|
||||
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
||||
ret = this.options.extensions.renderers[token.type].call(this, token);
|
||||
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
|
||||
out += ret || '';
|
||||
@@ -2605,7 +2607,7 @@ marked.use = function(...args) {
|
||||
throw new Error('extension name required');
|
||||
}
|
||||
if (ext.renderer) { // Renderer extensions
|
||||
const prevRenderer = extensions.renderers?.[ext.name];
|
||||
const prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null;
|
||||
if (prevRenderer) {
|
||||
// Replace extension with func to run new extension but fall back if false
|
||||
extensions.renderers[ext.name] = function(...args) {
|
||||
@@ -2725,12 +2727,11 @@ marked.walkTokens = function(tokens, callback) {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (marked.defaults?.extensions?.childTokens?.[token.type]) { // Walk any extensions
|
||||
marked.defaults?.extensions.childTokens[token.type].forEach(function(childTokens) {
|
||||
if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) { // Walk any extensions
|
||||
marked.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
|
||||
marked.walkTokens(token[childTokens], callback);
|
||||
});
|
||||
}
|
||||
if (token.tokens && !marked.defaults?.extensions?.childTokens[token.type]) {
|
||||
} else if (token.tokens) {
|
||||
marked.walkTokens(token.tokens, callback);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-26
@@ -1476,9 +1476,7 @@
|
||||
var token, i, l, lastToken, cutSrc, lastParagraphClipped;
|
||||
|
||||
while (src) {
|
||||
var _this$options, _this$options$extensi, _this$options$extensi2;
|
||||
|
||||
if ((_this$options = this.options) != null && (_this$options$extensi = _this$options.extensions) != null && _this$options$extensi.block && this.options.extensions.block.some(function (extTokenizer) {
|
||||
if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some(function (extTokenizer) {
|
||||
if (token = extTokenizer.call(_this, src, tokens)) {
|
||||
src = src.substring(token.raw.length);
|
||||
tokens.push(token);
|
||||
@@ -1604,7 +1602,7 @@
|
||||
|
||||
cutSrc = src;
|
||||
|
||||
if ((_this$options$extensi2 = this.options.extensions) != null && _this$options$extensi2.startBlock) {
|
||||
if (this.options.extensions && this.options.extensions.startBlock) {
|
||||
(function () {
|
||||
var startIndex = Infinity;
|
||||
var tempSrc = src.slice(1);
|
||||
@@ -1786,15 +1784,13 @@
|
||||
}
|
||||
|
||||
while (src) {
|
||||
var _this$options2, _this$options2$extens, _this$options$extensi3;
|
||||
|
||||
if (!keepPrevChar) {
|
||||
prevChar = '';
|
||||
}
|
||||
|
||||
keepPrevChar = false; // extensions
|
||||
|
||||
if ((_this$options2 = this.options) != null && (_this$options2$extens = _this$options2.extensions) != null && _this$options2$extens.inline && this.options.extensions.inline.some(function (extTokenizer) {
|
||||
if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some(function (extTokenizer) {
|
||||
if (token = extTokenizer.call(_this2, src, tokens)) {
|
||||
src = src.substring(token.raw.length);
|
||||
tokens.push(token);
|
||||
@@ -1908,7 +1904,7 @@
|
||||
|
||||
cutSrc = src;
|
||||
|
||||
if ((_this$options$extensi3 = this.options.extensions) != null && _this$options$extensi3.startInline) {
|
||||
if (this.options.extensions && this.options.extensions.startInline) {
|
||||
(function () {
|
||||
var startIndex = Infinity;
|
||||
var tempSrc = src.slice(1);
|
||||
@@ -2309,11 +2305,9 @@
|
||||
var l = tokens.length;
|
||||
|
||||
for (i = 0; i < l; i++) {
|
||||
var _this$options$extensi, _this$options$extensi2;
|
||||
|
||||
token = tokens[i]; // Run any renderer extensions
|
||||
|
||||
if ((_this$options$extensi = this.options.extensions) != null && (_this$options$extensi2 = _this$options$extensi.renderers) != null && _this$options$extensi2[token.type]) {
|
||||
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
||||
ret = this.options.extensions.renderers[token.type].call(this, token);
|
||||
|
||||
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
|
||||
@@ -2489,11 +2483,9 @@
|
||||
var l = tokens.length;
|
||||
|
||||
for (i = 0; i < l; i++) {
|
||||
var _this$options$extensi3, _this$options$extensi4;
|
||||
|
||||
token = tokens[i]; // Run any renderer extensions
|
||||
|
||||
if ((_this$options$extensi3 = this.options.extensions) != null && (_this$options$extensi4 = _this$options$extensi3.renderers) != null && _this$options$extensi4[token.type]) {
|
||||
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
||||
ret = this.options.extensions.renderers[token.type].call(this, token);
|
||||
|
||||
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
|
||||
@@ -2742,10 +2734,8 @@
|
||||
}
|
||||
|
||||
if (ext.renderer) {
|
||||
var _extensions$renderers;
|
||||
|
||||
// Renderer extensions
|
||||
var prevRenderer = (_extensions$renderers = extensions.renderers) == null ? void 0 : _extensions$renderers[ext.name];
|
||||
var prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null;
|
||||
|
||||
if (prevRenderer) {
|
||||
// Replace extension with func to run new extension but fall back if false
|
||||
@@ -2923,18 +2913,12 @@
|
||||
|
||||
default:
|
||||
{
|
||||
var _marked$defaults, _marked$defaults$exte, _marked$defaults$exte2, _marked$defaults3, _marked$defaults3$ext;
|
||||
|
||||
if ((_marked$defaults = marked.defaults) != null && (_marked$defaults$exte = _marked$defaults.extensions) != null && (_marked$defaults$exte2 = _marked$defaults$exte.childTokens) != null && _marked$defaults$exte2[token.type]) {
|
||||
var _marked$defaults2;
|
||||
|
||||
if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) {
|
||||
// Walk any extensions
|
||||
(_marked$defaults2 = marked.defaults) == null ? void 0 : _marked$defaults2.extensions.childTokens[token.type].forEach(function (childTokens) {
|
||||
marked.defaults.extensions.childTokens[token.type].forEach(function (childTokens) {
|
||||
marked.walkTokens(token[childTokens], callback);
|
||||
});
|
||||
}
|
||||
|
||||
if (token.tokens && !((_marked$defaults3 = marked.defaults) != null && (_marked$defaults3$ext = _marked$defaults3.extensions) != null && _marked$defaults3$ext.childTokens[token.type])) {
|
||||
} else if (token.tokens) {
|
||||
marked.walkTokens(token.tokens, callback);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user