(): MarkupProbeCache import {create_markup_probe_cache} from '@fuzdev/fuz_code/lexer_markup.js'; returns
MarkupProbeCache Hand-written HTML/XML lexer.
Emits: flat comment, processing_instruction, doctype, cdata, and
entity (alias named_entity for the &-style form); a tag container
holding a nested tag (the <name opener with punctuation/namespace
children — the name itself stays plain text), attr_name (with namespace),
attr_value (spanning the = and quotes, which are punctuation with
attr_equals/attr_quote aliases, plus entities), and a final
punctuation closer; special_attr containers for style=/on*=
attributes whose value embeds css/js; and script/style region
containers wrapping lang_js/lang_css around embedded language windows.
Two registrations share this scanner: lexer_markup (markup/html/
mathml/svg) uses HTML semantics — rawtext elements (script, style)
and RCDATA elements (textarea/title) plus the style=/on*= attribute
embedding; lexer_xml (xml/ssml/atom/rss) scans plain XML with
neither.
HTML-semantics details: a comment ends at the first --> (even one
containing a second <!--); doctypes skip a […] internal subset; CDATA
sections inside <script>/<style> are handed to the embedded language
as-is (no included_cdata structure — HTML treats them as source text);
rawtext close tags accept whitespace before > (</script >).
Resilience: unterminated comments, processing instructions, doctypes, CDATA sections, tags, quoted attribute values, and rawtext regions all extend to the end of the window.
9 declarations
(): MarkupProbeCache import {create_markup_probe_cache} from '@fuzdev/fuz_code/lexer_markup.js'; MarkupProbeCache (l: Lexer, i: number, end: number, mode: MarkupLexMode, cache: MarkupProbeCache): number import {lex_markup_construct} from '@fuzdev/fuz_code/lexer_markup.js'; Lexes one <… construct at i, returning the next scan position.
Exported for lexer_md, which dispatches raw markup out of markdown text.
linumberendnumbermodecachenumber (l: Lexer, mode: MarkupLexMode): void import {lex_markup_window} from '@fuzdev/fuz_code/lexer_markup.js'; The shared markup window lexer — lexes [l.pos, l.end) per mode.
The entry point for the html/xml registrations here and for lexer_svelte.
lmodevoid SyntaxLang import {lexer_markup} from '@fuzdev/fuz_code/lexer_markup.js'; The HTML markup language registration for the lexer engine.
SyntaxLang import {lexer_xml} from '@fuzdev/fuz_code/lexer_markup.js'; The XML language registration — the same scanner without HTML's rawtext
elements or style=/on*= attribute embedding.
MarkupLexMode import {MARKUP_MODE_HTML} from '@fuzdev/fuz_code/lexer_markup.js'; The html dialect mode — also used by lexer_md for raw markup embedded in markdown text.
MarkupLexMode import type {MarkupLexMode} from '@fuzdev/fuz_code/lexer_markup.js'; Dialect configuration for the shared markup scanner — how html, xml, and svelte differ. Instances are module-level constants (one per dialect) so the scanner stays monomorphic.
script_embedLanguage embedded in <script> rawtext regions (resolved through the
lexer registry at lex time), or null to disable rawtext regions
entirely (xml).
type string | null
script_containerContainer type id wrapping script content — lang_js for html,
lang_ts for svelte. Unused when script_embed is null.
type number
rcdataRCDATA textarea/title regions (html only — svelte keeps
expressions live inside them).
type boolean
special_attrsstyle=/on*= attribute embedding (html only).
type boolean
attr_commentsJS-style line and block comments between attributes emit comment leaves
(svelte only — in html/xml a // inside a tag is ordinary bogus attribute
text, not a comment).
type boolean
lex_expressionLexes a {…} expression at from, returning the position after it —
the svelte hook, null for html/xml. full enables block/each forms
(top level); tag and attribute contexts get the simple form.
type ((l: Lexer, from: number, end: number, full: boolean) => number) | null
MarkupProbeCache import type {MarkupProbeCache} from '@fuzdev/fuz_code/lexer_markup.js'; Monotonic next-occurrence caches for the markup scanner's probes (see
advance_probe). The scan visits constructs in increasing position order,
but its probes (</{ between constructs, & in text gaps and attribute
values) target chars the current construct doesn't consume — without the
caches, input dense in one probe char but lacking another re-scans the
document tail per construct, quadratic in document size. One cache spans a
whole window scan (or a whole md document scan, threaded through
lex_markup_construct); embedded guest windows create their own.
lttype number
bracetype number
amptype number
(text: string, i: number, end: number): number import {scan_entity_end} from '@fuzdev/fuz_code/lexer_markup.js'; Scans an entity reference at the & at i, returning its exclusive end or
-1. Accepts a named form (1–8 case-insensitive alphanumerics, &…;) and a
numeric form (&#…; or &#x…;, 1–8 hex digits allowed in both).
textstringinumberendnumbernumber