diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 1890ffb96..2dab2ab44 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -259,6 +259,26 @@ def test_truncate_html_words(self): utils.truncate_html_words('' + 'word ' * 100, 20), '' + 'word ' * 20 + '…') + # Words enclosed or intervaled by HTML tags with a custom end + # marker containing HTML tags. + self.assertEqual( + utils.truncate_html_words('

' + 'word ' * 100 + '

', 20, + 'marker'), + '

' + 'word ' * 20 + 'marker

') + self.assertEqual( + utils.truncate_html_words( + '' + 'word ' * 100 + '', 20, + 'marker'), + '' + 'word ' * 20 + 'marker') + self.assertEqual( + utils.truncate_html_words('
' + 'word ' * 100, 20, + 'marker'), + '
' + 'word ' * 20 + 'marker') + self.assertEqual( + utils.truncate_html_words('' + 'word ' * 100, 20, + 'marker'), + '' + 'word ' * 20 + 'marker') + # Words with hypens and apostrophes. self.assertEqual( utils.truncate_html_words("a-b " * 100, 20),