How to export a whole wiki to Markdown

Hi!

It seems that each page has the option to be exported to PDF, HTML, or XAR, including its child pages when using HTML or XAR. If I go to the root page, I can thus export the whole wiki.

I have installed the Markdown extension, as it seems it supports both input (parsing) and output (rendering). I have noticed a dropdown on each page, when in edit mode, to convert the page markup. I tried on one page and it seems it did the conversion but with newlines replaced by spaces, and then XWiki reports an error when trying to display the page. That’s a problem in itself but my bigger question is:

How can I actually export the whole wiki using the Markdown format (although each page use the XWiki format) ? Eve though I have installed the Markdown extension, the export dialog only propose PDF, HTML, and XAR. The XAR format seems nice as I have a bunch of metadata for each page, but I’d like the actual content to be Markdown, instead of the XWiki markup.

Some additional info: the bottom of each page reports XWiki Debian 12.1. Although the Markdown 1.2 extension is installed, the disable syntax options only lists Markdown 1.0 and 1.1.

Thanks!

About this one, could you report an issue at https://jira.xwiki.org/projects/MARKDOWN/summary if you believe there’s an error? But please verify first that it’s not correct MD :slight_smile:

This feature doesn’t exist. The export feature doesn’t do any conversion. It just exports the page as they are. If a page is in Markdown Syntax the exported XML for that page will contain the content inside the XML in Markdown Syntax. If a page is in XWiki Syntax 2.1, it’ll be exported in XML having content in XWiki Syntax 2.1, etc.

The only format that we export to is HTML, to generate an offline version of the wiki that you can open in your browser locally.

What page? In what export format? What is “XWiki Debian 12.1” :slight_smile: ?

More generally could you explain your use case? It seems like you would want the various wiki pages in a non-MD syntax but when you export to XAR, that it would perform an on-the-fly conversion to MD. What’s the purpose? The goal of XAR is for you to be able to reimport in the wiki (same one or another one), so you’d reimport as MD and not as the original syntax, which would ruin your wiki (since the pages would not longer be in their original syntaxes).

Thanks

But please verify first that it’s not correct MD

It seems to be correct, but without newlines. Even when I add them afterwards, they are removed when I save.

This feature doesn’t exist.

Ok then. Is there something I can do to mass-convert all the pages to Markdown ?
Or could I use some XWiki JAR to process the content of the XAR files to do the conversion with an offline script ?

What page? In what export format? What is “XWiki Debian 12.1”

I mean this the regular footer I see on my XWiki instance. I thought it was how it was reporting its version. Sorry for the confusion.

What’s the purpose?

I have an existing publishing pipeline processing Markdown files as input, and I wanted to process content authored within XWiki with the same pipeline (but this is a lot of different pages, that’s why I’d like to the conversion “massively”).

Thanks for your answer !

First a page is not just content but can contain metadata (we call the objects or xobjects). Some xobject properties are of type textarea and can contain markup too. So I guess you want to convert them too?

There are plenty of ways to do what you want but it requires a bit of coding:

I’ve written a quick groovy script to show you how it can be done, see https://snippets.xwiki.org/xwiki/bin/view/Extension/Export%20pages%20to%20Markdown/

Hi, I still hadn’t the time to try your solution. Just a quick message to say Thanks.