How it works
From posting to displaying to editing, s9e\TextFormatter separates its operations in 4 distinct phases:
Configuration: configure s9e\TextFormatter and the plugins you want to use, or use a preconfigured bundle.
Parsing: the text is parsed and can be stored as an XML document.
Rendering: the XML document is transformed into HTML.
Unparsing: the XML document is transformed back into plain text.
Parsing ↗ ↘ Original text XML → Rendering → HTML ↖ ↙ Unparsing
The configurator object can be used to generate a parser object and a renderer object. They can be serialized and should be cached for performance. Preconfigured parsers and renderers are available through bundles.
$parser ↗ ↕ $configurator → finalize() (cache) ↘ ↕ $renderer
The parser object transforms plain text into XML, the renderer object transforms XML into HTML. The XML can be reverted back to the original text using the
s9e\TextFormatter\Unparser::unparse() static method. This is done without losing or modifying any content. (apart from a few control characters such as NUL bytes)
$parser->parse() ↗ ↘ $text $xml → $renderer->render() → $html ↖ ↙ Unparser::unparse()