|
|
@ -26,6 +26,7 @@ let querystring = require('querystring'); |
|
|
|
let gravatar = require('gravatar'); |
|
|
|
let gravatar = require('gravatar'); |
|
|
|
let filesize = require('file-size'); |
|
|
|
let filesize = require('file-size'); |
|
|
|
let AsyncLock = require('async-lock'); |
|
|
|
let AsyncLock = require('async-lock'); |
|
|
|
|
|
|
|
let JSDOM = require('jsdom').JSDOM; |
|
|
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
module.exports = { |
|
|
|
resolvePath(s) { |
|
|
|
resolvePath(s) { |
|
|
@ -41,20 +42,16 @@ module.exports = { |
|
|
|
.split('<table>').join('<table class="ui celled table">') |
|
|
|
.split('<table>').join('<table class="ui celled table">') |
|
|
|
.split('<blockquote>').join('<div class="ui message">').split('</blockquote>').join('</div>'); |
|
|
|
.split('<blockquote>').join('<div class="ui message">').split('</blockquote>').join('</div>'); |
|
|
|
|
|
|
|
|
|
|
|
let cheerio = require('cheerio'); |
|
|
|
let jsdom = new JSDOM(), document = jsdom.window.document; |
|
|
|
let $ = cheerio.load('<html><head></head><body></body></html>'); |
|
|
|
document.body.innerHTML = s; |
|
|
|
let body = $('body'); |
|
|
|
|
|
|
|
body.html(s); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let a = $('img:only-child'); |
|
|
|
let a = document.querySelectorAll('p > img:only-child'); |
|
|
|
for (let img of Array.from(a)) { |
|
|
|
for (let img of Array.from(a)) { |
|
|
|
if (!img.prev && !img.next) { |
|
|
|
img.style.display = 'block'; |
|
|
|
$(img).css('display', 'block'); |
|
|
|
img.style.margin = '0 auto'; |
|
|
|
$(img).css('margin', '0 auto'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return body.html(); |
|
|
|
return document.body.innerHTML; |
|
|
|
}; |
|
|
|
}; |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
if (!keys) { |
|
|
|
if (!keys) { |
|
|
|