Converting document syntax programmatically

Hi all,

I would like to programatically convert our recently imported set of Markdown pages to a set of Documents in XWiki 2.1 syntax, since we have some issue with the Markdown 1.2 Syntax. Converting a page by hand in the Editor works well for us, however, we can not really do this by hand with 6k documents. I have been reading through the Scriping API, however, I could not identify a method or a way to achieve this. Did anyone else have a similar issue?

Thank you very much!

Best
Johannes

I would be interested to know more about this. It would also be great if you could raise some issues at http://jira.xwiki.org/projects/MARKDOWN/summary

That’s quite easy to do actually. See http://rendering.xwiki.org/xwiki/bin/view/Main/GettingStarted#HRenderXWikiSyntax2.1contentintoXHTML

You can see an example using groovy here: http://snippets.xwiki.org/xwiki/bin/view/Extension/Convert%20Confluence%20to%20XWiki%20Syntax

You can also use velocity and this script service and do a parse() followed by a render():
http://extensions.xwiki.org/xwiki/bin/view/Extension/Rendering%20Module#HRenderingScriptService

Then you need to iterate over pages, see https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Scripting/APIGuide/ for example (and http://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Scripting/ more generally).

Thank you very much for the quick reply! I will raise our issues in your jira - probably by the end of the week. :slight_smile:

The tickets will be more specific than this:
It is mostly about escaping XWiki Links in Markdown. Some of our documents have dots in their name, hence also in the path. When referencing such a document “” goes missing and the link becomes for example [[ asd| 1. groups.bla.blub ]] where we would actually expect 1\. groups.
Also there have been some issue with tables, however, I will have to ask my colleagues what the specific problem was.

I’d also be willing to contribute some fixes as soon as I know what files I’d have to touch!

Best,
Johannes

ok cool, it shouldn’t be hard to fix the problems in the markdown syntax for XWiki.

Actually it’s weird since we should already support dots in page names in links.

Great! I can help you and guide you to the right place. Let’s see the jiras and we can start a discussion on them. Thanks