Greetings dear reader,
this small web application renders user's input in reStructuredText into HTML. It is written in mod_python. I have put it into Public Domain. I hope you find it useful.
The following is the source code of it. Hail to Python for it is so short.
Author: | Jiri Barton <jbar@hosting4u.cz> |
---|
from docutils.core import publish_string def index(req, content=''): req.content_type = 'text/html; charset=UTF-8' req.send_http_header() return publish_string( source=content, settings_overrides={'file_insertion_enabled': 0, 'raw_enabled': 0}, writer_name='html')
<html> <head> <title>reST renderer</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <h1>reST to HTML conversion</h1> <form action="render.py" method="post"> <label>Type some reST into the box below:</label> <br /> <textarea name="content" rows="20" cols="80"></textarea> <br /><br /> <input type="submit" value="Render" /> </form> </body> </html>
(be sure to put render.py and rest.html in the directory (such as /home/jbar/scratchpad/rest) and edit the path below... and don't forget to load mod_python)
<Directory "/home/jbar/scratchpad/rest"> AddHandler mod_python .py PythonHandler mod_python.publisher PythonDebug On </Directory> Alias /rest /home/jbar/scratchpad/rest