(s: string, i: number)
| 1684 | |
| 1685 | // Parses the markup at `i`, and returns its end or -1 when it is incomplete |
| 1686 | private markup(s: string, i: number): number { |
| 1687 | const n = s.length |
| 1688 | if (i + 1 >= n) return -1 |
| 1689 | const c = s.charCodeAt(i + 1) |
| 1690 | if (c === SLASH) return this.endTag(s, i) |
| 1691 | if (c === QUESTION) return this.processingInstruction(s, i) |
| 1692 | if (c !== BANG) return this.startTag(s, i) |
| 1693 | if (i + 2 >= n) return -1 |
| 1694 | const keyword = s.charCodeAt(i + 2) === DASH ? "<!--" : s.charCodeAt(i + 2) === LBRACKET ? "<![CDATA[" : "<!DOCTYPE" |
| 1695 | if (!s.startsWith(keyword, i)) { |
| 1696 | if (n - i < keyword.length && keyword.startsWith(s.slice(i))) return -1 |
| 1697 | throw this.syntax("invalid markup", i) |
| 1698 | } |
| 1699 | return keyword === "<!--" |
| 1700 | ? this.comment(s, i) |
| 1701 | : keyword === "<!DOCTYPE" |
| 1702 | ? this.doctypeDeclaration(s, i) |
| 1703 | : this.cdata(s, i) |
| 1704 | } |
| 1705 | |
| 1706 | private checkSize(i: number, end: number): void { |
| 1707 | if (end - i > this.maxTokenSize) { |
no test coverage detected