MCPcopy
hub / github.com/markedjs/marked / parse

Function parse

docs/demo/worker.js:53–82  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

51}
52
53function parse(e) {
54 switch (e.data.task) {
55 case 'defaults': {
56 postMessage({
57 id: e.data.id,
58 task: e.data.task,
59 defaults: getDefaults(),
60 });
61 break;
62 }
63 case 'parse': {
64 const marked = versionCache[currentVersion];
65 // marked 0.0.1 had tokens array as the second parameter of lexer and no options
66 const options = currentVersion.endsWith('@0.0.1') ? [] : mergeOptions(e.data.options);
67 const startTime = new Date();
68 const lexed = marked.lexer(e.data.markdown, options);
69 const lexedList = jsonString(lexed);
70 const parsed = marked.parser(lexed, options);
71 const endTime = new Date();
72 postMessage({
73 id: e.data.id,
74 task: e.data.task,
75 lexed: lexedList,
76 parsed,
77 time: endTime - startTime,
78 });
79 break;
80 }
81 }
82}
83
84function jsonString(input, level) {
85 level = level || 0;

Callers 2

worker.jsFile · 0.70
buildFunction · 0.50

Calls 5

getDefaultsFunction · 0.85
mergeOptionsFunction · 0.85
jsonStringFunction · 0.85
lexerMethod · 0.80
parserMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…