Fixed issue with self-closing tags. Fix #125

This commit is contained in:
Éloi Rivard 2019-12-29 16:23:55 +01:00
parent de20908e57
commit 0846955dd7
2 changed files with 6 additions and 1 deletions

View File

@ -171,7 +171,7 @@ class Document:
An internal method, which can be overridden in subclasses, for example,
to disable or to improve DOM-to-text conversion in .summary() method
"""
return clean_attributes(tounicode(self.html))
return clean_attributes(tounicode(self.html, method='html'))
def summary(self, html_partial=False):
"""

View File

@ -106,3 +106,8 @@ class TestArticleOnly(unittest.TestCase):
s = doc.summary()
assert 'foo' in s
def test_not_self_closing(self):
sample = '<h2><a href="#"></a>foobar</h2>'
doc = Document(sample)
assert '<body id="readabilityBody"><h2><a href="#"></a>foobar</h2></body>' == doc.summary()