MCPcopy
hub / github.com/witheve/Eve / parseDoc

Function parseDoc

src/runtime/parser.ts:1437–1465  ·  view source on GitHub ↗
(doc, docId = `doc|${docIx++}`)

Source from the content-addressed store, hash-verified

1435
1436let docIx = 0;
1437export function parseDoc(doc, docId = `doc|${docIx++}`) {
1438 let start = time();
1439 let {text, spans, blocks, extraInfo} = parseMarkdown(doc, docId);
1440 let parsedBlocks = [];
1441 let allErrors = [];
1442 for(let block of blocks) {
1443 extraInfo[block.id] = {info: block.info};
1444 if(block.info.indexOf("disabled") > -1) {
1445 extraInfo[block.id].disabled = true;
1446 }
1447 if(block.info !== "" && block.info.indexOf("eve") === -1) continue;
1448 let {results, lex, errors} = parseBlock(block.literal, block.id, block.startOffset, spans, extraInfo);
1449 // if this block is disabled, we want the parsed spans and such, but we don't want
1450 // the block to be in the set sent to the builder
1451 if(!extraInfo[block.id].disabled) {
1452 if(errors.length) {
1453 allErrors.push(errors);
1454 } else if(results) {
1455 results.endOffset = block.endOffset;
1456 parsedBlocks.push(results);
1457 }
1458 }
1459 }
1460 return {
1461 results: {blocks: parsedBlocks, text, spans, extraInfo},
1462 time: time(start),
1463 errors: allErrors,
1464 }
1465}

Callers

nothing calls this directly

Calls 2

parseBlockFunction · 0.85
parseMarkdownFunction · 0.70

Tested by

no test coverage detected