Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A common lisp library that implements a css3 selector query language on CXML DOM documents and Nodes

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 src
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 COPYING
Octocat-spinner-32 README.mediawiki
Octocat-spinner-32 css-selectors.asd
README.mediawiki

Table of Contents

css-selectors: a jquery-style dom query language

CSS-selectors is a query language for finding specific nodes in cxml dom documents and dom sub trees.

API

query

 (query 
   (or css-selector-string match-fn)
   (or nodes *document*))

Similar to jQuery('css-selector', NodeList or *document*)

Returns a list of matching nodes.

if the second argument is a css-selector, compile it (as with compile-css-node-matcher) into a matcher function and call query again with it

if the second argument is a function, it is assumed to take a single node and to test whether or not that node matches the css-selector match function

If the css-selector-string is constantp, it will be compiled at compile time

node-matches?

 (node-matches? node-node (or match-fn css-selector-string))

if the second argument is a css-selector, compile it (as with compile-css-node-matcher) into a matcher function and call node-matches again with it

if the second argument is a function, it is assumed to take a single node and to test whether or not that node matches the css-selector match function

If the css-selector-string is constantp, it will be compiled at compile time

parse-results

 (parse-results inp)

Parses a css3 selector into an AST representing the selector expression. Probably only useful for debugging or implementing a different compiler.

Uses clppcre and *VERY* basic flex parser (defined in parse.lisp) to create a lexer. Combines that lexer with a parser generated by cl-yacc and runs the input through the parse.

compile-css-node-matcher

 (compile-css-node-matcher inp)

Turns a parse-tree or css-selector-string into a compiled lambda matcher function this matcher function can be used with query and node-matches?. The matcher function takes two arguments

Pseudo Selectors

Implementing new pseudo selectors

Any function defined in the :pseudo (:css-selectors.pseudo) will be available as a pseudo selector (see pseudo.lisp for examples).

All pseudo selectors should be of the following format: (defun pseudo:MY-NEW-PSEUDO (node &optional sub-sel-function) ...)

If your pseudo selector has no args, then it should signal an error if a sub-selction-function is passed to it and vice-versa

Authors

;; Copyright (c) 2011 Russ Tyndall , Acceleration.net http://www.acceleration.net
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are
;; met:
;;
;;  - Redistributions of source code must retain the above copyright
;;    notice, this list of conditions and the following disclaimer.
;;
;;  - Redistributions in binary form must reproduce the above copyright
;;    notice, this list of conditions and the following disclaimer in the
;;    documentation and/or other materials provided with the distribution.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
;; A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Something went wrong with that request. Please try again.