PHP - Manual: CommonMark\CQL
2024-11-13
(cmark >= 1.1.0)
CommonMark Query Language is a DSL for describing how to travel through a CommonMark Node tree implemented as a parser and compiler for a small set of instructions, and a virtual machine for executing those instructions.
In it's most simplistic form, a CQL query combines the following paths and /
to describe how to travel through a tree:
/firstChild/lastChild
would travel to the last child node of the first child node.
CQL can be instructed to loop, for example through the children of, or siblings to a particular node, by using the path children
, or siblings
. For example, /firstChild/children
will travel to all the children of the first child node.
CQL can be instructed how to travel by using a subquery like [/firstChild]
. For example, /firstChild/children[/firstChild]
will travel to the first child node of all the children of the first child node.
While looping, CQL can be instructed to constrict the travelled path to nodes of particular type. For example /children(BlockQuote)
will travel to the children of a node where the type is BlockQuote
. The following types are recognized (case insensitively):