Extensions Wiki » Extensions » Convert Confluence to XWiki Syntax

Convert Confluence to XWiki Syntax

Last modified by Vincent Massol on 2012/05/19 11:11
cogConverts some content in Confluence wiki markup into XWiki Syntax 2.1 markup
TypeSnippet
Developed by

Vincent Massol

LicenseGNU Lesser General Public License 2.1

Table of contents

Description

{{groovy}}
import com.xpn.xwiki.web.Utils
import org.xwiki.rendering.renderer.printer.*
import org.xwiki.rendering.converter.*
import org.xwiki.rendering.syntax.*

// Read Confluence Content (You can get it from wherever you wish: local file, web page, etc)
def content = """
h1. Biggest heading
Hello *bold* world
"""

// Convert to XWiki 2.1 Syntax
def converter =  Utils.getComponent(Converter.class);
def printer = new DefaultWikiPrinter();
converter.convert(new StringReader(content), Syntax.CONFLUENCE_1_0, Syntax.XWIKI_2_1, printer);
def newContent = printer.toString()

// Create new Document with converted content
def newDoc = xwiki.getDocument("Main.NewDoc")
newDoc.setContent(newContent)
newDoc.save()
{{/groovy}}

Notes:

  • Note 1: Since Confluence now uses HTML as the internal format you can use the same script to convert from HTML to XWiki Syntax
  • Note 2: XWiki supports several syntaxes natively so you don't need to convert, except that the XWik Syntax is the most complete one and can be used without loss with the XWiki WYSIWYG editor (see PageEditing).
Created by Vincent Massol on 2012/05/19 11:07

Download XWiki