CSS selectors for querying and processing HTML trees in HXT
Haskell
Switch branches/tags
Nothing to show
Pull request Compare This branch is 4 commits behind shangaslammi:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Text/XML/HXT
test-html
.gitignore
LICENSE
README.md
hxt-css-selectors.cabal
test-css.hs

README.md

CSS Selectors for HXT

This package adds css-style selectors to HXT that can be used for both querying and for processing sub-trees of HTML/XML documents.

CSS selectors are constructed either with the quasi-quoter css which allows for compile time validation of the selector patterns, or by using the function parseSelector :: String -> Maybe Selector.

Examples

-- Find each link that is inside a text paragraph in the main content
links = select [css|#content p a|] >>> getAttributeValue "href"

-- Change every unordered list that is a direct child of a div into an ordered list
ulToOl = process [css|div > ul|] $ setElemName (mkName "ol")

Current Status

hxt-css-selectors is a new project that is still mostly incomplete and highly unstable. My current priorities are

  1. Complete test suite that covers all the interesting parts of the CSS Level 3 Selectors document (in progress)
  2. Implementation that passes all tests (but might be ugly/hacky)
  3. Clean and elegant implementation
  4. Performance optimizations