diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2017-04-23 13:54:21 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2017-04-23 18:43:26 +0200 |
commit | 9aa4203c7efd5ef1015eb32eca5e0764a5afe183 (patch) | |
tree | 8401005b860541ea8f4be94e7b58d7d0eb808eac /aurweb/scripts | |
parent | 016b40f99d679f0787f7c8a5f61f4a411b6c3632 (diff) | |
download | aur-9aa4203c7efd5ef1015eb32eca5e0764a5afe183.tar.gz aur-9aa4203c7efd5ef1015eb32eca5e0764a5afe183.tar.xz |
Add Markdown support to package comments
Support Markdown syntax in package comments. Among other things, this
makes it easier to paste command line output and patches.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'aurweb/scripts')
-rwxr-xr-x | aurweb/scripts/rendercomment.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/aurweb/scripts/rendercomment.py b/aurweb/scripts/rendercomment.py index 593cd36a..7e8a16b8 100755 --- a/aurweb/scripts/rendercomment.py +++ b/aurweb/scripts/rendercomment.py @@ -2,6 +2,7 @@ import sys import bleach +import markdown import aurweb.db @@ -22,9 +23,10 @@ def main(): conn = aurweb.db.Connection() - html = get_comment(conn, commentid) - html = html.replace('\n', '<br>') - html = bleach.clean(html, tags=['br']) + text = get_comment(conn, commentid) + html = markdown.markdown(text, extensions=['nl2br']) + allowed_tags = bleach.sanitizer.ALLOWED_TAGS + ['p', 'br'] + html = bleach.clean(html, tags=allowed_tags) save_rendered_comment(conn, commentid, html) conn.commit() |