MCPcopy Create free account
hub / github.com/Effect-TS/effect / markup

Method markup

packages/effect/src/encoding/Xml.ts:1686–1704  ·  view source on GitHub ↗
(s: string, i: number)

Source from the content-addressed store, hash-verified

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) {

Callers 2

checkPendingMethod · 0.95
parseMethod · 0.95

Calls 8

endTagMethod · 0.95
processingInstructionMethod · 0.95
startTagMethod · 0.95
syntaxMethod · 0.95
commentMethod · 0.95
doctypeDeclarationMethod · 0.95
cdataMethod · 0.95
sliceMethod · 0.80

Tested by

no test coverage detected