class Formatter (View source)

The Formatter parses plain text content and renders it as HTML.

Waterhole uses the TextFormatter library to safely format markup. This class is an abstraction around TextFormatter, enabling extension and caching of its configuration and renderer.

Properties

protected $configurationCallbacks
protected $parsingCallbacks
protected $renderingCallbacks

Methods

__construct(Filesystem $files, string $cacheDir, Repository $cache, string $cacheKey)

No description

void
configure(callable $callback)

Add a configuration callback to the formatter.

string
parse(string $text, Context $context = null)

Parse plain text into an XML document for storage in the database.

void
parsing(callable $callback)

Add a parsing callback to the formatter.

string
render(string $xml, Context $context = null)

Transform a parsed XML document into HTML.

void
rendering(callable $callback)

Add a rendering callback to the formatter.

string
unparse(string $xml)

Revert a parsed XML document back into plain text.

void
flush()

Flush the formatter from the cache.

Configurator
getConfigurator()

No description

getComponent(string $name)

No description

Parser
getParser()

No description

Renderer
getRenderer()

No description

Details

__construct(Filesystem $files, string $cacheDir, Repository $cache, string $cacheKey)

No description

Parameters

Filesystem $files
string $cacheDir
Repository $cache
string $cacheKey

void configure(callable $callback)

Add a configuration callback to the formatter.

Parameters

callable $callback

Return Value

void

string parse(string $text, Context $context = null)

Parse plain text into an XML document for storage in the database.

Parameters

string $text
Context $context

Return Value

string

void parsing(callable $callback)

Add a parsing callback to the formatter.

Parameters

callable $callback

Return Value

void

string render(string $xml, Context $context = null)

Transform a parsed XML document into HTML.

Parameters

string $xml
Context $context

Return Value

string

void rendering(callable $callback)

Add a rendering callback to the formatter.

Parameters

callable $callback

Return Value

void

string unparse(string $xml)

Revert a parsed XML document back into plain text.

Parameters

string $xml

Return Value

string

void flush()

Flush the formatter from the cache.

Return Value

void

protected Configurator getConfigurator()

No description

Return Value

Configurator

protected getComponent(string $name)

No description

Parameters

string $name

protected Parser getParser()

No description

Return Value

Parser

protected Renderer getRenderer()

No description

Return Value

Renderer