| 502 | * @param {number} endPos end position |
| 503 | */ |
| 504 | const flushText = (endPos) => { |
| 505 | if (textStart < endPos) { |
| 506 | if (callbacks.text !== undefined) { |
| 507 | callbacks.text(input, textStart, endPos); |
| 508 | } |
| 509 | // Advance `textStart` so a second `flushText` for the same span |
| 510 | // (e.g. from the EOF handler after a tag-open transition already |
| 511 | // flushed the pending text) is a no-op rather than a duplicate |
| 512 | // emit. emitOpenTag / emitCloseTag overwrite `textStart` with |
| 513 | // their own `nextPos` anyway, so this doesn't shift their start. |
| 514 | textStart = endPos; |
| 515 | } |
| 516 | }; |
| 517 | |
| 518 | /** |
| 519 | * @param {number} endPos end position |