Strip taz product-teaser promo from readable view
The "taz FUTURZWEI im Abo entdecken" box has neither an /abo/ link nor an "Abo" aria-label, so the existing taz rules missed it. Remove its section.article-produktteaser-container before Readability parses the page.
This commit is contained in:
1 parent
81f5f0f722
commit
1928c79b7a
2 files changed
+36
No files matched your search
@@ -1280,6 +1280,38 @@ describe('useFeeds', () => {
|
||||
expect(feeds.value[0].content).not.toContain('<img')
|
||||
})
|
||||
|
||||
it('strips taz product-teaser sections (e.g. the FUTURZWEI promo)', async () => {
|
||||
feeds.value = [{
|
||||
id: 1,
|
||||
title: 'Article one',
|
||||
url: 'https://taz.de/Article-one/!6218657/',
|
||||
content: '',
|
||||
}]
|
||||
axios.post.mockResolvedValueOnce({
|
||||
data: {
|
||||
content: `<html><body><article>
|
||||
<p>some article text long enough for readability to keep the paragraph as the main content body, padded with extra words to pass the content-length heuristics used by Mozilla Readability when scoring candidate nodes.</p>
|
||||
<section class="module columns article-produktteaser-container"><article class="column">
|
||||
<a href="/taz-FUTURZWEI/endlich-mal-ein-magazin-fuer-zukunft/!v=74fecf50/" class="teaser-link">
|
||||
<div class="text-column"><h2><span>taz FUTURZWEI im Abo entdecken</span><span>Endlich mal ein Magazin für Zukunft</span></h2>
|
||||
<p>taz FUTURZWEI ist unser Magazin für eine bessere Zukunft. Das Abo bietet jährlich vier Ausgaben für nur 38 Euro.</p>
|
||||
<ul><li>Jedes Quartal neu in Ihrem Briefkasten</li><li>Nur 38 Euro im Jahr</li></ul></div>
|
||||
<p>Jetzt abonnieren</p>
|
||||
</a>
|
||||
</article></section>
|
||||
<p>more article text long enough to survive readability's content-length heuristics as well, since it needs to look like part of the main body too.</p>
|
||||
</article></body></html>`,
|
||||
},
|
||||
})
|
||||
|
||||
await getReadable(feeds.value[0], 0)
|
||||
|
||||
expect(feeds.value[0].readable).toBe(true)
|
||||
expect(feeds.value[0].content).toContain('main content body')
|
||||
expect(feeds.value[0].content).not.toContain('FUTURZWEI')
|
||||
expect(feeds.value[0].content).not.toContain('Jetzt abonnieren')
|
||||
})
|
||||
|
||||
it('strips Al-Jazeera-style "Recommended Stories" sections', async () => {
|
||||
feeds.value = [{
|
||||
id: 1,
|
||||
|
||||
@@ -291,6 +291,10 @@ async function getReadable(feed, index) {
|
||||
const container = el.closest('section') ?? el.closest('article')
|
||||
if (container) container.remove()
|
||||
})
|
||||
// taz product teasers (e.g. the "taz FUTURZWEI im Abo entdecken" box): a
|
||||
// <section> whose link has neither an /abo/ href nor an "Abo" aria-label,
|
||||
// so only its container class identifies it.
|
||||
doc.querySelectorAll('section.article-produktteaser-container').forEach(el => el.remove())
|
||||
// Al Jazeera embeds a "Recommended Stories" section (a heading followed by
|
||||
// a list of unrelated article teasers), marked up as <section class="more-on">.
|
||||
// It's not part of the article, so strip it before Readability pulls it
|
||||
|
||||
Reference in new issue
Block a user