mirror of
https://github.com/karakeep-app/karakeep.git
synced 2026-02-28 18:25:55 +01:00
18 lines
409 B
TypeScript
18 lines
409 B
TypeScript
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);
|
|
}
|