All interaction with PHP Structured Text occurs through the class PhpStructuredText. Each time you need to convert some structured text to (X)HTML, create a new instance of PhpStructuredText, optionally set some properties, then call render or renderAsDom.
Simple use of the PhpStructuredText class would look something like:
$structuredText = new PhpStructuredText($content); echo $structuredText->render();
A slightly more complicated use, that sets some properties, then renders to an XML DOM instance for further processing and final conversion to an XML fragment, might look like:
$structuredText = new PhpStructuredText($content); $structuredText->setInitialHeadingLevel(3); $structuredText->setExternalVariable("summary", true); $dom = $structuredText->renderAsDom(); // ... // ... some DOM manipulations ... // ... $xmlFragment = $structuredText->textFromDom($dom);
PhpStructuredText($text) — constructor
Creates an instance of PhpStructuredText, initialized with the contents of the $text parameter. $text should contain valid structured text markup.
Sets a variable which can be tested using the
:endifconstruct within structured text.
For example, the following structured text would render two different versions of a document, based on the value of the variable called summary:
:if:summary Summary text would go here... :else The full text would go here... :endif
By default, headings are rendered, starting at
<h1>. To render text that needs an initial heading level greater than one, call this method.
<a>elements, for opening all links in other windows or frames.
Returns the document title that has been set by the
:title:title textconstruct within structured text.
Returns an (X)HTML fragment that is a rendering of the structured text that was passed to the constructor.
Returns an XML DOM representation of the structured text that was passed to the constructor. The root element of the DOM is
<root>, and its children are the top-level elements from the structured text.
Given a DOM instance that was returned from an earlier call to renderAsDom(), this method will strip away the root element, and return an XML-fragment that represents the original structured text.
Typically, an application would call renderAsDom(), do some DOM manipulation, then get a text representation of the modified DOM, by calling textFromDom($dom).