Return parsed dom back to backend
This commit is contained in:
4
packages/api/src/readability.d.ts
vendored
4
packages/api/src/readability.d.ts
vendored
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -2899,7 +2899,7 @@ Readability.prototype = {
|
||||
siteIcon: metadata.siteIcon,
|
||||
previewImage: metadata.previewImage,
|
||||
publishedDate: metadata.publishedDate || publishedAt || this._articlePublishedDate,
|
||||
window: articleContent,
|
||||
dom: articleContent,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user