Browse Source

Make block image in markdown center render

pull/6/head
Menci 8 years ago
parent
commit
663c41b068
  1. 1
      package.json
  2. 16
      utility.js

1
package.json

@ -26,6 +26,7 @@
"adm-zip": "^0.4.7",
"ansi-to-html": "^0.4.2",
"body-parser": "^1.15.2",
"cheerio": "^1.0.0-rc.1",
"cookie-parser": "^1.4.3",
"cssfilter": "0.0.10",
"download": "^5.0.3",

16
utility.js

@ -104,9 +104,23 @@ module.exports = {
};
let replaceUI = s => {
if (noReplaceUI) return s;
return s.split('<pre>').join('<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; ">').split('</pre>').join('</pre></div>')
s = s.split('<pre>').join('<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; ">').split('</pre>').join('</pre></div>')
.split('<table>').join('<table class="ui table">')
.split('<blockquote>').join('<div class="ui message">').split('</blockquote>').join('</div>');
let cheerio = require('cheerio');
let $ = cheerio.load(s);
let a = $('img:only-child');
for (let img of Array.from(a)) {
if (!img.prev && !img.next) {
$(img).css('display', 'block');
$(img).css('margin', '0 auto');
}
}
return $.html();
};
return new Promise((resolve, reject) => {
if (!keys) {

Loading…
Cancel
Save