HTML Balance
HTML tag-balance verification. Walks an HTML fragment and refuses unbalanced container tags, orphan close tags, mismatched-name close tags, void-element close tags, unterminated comments, and unterminated raw-text elements ( / / / ). Returns null when balanced; otherwise an issue object with code, message, line, and column so operators can surface "you forgot to close this tag at line N" feedback at save time.
Intent is operator-side structural feedback, not security validation. Attribute syntax, custom-element / shadow-DOM namespaces, script/style content semantics, and XSS-class checks are all out of scope here — the security pass is b.guardHtml, composed by b.htmlBalance.checkSafe for operators wanting both gates in one call.
Void elements (, , , …) are recognised and never expected to close. Self-closing slash forms () are honoured. Raw-text elements skip their content entirely so bodies containing literal < / aren't mis-read as markup.
b.htmlBalance.check(html) #
Returns null when html is balanced; otherwise an issue object { code, message, line, column }. Issue codes: html/unterminated-comment, html/unterminated-tag, html/orphan-close, html/mismatched-close, html/void-close, html/unclosed-raw-text, html/unclosed-tag. Non-string inputs and the empty string return null (nothing to balance). Self-closing slash forms and HTML5 void elements are recognised; raw-text elements skip their bodies so JS containing < characters doesn't mis-balance.
b.htmlBalance.check("hello
");
// → null
var issue = b.htmlBalance.check("hello
");
// → { code: "html/mismatched-close", message: "