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

Function looksLikePreformattedDiagram

src/utils/markdown.ts:43–65  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

41}
42
43export function looksLikePreformattedDiagram(content: string): boolean {
44 const lines = content.split('\n').filter(line => line.trim().length > 0)
45 if (lines.length < 3) {
46 return false
47 }
48
49 let diagramLineCount = 0
50 let indentedLineCount = 0
51 for (const line of lines) {
52 if (STRUCTURED_DIAGRAM_CHAR_RE.test(line)) {
53 diagramLineCount += 1
54 }
55 if (/^\s{4,}\S/.test(line)) {
56 indentedLineCount += 1
57 }
58 }
59
60 if (diagramLineCount < 2) {
61 return false
62 }
63
64 return diagramLineCount + indentedLineCount >= Math.ceil(lines.length / 2)
65}
66
67function classifyPotentialDiagramLine(
68 line: string,

Calls

no outgoing calls

Tested by

no test coverage detected