1
0
Fork 0
forked from github/pelican

Introduce paragraph count summary (#2761)

Co-authored-by: Justin Mayer <entroP@gmail.com>
This commit is contained in:
Agathe 2024-06-25 15:07:41 +02:00 committed by GitHub
commit 513abbfdc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 80 additions and 2 deletions

View file

@ -401,6 +401,23 @@ class TestUtils(LoggedTestCase):
self.assertEqual(utils.truncate_html_words("&#1234 text", 20), "&#1234 text")
self.assertEqual(utils.truncate_html_words("&#xabc text", 20), "&#xabc text")
def test_truncate_html_paragraphs(self):
one = "<p>one</p>"
self.assertEqual(utils.truncate_html_paragraphs(one, 0), "")
self.assertEqual(utils.truncate_html_paragraphs(one, 1), one)
self.assertEqual(utils.truncate_html_paragraphs(one, 2), one)
two = one + "<p>two</p>"
self.assertEqual(utils.truncate_html_paragraphs(two, 1), one)
self.assertEqual(utils.truncate_html_paragraphs(two, 2), two)
three = two + "<p>three</p>"
self.assertEqual(utils.truncate_html_paragraphs(three, 1), one)
self.assertEqual(utils.truncate_html_paragraphs(three, 2), two)
self.assertEqual(utils.truncate_html_paragraphs(three, 3), three)
self.assertEqual(utils.truncate_html_paragraphs(three, 4), three)
def test_process_translations(self):
fr_articles = []
en_articles = []