[pydotorg-www] tip on converting reStructuredText to MoinMoin wiki format

Sumana Harihareswara sh at changeset.nyc
Mon Feb 10 10:50:29 EST 2020


Here is a tip for anyone who is converting a complicated page on the 
wiki from reStructuredText to MoinMoin wiki format, as I just did 
https://wiki.python.org/psf/PackagingWG?action=diff&rev1=107&rev2=108 . 
I'd been looking for an rST-to-MoinMoin converter but hadn't found one, 
so I ended up using pandoc to get to an intermediate HTML state, then an 
HTML-to-MoinMoin format.

(I did this so I could use the  `<<TableOfContents()>>`  syntax to 
automatically get a table of contents and easy anchor tag links to page 
sections.)

Cleaned up to remove backtracking, I:

1) copied the rST source text of the page into a local file, 
packagingwg.rst

2) removed the `#format rst` line from the start (but copied the rest of 
the hashmarked stuff from the start, like an #acl line, into a separate 
scratch pad to retain for later)

3) turned the rST into HTML using pandoc: `pandoc -o packagingwg.html 
packagingwg.rst` (this gave me a few errors, like "[WARNING] Reference 
not found for 'fundable packaging improvements' at chunk line 1 column 
50", which meant it slightly misformatted a few internal wiki links

4) installed libhtml-wikiconverter-moinmoin-perl which is available as a 
Debian package

5) converted from HTML to MoinMoin using  `html2wiki --dialect=MoinMoin 
packagingwg.html > packagingwg.wiki`

6) pasted the non-format-related hashmarked lines from my scratch pad 
into the start of packagingwg.wiki

7) corrected the "Reference not found" errors by removing the `|` in any 
hyperlinks that had turned into `[[|internal-pagename]`

8) replaced the contents of the page source with packagingwg.wiki

Worked fine!

Only on the revision AFTER that (so, knowing what format to use for the 
renderer, I suppose) will MoinMoin properly preview a table of contents 
for the page. So, heads-up.

If there is an easier rst-to-MoinMoin path, or if there's a table of 
contents syntax available that works for reStructuredText-formatted 
pages on wiki.python.org, please let me know! I looked but I may have 
missed something.

-- 
Sumana Harihareswara
Changeset Consulting
https://changeset.nyc


More information about the pydotorg-www mailing list