// HTML semantic container extraction
// Extracts the main content area before feeding to pandoc
// Uses balanced tag counting for nested elements
// ── Prompt injection hardening ──────────────────────────────────────────
// Strip known injection vectors from HTML before content extraction.
// These are deterministic, zero-cost filters — no ML, no arms race.
// They remove delivery mechanisms, not payload content.
//
// Performance: merged 10+ sequential .replace() passes into 5 grouped passes.
// Each .replace() on a 100KB string allocates a new 100KB string, so fewer
// passes = fewer allocations. Block-element removals share one regex via
// alternation since they all follow the same ... pattern.
// [perf] Single regex for all block-level elements that need removal.
// Matches