 | Converts some content in Confluence wiki markup into XWiki Syntax 2.1 markup |
| Type | Snippet |
| Developed by | Vincent Massol |
| License | GNU Lesser General Public License 2.1 |
{{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).