On this page
  1. astree
  2. Role
  3. Install
  4. Quickstart
  5. When to Reach for It
  6. Gotchas & Pitfalls
  7. Pairs With
  8. Metadata

astree

Prev: sametime | Up: projects | Next: parse-md
Rel: wispsy, Foundation, parse-html5, builtouts
Ref: wispsy on GitHub | astree pyproject.toml
Tags: #public #wispsy #project #foundation #tier/core


Role

Shared structural traversal (walk, ancestors, descendants, transform) with specialized HTML (html.parser), JSON, Markdown, Python, and optional JavaScript (tree-sitter) syntax-tree adapters, plus CSS selectors and declarative Field extraction.

Install

pip install astree
# Optional JavaScript adapter (tree-sitter):
pip install "astree[javascript]"

Quickstart

from astree import Document, Field, extract_all

doc = Document.from_html('<article class="card" data-id="42"><h2>Headline</h2></article>')
records = extract_all(doc, "article.card", {
    "id": Field(attribute="data-id", convert=int),
    "headline": Field("h2"),
})
assert records == [{"id": 42, "headline": "Headline"}]

When to Reach for It

Gotchas & Pitfalls

Pairs With


Metadata

type: project-card
slug: astree
org: wispsy
repo: wispsy/astree
package: astree
version: 0.1.1
requires_python: ">=3.14"
layer: foundation
topic: wispsy-foundation
status: active
language: python
source_docs: README.md, docs/

Linked from

Related notes