(text: string)
| 231 | * inside a template literal is acceptable, false-firing on prose is not. |
| 232 | */ |
| 233 | export function blankStringContents(text: string): string { |
| 234 | const out = text.split(''); |
| 235 | let i = 0; |
| 236 | const n = text.length; |
| 237 | while (i < n) { |
| 238 | const c = text[i]!; |
| 239 | if (c === '"' || c === "'" || c === '`') { |
| 240 | const quote = c; |
| 241 | i++; |
| 242 | while (i < n && text[i] !== quote) { |
| 243 | if (text[i] === '\\' && i + 1 < n) { |
| 244 | out[i] = ' '; |
| 245 | out[i + 1] = ' '; |
| 246 | i += 2; |
| 247 | continue; |
| 248 | } |
| 249 | if (quote !== '`' && text[i] === '\n') break; // unterminated — stop blanking |
| 250 | if (text[i] !== '\n') out[i] = ' '; // keep newlines for line math |
| 251 | i++; |
| 252 | } |
| 253 | if (i < n && text[i] === quote) i++; |
| 254 | continue; |
| 255 | } |
| 256 | i++; |
| 257 | } |
| 258 | return out.join(''); |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Scan one symbol's body for dynamic-dispatch sites. |
no test coverage detected