changeset 588:c8cca1a373dd

server_side: static blog: convert \n in raw text message to <br/>
author souliane <souliane@mailoo.org>
date Mon, 15 Dec 2014 16:03:01 +0100
parents 6a1fea10ae8c
children 1bffc4c244c3
files src/server/blog.py src/server/html_tools.py
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/server/blog.py	Mon Dec 15 16:01:51 2014 +0100
+++ b/src/server/blog.py	Mon Dec 15 16:03:01 2014 +0100
@@ -31,7 +31,7 @@
 import re
 import os
 
-from libervia.server.html_tools import sanitizeHtml
+from libervia.server.html_tools import sanitizeHtml, convertNewLinesToXHTML
 from libervia.server.constants import Const as C
 
 
@@ -348,7 +348,7 @@
                 return entry['%s_xhtml' % key].encode('utf-8')
             elif key in entry:
                 processor = addURLToText if key.startswith('content') else sanitizeHtml
-                return processor(entry[key]).encode('utf-8')
+                return convertNewLinesToXHTML(processor(entry[key])).encode('utf-8')
             return ''
 
         def addMainItemLink(elem):
--- a/src/server/html_tools.py	Mon Dec 15 16:01:51 2014 +0100
+++ b/src/server/html_tools.py	Mon Dec 15 16:03:01 2014 +0100
@@ -30,3 +30,7 @@
         }
 
     return "".join(html_escape_table.get(c, c) for c in text)
+
+
+def convertNewLinesToXHTML(text):
+    return text.replace('\n', '<br/>')