Document handler for RST text documents.
RST (ReStructured Text) is a text based markup language developed inside the docutils project, with a rather complete description of the markup language:
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html
The basic RST syntax can be extended with so called directives, which can contain user specific markup blocks handled by external applications or custom scripts. This class does not support all of the directives known from docutils yet, but you may register custom additional ones.
RST can be converted forth and back between Docbook and RST. Additionally you may register cusom visitors for the abstract sysntax tree (AST) the RST parser creates, to directly convert the AST into other languages then Docbook. Two different visitors for XHTML are already implemented in the component:
Additional directives, which are implemented by extending from the ezcDocumentRstDirective class, can be registerd before the conversion:
This class can also read docbook documents (ezcDocumentDocbook) and convert it back to RST, which then works like:
Source for this file: /Document/src/document/rst.php
ezcDocument | --ezcDocumentRst
Version: | //autogen// |
protected ezcDocumentRstDocumentNode |
$ast
Asbtract syntax tree. The internal representation of RST documents. |
protected string |
$contents
Plain RST contents as a string |
protected array |
$directives
= array(
Registered directives Directives are special RST element, which are documented at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#directives Directives are the best entry point for custom rules, and you may register custom directive classes using the class method registerDirective(). |
protected array |
$roles
= array(
Registered interpreted text role handlers Interpreted text roles are special RST element, which are documented at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#interpreted-text Interpreted text roles are the best entry point for custom rules for inline markup. You can register custom text role using the class method registerRole(). |
From ezcDocument | |
---|---|
protected |
ezcDocument::$errors
|
protected |
ezcDocument::$options
|
protected |
ezcDocument::$path
|
public void |
createFromDocbook(
$document
)
Create document from docbook document |
public ezcDocumentDocbook |
getAsDocbook(
)
Return document compiled to the docbook format |
public ezcDocumentXhtml |
getAsXhtml(
)
Return document compiled to the HTML format |
public string |
getDirectiveHandler(
$name
)
Get directive handler |
public string |
getRoleHandler(
$name
)
Get text role handler |
public void |
loadString(
$string
)
Create document from input string |
public void |
registerDirective(
$name
, $class
)
Register directive handler |
public void |
registerRole(
$name
, $class
)
Register text role handler |
public string |
save(
)
Return document as string |
public mixed |
validateFile(
$file
)
Validate the input file |
public mixed |
validateString(
$string
)
Validate the input string |
From ezcDocument | |
---|---|
public ezcDocument |
ezcDocument::__construct()
Construct new document |
public abstract void |
ezcDocument::createFromDocbook()
Create document from docbook document |
public abstract ezcDocumentDocbook |
ezcDocument::getAsDocbook()
Return document compiled to the docbook format |
public array |
ezcDocument::getErrors()
Return list of errors occured during visiting the document. |
public string |
ezcDocument::getPath()
Get document base path |
public void |
ezcDocument::loadFile()
Create document from file |
public abstract void |
ezcDocument::loadString()
Create document from input string |
public abstract string |
ezcDocument::save()
Return document as string |
public void |
ezcDocument::setPath()
Set document base path |
public void |
ezcDocument::triggerError()
Trigger visitor error |
Create document from docbook document
A document of the docbook format is provided and the internal document structure should be created out of this.
This method is required for all formats to have one central format, so that each format can be compiled into each other format using docbook as an intermediate format.
You may of course just call an existing converter for this conversion.
Name | Type | Description |
---|---|---|
$document |
ezcDocumentDocbook |
Method | Description |
---|---|
ezcDocument::createFromDocbook() |
Create document from docbook document |
Return document compiled to the docbook format
The internal document structure is compiled to the docbook format and the resulting docbook document is returned.
This method is required for all formats to have one central format, so that each format can be compiled into each other format using docbook as an intermediate format.
You may of course just call an existing converter for this conversion.
Method | Description |
---|---|
ezcDocument::getAsDocbook() |
Return document compiled to the docbook format |
Return document compiled to the HTML format
The internal document structure is compiled to the HTML format and the resulting HTML document is returned.
This is an optional interface for document markup languages which support a direct transformation to HTML as a shortcut.
Method | Description |
---|---|
ezcDocumentXhtmlConversion::getAsXhtml() |
Return document compiled to the XHTML format |
Get directive handler
Get directive handler class name for the specified name.
Name | Type | Description |
---|---|---|
$name |
string |
Get text role handler
Get text role handler class name for the specified name.
Name | Type | Description |
---|---|---|
$name |
string |
Create document from input string
Create a document of the current type handler class and parse it into a usable internal structure.
Name | Type | Description |
---|---|---|
$string |
string |
Method | Description |
---|---|
ezcDocument::loadString() |
Create document from input string |
Register directive handler
Register a custom directive handler for special directives or overwrite existing directive handlers. The directives are specified by its (lowercase) name and the class name, which should handle the directive and extend from ezcDocumentRstDirective.
Name | Type | Description |
---|---|---|
$name |
string | |
$class |
string |
Register text role handler
Register a custom text role handler for special text roles or overwrite existing text role handlers. The text roles are specified by its (lowercase) name and the class name, which should handle the text role and extend from ezcDocumentRstTextRole.
Name | Type | Description |
---|---|---|
$name |
string | |
$class |
string |
Return document as string
Serialize the document to a string an return it.
Method | Description |
---|---|
ezcDocument::save() |
Return document as string |
Validate the input file
Validate the input file against the specification of the current document format.
Returns true, if the validation succeded, and an array with ezcDocumentValidationError objects otherwise.
Name | Type | Description |
---|---|---|
$file |
string |
Method | Description |
---|---|
ezcDocumentValidation::validateFile() |
Validate the input file |
Validate the input string
Validate the input string against the specification of the current document format.
Returns true, if the validation succeded, and an array with ezcDocumentValidationError objects otherwise.
Name | Type | Description |
---|---|---|
$string |
string |
Method | Description |
---|---|
ezcDocumentValidation::validateString() |
Validate the input string |