XWiki Rendering @ FOSDEM 2014

Vincent Massol
Vincent MassolCTO, Software Developer at XWiki
XWiki Rendering

Vincent Massol
XWiki Committer
CTO XWiki SAS
!

@vmassol
Vincent Massol, February 2014

27 au 29 mars 2013
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!
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)
Library Initialization

// Initialize Rendering components and allow getting instances!
EmbeddableComponentManager componentManager = !
! new EmbeddableComponentManager();!
componentManager.initialize(this.getClass().getClassLoader());
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());
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());
Example 3: Execute Macros
Parser parser = componentManager.getInstance(Parser.class, !
! Syntax.XWIKI_2_1.toIdString());!
XDOM xdom = parser.parse(new StringReader("{{id name="test"/}}"));!

!
Transformation transformation = componentManager.getInstance(Transformation.class, !
! "macro");!
TransformationContext txContext = new TransformationContext(xdom, parser.getSyntax());!
transformation.transform(xdom, txContext);!

!
WikiPrinter printer = new DefaultWikiPrinter();!
BlockRenderer renderer = componentManager.getInstance(BlockRenderer.class, !
! Syntax.XHTML_1_0.toIdString());!
renderer.render(xdom, printer);!

!
Assert.assertEquals("<div id="test"></div>", printer.toString());
Demo Time!
!

Build a live preview web site using
XWiki Rendering and AngularJS

27 au 29 mars 2013
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!
Q&A

Me
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:
1 of 11

More Related Content

Viewers also liked(15)

Developing XWikiDeveloping XWiki
Developing XWiki
Vincent Massol2.7K views
XWiki: Developing simple apps quicklyXWiki: Developing simple apps quickly
XWiki: Developing simple apps quickly
Vincent Massol4K views
Future of XWiki SkinsFuture of XWiki Skins
Future of XWiki Skins
Ecaterina Moraru (Valica)1.2K views
RedPen, a document checkerRedPen, a document checker
RedPen, a document checker
Recruit Technologies30.7K views
Desarrollo de pruebas en entornos Java EEDesarrollo de pruebas en entornos Java EE
Desarrollo de pruebas en entornos Java EE
José Manuel López12.5K views
(Codemotion 2014) JVM GC: WTF?!(Codemotion 2014) JVM GC: WTF?!
(Codemotion 2014) JVM GC: WTF?!
Alonso Torres13.7K views
Accesibilidad web - más allá del marcadoAccesibilidad web - más allá del marcado
Accesibilidad web - más allá del marcado
Manuel Razzari19.9K views
Mapoteca accesibleMapoteca accesible
Mapoteca accesible
Manuel Razzari21.5K views
API Asynchrones en Java 8API Asynchrones en Java 8
API Asynchrones en Java 8
José Paumard65.9K views
Les Streams sont parmi nousLes Streams sont parmi nous
Les Streams sont parmi nous
José Paumard64.4K views

Similar to XWiki Rendering @ FOSDEM 2014

A Taste of ClojureA Taste of Clojure
A Taste of ClojureDavid Leung
448 views28 slides
Snippet for .netSnippet for .net
Snippet for .netSireesh K
111 views11 slides

Similar to XWiki Rendering @ FOSDEM 2014(20)

2017-06-22 Documentation as code2017-06-22 Documentation as code
2017-06-22 Documentation as code
Jérémie Bresson350 views
Scripting as a Second LanguageScripting as a Second Language
Scripting as a Second Language
Rob Dunn1.5K views
Bringing classical OOP into JavaScriptBringing classical OOP into JavaScript
Bringing classical OOP into JavaScript
Dmitry Sheiko1.7K views
A Taste of ClojureA Taste of Clojure
A Taste of Clojure
David Leung448 views
Snippet for .netSnippet for .net
Snippet for .net
Sireesh K111 views
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
Deniz Oguz10.5K views
Code snippetsCode snippets
Code snippets
Sireesh K144 views
How dojo worksHow dojo works
How dojo works
Amit Tyagi8.6K views
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for you
Simon Willison1.4K views
Write code that writes code!Write code that writes code!
Write code that writes code!
Jason Feinstein110 views
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
Andres Almiray3.6K views
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
Praveen kumar450 views
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
Ngoc Dao44.4K views
Nuxeo - OpenSocialNuxeo - OpenSocial
Nuxeo - OpenSocial
Thomas Roger690 views

More from Vincent Massol(20)

XWiki Testing with TestContainersXWiki Testing with TestContainers
XWiki Testing with TestContainers
Vincent Massol122 views
XWiki: The best wiki for developersXWiki: The best wiki for developers
XWiki: The best wiki for developers
Vincent Massol215 views
Advanced Java Testing @ POSS 2019Advanced Java Testing @ POSS 2019
Advanced Java Testing @ POSS 2019
Vincent Massol103 views
New types of tests for Java projectsNew types of tests for Java projects
New types of tests for Java projects
Vincent Massol105 views
Building XWikiBuilding XWiki
Building XWiki
Vincent Massol371 views
New types of tests for Java projectsNew types of tests for Java projects
New types of tests for Java projects
Vincent Massol309 views
What's new in XWiki 9.x and 10.xWhat's new in XWiki 9.x and 10.x
What's new in XWiki 9.x and 10.x
Vincent Massol263 views
QDashboard 1.2QDashboard 1.2
QDashboard 1.2
Vincent Massol4.6K views
Advanced Java TestingAdvanced Java Testing
Advanced Java Testing
Vincent Massol2.7K views
Developing XWikiDeveloping XWiki
Developing XWiki
Vincent Massol286 views
XWiki Status - July 2015XWiki Status - July 2015
XWiki Status - July 2015
Vincent Massol281 views
XWiki SAS development practicesXWiki SAS development practices
XWiki SAS development practices
Vincent Massol862 views
XWiki SAS: An open source companyXWiki SAS: An open source company
XWiki SAS: An open source company
Vincent Massol1.8K views
Implementing Quality on a Java ProjectImplementing Quality on a Java Project
Implementing Quality on a Java Project
Vincent Massol1.1K views
Evolutions XWiki 2012/2013Evolutions XWiki 2012/2013
Evolutions XWiki 2012/2013
Vincent Massol611 views

Recently uploaded(20)

XWiki Rendering @ FOSDEM 2014

  • 1. XWiki Rendering Vincent Massol XWiki Committer CTO XWiki SAS ! @vmassol Vincent Massol, February 2014 27 au 29 mars 2013
  • 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());
  • 7. Example 3: Execute Macros Parser parser = componentManager.getInstance(Parser.class, ! ! Syntax.XWIKI_2_1.toIdString());! XDOM xdom = parser.parse(new StringReader("{{id name="test"/}}"));! ! Transformation transformation = componentManager.getInstance(Transformation.class, ! ! "macro");! TransformationContext txContext = new TransformationContext(xdom, parser.getSyntax());! transformation.transform(xdom, txContext);! ! WikiPrinter printer = new DefaultWikiPrinter();! BlockRenderer renderer = componentManager.getInstance(BlockRenderer.class, ! ! Syntax.XHTML_1_0.toIdString());! renderer.render(xdom, printer);! ! Assert.assertEquals("<div id="test"></div>", 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: