2. What is XWiki Rendering?
•
•
•
A Java, open source (LGPL) library to convert an input in a given syntax
into an output in another syntax.
Needs: Wikis, Commenting system on web sites, any place where you ask
user to enter content.
Complex to implement properly!
3. Supported Syntaxes
Input Syntaxes
•
•
•
•
•
•
•
•
•
•
•
XWiki Syntax 1.0, 2.0, 2.1
HTML 4.x/XHTML 1.0
Plain text
Docbook 4.x
Confluence/Confluence XHTML
Mediawiki
JSPWiki
TWiki
Creole 1.0
Markdown
APT
Output Syntaxes
•
•
•
•
•
XWiki Syntax 2.0, 2.1
HTML 4.x/XHTML 1.0
Plain text
Docbook 4.x
APT
Future Syntaxes
•
•
PDF (prototype version using iText exists)
Asciidoc (need events in Asciidoctor)
4. Library Initialization
// Initialize Rendering components and allow getting instances!
EmbeddableComponentManager componentManager = !
! new EmbeddableComponentManager();!
componentManager.initialize(this.getClass().getClassLoader());
5. Example 1: Convert to XHTML
Converter converter =!
! componentManager.getInstance(Converter.class);!
!
WikiPrinter printer = new DefaultWikiPrinter();!
converter.convert(new StringReader("This is **bold**”),!
! Syntax.XWIKI_2_1, Syntax.XHTML_1_0, printer);!
!
Assert.assertEquals("<p>This is <strong>bold</strong></p>", !
! printer.toString());
6. Example 2: Italicize links
Parser parser = componentManager.getInstance(Parser.class, !
! Syntax.XWIKI_2_1.toIdString());!
XDOM xdom = parser.parse(new StringReader("This a [[link>MyPage]]"));!
!
// Find all links and make them italic!
for (Block block : xdom.getBlocks(new ClassBlockMatcher(LinkBlock.class), !
! Block.Axes.DESCENDANT)) {!
! Block parentBlock = block.getParent();!
! Block newBlock = new FormatBlock(Collections.<Block>singletonList(block), !
! ! Format.ITALIC);!
! parentBlock.replaceChild(newBlock, block);!
}!
!
WikiPrinter printer = new DefaultWikiPrinter();!
BlockRenderer renderer = componentManager.getInstance(BlockRenderer.class, !
! Syntax.XWIKI_2_1.toIdString());!
renderer.render(xdom, printer);!
!
Assert.assertEquals("This a //[[link>MyPage]]//", printer.toString());
8. Demo Time!
!
Build a live preview web site using
XWiki Rendering and AngularJS
27 au 29 mars 2013
9. Use it!
• Documentation on http://rendering.xwiki.org
• WYSIWYG editor using XWiki Rendering also available
• Use Maven for a simple start (recommended) or use the
•
Standalone JAR
Contribute to add more Syntaxes, more Macros!
11. Vincent Massol
• Speaker Bio
•
CTO XWiki SAS
•
•
XWiki (community-driven open source project)
Past: Maven, Apache Cargo, Apache Cactus, Pattern Testing
•
•
•
LesCastCodeurs podcast
Creator of OSSGTP open source group in Paris
3 books: JUnit in Action, Maven: A Developer’s Notebook, BBWM
• Your Projects
• Other Credentials: