8000 Merge pull request #128 from azmeuk/self-closing · Harry0201/python-readability@da9e285 · GitHub
[go: up one dir, main page]

Skip to content

Commit da9e285

Browse files
authored
Merge pull request buriy#128 from azmeuk/self-closing
Replaced XHTML output with HTML5 output in summary for empty elements (a, br), issue buriy#125
2 parents 5032e2d + 0846955 commit da9e285

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

readability/readability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def get_clean_html(self):
171171
An internal method, which can be overridden in subclasses, for example,
172172
to disable or to improve DOM-to-text conversion in .summary() method
173173
"""
174-
return clean_attributes(tounicode(self.html))
174+
return clean_attributes(tounicode(self.html, method='html'))
175175

176176
def summary(self, html_partial=False):
177177
"""

tests/test_article_only.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,8 @@ def test_many_repeated_spaces(self):
106106
s = doc.summary()
107107

108108
assert 'foo' in s
109+
110+
def test_not_self_closing(self):
111+
sample = '<h2><a href="#"></a>foobar</h2>'
112+
doc = Document(sample)
113+
assert '<body id="readabilityBody"><h2><a href="#"></a>foobar</h2></body>' == doc.summary()

0 commit comments

Comments
 (0)
0