Skip to main content

Module html

Module html 

Source
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 in Style:, the document shell in a layout).

Errors carry the span of the offending construct and a message that names the fix.

Structs§

HtmlAttr
One attribute of a start tag.
HtmlError

Enums§

AttrPart
One piece of a dynamic attribute value.
AttrValue
An attribute’s value.
Behaviour
The behavioural qualifiers: they shape what happens to the event, not which event it is.
EventModifier
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.
HtmlErrorKind
HtmlToken
One flat token of a view body.
KeyName
A key a keyboard qualifier names: one from KEY_MODIFIERS, or a single printable character.
ModifierError
Why a handler’s qualifiers cannot be accepted.
SystemKey
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 svg and math roots 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 driving Press names; 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 s for an HTML ATTRIBUTE value.
escape_text
Escape s for HTML TEXT content.
is_boolean_attribute
is_component_name
Whether name names a component use (<TodoRow>) rather than an HTML element: LGX components are Capitalized, HTML tags are lowercase.
is_executable_url
Whether url would execute if a browser followed it.
is_html_element
is_key_event
Whether event is one of KEY_EVENTS.
is_raw_text
The HTML RAW TEXT elements: their content is not markup, and escaping it CORRUPTS it.
is_selector_shaped
Whether target reads 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 byte open; 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.