Expand description
The LGX HTML tokenizer — real markup for the View: section of a component.
Flat and pure: a raw view body becomes start/end tags, text runs and {…} brace groups,
each with the byte span it came from. Nothing here knows the LOGOS expression grammar
(a brace group’s inner text is handed to the template parser, which hands holes to the
real expression parser) and nothing here builds a tree (nesting, whitespace collapse and
template tags live in super::template). What it does own:
- tag and attribute syntax: quoted, unquoted and valueless attributes;
/>; the HTML void elements, which never take an end tag; {…}groups in text and inside attribute values — scanned STRING- and NESTING-aware, so a LOGOS interpolation inside a hole ({greet("{x}")}) stays one group and a quoted"}"cannot end one;- character references (
&,©,A) in text and static attribute values; <!-- -->comments (dropped);- the refusals a component template must make:
<script>,<style>and a doctype are not a view’s business (styles live inStyle:, the document shell in a layout).
Errors carry the span of the offending construct and a message that names the fix.
Structs§
Enums§
- Attr
Part - One piece of a dynamic attribute value.
- Attr
Value - An attribute’s value.
- Behaviour
- The behavioural qualifiers: they shape what happens to the event, not which event it is.
- Event
Modifier - What an
on-<event>.<modifier>qualifier asks for. Every tier reads a handler’s modifiers through this type; the words themselves live only in the tables below. - Html
Error Kind - Html
Token - One flat token of a view body.
- KeyName
- A key a keyboard qualifier names: one from
KEY_MODIFIERS, or a single printable character. - Modifier
Error - Why a handler’s qualifiers cannot be accepted.
- System
Key - The system keys a qualifier may require to be held.
Constants§
- ATTR_
ESCAPES - The same, plus the quote that delimits an attribute value.
- BEHAVIOUR_
MODIFIERS (qualifier, behaviour)— the behavioural modifiers.- BOOLEAN_
ATTRIBUTES - The HTML BOOLEAN attributes: their state is their PRESENCE, and the value is ignored.
- EXECUTABLE_
SCHEMES - Schemes a browser EXECUTES rather than fetches. A URL carrying one is script, not a location.
- HTML_
ELEMENTS - The HTML elements, as the WHATWG HTML standard names them (plus the
svgandmathroots of the foreign content it embeds). - KEY_
EVENTS - The events that carry a key. A key qualifier on any other event could never match.
- KEY_
MODIFIERS (qualifier, KeyboardEvent.key)— the named keys a keyboard handler may wait for. The second column is what a browser reports for the key and what a drivingPressnames; the two are compared case-insensitively.- SYSTEM_
KEY_ MODIFIERS (qualifier, key)— the system keys.- TEXT_
ESCAPES - The attributes whose value is a URL the BROWSER will follow, fetch or submit to.
- URL_
ATTRIBUTES - VOID_
ELEMENTS - The HTML void elements: they never take an end tag.
Functions§
- classify_
modifiers - Classify every qualifier of one
on-<event>.<…>directive against the catalogue. - decode_
entities - escape_
attr - Escape
sfor an HTML ATTRIBUTE value. - escape_
text - Escape
sfor HTML TEXT content. - is_
boolean_ attribute - is_
component_ name - Whether
namenames a component use (<TodoRow>) rather than an HTML element: LGX components are Capitalized, HTML tags are lowercase. - is_
executable_ url - Whether
urlwould execute if a browser followed it. - is_
html_ element - is_
key_ event - Whether
eventis one ofKEY_EVENTS. - is_
raw_ text - The HTML RAW TEXT elements: their content is not markup, and escaping it CORRUPTS it.
- is_
selector_ shaped - Whether
targetreads as a CSS selector for a mount point rather than a file path: an id (#root), a class (.app), an attribute test ([data-app]), or exactly an element name (main,body). - is_
url_ attribute - is_void
- scan_
brace - Scan the
{…}group opening at byteopen; returns the index just past its}. String-aware (a"…"may contain braces;\"is an escaped quote) and nesting-aware. - tokenize
- Tokenize a raw view body.