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

Sumana Harihareswara sh at changeset.nyc
Mon Feb 10 11:57:33 EST 2020


Well, phooey, wasn't I silly for missing that! I could swear I had tried 
that and it hadn't worked; perhaps I'd been messing something else up. 
Thanks for the tip, David.

-Sumana

On 2/10/20 11:42 AM, David Goodger wrote:
> FYI, you could have simply inserted:
> 
>      .. contents::
> 
> Details here:
> https://docutils.sourceforge.io/docs/ref/rst/directives.html#table-of-contents
> 
> 
> David Goodger
> <https://david.goodger.org>
> 
> 
> On Mon, Feb 10, 2020 at 9:51 AM Sumana Harihareswara <sh at changeset.nyc>
> wrote:
> 
>> 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