Return parsed dom back to backend

This commit is contained in:
Hongbo Wu
2022-05-06 12:29:08 +08:00
parent 5f5076e864
commit eaad96acdd
3 changed files with 5 additions and 8 deletions

View File

@ -5,8 +5,6 @@
// TypeScript Version: 2.2
declare module '@omnivore/readability' {
import { DOMWindow } from 'jsdom'
/**
* A standalone version of the readability library used for Firefox Reader View.
*
@ -165,7 +163,7 @@ declare module '@omnivore/readability' {
previewImage?: string
/** Article published date */
publishedDate?: Date
window?: DOMWindow
dom?: Element
}
}

View File

@ -254,9 +254,8 @@ export const parsePreparedContent = async (
// Format code blocks
// TODO: we probably want to move this type of thing
// to the handlers, and have some concept of postHandle
if (article?.window) {
// const cWindow = new JSDOM(article?.content).window
article.window.document.querySelectorAll('code').forEach((e) => {
if (article?.dom) {
article.dom.querySelectorAll('code').forEach((e) => {
console.log(e.textContent)
if (e.textContent) {
const att = hljs.highlightAuto(e.textContent)
@ -271,7 +270,7 @@ export const parsePreparedContent = async (
e.replaceWith(code)
}
})
article.content = article.window.document.body.outerHTML
article.content = article.dom.outerHTML
}
const newWindow = new JSDOM('').window

View File

@ -2899,7 +2899,7 @@ Readability.prototype = {
siteIcon: metadata.siteIcon,
previewImage: metadata.previewImage,
publishedDate: metadata.publishedDate || publishedAt || this._articlePublishedDate,
window: articleContent,
dom: articleContent,
};
}
};