The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Pandoc::Selector - Pandoc document selector language

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')

DESCRIPTION

Pandoc::Selector provides a language to select elements of a Pandoc document. It borrows ideas from CSS Selectors, XPath and similar languages.

The language is being developed together with this implementation.

EXAMPLES

Header#main
Code.perl
Code.perl.raw
:inline

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 expression lists separated by pipes (|). For instance the selector Subscript|Superscript selects both Subscript elements and Superscript elements.

Selector        ::= ExpressionList ( '|' ExpressionList )*

An expression list is a list of one or more expressions:

ExpressionList  ::= Expression ( Expression )*

An expression is any of name expression, id expression, class expression, and type expression.

Expression      ::= NameExpression
                    | IdExpression
                    | ClassExpression
                    | TypeExpression

NameExpression  ::= Name

Name            ::= [A-Za-z]+

IdExpression    ::= '#' [\p{L}\p{N}_-]+

ClassExpression ::= '.' [\p{L}\p{N}_-]+

TypeExpression  ::= ':' Name

SEE ALSO

See example filter select to select parts of a document.