Added a feature to allow more images per article (with a test)

pull/65/head
Yuri Baburov 9 years ago
parent c6796195a7
commit 1fac7e685a

@ -482,7 +482,7 @@ class Document:
#if el.tag == 'div' and counts["img"] >= 1:
# continue
if counts["p"] and counts["img"] > counts["p"]:
if counts["p"] and counts["img"] > 1+counts["p"]*1.3:
reason = "too many images (%s)" % counts["img"]
to_remove = True
elif counts["li"] > counts["p"] and tag != "ul" and tag != "ol":

File diff suppressed because one or more lines are too long

@ -37,3 +37,10 @@ class TestArticleOnly(unittest.TestCase):
res = doc.summary(html_partial=True)
self.assertEqual('<div><div class="', res[0:17])
def test_too_many_images_sample_html_partial(self):
"""Using the too-many-images sample, make sure we still get the article."""
sample = load_sample('too-many-images.sample.html')
doc = Document(sample)
res = doc.summary(html_partial=True)
self.assertEqual('<div><div class="post-body', res[0:26])

Loading…
Cancel
Save