From 093eba077ae5d9d0c5db692bc68b64e94ce4f8ab Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 4 Apr 2022 15:11:11 +0000 Subject: [PATCH] markdown: Avoid needless code duplication. We only need to loop through the preprocessors once, and we should use the options passed in to the parser, not the default options from the original setOptions call. The first loop here was doing nothing. --- static/third/marked/lib/marked.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/static/third/marked/lib/marked.js b/static/third/marked/lib/marked.js index c69fbfc3d3..b6fe37b373 100644 --- a/static/third/marked/lib/marked.js +++ b/static/third/marked/lib/marked.js @@ -1416,9 +1416,6 @@ function marked(src, opt, callback) { htmlStashCounter = 0; htmlStash = []; - for (var k = 0; k < opt.preprocessors.length; k++) { - src = opt.preprocessors[k](src); - } try { tokens = Lexer.lex(src, opt) @@ -1480,8 +1477,8 @@ function marked(src, opt, callback) { if (opt) opt = merge({}, marked.defaults, opt); htmlStashCounter = 0; htmlStash = []; - for (var i = 0; i < marked.defaults.preprocessors.length; i++) { - src = marked.defaults.preprocessors[i](src); + for (var i = 0; i < opt.preprocessors.length; i++) { + src = opt.preprocessors[i](src); } return Parser.parse(Lexer.lex(src, opt), opt); } catch (e) {