added code for converting creole to html

* fixed the new line markup (\\) of creole
This commit is contained in:
lars 2010-04-26 01:43:11 +00:00
parent 8eda09bb20
commit 5355c8a34b

View file

@ -0,0 +1,14 @@
from creoleparser import text2html
"""
text can be creole-encoded, see http://www.wikicreole.org/imageServlet?page=CheatSheet%2Fcreole_cheat_sheet.png&width=340
"""
def creole2html(text):
# creoleparser returns an utf-8 encoded string by default, but this would cause "Markup" below to fail during decoding.
# The parameter "None" for "encoding" forces unicode output. This works with "Markup".
# Replace single backslashes with double ones (new line for creole), since python
# interprets a double backslash as the escape sequenze of a single backslash.
text = text.replace("\\", "\\\\")
return text2html(text, encoding=None)