The quote closing the string opened at `start`, or -1 when the string doesn't close.
(src: string, start: number)
| 96 | |
| 97 | /** The quote closing the string opened at `start`, or -1 when the string doesn't close. */ |
| 98 | function stringEnd(src: string, start: number): number { |
| 99 | const quote = src.charCodeAt(start); |
| 100 | for (let k = start + 1; k < src.length; k++) { |
| 101 | const c = src.charCodeAt(k); |
| 102 | if (c === quote) return k; |
| 103 | if (c === 92) k += src.charCodeAt(k + 1) === 13 && src.charCodeAt(k + 2) === 10 ? 2 : 1; |
| 104 | else if (c === 10 || c === 13) return -1; |
| 105 | } |
| 106 | return -1; |
| 107 | } |
| 108 | |
| 109 | /** `src` with the ranges (start and end pairs, in order) turned to spaces, line breaks kept. */ |
| 110 | function blankRanges(src: string, blanks: number[]): string { |