Skip to main content

Crate xtxt

Crate xtxt 

Source
Expand description

XTXT — a plain-text document format with structure.

A dependency-free implementation of the format defined in SPEC.md. This is a port of the Go reference implementation, not a binding: it agrees with it because both are checked against the same conformance suite.

let res = xtxt::parse("# Hello\n\nworld\n");
assert_eq!(res.doc.nodes.len(), 2);
assert_eq!(res.doc.nodes[0].kind, xtxt::Kind::Heading);

Structs§

Arg
One argument of a directive. key is empty for a positional argument.
Args
A directive’s arguments, in source order.
Block
A structured directive as an agent sees it.
Code
Document
A parsed document.
Extraction
The machine-facing view of a document: everything an agent needs without having to infer structure from prose.
Field
One Key: value entry in a block payload.
Fields
A block payload read as an ordered record. Order matters: a @chat block’s turns are fields, and their sequence is the conversation.
Issue
A diagnostic tied to a line of source.
Item
One entry in a list. checked is None unless it is a checklist item.
Link
Media
Node
A single block in the document tree.
Outline
One heading in the table of contents.
ParseResult
The outcome of parsing. A document is always returned, even when issues contains errors — recovery is part of the format’s compatibility guarantee.
Table
The interpreted payload of an @table block.
Task
A unit of work, from either a @task block or a checklist item.

Enums§

Kind
The type of a Node.
Severity
How serious a diagnostic is.

Functions§

extract
Build the machine-facing view of a document.
inline_html
Convert inline markup to HTML, escaping everything else.
inline_text
Strip inline markup, for plain text and analysis.
parse
Parse an XTXT document. Parsing never fails: unrecognised content becomes a diagnostic, not a lost node.
parse_fields
Interpret a block payload as an ordered record. Lines before the first field become the empty key, so nothing is lost.
parse_table
render_html
Render a document to an HTML fragment.
sort_issues
Order issues by line for stable reporting.
source_of
Reconstruct a directive’s source, for round-tripping and for showing unknown directives.
validate
Semantic checks with no plugin-declared directives.
validate_with
Semantic checks on top of the parser’s syntactic ones.