feat: translation flows, revision conflicts, delete scopes, article moves and a target site for new articles
This commit is contained in:
1 parent
339e646eb8
commit
45fbbc33b1
93 files changed
+7630
-294
No files matched your search
@@ -0,0 +1,16 @@
|
||||
const HTML_MIME = 'text/html'
|
||||
const BLOCK_SELECTOR = 'p, h1, h2, h3, h4, h5, h6, li, blockquote, pre'
|
||||
const BLANK_LINE = '\n\n'
|
||||
|
||||
export function bodyPlainText(html: string) {
|
||||
const document = new DOMParser().parseFromString(html, HTML_MIME)
|
||||
const blocks = Array.from(document.body.querySelectorAll(BLOCK_SELECTOR))
|
||||
.filter((block) => !block.querySelector(BLOCK_SELECTOR))
|
||||
.map((block) => (block.textContent ?? '').trim())
|
||||
.filter((text) => text !== '')
|
||||
return blocks.length > 0 ? blocks.join(BLANK_LINE) : (document.body.textContent ?? '').trim()
|
||||
}
|
||||
|
||||
export function conflictDownloadText(title: string, html: string) {
|
||||
return `${title}${BLANK_LINE}${bodyPlainText(html)}\n`
|
||||
}
|
||||
Reference in new issue
Block a user