aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/utils/htmlUtils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/shared/utils/htmlUtils.ts')
-rw-r--r--packages/shared/utils/htmlUtils.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/shared/utils/htmlUtils.ts b/packages/shared/utils/htmlUtils.ts
new file mode 100644
index 00000000..60272899
--- /dev/null
+++ b/packages/shared/utils/htmlUtils.ts
@@ -0,0 +1,17 @@
+import { compile } from "html-to-text";
+
+const compiledConvert = compile({
+ selectors: [{ selector: "img", format: "skip" }],
+});
+
+/**
+ * Converts HTML content to plain text
+ */
+export function htmlToPlainText(htmlContent: string): string {
+ if (!htmlContent) {
+ return "";
+ }
+
+ // TODO, we probably should also remove singlefile inline images from the content
+ return compiledConvert(htmlContent);
+}