Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

Drop any tags from h1 #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Readability.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,17 @@ private function getArticleTitle()
$hOnes = $this->dom->getElementsByTagName('h1');

if ($hOnes->length === 1) {
$curTitle = $hOnes->item(0)->nodeValue;
$header = $hOnes->item(0);

try {
foreach ($header->getElementsByTagName('*') as $element) {
$header->removeChild($element);
}
} catch (\Exception $e) {
}

$curTitle = $header->nodeValue;

$this->logger->info(sprintf('[Metadata] Using title from an H1 node: \'%s\'', $curTitle));
}
}
Expand Down