import m from 'mithril' import render from './lib/mithril-node-render' import isNode from 'detect-node' let tidy if (!isNode) { tidy = require('exports?tidy_html5!tidy-html5') } else { tidy = process.tidy } import { tidyOptions } from './constants' export function cleanMarkup (html, callback) { // fix center tags html = html.replace(/
') html = html.replace(/<\/center>/g, '
') html = html.replace(/', '') html = html.replace('', '') html = fixDoubleSpacing(html) html = tidy(`\n` + html, tidyOptions) callback(html) } export function fixDoubleSpacing (html) { // from FimFictionConverter by Nyerguds html = html.replace(/\s\s+/g, ' ') // push spaces to the closed side of tags html = html.replace(/\s+(<[a-z][^>]*>)\s+/g, ' $1') html = html.replace(/\s+(<\/[a-z][^>]*>)\s+/g, '$1 ') return html }