fix async code.
This commit is contained in:
parent
d6a5062087
commit
f7d36a715b
@ -1029,9 +1029,9 @@ function marked(src, opt, callback) {
|
||||
|
||||
if (opt) opt = merge({}, marked.defaults, opt);
|
||||
|
||||
var tokens = Lexer.lex(tokens, opt)
|
||||
var tokens = Lexer.lex(src, opt)
|
||||
, highlight = opt.highlight
|
||||
, pending = 0
|
||||
, pending = tokens.length
|
||||
, l = tokens.length
|
||||
, i = 0;
|
||||
|
||||
@ -1046,10 +1046,13 @@ function marked(src, opt, callback) {
|
||||
return callback(null, out);
|
||||
};
|
||||
|
||||
if (!pending) return done();
|
||||
|
||||
for (; i < l; i++) {
|
||||
(function(token) {
|
||||
if (token.type !== 'code') return;
|
||||
pending++;
|
||||
if (token.type !== 'code') {
|
||||
return --pending || done();
|
||||
}
|
||||
return highlight(token.text, token.lang, function(err, code) {
|
||||
if (code == null || code === token.text) {
|
||||
return --pending || done();
|
||||
|
Loading…
x
Reference in New Issue
Block a user