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

Method endTag

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

Source from the content-addressed store, hash-verified

2001 }
2002
2003 private endTag(s: string, i: number): number {
2004 const n = s.length
2005 const j = scanName(s, i + 2, n)
2006 if (j === i + 2) {
2007 if (j >= n) return -1
2008 throw this.syntax("invalid element name", j)
2009 }
2010 const k = skipSpace(s, j, n)
2011 if (k >= n) return -1
2012 if (s.charCodeAt(k) !== GT) throw this.syntax("expected \">\"", k)
2013 const open = this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined
2014 if (open === undefined) throw this.syntax("end tag without a start tag", i)
2015 if (j - i - 2 !== open.length || !s.startsWith(open, i + 2)) {
2016 throw this.syntax(`end tag </${s.slice(i + 2, j)}> does not match <${open}>`, i)
2017 }
2018 this.checkSize(i, k + 1)
2019 this.flushText()
2020 this.stack.pop()
2021 this.openNameSize -= open.length
2022 this.out.push(this.endElement(open))
2023 if (this.stack.length === 0) this.state = EPILOG
2024 return k + 1
2025 }
2026
2027 private comment(s: string, i: number): number {
2028 const end = s.indexOf("-->", i + 4)

Callers 1

markupMethod · 0.95

Calls 8

syntaxMethod · 0.95
checkSizeMethod · 0.95
flushTextMethod · 0.95
endElementMethod · 0.95
scanNameFunction · 0.85
skipSpaceFunction · 0.85
sliceMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected