I'm looking for a tool or script to convert Markdown files to Dokuwiki format, that will run on a PC.
This is so that I can use MarkdownPad on a PC to create initial drafts of documents, and then convert them to Dokuwiki format, to upload to a Dokuwiki installation that I have no control over. (This means that the Markdown plugin is no use to me.)
I could spend time writing a Python script to do the conversion myself, but I'd like to avoid spending time on this, if such a thing exists already.
The Markdown tags I'd like to have supported/converted are:
- Heading levels 1 – 5
- Bold, italic, underline, fixed width font
- Numbered and unnumbered lists
- Hyperlinks
- Horizontal rules
Does such a tool exist, or is there a good starting point available?
Things I've found and considered
-
I initially thought that txt2tags would be helpful, but although it can write both markdown and Dokuwiki, it is very tied to its own specific input format
-
I've also seen Markdown2Dokuwiki, and although I'd certainly be willing to use a sed script, even on a PC, this only supports a tiny, tiny part of Markdown's syntax.
-
python-markdown2 also sounded promising, but it only writes out HTML.
-
pandoc – but it doesn't support Dokuwiki output
Best Answer
Stop-Press - August 2014
Since Pandoc 1.13, Pandoc now contains my implementation of DokuWiki writing - and many more features are implemented there than in this script. So this script is now pretty-much redundant.
Having originally said I didn't want to write a Python script to do the conversion, I ended up doing just that.
The real time-saving step was to use Pandoc to parse the Markdown text, and write out a JSON representation of the document. This JSON file was then mostly fairly easy to parse, and write out in DokuWiki format.
Below is the script, which implements the bits of Markdown and DokuWiki that I cared about - and a few more. (I've not uploaded the corresponding test suite that I wrote)
Requirements to use it:
I hope this saves someone else some time too...
Edit 2: 2013-06-26: I've now put this code into GitHub, at https://github.com/claremacrae/markdown_to_dokuwiki.py. Note that the code there adds support for more formats, and also contains a test suite.
Edit 1: adjusted to add code for parsing code samples in Markdown's backtick style: