 | Provides API to convert textual inputs in a given syntax into some rendered output |
| Bundled With | XWiki Enterprise, XWiki Enterprise Manager |
View Source
Starting with XWiki Platform 3.0 the Rendering module has been extracted out of XWiki Platform and is now a generic library on its own that can be used without using XWiki Platform or XWiki Enterprise.
Now XWiki Platform adds some features, for example it adds a Script Service (requires XWiki 2.3M1+) to make it easy to access Rendering APIs from script.
/**
* @return the list of syntaxes for which a Parser is available
*/
public List<Syntax> getAvailableParserSyntaxes()
/**
* @return the list of syntaxes for which a Renderer is available
*/
public List<Syntax> getAvailableRendererSyntaxes()
/**
* @return the names of Transformations that are configured in the Rendering Configuration and which are used by
* the Transformation Manager when running all transformations
*/
public List<String> getDefaultTransformationNames()
/**
* Parses a text written in the passed syntax.
*
* @param text the text to parse
* @param syntaxId the id of the syntax in which the text is written in
* @return the XDOM representing the AST of the parsed text or null if an error occurred
* @since 3.2M3
*/
public XDOM parse(String text, String syntaxId)
/**
* Render a list of Blocks into the passed syntax.
*
* @param block the block to render
* @param outputSyntaxId the syntax in which to render the blocks
* @return the string representing the passed blocks in the passed syntax or null if an error occurred
* @since 3.2M3
*/
public String render(Block block, String outputSyntaxId)
/**
* Converts a Syntax specified as a String into a proper Syntax object.
*
* @param syntaxId the syntax as a string (eg "xwiki/2.0", "html/4.01", etc)
* @return the proper Syntax object representing the passed syntax
*/
public Syntax resolveSyntax(String syntaxId)
}
For example to parse some content in HTML and then render it in XWiki Syntax 2.1 from Velocity you would write:
{{velocity}}
#set ($xdom = $services.rendering.parse("<p>some <b>bold</bold></p>", "html/4.01"))
#set ($xwikiSyntax = $services.rendering.render($xdom, "xwiki/2.1"))
{{{$xwikiSyntax}}}
{{/velocity}}