* Locate the byte index of a header line (`[foo.bar]`) when it * appears at the start of a line. Returns -1 if not found.
(content: string, headerLine: string)
| 126 | * appears at the start of a line. Returns -1 if not found. |
| 127 | */ |
| 128 | function findHeaderIndex(content: string, headerLine: string): number { |
| 129 | // Search BOL or right after a newline. |
| 130 | if (content.startsWith(headerLine)) return 0; |
| 131 | const needle = '\n' + headerLine; |
| 132 | const idx = content.indexOf(needle); |
| 133 | return idx === -1 ? -1 : idx + 1; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Find the byte index of the next `[...]` or `[[...]]` table header |
no outgoing calls
no test coverage detected