Guides

ListRule
in package
implements Rule

FinalYes
Tags
link
https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#bullet-lists

Table of Contents

Interfaces

Rule

Constants

PRIORITY  = 90
LIST_MARKER_REGEX  = '/ ^( [-+*\x{2022}\x{2023}\x{2043}] # match bullet list markers: "*", "+", "-", "•", "‣", or "⁃" ) (?:\s+|$) # capture the spaces between marker and text to determine the list item text offset # (or eol, if text starts on a new line) /ux'
A regex matching all bullet list markers and a subset of the enumerated list markers.

Properties

$logger  : LoggerInterface
$productions  : RuleContainer

Methods

__construct()  : mixed
applies()  : bool
apply()  : TNode|null
Enters this state and loops through all relevant lines until a Node is produced.
getItemConfig()  : array{marker: string, indenting: int}
isListItemStart()  : bool
isListLine()  : bool
parseListItem()  : ListItemNode

Constants

LIST_MARKER_REGEX

A regex matching all bullet list markers and a subset of the enumerated list markers.

private mixed LIST_MARKER_REGEX = '/ ^( [-+*\x{2022}\x{2023}\x{2043}] # match bullet list markers: "*", "+", "-", "•", "‣", or "⁃" ) (?:\s+|$) # capture the spaces between marker and text to determine the list item text offset # (or eol, if text starts on a new line) /ux'
Tags
see
https://regex101.com/r/LBXWFV/1
see
https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#bullet-lists
see
https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#enumerated-lists

Properties

$logger read-only

private LoggerInterface $logger

Methods

apply()

Enters this state and loops through all relevant lines until a Node is produced.

public apply(BlockContext $blockContext[, CompoundNode|null $on = null ]) : TNode|null

The opening line is considered relevant and as such is always used (this is found the case in the self::Applies() method, otherwise we wouldn't have been here) but for all subsequent lines we use a Look Ahead to test whether it should be included in the Node.

By using a Look Ahead, we prevent the cursor from advancing; and this caused the cursor to 'rest' on the line that is considered that last relevant line. The document parser will advance the line after successfully parsing this and to send the Parser into a line that belongs to another state.

Parameters
$blockContext : BlockContext
$on : CompoundNode|null = null
Return values
TNode|null

getItemConfig()

public getItemConfig(string $line) : array{marker: string, indenting: int}
Parameters
$line : string
Return values
array{marker: string, indenting: int}

isListItemStart()

private isListItemStart(string|null $line[, string|null $listMarker = null ]) : bool
Parameters
$line : string|null
$listMarker : string|null = null
Return values
bool

isListLine()

private isListLine(string|null $line) : bool
Parameters
$line : string|null
Return values
bool
Loading…
On this page

Search results