Hacking Restructured Text
I am a great fan of Restructured Text. I write my blog using it. I write my business proposals using it, I write my documentation using it, I think you should write almsot everything you write now using it. I have even blogged many times about it.
RST is a minimal markup language. You can figure it out in a couple of hours, and then use it to produce pretty HTML pages, PDF docs, man pages, LaTeX documents, S5 slides, and other things.
Plus, the source works as a plain text version, and is very readable:
This is a title =============== Some text in a paragraph A subtitle ---------- * A list * More items 1. A numbered sublist 2. Another item a) A sub-sub-list b) With more items +-----------------------+-------------------------+ | A table | With two columns | +-----------------------+-------------------------+ | And Two | rows | +-----------------------+-------------------------+
See? Nice.
RST has another great thing that is not so well known: there is a parser for it, which turns the document into a tree of nodes reppresenting different parts of the document.
You can manipulate this node tree, modifying the document, and then generate the output.
But there is no way, right now, to generate RST from the tree. Which means it's a one way road.
Well, I am hacking to fix that.
Right now, I handle titles, sections, all sorts of lists, transitions, quotes, emphasis, italics, and a few other elements.
The only ones that seem difficult to implement are tables, but I still think I can do it. Although the produced RST doesn't look the same as the original, it is functionally identical.
How do I test if it works? With a test suite. If it works, it should be invariant this way:
RSTsample -> rst2html produces the exact same output as RSTsample -> rst2rst -> rst2html
If anyone wants a copy, email me.
I'd love to see that in kmail.
Adding layout options like the HTML editing mode, and then send it as RST in my email ...
Have you give a try to txt2tags ?
I have looked at txt2tags, but only recently, and superficially.