MCPcopy Create free account
hub / github.com/NateBJones-Projects/OB1 / htmlToText

Function htmlToText

recipes/gmail-smart-pull/scripts/pull-gmail.mjs:707–727  ·  view source on GitHub ↗
(html)

Source from the content-addressed store, hash-verified

705}
706
707function htmlToText(html) {
708 return html
709 .replace(/<br\s*\/?>/gi, "\n")
710 .replace(/<\/p>/gi, "\n\n")
711 .replace(/<\/div>/gi, "\n")
712 .replace(/<\/li>/gi, "\n")
713 .replace(/<\/h[1-6]>/gi, "\n\n")
714 .replace(/<\/tr>/gi, "\n")
715 .replace(/<li[^>]*>/gi, "- ")
716 .replace(/<[^>]+>/g, "")
717 .replace(/&nbsp;/g, " ")
718 .replace(/&amp;/g, "&")
719 .replace(/&lt;/g, "<")
720 .replace(/&gt;/g, ">")
721 .replace(/&quot;/g, '"')
722 .replace(/&#39;/g, "'")
723 .replace(/&#x27;/g, "'")
724 .replace(/[ \t]+/g, " ")
725 .replace(/\n{3,}/g, "\n\n")
726 .trim();
727}
728
729function stripQuotedReplies(text) {
730 const lines = text.split("\n");

Callers 1

processEmailFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…