diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 634dfbee..3863ba32 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -218,12 +218,18 @@ class TestUtils(LoggedTestCase): "∫dx " * 20 + '…') # Words with invalid or broken HTML references. - self.assertEqual(utils.truncate_html_words('&invalid;', 20), '&invalid;') - self.assertEqual(utils.truncate_html_words('�', 20), '�') - self.assertEqual(utils.truncate_html_words('�', 20), '�') - self.assertEqual(utils.truncate_html_words('&mdash', 20), '&mdash') - self.assertEqual(utils.truncate_html_words('Ӓ', 20), 'Ӓ') - self.assertEqual(utils.truncate_html_words('઼', 20), '઼') + self.assertEqual( + utils.truncate_html_words('&invalid;', 20), '&invalid;') + self.assertEqual( + utils.truncate_html_words('�', 20), '�') + self.assertEqual( + utils.truncate_html_words('�', 20), '�') + self.assertEqual( + utils.truncate_html_words('&mdash', 20), '&mdash') + self.assertEqual( + utils.truncate_html_words('Ӓ', 20), 'Ӓ') + self.assertEqual( + utils.truncate_html_words('઼', 20), '઼') def test_process_translations(self): fr_articles = [] diff --git a/pelican/utils.py b/pelican/utils.py index 59400699..ab2e4a6e 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -552,15 +552,15 @@ class _HTMLWordTruncator(HTMLParser): def _handle_ref(self, name, char): """ - Called by handle_entityref() or handle_charref() when a ref like + Called by handle_entityref() or handle_charref() when a ref like `—`, `—`, or `—` is found. - + The arguments for this method are: - + - `name`: the HTML entity name (such as `mdash` or `#8212` or `#x2014`) - `char`: the Unicode representation of the ref (such as `—`) - This method checks whether the entity is considered to be part of a + This method checks whether the entity is considered to be part of a word or not and, if not, signals the end of a word. """ # Compute the index of the character right after the ref.