added code for converting creole to html
* fixed the new line markup (\\) of creole
This commit is contained in:
parent
8eda09bb20
commit
5355c8a34b
1 changed files with 14 additions and 0 deletions
14
wortschlucker/src/tools.py
Normal file
14
wortschlucker/src/tools.py
Normal 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)
|
||||||
|
|
Loading…
Reference in a new issue