mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
This commit is contained in:
parent
016b40f99d
commit
9aa4203c7e
2 changed files with 7 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import bleach
|
import bleach
|
||||||
|
import markdown
|
||||||
|
|
||||||
import aurweb.db
|
import aurweb.db
|
||||||
|
|
||||||
|
@ -22,9 +23,10 @@ def main():
|
||||||
|
|
||||||
conn = aurweb.db.Connection()
|
conn = aurweb.db.Connection()
|
||||||
|
|
||||||
html = get_comment(conn, commentid)
|
text = get_comment(conn, commentid)
|
||||||
html = html.replace('\n', '<br>')
|
html = markdown.markdown(text, extensions=['nl2br'])
|
||||||
html = bleach.clean(html, tags=['br'])
|
allowed_tags = bleach.sanitizer.ALLOWED_TAGS + ['p', 'br']
|
||||||
|
html = bleach.clean(html, tags=allowed_tags)
|
||||||
save_rendered_comment(conn, commentid, html)
|
save_rendered_comment(conn, commentid, html)
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
|
@ -11,7 +11,8 @@ test_expect_success 'Test comment rendering.' '
|
||||||
EOD
|
EOD
|
||||||
"$RENDERCOMMENT" 1 &&
|
"$RENDERCOMMENT" 1 &&
|
||||||
cat <<-EOD >expected &&
|
cat <<-EOD >expected &&
|
||||||
Hello world!<br>This is a comment.
|
<p>Hello world!<br>
|
||||||
|
This is a comment.</p>
|
||||||
EOD
|
EOD
|
||||||
cat <<-EOD | sqlite3 aur.db >actual &&
|
cat <<-EOD | sqlite3 aur.db >actual &&
|
||||||
SELECT RenderedComment FROM PackageComments WHERE ID = 1;
|
SELECT RenderedComment FROM PackageComments WHERE ID = 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue