fix: strip source names from excerpts using nbsp separators
Google News RSS excerpts use (double non-breaking spaces) to separate the excerpt text from the source name. Added html_entity_decode and nbsp-based separators to handle this pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -192,7 +192,18 @@ class Peptide_News_Rest_API {
|
||||
return $text;
|
||||
}
|
||||
|
||||
$separators = array( ' - ', ' | ', ' — ', ' – ', ' // ' );
|
||||
// Decode HTML entities first so becomes actual characters.
|
||||
$text = html_entity_decode( $text, ENT_QUOTES | ENT_HTML5, 'UTF-8' );
|
||||
|
||||
// Common separators between title/excerpt and source name.
|
||||
// Includes regular spaces, non-breaking spaces (\xC2\xA0), and typographic dashes.
|
||||
$nbsp = "\xC2\xA0"; // UTF-8 non-breaking space
|
||||
$separators = array(
|
||||
' - ', ' | ', ' — ', ' – ', ' // ',
|
||||
$nbsp . $nbsp, // double non-breaking space (Google News RSS excerpts)
|
||||
' ', // double regular space
|
||||
$nbsp, // single non-breaking space
|
||||
);
|
||||
|
||||
// Build list of source names to try matching against.
|
||||
$source_names = array();
|
||||
|
||||
@@ -183,7 +183,18 @@ class Peptide_News_Rest_API {
|
||||
return $text;
|
||||
}
|
||||
|
||||
$separators = array( ' - ', ' | ', ' — ', ' – ', ' // ' );
|
||||
// Decode HTML entities first so becomes actual characters.
|
||||
$text = html_entity_decode( $text, ENT_QUOTES | ENT_HTML5, 'UTF-8' );
|
||||
|
||||
// Common separators between title/excerpt and source name.
|
||||
// Includes regular spaces, non-breaking spaces (\xC2\xA0), and typographic dashes.
|
||||
$nbsp = "\xC2\xA0"; // UTF-8 non-breaking space
|
||||
$separators = array(
|
||||
' - ', ' | ', ' — ', ' – ', ' // ',
|
||||
$nbsp . $nbsp, // double non-breaking space (Google News RSS excerpts)
|
||||
' ', // double regular space
|
||||
$nbsp, // single non-breaking space
|
||||
);
|
||||
|
||||
// Build list of source names to try matching against.
|
||||
$source_names = array();
|
||||
|
||||
Reference in New Issue
Block a user