import m from 'mithril'
import render from './lib/mithril-node-render'
import fetch from './fetch'
import { youtubeKey } from './constants'
export function cleanMarkup (html) {
if (!html) {
return Promise.resolve('')
}
return new Promise((resolve, reject) => {
// replace HTML non-breaking spaces with normal spaces
html = html.replace(/ /g, ' ')
html = html.replace(/ /g, ' ')
// fix some tags
html = html.replace(//g, '')
html = html.replace(/<\/u>/g, '')
html = html.replace(//g, '')
html = html.replace(/<\/s>/g, '')
html = html.replace(/
\s*/g, '
') html = html.replace(/\s*<\/p>/g, '
') html = html.replace(//g, '
') html = html.replace(/<\/div><\/p>/g, '') html = fixParagraphIndent(html) html = fixDoubleSpacing(html) // fix floating blockquote tags html = html.replace('
', '') html = html.replace('', '') // Fix links pointing to pages on fimfiction // Example: djazz let matchLink = /()/g html = html.replace(matchLink, (match, head, url, tail) => { if (url.substring(0, 1) !== '#' && url.substring(0, 2) !== '//' && url.substring(0, 4) !== 'http') { if (url.substring(0, 1) === '/') { url = 'http://www.fimfiction.net' + url } else { // do something else } } return head + url + tail }) let cache = new Map() let completeCount = 0 let matchYoutube = /