Skip to content

Commit

Permalink
Truncate URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Jan 9, 2024
1 parent d71b1a7 commit ffabd61
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/utils/getHTMLText.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ function getHTMLText(html) {
div.querySelectorAll('br').forEach((br) => {
br.replaceWith('\n');
});

// MASTODON-SPECIFIC classes
// Remove .invisible
div.querySelectorAll('.invisible').forEach((el) => {
el.remove();
});
// Add … at end of .ellipsis
div.querySelectorAll('.ellipsis').forEach((el) => {
el.append('...');
});

return div.innerText.replace(/[\r\n]{3,}/g, '\n\n').trim();
}

Expand Down

0 comments on commit ffabd61

Please sign in to comment.