* Extract description from field content, handling quoted strings properly. * Handles single quotes, double quotes, and backticks, preserving internal quotes.
(fieldContent: string)
| 1591 | * Handles single quotes, double quotes, and backticks, preserving internal quotes. |
| 1592 | */ |
| 1593 | function extractDescription(fieldContent: string): string | null { |
| 1594 | // Walk through all `description:` matches and return the first one at depth 0. |
| 1595 | // This prevents accidentally picking up `description:` keys inside nested child objects. |
| 1596 | const descRegex = /description\s*:\s*('([^']*)'|"([^"]*)"|`([^`]*)`)/g |
| 1597 | let m: RegExpExecArray | null |
| 1598 | while ((m = descRegex.exec(fieldContent)) !== null) { |
| 1599 | if (isAtDepthZero(fieldContent, m.index)) { |
| 1600 | return m[2] ?? m[3] ?? m[4] ?? null |
| 1601 | } |
| 1602 | } |
| 1603 | return null |
| 1604 | } |
| 1605 | |
| 1606 | function parseConstFieldContent( |
| 1607 | fieldContent: string, |
no test coverage detected