Skip to content

v0.9.0

Choose a tag to compare

@github-actions github-actions released this 26 Jul 16:01
· 13 commits to main since this release

--json-nodes — full node dumps for jq

pup's json{}, with a cleaner shape. Each match becomes one NDJSON object:

$ cull '.post h2 a' --json-nodes blog.html
{"tag":"a","attrs":{"href":"/posts/hello"},"text":"Hello, world","children":["Hello, world"]}
  • attrs is its own object — pup inlines attributes next to tag/text, so an attribute literally named tag collides; here it can't
  • text on every node is the collapsed subtree text (layout-aware: <br>/block boundaries become spaces, script/style excluded)
  • children interleaves child element objects with text-node strings — full structure, comments dropped
  • URL attributes (href, src, …) respect -b/--base, and auto-resolve when the input is a fetched URL
  • --array merges everything into one JSON array; -p pretty-prints — same as -j

It's also the escape hatch for raw <script> payloads, e.g. JSON-LD structured data:

$ cull 'script[type="application/ld+json"]' --json-nodes page.html \
    | jq '.children[0] | fromjson | {name, datePublished}'

When you'd rather name the fields up front and skip the jq pass, -j templates are still the short way: cull a -j '{url: . @href, text: .}'.

140 tests.

Install: brew install rashida-thorne/cull/cull · cargo binstall cull · scoop bucket add cull https://github.com/rashida-thorne/scoop-cull && scoop install cull · nix run github:rashida-thorne/cull · more options

Full changelog: https://github.com/rashida-thorne/cull/blob/main/CHANGELOG.md