MCPcopy Index your code
hub / github.com/panphora/overtype / parse

Method parse

src/parser.js:494–532  ·  view source on GitHub ↗

* Parse full markdown text * @param {string} text - Full markdown text * @param {number} activeLine - Currently active line index (optional) * @param {boolean} showActiveLineRaw - Show raw markdown on active line * @param {Function} instanceHighlighter - Instance-specific code highlighte

(text, activeLine = -1, showActiveLineRaw = false, instanceHighlighter, isPreviewMode = false)

Source from the content-addressed store, hash-verified

492 * @returns {string} Parsed HTML
493 */
494 static parse(text, activeLine = -1, showActiveLineRaw = false, instanceHighlighter, isPreviewMode = false) {
495 // Reset link counter for each parse
496 this.resetLinkIndex();
497
498 const lines = text.split('\n');
499 let inCodeBlock = false;
500
501 const parsedLines = lines.map((line, index) => {
502 // Show raw markdown on active line if requested
503 if (showActiveLineRaw && index === activeLine) {
504 const content = this.escapeHtml(line) || ' ';
505 return `<div class="raw-line">${content}</div>`;
506 }
507
508 // Check if this line is a code fence
509 const codeFenceRegex = /^```[^`]*$/;
510 if (codeFenceRegex.test(line)) {
511 inCodeBlock = !inCodeBlock;
512 // Parse fence markers normally to get styled output
513 return this.applyCustomSyntax(this.parseLine(line, isPreviewMode));
514 }
515
516 // If we're inside a code block, don't parse as markdown
517 if (inCodeBlock) {
518 const escaped = this.escapeHtml(line);
519 const indented = this.preserveIndentation(escaped, line);
520 return `<div>${indented || '&nbsp;'}</div>`;
521 }
522
523 // Otherwise, parse the markdown normally
524 return this.applyCustomSyntax(this.parseLine(line, isPreviewMode));
525 });
526
527 // Join without newlines to prevent extra spacing
528 const html = parsedLines.join('');
529
530 // Apply post-processing for list consolidation
531 return this.postProcessHTML(html, instanceHighlighter);
532 }
533
534 /**
535 * Post-process HTML to consolidate lists and code blocks

Callers 11

overtype.test.jsFile · 0.80
runAllTestsFunction · 0.80
links.test.jsFile · 0.80
updatePreviewMethod · 0.80
getRenderedHTMLMethod · 0.80
_parseDataValueMethod · 0.80
build.jsFile · 0.80

Calls 6

resetLinkIndexMethod · 0.95
escapeHtmlMethod · 0.95
applyCustomSyntaxMethod · 0.95
parseLineMethod · 0.95
preserveIndentationMethod · 0.95
postProcessHTMLMethod · 0.95

Tested by 1

runAllTestsFunction · 0.64