Pandoc::Selector - Pandoc document selector language
Contents
Description
Pandoc::Selector provides a language to select elements of a Pandoc document. It borrows ideas from CSS
Selectors <https://www.w3.org/TR/selectors-3/>, XPath <https://www.w3.org/TR/xpath/> and similar
languages.
The language is being developed together with this implementation.
Examples
Header#main
Code.perl
Code.perl.raw
:inline
Name
Pandoc::Selector - Pandoc document selector language
See Also
See example filter "select" to select parts of a document.
perl v5.38.2 2024-08-03 Pandoc::Selector(3pm)
Selector Grammar
Whitespace between parts of the syntax is optional and not included in the following grammar. A Selector
is a list of one or more expressionlists separated by pipes ("|"). For instance the selector
"Subscript|Superscript" selects both Subscript elements and Superscript elements.
Selector ::= ExpressionList ( '|' ExpressionList )*
An expressionlist is a list of one or more expressions:
ExpressionList ::= Expression ( Expression )*
An expression is any of nameexpression, idexpression, classexpression, and typeexpression.
Expression ::= NameExpression
| IdExpression
| ClassExpression
| TypeExpression
NameExpression ::= Name
Name ::= [A-Za-z]+
IdExpression ::= '#' [\p{L}\p{N}_-]+
ClassExpression ::= '.' [\p{L}\p{N}_-]+
TypeExpression ::= ':' Name
Synopsis
my $selector = Pandoc::Selector->new('Code.perl|CodeBlock.perl');
# check whether an element matches
$selector->match($element);
# use as element method
$element->match('Code.perl|CodeBlock.perl')
