MCPcopy Index your code
hub / github.com/nodejs/node / marked

Function marked

test/fixtures/snapshot/marked.js:2578–2680  ·  view source on GitHub ↗

* Marked

(src, opt, callback)

Source from the content-addressed store, hash-verified

2576 */
2577
2578 function marked(src, opt, callback) {
2579 // throw error in case of non string input
2580 if (typeof src === 'undefined' || src === null) {
2581 throw new Error('marked(): input parameter is undefined or null');
2582 }
2583
2584 if (typeof src !== 'string') {
2585 throw new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected');
2586 }
2587
2588 if (typeof opt === 'function') {
2589 callback = opt;
2590 opt = null;
2591 }
2592
2593 opt = merge({}, marked.defaults, opt || {});
2594 checkSanitizeDeprecation(opt);
2595
2596 if (callback) {
2597 var highlight = opt.highlight;
2598 var tokens;
2599
2600 try {
2601 tokens = Lexer.lex(src, opt);
2602 } catch (e) {
2603 return callback(e);
2604 }
2605
2606 var done = function done(err) {
2607 var out;
2608
2609 if (!err) {
2610 try {
2611 if (opt.walkTokens) {
2612 marked.walkTokens(tokens, opt.walkTokens);
2613 }
2614
2615 out = Parser.parse(tokens, opt);
2616 } catch (e) {
2617 err = e;
2618 }
2619 }
2620
2621 opt.highlight = highlight;
2622 return err ? callback(err) : callback(null, out);
2623 };
2624
2625 if (!highlight || highlight.length < 3) {
2626 return done();
2627 }
2628
2629 delete opt.highlight;
2630 if (!tokens.length) return done();
2631 var pending = 0;
2632 marked.walkTokens(tokens, function (token) {
2633 if (token.type === 'code') {
2634 pending++;
2635 setTimeout(function () {

Callers 1

check-marked.jsFile · 0.85

Calls 8

mergeFunction · 0.70
callbackFunction · 0.70
doneFunction · 0.70
parseMethod · 0.65
setTimeoutFunction · 0.50
escapeFunction · 0.50
callMethod · 0.45
lexMethod · 0.45

Tested by

no test coverage detected