final class Nodes

Reads the CommonMark nodes that cards are built from, and escapes text written back.

Methods§

public static function text(Node $node, bool $literals = false): string

Returns the text of a node.

Parameters

$nodeNodeThe node
$literalsboolWhether code spans keep their backticks

Returns

string The text of the node and its inline children

Throws

InvalidInputException When the node holds inline Markdown other than text, emphasis and code
Test cases 9
Called from 20
Calls 4
public static function items(Node $node): list<ListItem>
public static function field(Node $node): string|null

Returns the name of a bold field heading.

Parameters

$nodeNodeThe block

Returns

string|null The lowercase field name, or null when the block is not a field heading

Throws

InvalidInputException When the bold text holds unsupported inline Markdown
Test cases 2
Called from 2
Calls 3
public static function pair(Paragraph $node): array{string, string}

Splits a "**name:** value" paragraph.

Parameters

$nodeParagraphThe paragraph

Returns

array{string, string} The name and the trimmed value

Throws

InvalidInputException When the paragraph does not start with a bold name and a colon
Test cases 2
Called from 4
Calls 9
public static function escape(string $text): string

Escapes text so Markdown reads it back unchanged.

Parameters

$textstringThe text

Returns

string The escaped text
Test cases 1
Called from 11
Calls 1
public static function destination(string $url): string
public static function anchor(string $id): string

Returns the heading anchor of an item ID.

Parameters

$idstringThe item ID

Returns

string The lowercase ID without dots
Test cases 1
Called from 2
Calls 2

Test cases 37§

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

Dedicated tests 19
Other tests reaching this symbol 18

Relations§

Static calls 54