HTX Guide · 1.5.0-alpha.2
Formatter
Canonical HTX formatting rules.
HTX 1.5.0-alpha.2 (reference implementation 0.3.0-alpha.3) — Features below are available in the
htxCLI unless noted as browser-only.
Status: Shipped — htx format in CLI
Goals
- One canonical HTX style for humans and agents
- Round-trip:
format(parse(htx))preserves semantics - Minimal diff noise in version control
Rules
Document
- Single trailing newline at EOF
- One blank line between top-level blocks
- Frontmatter keys alphabetically sorted (optional, recommended)
Block directives
::section { #main .container }
::card [Title] { .highlight }
Content line one.
Content line two.
::
::
| Rule | Value |
|---|---|
| Child indent | 2 spaces |
Close :: |
Same column as open :: |
| Attribute order | #id, .classes (alpha), key="value" (alpha) |
| Argument position | Before attributes: [Title] { .x } |
Inline
- No space before
:tag{ - Spaces inside
[ text ]preserved
CommonMark
- ATX headings with space after
# - Lists use
-consistently (configurable) - Fenced code: language on open fence
CLI (planned)
htx format document.htx --write
htx format document.htx --check # exit 1 if not formatted
Agent guidance
Agents SHOULD emit formatted HTX to reduce parser variance and improve diff readability.