Merge pull request #128 from azmeuk/self-closing

Replaced XHTML output with HTML5 output in summary for empty elements (a, br), issue #125
pull/132/head
Yuri Baburov 4 years ago committed by GitHub
commit da9e285f73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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):
"""

@ -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()

Loading…
Cancel
Save