mirror of https://github.com/zulip/zulip.git
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:
parent
a77bf90601
commit
093eba077a
|
@ -1416,9 +1416,6 @@ function marked(src, opt, callback) {
|
||||||
|
|
||||||
htmlStashCounter = 0;
|
htmlStashCounter = 0;
|
||||||
htmlStash = [];
|
htmlStash = [];
|
||||||
for (var k = 0; k < opt.preprocessors.length; k++) {
|
|
||||||
src = opt.preprocessors[k](src);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tokens = Lexer.lex(src, opt)
|
tokens = Lexer.lex(src, opt)
|
||||||
|
@ -1480,8 +1477,8 @@ function marked(src, opt, callback) {
|
||||||
if (opt) opt = merge({}, marked.defaults, opt);
|
if (opt) opt = merge({}, marked.defaults, opt);
|
||||||
htmlStashCounter = 0;
|
htmlStashCounter = 0;
|
||||||
htmlStash = [];
|
htmlStash = [];
|
||||||
for (var i = 0; i < marked.defaults.preprocessors.length; i++) {
|
for (var i = 0; i < opt.preprocessors.length; i++) {
|
||||||
src = marked.defaults.preprocessors[i](src);
|
src = opt.preprocessors[i](src);
|
||||||
}
|
}
|
||||||
return Parser.parse(Lexer.lex(src, opt), opt);
|
return Parser.parse(Lexer.lex(src, opt), opt);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue