fix: allow parsing codeblocks with multiple text nodes in children (#1842)

This commit is contained in:
Zaidhaan 2023-03-02 22:27:32 +08:00 committed by GitHub
parent f3ad179c69
commit dbfb450e23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -162,6 +162,13 @@ export function htmlToText(html: string) {
}
}
export function recursiveTreeToText(input: Node): string {
if (input && input.children && input.children.length > 0)
return input.children.map((n: Node) => recursiveTreeToText(n)).join('')
else
return treeToText(input)
}
export function treeToText(input: Node): string {
let pre = ''
let body = ''