(s: string, args: string[] = [])
| 400 | tokenize(argMap?.[param] ?? argMap?.['?'] ?? '\\placeholder{}', args) |
| 401 | ); |
| 402 | } else { |
| 403 | result.push(token); |
| 404 | } |
| 405 | |
| 406 | return result; |
| 407 | } |
| 408 | |
| 409 | /** |
| 410 | * Create Tokens from a stream of LaTeX |
| 411 | * |
| 412 | * @param s - A string of LaTeX. It can include comments (with the `%` |
| 413 | * marker) and multiple lines. |
| 414 | */ |
| 415 | export function tokenize( |
| 416 | s: string, |
| 417 | args: string[] = [], |
| 418 | comments?: DiscardedComment[] |
| 419 | ): Token[] { |
| 420 | // Merge multiple lines into one, and remove comments. |
| 421 | // Split keeping the line separators (capture group) so the exact separator |
| 422 | // length — `\n` (1) or `\r\n` (2) — advances the original-input offset used |
| 423 | // to report discarded-comment spans. `parts` alternates line, separator, |
| 424 | // line, separator, …; even indices are lines, odd indices are the following |
| 425 | // separator (or `undefined` for the last line). |
| 426 | const str = s.toString(); |
no test coverage detected