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.
This commit is contained in:
Steve Howell 2022-04-04 15:11:11 +00:00 committed by Tim Abbott
parent a77bf90601
commit 093eba077a
1 changed files with 2 additions and 5 deletions

View File

@ -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) {