aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/utils/htmlUtils.ts
blob: 60272899b4c0e5eb218129aca1e6de5699fb9e83 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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);
}