aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--famille.py9
-rw-r--r--templates/news/show.html2
2 files changed, 9 insertions, 2 deletions
diff --git a/famille.py b/famille.py
index 4a8cb73..6b128d6 100644
--- a/famille.py
+++ b/famille.py
@@ -5,6 +5,13 @@ from flask import Flask, request, session, g, redirect, url_for, \
abort, render_template, flash, _app_ctx_stack
from functools import wraps
import hashlib
+from docutils import core
+from docutils.writers.html4css1 import Writer
+
+def rstify_comment(string):
+ w = Writer()
+ result = core.publish_parts(string, writer=w)['fragment']
+ return result
# configuration
app = Flask(__name__)
@@ -68,7 +75,7 @@ def show_news(news_id):
return render_template("news/show.html", news=news, comments=comments)
elif request.method == 'POST':
user_id = session['user_id']
- content = request.form['content']
+ content = rstify(request.form['content'])
g.db.execute("INSERT INTO comments ('user_id', 'content', 'news_id') "
"VALUES (?, ?, ?)", (user_id, content, news_id))
g.db.commit()
diff --git a/templates/news/show.html b/templates/news/show.html
index c7795cd..459d9a4 100644
--- a/templates/news/show.html
+++ b/templates/news/show.html
@@ -21,7 +21,7 @@
{% for comment in comments %}
<h3 class="comment">Posté par <a href="">{{comment.name}}</a> le {{comment.date}} </h3>
<div class="comment_content"/>
-{{comment.content}}
+{{comment.content|safe}}
</div>
{% endfor %}