SlideShare a Scribd company logo
1 of 11
Download to read offline
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:

More Related Content

More from XWiki

More from XWiki (20)

L'intranet collaboratif Aelia : l'étude de cas
L'intranet collaboratif Aelia : l'étude de casL'intranet collaboratif Aelia : l'étude de cas
L'intranet collaboratif Aelia : l'étude de cas
 
An collaborative intranet: the Aelia case study
An collaborative intranet: the Aelia case studyAn collaborative intranet: the Aelia case study
An collaborative intranet: the Aelia case study
 
La base de connaissance de la FNAB
La base de connaissance de la FNABLa base de connaissance de la FNAB
La base de connaissance de la FNAB
 
Collaborative Watch: the AFP case study
Collaborative Watch: the AFP case studyCollaborative Watch: the AFP case study
Collaborative Watch: the AFP case study
 
Une solution de veille partagée et collaborative : le cas de l'AFP
Une solution de veille partagée et collaborative : le cas de l'AFPUne solution de veille partagée et collaborative : le cas de l'AFP
Une solution de veille partagée et collaborative : le cas de l'AFP
 
Créer ses applications métier : le cas DCNS
Créer ses applications métier : le cas DCNSCréer ses applications métier : le cas DCNS
Créer ses applications métier : le cas DCNS
 
La base de connaissances du CNFPT
La base de connaissances du CNFPTLa base de connaissances du CNFPT
La base de connaissances du CNFPT
 
Documentation of an application revamping program: the Capgemini case study
Documentation of an application revamping program: the Capgemini case studyDocumentation of an application revamping program: the Capgemini case study
Documentation of an application revamping program: the Capgemini case study
 
Documentation d'un programme de rénovation applicative : le cas Capgemini
Documentation d'un programme de rénovation applicative : le cas CapgeminiDocumentation d'un programme de rénovation applicative : le cas Capgemini
Documentation d'un programme de rénovation applicative : le cas Capgemini
 
Base de connaissance : le cas CAPHC
Base de connaissance : le cas CAPHCBase de connaissance : le cas CAPHC
Base de connaissance : le cas CAPHC
 
Knowledge Exchange Network: the CAPHC use case
Knowledge Exchange Network: the CAPHC use caseKnowledge Exchange Network: the CAPHC use case
Knowledge Exchange Network: the CAPHC use case
 
La plateforme IWA : retour d'expérience
La plateforme IWA : retour d'expérienceLa plateforme IWA : retour d'expérience
La plateforme IWA : retour d'expérience
 
How DCNS creates its own business applications
How DCNS creates its own business applicationsHow DCNS creates its own business applications
How DCNS creates its own business applications
 
Ressources pédagogiques en ligne
Ressources pédagogiques en ligneRessources pédagogiques en ligne
Ressources pédagogiques en ligne
 
L'intranet collaboratif Fidelia Assistance
L'intranet collaboratif Fidelia AssistanceL'intranet collaboratif Fidelia Assistance
L'intranet collaboratif Fidelia Assistance
 
Documentation produit : le cas Easyvista
Documentation produit : le cas EasyvistaDocumentation produit : le cas Easyvista
Documentation produit : le cas Easyvista
 
Documentation and Knowledge management: the EasyVista's use case
Documentation and Knowledge management: the EasyVista's use caseDocumentation and Knowledge management: the EasyVista's use case
Documentation and Knowledge management: the EasyVista's use case
 
Collaborative intranet: the Fidelia Assistance case study
Collaborative intranet: the Fidelia Assistance case studyCollaborative intranet: the Fidelia Assistance case study
Collaborative intranet: the Fidelia Assistance case study
 
L'intranet Numéricable / SFR
L'intranet Numéricable / SFRL'intranet Numéricable / SFR
L'intranet Numéricable / SFR
 
La mise en place d'un centre de ressources : le cas XWiki / FOPH
La mise en place d'un centre de ressources : le cas XWiki / FOPHLa mise en place d'un centre de ressources : le cas XWiki / FOPH
La mise en place d'un centre de ressources : le cas XWiki / FOPH
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

XWiki Rendering: A content rendering engine

  • 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: