Documentation
¶
Overview ¶
Package md2a2ui converts Markdown text into A2UI component trees.
It uses goldmark to parse CommonMark markdown and walks the resulting AST, emitting a flat list of A2UI components connected by ID references in the adjacency-list model the A2UI protocol expects.
The output is a complete updateComponents message, ready to marshal as JSON and send to any A2UI renderer that uses the v0.9 basic catalog.
Index ¶
Constants ¶
const Version = "v0.9"
Version is the A2UI protocol version this library targets.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component struct {
ID string `json:"id"`
Component string `json:"component"`
Text string `json:"text,omitempty"`
Variant string `json:"variant,omitempty"`
Children []string `json:"children,omitempty"`
Child string `json:"child,omitempty"`
Axis string `json:"axis,omitempty"`
URL string `json:"url,omitempty"`
AltText string `json:"altText,omitempty"`
Direction string `json:"direction,omitempty"`
}
Component is a single A2UI component in the adjacency-list model. Only the fields relevant to the markdown→A2UI mapping are included; the struct uses omitempty on optional fields so the JSON stays clean.
type Message ¶
type Message struct {
Version string `json:"version"`
UpdateComponents *UpdateComponents `json:"updateComponents"`
}
Message is a top-level A2UI agent-to-renderer message containing an updateComponents payload. Marshal it to JSON and send it to a renderer that already has a surface created.
func Convert ¶
Convert parses markdown and returns a complete updateComponents A2UI message. The component tree is rooted in a Column whose id is "root".
A custom surfaceId can be set via the ConvertWithSurface function.
func ConvertWithSurface ¶
ConvertWithSurface is like Convert but lets the caller choose the surfaceId that appears in the updateComponents message.
func (*Message) EnsureRootValid ¶
EnsureRootValid verifies that the component list has exactly one component with id "root". A2UI requires this.
type UpdateComponents ¶
type UpdateComponents struct {
SurfaceID string `json:"surfaceId"`
Components []Component `json:"components"`
}
UpdateComponents is the A2UI message body that carries a flat list of component definitions for a specific surface.