(content: string)
| 41 | } |
| 42 | |
| 43 | export 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 | |
| 67 | function classifyPotentialDiagramLine( |
| 68 | line: string, |
no outgoing calls
no test coverage detected