Guides

DirectiveRule
in package
implements Rule

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

Table of Contents

Interfaces

Rule

Constants

PRIORITY  = 70

Properties

$directives  : array<string, BaseDirective>
$generalDirective  : GeneralDirective
$inlineMarkupRule  : InlineMarkupRule
$logger  : LoggerInterface

Methods

__construct()  : mixed
applies()  : bool
apply()  : TNode|null
Enters this state and loops through all relevant lines until a Node is produced.
collectDirectiveContents()  : Buffer
collectDirectiveOptionContent()  : void
Collects the content of multiline directive options:
getDirectiveHandler()  : BaseDirective
interpretDirectiveOptions()  : void
isDirectiveOption()  : bool
parseDirective()  : Directive|null
parseDirectiveContent()  : void
parseDirectiveOption()  : DirectiveOption
Directive options are stored in the field-list syntax:
postProcessNode()  : Node
Post processes a node created by a directive to apply common options
registerDirective()  : void

Constants

Properties

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

collectDirectiveOptionContent()

Collects the content of multiline directive options:

private collectDirectiveOptionContent(LinesIterator $documentIterator, DirectiveOption $directiveOption) : void

.. figure:: foo.jpg :width: 100 :alt: Field options might use more than one line

This is a foo!

Parameters
$documentIterator : LinesIterator
$directiveOption : DirectiveOption

isDirectiveOption()

private isDirectiveOption(string|null $line) : bool
Parameters
$line : string|null
Return values
bool

parseDirectiveOption()

Directive options are stored in the field-list syntax:

private parseDirectiveOption(string $line) : DirectiveOption

.. figure:: foo.jpg :width: 100 :alt: Field options might use more than one line :yet another option: abc :empty option:

Parameters
$line : string
Tags
throws
InvalidArgumentException
Return values
DirectiveOption

        
On this page

Search results