mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36: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 () {
|
||||
const turndown = new TurndownService()
|
||||
turndown.use(gfm)
|
||||
turndown.remove('script')
|
||||
return turndown
|
||||
}
|
||||
|
||||
@@ -32,18 +32,7 @@ function createNoteFromUrl (url, storage, folder, dispatch = null, location = nu
|
||||
})
|
||||
|
||||
res.on('end', () => {
|
||||
const html = document.createElement('html')
|
||||
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 = ''
|
||||
const markdownHTML = td.turndown(data)
|
||||
|
||||
if (dispatch !== null) {
|
||||
createNote(storage, {
|
||||
|
||||
Reference in New Issue
Block a user