The lquery Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The lquery Reference Manual

This is the lquery Reference Manual, version 3.2.0, generated automatically by Declt version 2.3 "Robert April" on Tue Feb 20 09:02:15 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

About lQuery

lQuery is a DOM manipulation library written in Common Lisp, inspired by and based on the jQuery syntax and functions. It uses Plump and CLSS as DOM and selector engines. The main idea behind lQuery is to provide a simple interface for crawling and modifying HTML sites, as well as to allow for an alternative approach to templating.

How To

Load lQuery with ASDF or Quicklisp.

(ql:quickload :lquery)

First, lQuery needs to be initialized with a document to work on:

(defvar *doc* (lquery:$ (initialize (asdf:system-relative-pathname :lquery "test.html"))))

After that, you can use the $ macro to select and manipulate the DOM:

(lquery:$ *doc* "article")
(lquery:$ *doc* 
  "article"
  (add-class "fancy")
  (attr "foo" "bar"))

To render the HTML to a string use SERIALIZE. If you want to save it to a file directly, there's also WRITE-TO-FILE.

(lquery:$ *doc* (serialize))
(lquery:$ *doc* (write-to-file #p"~/plump-test.html"))

So a quick file manipulation could look something like this:

(lquery:$ (initialize (asdf:system-relative-pathname :lquery "test.html"))
  "article"
  (append-to "#target")
  (add-class "foo")
  (root)
  (write-to-file #p"~/plump-test.html"))

Aside from using selectors as the first step, it's also possible to use any other variable or list and operate on it.
Since 2.0: Literal function calls need to be added with INLINE. Note that the result of the inline function will be used as if literally put in place. For example, an inlined function that evaluates to a string will result in a CSS-select.

(lquery:$ (inline (list node-a node-b))
  "article"
  (serialize))

Selectors can come at any point in the sequence of lQuery operations and will always act on the current set of elements. If an operation evaluates to a list, array, vector or a single node, the current set of elements is set to this result.

(lquery:$ *doc*
  "a"
  (text "Link")
  (inline (lquery:$ *doc* "p"))
  (text "Paragraph"))

This is equivalent to the following:

(lquery:$ *doc*
  "a" (text "Link"))
(lquery:$ *doc*
  "p" (text "Paragraph"))

Functions in the argument list will be translated to a function invocation with the current list of elements as their argument.

(lquery:$ *doc*
  "a" #'(lambda (els) (aref els 0)))

lQuery2.0 also supports compile-time evaluation of forms, whose results are then put in place of their function calls:

(lquery:$ *doc* (eval (format NIL "~a" *selector*)))

Keep in mind that the lexical environment is not the same at compile-time as at run-time.

Often times you'll also want to retrieve multiple, different values from your current set of nodes. To make this more convenient, you can use the COMBINE form:

(lquery:$ *doc*
  "a"
  (combine (attr :href) (text))
  (map-apply #'(lambda (url text) (format T "[~a](~a)" text url))))

lQuery uses vectors internally to modify and handle sets of nodes. These vectors are usually modified instead of copied to avoid unnecessary resource allocation. This however also means that lQuery functions are possibly side-effecting. If you pass an adjustable vector into lQuery through INLINE or similar, it will not be copied and therefore side-effects might occur. lQuery will automatically copy everything else that isn't an adjustable vector through ENSURE-PROPER-VECTOR. If you do want to pass in an adjustable vector, but make sure it doesn't affect it, use COPY-PROPER-VECTOR.

Test Suite

To ensure that functions are at least somewhat stable in their behaviour, lQuery includes a test suite. You can load this through Quicklisp/ASDF with

(ql:quickload :lquery-test)
(lquery-test:run)

The tests are rather loose, but should cover all functions to at least behave mostly according to expectation.

Extending lQuery3.1

lQuery allows extension in a couple of ways. The most important of which are node functions themselves, which come in two flavours: lquery-funs and lquery-list-funs. Any lquery function resides in the package LQUERY-FUNCS, which is automatically scanned by the $ macro. The two macros responsible for defining new lquery functions automatically place the resulting operations in this package for you.

(define-lquery-function name (node-name &rest arguments) &body body)
(define-lquery-list-function name (vector-name &rest arguments) &body body)

Any function generated by these macros can be called either with a single node or a vector of nodes. In the case of a regular node operation, if it receives a vector of nodes, the function is called once for each node and the results are collected into a vector, which is then returned. If it receives a single node, only a single result is returned. In the case of a node list function, the return value can be either a vector or a single value, depending on what the goal of the operation is. It is expected that node list functions will modify the given vector directly in order to avoid unnecessary copying.

Some constructs would be very cumbersome to write as functions, or would simply be more suited in the form of a macro. To allow for this, lQuery3.1 includes a mechanism of $ local macros. The previously mentioned forms like INLINE are handled through this system. Just like lquery functions, lquery macros reside in their own package LQUERY-MACROS. The responsible macro for defining new lquery macros will automatically place it in there for you.

(define-lquery-macro name (previous-form &rest arguments) &body body)

The $ macro itself can be extended as well by providing additional argument- or value-handlers. The following two macros make this possible:

(define-argument-handler type (argument-name operator-name) &body body)

Argument handlers transform the arguments at compile-time. For example, this would allow an extension to turn literal arrays into lists so they can be processed as well.

(define-value-handler type (variable-name operator-name) &body body)

Value handlers on the other hand determine the action at run-time. This is mostly useful for defining special actions on certain variable values.

What's New

3.1.0

Renamed DEFINE-NODE-\* macros into more sensible DEFINE-LQUERY-*. Added macro system, new standard COMBINE macro.

3.0.0

Complete rewrite of everything. This version is compatibility breaking. While the node functions themselves perform just the same as before (with one or two exceptions), lQuery now uses vectors instead of lists internally. If you ever relied on lQuery return values, this version will most likely break your code. Effort has been made to keep upgrading as simple as possible though; passing lists into an lQuery chain automatically transforms it for example.

Thanks to the change to Plump, lQuery is now also able to parse almost any kind of X/HT/ML document, which was not well possible previously. And thanks to switching to CLSS, lQuery is now much faster at selecting nodes from the DOM.

2.0.0

Added extension system and INLINE, EVAL handling. Revamped base macros to be more stable and simple.

Further Reading


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 lquery

Maintainer

Nicolas Hafner <shinmera@tymoon.eu>

Author

Nicolas Hafner <shinmera@tymoon.eu>

Home Page

https://github.com/Shinmera/lquery

License

Artistic

Description

A library to allow jQuery-like HTML/DOM manipulation.

Version

3.2.0

Dependencies
Source

lquery.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 lquery.asd

Location

lquery.asd

Systems

lquery (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 lquery/package.lisp

Parent

lquery (system)

Location

package.lisp

Packages

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 lquery/toolkit.lisp

Dependency

package.lisp (file)

Parent

lquery (system)

Location

toolkit.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.4 lquery/lquery.lisp

Dependency

toolkit.lisp (file)

Parent

lquery (system)

Location

lquery.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.5 lquery/lquery-funcs.lisp

Dependency

lquery.lisp (file)

Parent

lquery (system)

Location

lquery-funcs.lisp

Exported Definitions
Internal Definitions

parent-lists (function)


Previous: , Up: Lisp files   [Contents][Index]

3.1.6 lquery/lquery-macros.lisp

Dependency

lquery-funcs.lisp (file)

Parent

lquery (system)

Location

lquery-macros.lisp

Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 lquery-macros

Source

package.lisp (file)

Nickname

org.shirakumo.lquery.macros

Exported Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

4.2 lquery-funcs

Source

package.lisp (file)

Nickname

org.shirakumo.lquery.funcs

Exported Definitions

Previous: , Up: Packages   [Contents][Index]

4.3 lquery

Source

package.lisp (file)

Nickname

org.shirakumo.lquery

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Special variables

Special Variable: *lquery-master-document*

The master document used at the beginning of a chain.

Package

lquery

Source

toolkit.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Macros

Macro: $ &body ACTIONS

Performs lQuery operations on the current document.

Each argument is executed in sequence. The arguments are evaluated according to the defined argument-handlers. By default, the following cases are handled:
* STRING Translates to a CLSS:QUERY on the current elements.
* FUNCTION Translates to a function call with the list of nodes as argument.
* SYMBOL Delegates to the value handlers.
* LIST Lists are transformed according to their first element, which must be a symbol. If the symbol’s name corresponds to a function found in the LQUERY-MACROS package, The form is assembled according to that function. Otherwise if it corresponds to an LQUERY-FUNCS function, it is expanded into a call to that function. If the symbol cannot be found in either package, it is put back in place, but the call itself is assembled like so: (FUNCTION PREVIOUS-RESULT ARGUMENT*)

Values are handled at runtime according to the defined variable-handlers. By default, the following cases are handled at run time:
* STRING Performs a CLSS:QUERY on the current elements.
* DOM:NODE Replaces the current set of nodes with just this node.
* FUNCTION Calls the given function with the current set of nodes as argument.
* LIST Lists are transformed into a proper vector.
* ARRAY Arrays are transformed into a proper vector.
* VECTOR Vectors that are not adjustable are transformed into a proper vector.
* T Any other value simply replaces the current list of nodes.

Package

lquery

Source

lquery.lisp (file)

Macro: $1 &body ACTIONS

This is the same as $, except it automatically uses NODE at the end and thus only returns the first result, if any.

Package

lquery

Source

lquery.lisp (file)

Macro: define-argument-handler TYPE (ARGUMENT-NAME OPERATOR-NAME) &body BODY

Defines a new argument handler that decides what to do with a certain type of argument at compile-time.

TYPE — A type or EQL specifier.
ARGUMENT-NAME — Symbol bound to the argument.
OPERATOR-NAME — Symbol bound to the object being operated on.
BODY ::= form*

Package

lquery

Source

lquery.lisp (file)

Macro: define-lquery-function NAME (NODE-NAME &rest ARGUMENTS) &body BODY

Defines a new node function. This is the main mechanism by which node manipulations are defined. All lquery functions are automatically created in the lquery-funcs package.

NAME — A symbol naming the lquery function. Automatically interned in the LQUERY-FUNCS package. NODE-NAME — Symbol bound to the current node.
ARGUMENTS — A lambda-list specifying the arguments for the function.
BODY ::= form*

Package

lquery

Source

lquery.lisp (file)

Macro: define-lquery-list-function NAME (VECTOR-NAME &rest ARGUMENTS) &body BODY

Defines a new function that operates on the current node array instead of individual elements.
All lquery functions are automatically created in the lquery-funcs package.

NAME — A symbol naming the lquery function. Automatically interned in the LQUERY-FUNCS package. VECTOR-NAME — Symbol bound to the node vector.
ARGUMENTS — A lambda-list specifying the arguments for the function.
BODY ::= form*

Package

lquery

Source

lquery.lisp (file)

Macro: define-lquery-macro NAME (PREVIOUS-FORM &rest ARGUMENTS) &body BODY

Define a new lquery local macro.
All lquery macros are automatically created in the lquery-macros package.

NAME — A symbol naming the lquery macro. Automatically interned in the LQUERY-MACROS package. PREVIOUS-FORM — Symbol bound to the so far assembled form, the previous value so to speak.
ARGUMENTS — A lambda-list specifying the arguments for the macro (note that this must be a standard lambda-list). BODY ::= form*

Package

lquery

Source

lquery.lisp (file)

Macro: define-lquery-subroutine NAME (&rest ARGUMENTS) &body BODY

Defines a shorthand function. The body is a set of lQuery instructions as you’d use in $.

NAME — A symbol naming the subroutine. Automatically interned in the LQUERY-FUNCS package. ARGUMENTS — A lambda-list specifying the arguments for the function.
BODY ::= lquery-form*

Package

lquery

Source

lquery.lisp (file)

Macro: define-value-handler TYPE (VARIABLE-NAME OPERATOR-NAME) &body BODY

Defines a new symbol handler that decides what to do with a certain type of symbol at run-time (variable type).

TYPE — A type or EQL specifier.
VARIABLE-NAME — Symbol bound to the argument.
OPERATOR-NAME — Symbol bound to the object being operated on.
BODY ::= form*

Package

lquery

Source

lquery.lisp (file)

Macro: with-master-document (&optional DOC) &body BODY

Surrounds the body in a binding for the *lquery-master-document* to ensure it does not get clobbered.

Package

lquery

Source

toolkit.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Functions

Function: add WORKING-NODES SELECTOR-OR-NODES

Add elements to the set of matched elements.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: add-class NODE &rest CLASSES

Adds the specified class(es) to the set of matched elements.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: after NODES HTML-OR-NODES

Insert content (in html-string or node-list form) after each element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: ancestor WORKING-NODES

Find the common ancestor of all elements.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: append NODES HTML-OR-NODES

Insert content (in html-string or node-list form) to the end of each element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: append-to WORKING-NODES SELECTOR-OR-NODES

Insert every element to the end of the target(s).

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: attr NODE &rest PAIRS

Retrieve or set attributes on a node.
The value on a node is turned into a string using PRINC-TO-STRING. If a value is NIL, the associated attribute is removed.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: before NODES HTML-OR-NODES

Insert content (in html-string or node-list form) before each element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: child-index NODE

Returns the index of the element within its parent, also counting text nodes. See index() otherwise.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: children NODES &optional SELECTOR

Get the children of each element, optionally filtered by a selector.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: clone NODE

Create a deep copy of the set of matched elements.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: closest NODE SELECTOR

For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. If no matching element can be found the root is entered instead.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: combine NODES &rest CALLS

COMBINES multiple lquery function calls into one by gathering them into a list for each element.

($ (combine (text) (attr :a))) would be equivalent to
($ (map #’(lambda (node) (list (lquery-funcs:text node) (lquery-funcs:attr node :a))))) This construct is especially useful in combination with MAP-APPLY.

Package

lquery-macros

Source

lquery-macros.lisp (file)

Function: contains NODES STRING

Select all elements that contain the specified text.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: contents NODES

Get the children of each element, including text and comment nodes.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: copy-proper-vector SEQUENCE &key TRANSFORM

Copies the sequence into a new proper vector.

Package

lquery

Source

toolkit.lisp (file)

Function: css NODE &rest PAIRS

Retrieve or set css style attributes on a node.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: data NODE &rest PAIRS

Retrieve or set data attributes on a node. This is a convenience method and uses attr in the back.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: deepest NODE

Returns the innermost (left-bound) child element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: detach NODES &optional SELECTOR

Removes the node (optionally filtered by the selector) from the document. Alias for remove()

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: each NODES FUN &key REPLACE

Execute the specified function on each element until NIL is returned or all elements have been processed. The original set of elements is returned if replace is NIL.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: empty NODE

Remove all child nodes from the set of matched elements.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: empty-p NODE

Check if the node contains no children and/or only empty (whitespace) text nodes. If it is empty, T is returned, otherwise NIL.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: ensure-proper-vector VAR

Ensure that the variable is a proper vector.

Package

lquery

Source

toolkit.lisp (file)

Function: eq WORKING-NODES INDEX

Reduce the set of matched elements to the one at the specified index

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: eval NODES FORM

Evaluates the form at compile-time and puts its resulting value in place.

Package

lquery-macros

Source

lquery-macros.lisp (file)

Function: even WORKING-NODES

Selects even elements, 1-indexed

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: filter NODES SELECTOR-OR-FUNCTION

Reduce the set of matched elements to those that match the selector or pass the function’s test.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: find NODES SELECTOR-OR-FUNCTION &key TEST-SELF

Get the descendants of each element filtered by selector or function.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: first WORKING-NODES

Reduce the set of matched elements to the first in the set.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: function NODES NAME

Macro to allow #’foo to be used in lquery chains.

Package

lquery-macros

Source

lquery-macros.lisp (file)

Function: gt WORKING-NODES INDEX

Select all elements at a greater than index(0) within the matched set.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: has NODES SELECTOR-OR-NODES

Reduce the set of matched elements to those that have a descendant that matches the selector or element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: has-class WORKING-NODES CLASS

Determine whether any of the matched elements are assigned to the given class.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: hide WORKING-NODES

Hide the matched elements (short for (css "display" "none")).

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: html NODE &optional NEW-CONTENT

Get the HTML contents of the elements or set the HTML contents of every matched element. If the new content is not a string, it is turned into one as per PRINC-TO-STRING.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: html-file WORKING-NODES PATHNAME

Read an HTML file and insert its contents into each element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: index NODE

Find the index of the node within its parent.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: initialize NODES &rest INIT-CALLS

See lquery function INITIALIZE.

This is merely a performance macro to avoid the unnecessary default allocation of a vector.

Package

lquery-macros

Source

lquery-macros.lisp (file)

Function: initialize WORKING-NODES DOCUMENT

Re-initializes lQuery with a new page.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: initialize DOCUMENT

Sets the *lquery-master-document* variable to the provided document.

Package

lquery

Source

toolkit.lisp (file)

Function: inline NODES FORM

Treats the form as if the evaluated value was put literally in place.

See DETERMINE-VALUE.

Package

lquery-macros

Source

lquery-macros.lisp (file)

Function: insert-after WORKING-NODES SELECTOR-OR-NODES

Insert every element after the target.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: insert-before WORKING-NODES SELECTOR-OR-NODES

Insert every element before the target.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: is WORKING-NODES SELECTOR-OR-NODES

Check the current elements against a selector or list of elements and return true if at least one of them matches.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: is-empty NODE

Check if the node contains no children and/or only empty (whitespace) text nodes. If it is empty, T is returned, otherwise NIL. Alias of EMPTY-P

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: last WORKING-NODES

Reduce the set of matched elements to the final one in the set.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: length WORKING-NODES

Returns the number of elements in the list.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: load-page FILE-OR-STRING

Load the given file or string into a HTML DOM.

Package

lquery

Source

toolkit.lisp (file)

Function: lt WORKING-NODES INDEX

Select all elements at an index less than the index within the matched set.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: make-proper-vector &key SIZE INITIAL-ELEMENT INITIAL-CONTENTS FILL-POINTER

Creates a new proper vector.

Package

lquery

Source

toolkit.lisp (file)

Function: map WORKING-NODES FUNCTION

Pass each element through a function (which has to accept one argument, the node), returning the list of all results.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: map-apply WORKING-NODES FUNCTION

Pass each element through a function by apply, returning the vector of all results. This is commonly useful in combination with COMBINE.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: next NODES &optional SELECTOR

Get the immediately following sibling of each element (if there is one). If a selector is provided, the sibling is only included if it matches.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: next-all NODES &optional SELECTOR

Get all following siblings of each element. If a selector is provided, the sibling is only included if it matches.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: next-until NODES SELECTOR-OR-NODES

Get all following silings of each element up to (excluding) the element matched by the selector or node list.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: node WORKING-NODES &optional N

Return the specified node (default first) directly, without encompassing it into a vector if it exists. Otherwise return NIL.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: not WORKING-NODES SELECTOR-OR-NODES

Remove matching elements from the working elements.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: not-empty NODE

Check if the node contains no children and/or only empty (whitespace) text nodes. If the node is effectively empty NIL is returned, otherwise T

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: odd WORKING-NODES

Select all odd elements from the current set, 1-indexed.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: parent NODES &optional SELECTOR

Get the parent of each element, optionally filtered by a selector.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: parents NODES &optional SELECTOR

Get the ancestors of each element, optionally filtered by a selector. Closest parent first.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: parents-until NODES SELECTOR-OR-NODES

Get the ancestors of each element, up to (excluding) the element matched by the selector or node list. Closest parent first

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: parse-html HTML

Build the given string into DOM objects related to the master document.

Package

lquery

Source

toolkit.lisp (file)

Function: prepend NODES HTML-OR-NODES

Insert content, specified by the parameter, to the beginning of each element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: prepend-to WORKING-NODES SELECTOR-OR-NODES

Insert every element to the beginning of the target(s).

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: prev NODES &optional SELECTOR

Get the immediately preceding sibling of each element (if there is one). If a selector is provided, the sibling is only included if it matches.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: prev-all NODES &optional SELECTOR

Get all preceeding siblings of each element. If a selector is provided, the sibling is only included if it matches.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: prev-until NODES SELECTOR-OR-NODES

Get all preceeding silings of each element down to (excluding) the element matched by the selector or node list.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: remove NODE &optional SELECTOR

Remove the set of matched elements from the DOM.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: remove-attr NODE &rest ATTRIBUTES

Remove attributes from each element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: remove-class NODE &rest CLASSES

Remove classes from each element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: remove-data NODE &rest DATA

Remove data attributes from each element. This is a convenience method and uses remove-attr in the back.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: render-text NODE

Return the "rendered" representation of the text inside the node and its children.

In effect the text is gathered from the component and all of
its children, but transforming the text in such a way that:
- All ASCII white space (Space, Tab, CR, LF) is converted into spaces.
- There are no consecutive spaces.
- There are no spaces at the beginning or end.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: replace-all WORKING-NODES SELECTOR-OR-NODES

Replace each in the set of matched elements with the current nodes.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: replace-with WORKING-NODES HTML-OR-NODES

Replace each element with the provided new content and return the set of elements that was removed.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: root WORKING-NODES

Returns to the root. Essentially traverses up the tree of the first element in the set until the root is reached.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: serialize NODE &optional STREAM FORMAT

Serialize the node into a string.

Allows two optional arguments:
STREAM — NIL to return a string, or a stream to output to. FORMAT — One of :DEFAULT, :HTML, :XML to designate the way in which to invoke Plump’s serializer.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: show WORKING-NODES

Display the matched elements (short for (css :display ’block’))

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: siblings NODES &optional SELECTOR

Get the siblings of each element, optionally filtered by a selector.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: size WORKING-NODES

Return the number of elements in the list.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: slice WORKING-NODES START &optional END

Reduce the set of matched elements to a subset specified by a range of indices

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: splice NODE

Splice the element’s contents in place of itself.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: text NODE &optional TEXT

Get the combined text contents of each element, including their descendants. If text is set, all text nodes are removed and a new text node is appended to the end of the node. If text is NIL, all direct text nodes are removed from the node. If text is not a string, it is transformed into one by PRINC-TO-STRING.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: toggle-class NODE &rest CLASSES

Add or remove one or more classes from each element, depending on their presence within the element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: unwrap NODE

Remove the parents of the set of matched elements from the DOM, inserting the parents children in place of it.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: val NODE &optional VALUE

Get the current values or set the value of every matched element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: wrap NODES HTML-OR-NODES

Wrap an HTML structure around each element. Note that always the first node of the structure to wrap is chosen.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: wrap-all WORKING-NODES HTML-OR-NODES

Wrap an HTML structure around all elements and put it in place of the first element, removing all other elements from their position.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: wrap-inner NODES HTML-OR-NODES

Wrap an HTML structure around the contents of each element.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)

Function: write-to-file WORKING-NODES FILE &key IF-DOES-NOT-EXIST IF-EXISTS

Write the serialized node to the file. Note that always only the first element is written.

Package

lquery-funcs

Source

lquery-funcs.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Macros

Macro: deflqfun NAME ARGS &rest FORMS
Package

lquery

Source

lquery.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: %$ ACTIONS
Package

lquery

Source

lquery.lisp (file)

Function: assure-attribute SYMBOL-OR-STRING
Package

lquery

Source

toolkit.lisp (file)

Function: build-elements HTML
Package

lquery

Source

toolkit.lisp (file)

Function: classes NODE
Package

lquery

Source

toolkit.lisp (file)

Function: funcs-or-select OBJECT

Return the object as a function or use it to construct a node-matches? function.

Package

lquery

Source

toolkit.lisp (file)

Function: get-css-styles NODE
Package

lquery

Source

toolkit.lisp (file)

Function: mkstr &rest ARGS

Concatenates args by printing into string.

Package

lquery

Source

toolkit.lisp (file)

Function: nodes-or-build OBJECT

Clone the object as a node list or use it to build a new HTML node.

Package

lquery

Source

toolkit.lisp (file)

Function: nodes-or-select OBJECT &optional ROOT

Return the object as a node list or use it to form a select query.

Package

lquery

Source

toolkit.lisp (file)

Function: nodes-or-selector-func OBJECT

Build a function matching the selector or checking the equality/inclusion of the object.

Package

lquery

Source

toolkit.lisp (file)

Function: parent-lists NODES
Package

lquery

Source

lquery-funcs.lisp (file)

Function: parse-css CSS
Package

lquery

Source

toolkit.lisp (file)

Function: replace-vector VECTOR FUNCTION
Package

lquery

Source

toolkit.lisp (file)

Function: replace-vector-if VECTOR CONDITION &key KEY
Package

lquery

Source

toolkit.lisp (file)

Function: set-css-styles NODE CSS-STYLES
Package

lquery

Source

toolkit.lisp (file)

Function: symb &rest ARGS

Interns the mkstr output/returns as symbol.

Package

lquery

Source

toolkit.lisp (file)

Function: trim STRING &optional CHARS
Package

lquery

Source

toolkit.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Generic functions

Generic Function: determine-argument ARG NODES

Determines what to do with a given argument at compile-time (static type).

Package

lquery

Source

lquery.lisp (file)

Methods
Method: determine-argument (STRING string) NODES
Method: determine-argument (SYMBOL symbol) NODES
Method: determine-argument (LIST list) NODES
Generic Function: determine-value SYMBOL NODES

Determines what to do with a given symbol at run-time (variable type).

Package

lquery

Source

lquery.lisp (file)

Methods
Method: determine-value (FUNCTION function) NODES
Method: determine-value (NODE node) NODES
Method: determine-value (SELECTOR string) NODES
Method: determine-value (VECTOR vector) NODES
Method: determine-value (ARRAY array) NODES
Method: determine-value (LIST list) NODES
Method: determine-value VARIABLE NODES

Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L  
Index Entry  Section

F
File, Lisp, lquery.asd: The lquery<dot>asd file
File, Lisp, lquery/lquery-funcs.lisp: The lquery/lquery-funcs<dot>lisp file
File, Lisp, lquery/lquery-macros.lisp: The lquery/lquery-macros<dot>lisp file
File, Lisp, lquery/lquery.lisp: The lquery/lquery<dot>lisp file
File, Lisp, lquery/package.lisp: The lquery/package<dot>lisp file
File, Lisp, lquery/toolkit.lisp: The lquery/toolkit<dot>lisp file

L
Lisp File, lquery.asd: The lquery<dot>asd file
Lisp File, lquery/lquery-funcs.lisp: The lquery/lquery-funcs<dot>lisp file
Lisp File, lquery/lquery-macros.lisp: The lquery/lquery-macros<dot>lisp file
Lisp File, lquery/lquery.lisp: The lquery/lquery<dot>lisp file
Lisp File, lquery/package.lisp: The lquery/package<dot>lisp file
Lisp File, lquery/toolkit.lisp: The lquery/toolkit<dot>lisp file
lquery.asd: The lquery<dot>asd file
lquery/lquery-funcs.lisp: The lquery/lquery-funcs<dot>lisp file
lquery/lquery-macros.lisp: The lquery/lquery-macros<dot>lisp file
lquery/lquery.lisp: The lquery/lquery<dot>lisp file
lquery/package.lisp: The lquery/package<dot>lisp file
lquery/toolkit.lisp: The lquery/toolkit<dot>lisp file

Jump to:   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   $   %  
A   B   C   D   E   F   G   H   I   L   M   N   O   P   R   S   T   U   V   W  
Index Entry  Section

$
$: Exported macros
$1: Exported macros

%
%$: Internal functions

A
add: Exported functions
add-class: Exported functions
after: Exported functions
ancestor: Exported functions
append: Exported functions
append-to: Exported functions
assure-attribute: Internal functions
attr: Exported functions

B
before: Exported functions
build-elements: Internal functions

C
child-index: Exported functions
children: Exported functions
classes: Internal functions
clone: Exported functions
closest: Exported functions
combine: Exported functions
contains: Exported functions
contents: Exported functions
copy-proper-vector: Exported functions
css: Exported functions

D
data: Exported functions
deepest: Exported functions
define-argument-handler: Exported macros
define-lquery-function: Exported macros
define-lquery-list-function: Exported macros
define-lquery-macro: Exported macros
define-lquery-subroutine: Exported macros
define-value-handler: Exported macros
deflqfun: Internal macros
detach: Exported functions
determine-argument: Internal generic functions
determine-argument: Internal generic functions
determine-argument: Internal generic functions
determine-argument: Internal generic functions
determine-value: Internal generic functions
determine-value: Internal generic functions
determine-value: Internal generic functions
determine-value: Internal generic functions
determine-value: Internal generic functions
determine-value: Internal generic functions
determine-value: Internal generic functions
determine-value: Internal generic functions

E
each: Exported functions
empty: Exported functions
empty-p: Exported functions
ensure-proper-vector: Exported functions
eq: Exported functions
eval: Exported functions
even: Exported functions

F
filter: Exported functions
find: Exported functions
first: Exported functions
funcs-or-select: Internal functions
function: Exported functions
Function, %$: Internal functions
Function, add: Exported functions
Function, add-class: Exported functions
Function, after: Exported functions
Function, ancestor: Exported functions
Function, append: Exported functions
Function, append-to: Exported functions
Function, assure-attribute: Internal functions
Function, attr: Exported functions
Function, before: Exported functions
Function, build-elements: Internal functions
Function, child-index: Exported functions
Function, children: Exported functions
Function, classes: Internal functions
Function, clone: Exported functions
Function, closest: Exported functions
Function, combine: Exported functions
Function, contains: Exported functions
Function, contents: Exported functions
Function, copy-proper-vector: Exported functions
Function, css: Exported functions
Function, data: Exported functions
Function, deepest: Exported functions
Function, detach: Exported functions
Function, each: Exported functions
Function, empty: Exported functions
Function, empty-p: Exported functions
Function, ensure-proper-vector: Exported functions
Function, eq: Exported functions
Function, eval: Exported functions
Function, even: Exported functions
Function, filter: Exported functions
Function, find: Exported functions
Function, first: Exported functions
Function, funcs-or-select: Internal functions
Function, function: Exported functions
Function, get-css-styles: Internal functions
Function, gt: Exported functions
Function, has: Exported functions
Function, has-class: Exported functions
Function, hide: Exported functions
Function, html: Exported functions
Function, html-file: Exported functions
Function, index: Exported functions
Function, initialize: Exported functions
Function, initialize: Exported functions
Function, initialize: Exported functions
Function, inline: Exported functions
Function, insert-after: Exported functions
Function, insert-before: Exported functions
Function, is: Exported functions
Function, is-empty: Exported functions
Function, last: Exported functions
Function, length: Exported functions
Function, load-page: Exported functions
Function, lt: Exported functions
Function, make-proper-vector: Exported functions
Function, map: Exported functions
Function, map-apply: Exported functions
Function, mkstr: Internal functions
Function, next: Exported functions
Function, next-all: Exported functions
Function, next-until: Exported functions
Function, node: Exported functions
Function, nodes-or-build: Internal functions
Function, nodes-or-select: Internal functions
Function, nodes-or-selector-func: Internal functions
Function, not: Exported functions
Function, not-empty: Exported functions
Function, odd: Exported functions
Function, parent: Exported functions
Function, parent-lists: Internal functions
Function, parents: Exported functions
Function, parents-until: Exported functions
Function, parse-css: Internal functions
Function, parse-html: Exported functions
Function, prepend: Exported functions
Function, prepend-to: Exported functions
Function, prev: Exported functions
Function, prev-all: Exported functions
Function, prev-until: Exported functions
Function, remove: Exported functions
Function, remove-attr: Exported functions
Function, remove-class: Exported functions
Function, remove-data: Exported functions
Function, render-text: Exported functions
Function, replace-all: Exported functions
Function, replace-vector: Internal functions
Function, replace-vector-if: Internal functions
Function, replace-with: Exported functions
Function, root: Exported functions
Function, serialize: Exported functions
Function, set-css-styles: Internal functions
Function, show: Exported functions
Function, siblings: Exported functions
Function, size: Exported functions
Function, slice: Exported functions
Function, splice: Exported functions
Function, symb: Internal functions
Function, text: Exported functions
Function, toggle-class: Exported functions
Function, trim: Internal functions
Function, unwrap: Exported functions
Function, val: Exported functions
Function, wrap: Exported functions
Function, wrap-all: Exported functions
Function, wrap-inner: Exported functions
Function, write-to-file: Exported functions

G
Generic Function, determine-argument: Internal generic functions
Generic Function, determine-value: Internal generic functions
get-css-styles: Internal functions
gt: Exported functions

H
has: Exported functions
has-class: Exported functions
hide: Exported functions
html: Exported functions
html-file: Exported functions

I
index: Exported functions
initialize: Exported functions
initialize: Exported functions
initialize: Exported functions
inline: Exported functions
insert-after: Exported functions
insert-before: Exported functions
is: Exported functions
is-empty: Exported functions

L
last: Exported functions
length: Exported functions
load-page: Exported functions
lt: Exported functions

M
Macro, $: Exported macros
Macro, $1: Exported macros
Macro, define-argument-handler: Exported macros
Macro, define-lquery-function: Exported macros
Macro, define-lquery-list-function: Exported macros
Macro, define-lquery-macro: Exported macros
Macro, define-lquery-subroutine: Exported macros
Macro, define-value-handler: Exported macros
Macro, deflqfun: Internal macros
Macro, with-master-document: Exported macros
make-proper-vector: Exported functions
map: Exported functions
map-apply: Exported functions
Method, determine-argument: Internal generic functions
Method, determine-argument: Internal generic functions
Method, determine-argument: Internal generic functions
Method, determine-value: Internal generic functions
Method, determine-value: Internal generic functions
Method, determine-value: Internal generic functions
Method, determine-value: Internal generic functions
Method, determine-value: Internal generic functions
Method, determine-value: Internal generic functions
Method, determine-value: Internal generic functions
mkstr: Internal functions

N
next: Exported functions
next-all: Exported functions
next-until: Exported functions
node: Exported functions
nodes-or-build: Internal functions
nodes-or-select: Internal functions
nodes-or-selector-func: Internal functions
not: Exported functions
not-empty: Exported functions

O
odd: Exported functions

P
parent: Exported functions
parent-lists: Internal functions
parents: Exported functions
parents-until: Exported functions
parse-css: Internal functions
parse-html: Exported functions
prepend: Exported functions
prepend-to: Exported functions
prev: Exported functions
prev-all: Exported functions
prev-until: Exported functions

R
remove: Exported functions
remove-attr: Exported functions
remove-class: Exported functions
remove-data: Exported functions
render-text: Exported functions
replace-all: Exported functions
replace-vector: Internal functions
replace-vector-if: Internal functions
replace-with: Exported functions
root: Exported functions

S
serialize: Exported functions
set-css-styles: Internal functions
show: Exported functions
siblings: Exported functions
size: Exported functions
slice: Exported functions
splice: Exported functions
symb: Internal functions

T
text: Exported functions
toggle-class: Exported functions
trim: Internal functions

U
unwrap: Exported functions

V
val: Exported functions

W
with-master-document: Exported macros
wrap: Exported functions
wrap-all: Exported functions
wrap-inner: Exported functions
write-to-file: Exported functions

Jump to:   $   %  
A   B   C   D   E   F   G   H   I   L   M   N   O   P   R   S   T   U   V   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*lquery-master-document*: Exported special variables

S
Special Variable, *lquery-master-document*: Exported special variables

Jump to:   *  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   L   P   S  
Index Entry  Section

L
lquery: The lquery system
lquery: The lquery package
lquery-funcs: The lquery-funcs package
lquery-macros: The lquery-macros package

P
Package, lquery: The lquery package
Package, lquery-funcs: The lquery-funcs package
Package, lquery-macros: The lquery-macros package

S
System, lquery: The lquery system

Jump to:   L   P   S