final class DomSource
    implements SourceExtension

Selects elements of HTML, XML, IETF XML and Markdown sources with CSS selectors.

Markdown is rendered to HTML first. XML may not declare a DTD or entities. An evidence selector may also be an exact Text Fragment within an HTML scope. A selection may not contain both an element and one of its descendants.

Methods§

public function __construct(private ResourceLoader $loader = new \Requirements\Source\ResourceLoader())

Parameters

$loaderResourceLoaderReads the source document
Calls 1
public function select(
    Source $source,
    string $selector,
    string $directory,
    bool $live,
): list<Unit>

Selects the elements a CSS selector or Text Fragment identifies.

Parameters

$sourceSourceThe source declaration
$selectorstringA CSS selector, or an exact Text Fragment within the HTML scope
$directorystringThe configuration directory
$liveboolWhether to read the current URI instead of a pinned snapshot

Returns

list<Unit> One unit per element, located by its node path

Throws

CommonMarkException When a Markdown source cannot be rendered
RuntimeException When the source is unsafe or malformed, a fragment is misused or ancestors and descendants are selected together
Test cases 20
Calls 21

Private surface 1§

Implementation details, listed for orientation only.

private ResourceLoader $loader = new \Requirements\Source\ResourceLoader()

Test cases 34§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 20
Other tests reaching this symbol 14

Relations§

Instantiated in 1