Text/Plain formatter is pretty broken
My Wiki acts mainly as documentation for my program. I wanted to export the Wiki's contents as doc/*.txt into the program's tarball so they could easily be read with standard UNIX tools such as less. Unfortunately the text_plain.py included with MoinMoin created pretty unusable output. This is pretty much a complete rewrite, which fixes/changes at least the following:
Wiki links are now written like <Link text> [WikiLink.txt]. If the link text and WikiLink is the same, it writes just <WikiLink.txt>. Maybe you don't want the .txt part.
URLs were written as [None] instead of containing the actual URL
- Text is wrapped at 80 chars
- Added an empty line between paragraphs.
- In some situations there were too many empty lines making the output ugly. Now there are never more than one empty line between lines containing text.
If { { { block ends with } } } line containing text in the same line, it wrote <text>------etc. instead of putting the ---- in its own line
- Numeric/bulletin lists broke if there were any sublists
- Sometimes spaces were missing. For example it could output "some*bold* text".
I changed superscript to output only one ^ character. It's typically used for things like 232 so a single ^ character looks better.
>1 depth headers use now "-" characters, not "="
- Tables now output readable tables
Definition lists were written as "key<LF>:<LF>value", ie. the ":" in its own line. It was done only if "compact=1", which it always seemed to be. I don't know what it was supposed to do, so I just commented it out. Now the output at least looks right..
I'm not a real Python programmer, so the code might be stupid in places. I'm including the whole file instead of the patch because pretty much the whole file was changed.
If possible it would be nice to get a diff too -- ReimarBauer 2007-12-26 22:05:11
I updated this code to work with MoinMoin 1.8.2. A couple of issues though:
- Table of contents now has extra empty lines in it. This didn't happen with 1.5.8, so I guess something changed. I don't currently have time to figure out how to fix this.
- Indentation code in wrap() got uglier. It could use a cleanup, but again I'm busy so I was just happy to get it working..
Minor update for 1.9.2. Added a diff since ReimarBauer asked for it, although I doubt it's all too helpful. Would be nice to get this included some day. You can see examples of generated pages from http://www.dovecot.org/tmp/wiki-export.tar.gz
I've beautified the the patch text_plain.py.patch (pep8 (0.5.0) is happy) and did a few small code cleanups. There are currently tow known problems:
- the formatter may add a asterisk before the table starts (looks like it happens only when there is a empty line above the table)
- there is a empty line between list items.
-- PascalVolk 2010-04-06 20:52:48
Hi Pascal, it is almost pretty good, thx.
Can you please have a look at the smiley table. Do you have an idea how to fix that. Also some tables are too complex for the current solution. And please clean up this page, may be move the old patches to an "old" page. An example how to call it <<Action(format,"formats to text/plain", mimetype=text/plain)>> besides adding url parameters. -- ReimarBauer 2010-04-25 11:46:14
Moved old patches to /OldPatches -- PascalVolk 2010-05-03 08:50:45
beautified patch implemented in 1.9 -- ReimarBauer 2010-05-03 22:13:07