mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Remove manual script tag filter and use turndown remove filter
This commit is contained in:
@@ -4,5 +4,6 @@ const { gfm } = require('turndown-plugin-gfm')
|
|||||||
export const createTurndownService = function () {
|
export const createTurndownService = function () {
|
||||||
const turndown = new TurndownService()
|
const turndown = new TurndownService()
|
||||||
turndown.use(gfm)
|
turndown.use(gfm)
|
||||||
|
turndown.remove('script')
|
||||||
return turndown
|
return turndown
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,18 +32,7 @@ function createNoteFromUrl (url, storage, folder, dispatch = null, location = nu
|
|||||||
})
|
})
|
||||||
|
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
const html = document.createElement('html')
|
const markdownHTML = td.turndown(data)
|
||||||
html.innerHTML = data
|
|
||||||
|
|
||||||
const scripts = html.getElementsByTagName('script')
|
|
||||||
for (let i = scripts.length - 1; i >= 0; i--) {
|
|
||||||
scripts[i].parentNode.removeChild(scripts[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
const body = html.getElementsByTagName('body')[0].innerHTML
|
|
||||||
const markdownHTML = td.turndown(body)
|
|
||||||
|
|
||||||
html.innerHTML = ''
|
|
||||||
|
|
||||||
if (dispatch !== null) {
|
if (dispatch !== null) {
|
||||||
createNote(storage, {
|
createNote(storage, {
|
||||||
|
|||||||
Reference in New Issue
Block a user