class Formatter implements ExtenderInterface, LifecycleInterface

Methods

configure(callable|string $callback)

<p>Configure the formatter. This can be used to add support for custom markdown/bbcode/etc tags, or otherwise change the formatter. Please see documentation for the s9e text formatter library for more information on how to use this.</p>

parse(callable|string $callback)

<p>Prepare the system for parsing. This can be used to modify the text that will be parsed, or to modify the parser.</p>

unparse(callable|string $callback)

<p>Prepare the system for unparsing. This can be used to modify the text that was parsed.</p>

render(callable|string $callback)

<p>Prepare the system for rendering. This can be used to modify the xml that will be rendered, or to modify the renderer.</p>

extend(Container $container, Extension $extension = null)

No description

onEnable(Container $container, Extension $extension)

No description

onDisable(Container $container, Extension $extension)

No description

Details

Formatter configure(callable|string $callback)

<p>Configure the formatter. This can be used to add support for custom markdown/bbcode/etc tags, or otherwise change the formatter. Please see documentation for the s9e text formatter library for more information on how to use this.</p>

Parameters

callable|string $callback <p>The callback can be a closure or invokable class, and should accept:</p> <ul> <li>\s9e\TextFormatter\Configurator $configurator</li> </ul> <p>The callable should return void.</p>

Return Value

Formatter

Formatter parse(callable|string $callback)

<p>Prepare the system for parsing. This can be used to modify the text that will be parsed, or to modify the parser.</p>

<p>Please note that the text to be parsed must be returned, regardless of whether it's changed.</p>

Parameters

callable|string $callback <p>The callback can be a closure or invokable class, and should accept:</p> <ul> <li>\s9e\TextFormatter\Parser $parser</li> <li>mixed $context</li> <li>string $text: The text to be parsed.</li> <li>\Flarum\User\User|null $actor. This argument MUST either be nullable, or omitted entirely.</li> </ul> <p>The callback should return:</p> <ul> <li>string $text: The text to be parsed.</li> </ul>

Return Value

Formatter

Formatter unparse(callable|string $callback)

<p>Prepare the system for unparsing. This can be used to modify the text that was parsed.</p>

<p>Please note that the parsed text must be returned, regardless of whether it's changed.</p>

Parameters

callable|string $callback <p>The callback can be a closure or invokable class, and should accept:</p> <ul> <li>mixed $context</li> <li>string $xml: The parsed text.</li> </ul> <p>The callback should return:</p> <ul> <li>string $xml: The text to be unparsed.</li> </ul>

Return Value

Formatter

Formatter render(callable|string $callback)

<p>Prepare the system for rendering. This can be used to modify the xml that will be rendered, or to modify the renderer.</p>

<p>Please note that the xml to be rendered must be returned, regardless of whether it's changed.</p>

Parameters

callable|string $callback <p>The callback can be a closure or invokable class, and should accept:</p> <ul> <li>\s9e\TextFormatter\Renderer $renderer</li> <li>mixed $context</li> <li>string $xml: The xml to be rendered.</li> <li>ServerRequestInterface $request. This argument MUST either be nullable, or omitted entirely.</li> </ul> <p>The callback should return:</p> <ul> <li>string $xml: The xml to be rendered.</li> </ul>

Return Value

Formatter

extend(Container $container, Extension $extension = null)

Parameters

Container $container
Extension $extension

onEnable(Container $container, Extension $extension)

Parameters

Container $container
Extension $extension

onDisable(Container $container, Extension $extension)

Parameters

Container $container
Extension $extension