also removing <style> tags

This commit is contained in:
Kilian Singer 2025-08-20 18:42:36 +02:00
parent c24097245b
commit 09d620c294

View file

@ -206,7 +206,9 @@ export function htmlBodyToPlainText(htmlString) {
// remove invisible elements https://stackoverflow.com/questions/39813081/queryselector-where-display-is-not-none
// return doc;
const docsan=doc.querySelectorAll('[style*="visibility:hidden"]').forEach(e => e.remove());//.querySelector('html').children.not(':visible').remove()
doc.querySelectorAll('[style*="display:none"]').forEach(e => e.remove());//.querySelector('html').children.not(':visible').remove()
doc.querySelectorAll('style').forEach(e => e.remove());//.querySelector('html').children.not(':visible').remove()
// Extract text content
const textContent = doc.body.textContent || "";
// Trim whitespace