From da51003290fa12021e941a4df1ae63be1aeff188 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 11 2017 16:28:57 +0000 Subject: [PATCH 1/3] Allow the td and th tags to have an align attribute Fixes https://pagure.io/pagure/issue/2221 --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index c9f5dc0..de7815f 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -3404,6 +3404,8 @@ def clean_input(text, ignore=None): attrs['table'] = ['class'] attrs['span'] = ['class', 'id'] attrs['div'] = ['class'] + attrs['td'] = ['align'] + attrs['th'] = ['align'] if not ignore or 'img' not in ignore: attrs['img'] = filter_img_src From cc68031a9a06247bf8ff14f526ffa3da1d883a13 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 11 2017 16:28:57 +0000 Subject: [PATCH 2/3] Make the html table created in the comment section prettier Fixes https://pagure.io/pagure/issue/2221 --- diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index 8237b0a..3466f7e 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -23,6 +23,19 @@ html border-bottom:1px solid #DDD; } +.issue_comment table { + margin-bottom: 1em; +} + +.issue_comment table, .issue_comment th, .issue_comment td { + border: 1px solid #e5e5e5; + padding: .35em; +} + +.issue_comment th { + background-color: #f5f5f5; +} + .notification-spacer { From c7f3852004cdd22aca73efe1926ee1a144632244 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 11 2017 16:28:57 +0000 Subject: [PATCH 3/3] Add unit-tests for text2markdown with a table having orientation --- diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py index 0fcb6fc..d816823 100644 --- a/tests/test_pagure_lib.py +++ b/tests/test_pagure_lib.py @@ -4284,6 +4284,46 @@ class PagureLibtests(tests.Modeltests): } ) + def test_text2markdown_table(self): + """ Test the text2markdown function with a markdown table. """ + + text = """ +| Left-aligned | Center-aligned | Right-aligned | +| :--- | :---: | ---: | +| git status | git status | git status | +| git diff | git diff | git diff | + + +foo bar + """ + + expected = """ + + + + + + + + + + + + + + + + + + + +
Left-alignedCenter-alignedRight-aligned
git statusgit statusgit status
git diffgit diffgit diff
+

foo bar

""" + + with pagure.APP.app_context(): + html = pagure.lib.text2markdown(text) + self.assertEqual(html, expected) + if __name__ == '__main__': SUITE = unittest.TestLoader().loadTestsFromTestCase(PagureLibtests)