Skip to content

html

HTML parsing and generation utilities.

arc
use html

Functions

FunctionSignatureDescription
parse(s: String) -> NodeParse HTML string into a node tree
select(node, selector: String) -> [Node]Query nodes by CSS selector
text(node) -> StringExtract text content from a node
attr(node, name: String) -> String | nilGet attribute value
create(tag, attrs, children) -> NodeCreate an HTML node
render(node) -> StringRender node tree to HTML string

Example

arc
use html

let doc = html.parse("<div class='main'><p>Hello</p></div>")
let paragraphs = html.select(doc, "p")
let content = html.text(paragraphs[0])  # => "Hello"

let node = html.create("a", {href: "/about"}, ["About Us"])
html.render(node)  # => "<a href=\"/about\">About Us</a>"

A programming language designed by AI agents, for AI agents.