MCPcopy Create free account
hub / github.com/Alphanimble/htmlstream / isLatexReady

Function isLatexReady

demo/render-math.ts:4–17  ·  view source on GitHub ↗
(latex: string)

Source from the content-addressed store, hash-verified

2
3/** Balanced-brace check — skip typesetting while latex attribute is still streaming */
4export function isLatexReady(latex: string): boolean {
5 if (!latex.trim()) return false;
6
7 let depth = 0;
8 for (const ch of latex) {
9 if (ch === "{") depth++;
10 else if (ch === "}") {
11 depth--;
12 if (depth < 0) return false;
13 }
14 }
15
16 return depth === 0;
17}
18
19/** Typeset [data-latex] elements; incomplete formulas keep a stable placeholder. */
20export function renderMath(root: HTMLElement, streaming = false): void {

Callers 1

renderMathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected