(s: string, out: string[], from: number, to: number)
| 171 | } |
| 172 | |
| 173 | function blankRazor(s: string, out: string[], from: number, to: number): void { |
| 174 | let i = from; |
| 175 | while (i < to) { |
| 176 | const at = s.indexOf('@', i); |
| 177 | if (at < 0 || at >= to) return; |
| 178 | // `name@host` is text to Razor, as it is here. |
| 179 | if (at > 0 && /\w/.test(s[at - 1]!)) { |
| 180 | i = at + 1; |
| 181 | continue; |
| 182 | } |
| 183 | const next = s[at + 1]; |
| 184 | if (next === '@') { |
| 185 | blank(out, at, at + 1); |
| 186 | i = at + 2; |
| 187 | } else if (next === '*') { |
| 188 | const end = s.indexOf('*@', at + 2); |
| 189 | const stop = end < 0 || end + 2 > to ? to : end + 2; |
| 190 | blank(out, at, stop); |
| 191 | i = stop; |
| 192 | } else if (next === '{' || next === '(') { |
| 193 | const end = pastBracket(s, at + 1); |
| 194 | if (end < 0 || end > to) return; |
| 195 | blank(out, at, end); |
| 196 | if (next === '(') out[at] = '0'; |
| 197 | i = end; |
| 198 | } else if (next === ':') { |
| 199 | blank(out, at, at + 2); |
| 200 | i = at + 2; |
| 201 | } else { |
| 202 | const word = /^[A-Za-z_]\w*/.exec(s.slice(at + 1, at + 33))?.[0]; |
| 203 | if (!word) { |
| 204 | i = at + 1; |
| 205 | } else if (CONTROL.has(word)) { |
| 206 | i = blankControl(s, out, at, to); |
| 207 | } else { |
| 208 | const end = Math.min(pastExpression(s, at + 1), to); |
| 209 | blank(out, at, end); |
| 210 | out[at] = '0'; |
| 211 | i = Math.max(end, at + 1); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | /** `source` with its Razor blanked; every offset and line stays where it was. */ |
| 218 | export function blankRazorInScript(source: string): string { |
no test coverage detected