Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the clss Reference Manual, version 0.3.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 13:06:07 2020 GMT+0.
• Introduction | What clss is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
CLSS is a DOM traversal engine based on CSS selectors. It makes use of the Plump-DOM and is used by lQuery.
Load CLSS through Quicklisp or ASDF:
(ql:quickload :clss)
Using a standard CSS selector you can retrieve a vector of nodes from the DOM:
(clss:select "img" (plump:parse "<div><p>A beautiful image: <img src="//example.com/image.png" alt="image" /></p></div>"))
CLSS implements Level 3 selectors and offers most of the features from the spec. Some things were left out as they make no sense outside a CSS context.
As Plump supports XML as well as HTML, it also includes special handling for a few nodes that are not elements and are thus not reachable by standard CSS selectors. In order to solve this problem, CLSS adds an extra operator, the ^
caret. The caret is followed by a Plump-DOM class-name and will then match any elements that conform to a typep
test against it.
(clss:select "^CDATA" (plump:parse "<foo><![CDATA[bar]]></foo>"))
CSS selectors in themselves also don't support XML namespaces due to the ambiguity arising with pseudo-selectors. CLSS solves this by interpreting a double colon as a name. Thus, a tag with the name of foo:bar
is selected by foo::bar
.
CLSS attempts to be a fast engine and various parts of it have been tuned for this purpose, which limits the extensibility of CLSS a bit. However, it is still possible to f.e. programmatically construct a selector.
Using define-pseudo-selector
you can add your own extensions to CLSS:
(clss:define-pseudo-selector outside-link (node)
(let ((href (plump:attribute node "href")))
(and href (cl-ppcre:scan "^(http|https)://" href))))
(clss:select "a:outside-link" (plump:parse "<foo><a href=\"/baloney\"/><a href=\"http://example.com\"/></foo>"))
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The clss system |
Nicolas Hafner <shinmera@tymoon.eu>
Nicolas Hafner <shinmera@tymoon.eu>
(:git "https://github.com/shinmera/clss.git")
zlib
A DOM tree searching engine based on CSS selectors.
0.3.1
clss.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The clss.asd file | ||
• The clss/package.lisp file | ||
• The clss/selector.lisp file | ||
• The clss/parser.lisp file | ||
• The clss/engine.lisp file | ||
• The clss/pseudo-selectors.lisp file |
Next: The clss/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
clss.asd
clss (system)
Next: The clss/selector․lisp file, Previous: The clss․asd file, Up: Lisp files [Contents][Index]
Next: The clss/parser․lisp file, Previous: The clss/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
clss (system)
selector.lisp
make-group (function)
Next: The clss/engine․lisp file, Previous: The clss/selector․lisp file, Up: Lisp files [Contents][Index]
selector.lisp (file)
clss (system)
parser.lisp
parse-selector (function)
Next: The clss/pseudo-selectors․lisp file, Previous: The clss/parser․lisp file, Up: Lisp files [Contents][Index]
parser.lisp (file)
clss (system)
engine.lisp
Previous: The clss/engine․lisp file, Up: Lisp files [Contents][Index]
engine.lisp (file)
clss (system)
pseudo-selectors.lisp
match-nth (function)
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The clss package |
package.lisp (file)
org.shirakumo.clss
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros | ||
• Exported compiler macros | ||
• Exported functions | ||
• Exported generic functions | ||
• Exported conditions |
Next: Exported compiler macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Define a new pseudo-selector of NAME.
NAME — A symbol or string naming the selector (case insensitive always).
NODENAME — A variable symbol the matched node is bound to.
ARGS-LAMBDA — A lambda-list of the expected arguments for the pseudo-selector.
Note that keyword arguments make no sense in this context.
BODY ::= form*
engine.lisp (file)
Next: Exported functions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
engine.lisp (file)
engine.lisp (file)
Next: Exported generic functions, Previous: Exported compiler macros, Up: Exported definitions [Contents][Index]
selector.lisp (file)
selector.lisp (file)
selector.lisp (file)
selector.lisp (file)
selector.lisp (file)
selector.lisp (file)
selector.lisp (file)
selector.lisp (file)
selector.lisp (file)
Attempts to match the CONSTRAINT form against the node. Returns NIL if it fails to do so, unspecified otherwise.
engine.lisp (file)
Match a matcher group against the root-node and possibly all its children. Returns an array of mached nodes.
engine.lisp (file)
engine.lisp (file)
Attempts to match a matcher against a node. Returns T if all constraints match, NIL otherwise.
engine.lisp (file)
Match a selector against the root-node and possibly all its children. Returns an array of matched nodes.
engine.lisp (file)
Tests whether the node matches the selector.
SELECTOR — A CSS-selector string or a compiled selector list. NODE — The node to test.
engine.lisp (file)
Parse a selector string into its "compiled" list form.
parser.lisp (file)
Returns the pseudo-selector function associated with NAME, if any.
engine.lisp (file)
(setf pseudo-selector) (function)
Sets FUNCTION as the pseudo-selector for NAME.
engine.lisp (file)
pseudo-selector (function)
Removes the pseudo-selector associated with NAME.
engine.lisp (file)
Match the given selector against the root-node and possibly all its children.
Returns an array of matched nodes.
SELECTOR — A CSS-selector string or a compiled selector list.
ROOT-NODE — A single node, list or vector of nodes to start matching from.
SEARCH-TYPE — Select the search algorithm, options are ":depth-first" and ":breadth-first".
engine.lisp (file)
Next: Exported conditions, Previous: Exported functions, Up: Exported definitions [Contents][Index]
engine.lisp (file)
engine.lisp (file)
engine.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
Condition signalled when a pseudo selector is defined according to spec, but makes no sense in the context of CLSS and has thus been left unimplemented.
engine.lisp (file)
error (condition)
:name
(quote (error "name required."))
name (generic function)
(setf name) (generic function)
Signalled when a selector or matcher has been found to be malformed.
This really shouldn’t happen unless you’re passing raw lists
for the selector to the matcher.
engine.lisp (file)
error (condition)
:selector
(quote (error "selector malformed."))
selector (generic function)
(setf selector) (generic function)
Condition signalled when trying to use a pseudo selector that has not been defined. This is signalled at match-time, rather than at selector-compile-time.
engine.lisp (file)
error (condition)
:name
(quote (error "name required."))
name (generic function)
(setf name) (generic function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal functions | ||
• Internal generic functions | ||
• Internal conditions |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
Hash table for pseudo selector functions.
Links string names to functions of one or more arguments.
engine.lisp (file)
parser.lisp (file)
Next: Internal generic functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
parser.lisp (file)
Returns ITEM if it is an element of STRING split by the SPLIT character.
engine.lisp (file)
selector.lisp (file)
pseudo-selectors.lisp (file)
Match a combinator and matcher pair against a list of nodes. Returns a vector of matching nodes.
engine.lisp (file)
Match a combinator and matcher pair against a list of nodes. For every match the function specified in "MATCHING-NODES-PROCESSOR" is called with the found match as the only argument.
engine.lisp (file)
Reads an any constraint and returns it.
parser.lisp (file)
Reads an attribute comparator string and returns it if found.
parser.lisp (file)
Reads a complete attribute constraint and returns it.
parser.lisp (file)
Reads an attribute value and returns it.
parser.lisp (file)
Reads a class constraint and returns it.
parser.lisp (file)
Reads the combinator between matchers and returns it.
parser.lisp (file)
Read any constraint. Dispatches depending on the next character consumed.
parser.lisp (file)
Reads a selector group and returns it.
parser.lisp (file)
Reads an ID attribute constraint and returns it.
parser.lisp (file)
Read a matcher (a sequence of constraints) and return it.
parser.lisp (file)
Reads a CSS selector name-like string.
parser.lisp (file)
Reads an arguments list of a pseudo selector.
parser.lisp (file)
Reads a complete pseudo constraint and returns it.
parser.lisp (file)
Reads a complete selector and returns it.
parser.lisp (file)
Reads a tag constraint and returns it.
parser.lisp (file)
Reads a DOM type constraint and returns it.
parser.lisp (file)
Next: Internal conditions, Previous: Internal functions, Up: Internal definitions [Contents][Index]
engine.lisp (file)
Previous: Internal generic functions, Up: Internal definitions [Contents][Index]
Condition signalled to immediately return from MATCH-PAIR.
engine.lisp (file)
condition (condition)
:value
(quote nil)
value (generic function)
(setf value) (generic function)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | C F L |
---|
Jump to: | C F L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
C D E F G M N P R S V |
---|
Jump to: | (
C D E F G M N P R S V |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | %
*
S |
---|
Jump to: | %
*
S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C P S U |
---|
Jump to: | C P S U |
---|