MCPcopy Create free account
hub / github.com/Noumena-Network/code / lexMarkdownPreservingPreformattedDiagrams

Function lexMarkdownPreservingPreformattedDiagrams

src/utils/markdown.ts:384–407  ·  view source on GitHub ↗
(
  content: string,
)

Source from the content-addressed store, hash-verified

382}
383
384export function lexMarkdownPreservingPreformattedDiagrams(
385 content: string,
386): Token[] {
387 configureMarked()
388 const segments = detectPreformattedMarkdownSegments(content)
389 if (segments.length === 0) {
390 return marked.lexer(repairMalformedPipeTables(content))
391 }
392
393 const tokens: Token[] = []
394 for (const segment of segments) {
395 if (segment.type === 'preformatted_diagram') {
396 tokens.push({
397 type: 'code',
398 raw: segment.content,
399 text: segment.content,
400 lang: '',
401 } as Token)
402 continue
403 }
404 tokens.push(...marked.lexer(repairMalformedPipeTables(segment.content)))
405 }
406 return tokens
407}
408
409export function configureMarked(): void {
410 if (markedConfigured) return

Callers 3

cachedLexerFunction · 0.85
StreamingMarkdownFunction · 0.85
applyMarkdownFunction · 0.85

Calls 3

configureMarkedFunction · 0.85

Tested by

no test coverage detected