|
|
@ -12,12 +12,16 @@ const convert = (html: string) => |
|
|
|
listStyle: "linebreak", |
|
|
|
listStyle: "linebreak", |
|
|
|
}) |
|
|
|
}) |
|
|
|
export const htmlToText = (html: string) => { |
|
|
|
export const htmlToText = (html: string) => { |
|
|
|
const text = convert(html) |
|
|
|
try { |
|
|
|
|
|
|
|
const text = convert(html) |
|
|
|
return text |
|
|
|
return text |
|
|
|
.replaceAll(/&\w*;/g, "") |
|
|
|
.replaceAll(/&\w*;/g, "") |
|
|
|
.replaceAll(/<!--\s?(.|\R|\s)*?-->/g, "") |
|
|
|
.replaceAll(/<!--\s?(.|\R|\s)*?-->/g, "") |
|
|
|
.replaceAll(/<.*><\/.*>/g, "") |
|
|
|
.replaceAll(/<.*><\/.*>/g, "") |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log("htmlToText", e) |
|
|
|
|
|
|
|
return "" |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const SHOULD_NOT_PARSE = "SHOULD_NOT_PARSE" |
|
|
|
export const SHOULD_NOT_PARSE = "SHOULD_NOT_PARSE" |
|
|
|