forked from enviPath/enviPy
fix: handle line-clamp issue with news
This commit is contained in:
@ -63,17 +63,17 @@ class DiscourseAPI {
|
||||
* @returns {string} Cleaned excerpt
|
||||
*/
|
||||
extractExcerpt(excerpt) {
|
||||
if (!excerpt) return 'Click to read more...';
|
||||
if (!excerpt) return 'Click to read more';
|
||||
|
||||
// Remove HTML tags and clean up
|
||||
// Remove HTML tags and clean up; collapse whitespace; do not add manual ellipsis
|
||||
return excerpt
|
||||
.replace(/<[^>]*>/g, '') // Remove HTML tags
|
||||
.replace(/ /g, ' ') // Replace with spaces
|
||||
.replace(/&/g, '&') // Replace & with &
|
||||
.replace(/</g, '<') // Replace < with <
|
||||
.replace(/>/g, '>') // Replace > with >
|
||||
.replace(/\s+/g, ' ') // Collapse all whitespace/newlines
|
||||
.trim()
|
||||
.substring(0, 200) + '...'; // Limit length
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user