* Comments and CDATA end with `-->` and `]]>`. * * Their common qualities are: * - Their end sequences have a distinct character they start with. * - That character is then repeated, so we have to check multiple repeats. * - All characters but the start character of the sequence can b
(c: number)
| 522 | * - All characters but the start character of the sequence can be skipped. |
| 523 | */ |
| 524 | private stateInCommentLike(c: number): void { |
| 525 | if (c === this.currentSequence[this.sequenceIndex]) { |
| 526 | if (++this.sequenceIndex === this.currentSequence.length) { |
| 527 | if (this.currentSequence === Sequences.CdataEnd) { |
| 528 | this.cbs.oncdata(this.sectionStart, this.index - 2) |
| 529 | } else { |
| 530 | this.cbs.oncomment(this.sectionStart, this.index - 2) |
| 531 | } |
| 532 | |
| 533 | this.sequenceIndex = 0 |
| 534 | this.sectionStart = this.index + 1 |
| 535 | this.state = State.Text |
| 536 | } |
| 537 | } else if (this.sequenceIndex === 0) { |
| 538 | // Fast-forward to the first character of the sequence |
| 539 | if (this.fastForwardTo(this.currentSequence[0])) { |
| 540 | this.sequenceIndex = 1 |
| 541 | } |
| 542 | } else if (c !== this.currentSequence[this.sequenceIndex - 1]) { |
| 543 | // Allow long sequences, eg. --->, ]]]> |
| 544 | this.sequenceIndex = 0 |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | private startSpecial(sequence: Uint8Array, offset: number) { |
| 549 | this.enterRCDATA(sequence, offset) |
no test coverage detected