Browse Source

UI for markdown tables and blockquotes

master
Menci 8 years ago
parent
commit
8ffa953b8e
  1. 10
      utility.js

10
utility.js

@ -39,14 +39,16 @@ module.exports = {
return path.resolve.apply(null, a); return path.resolve.apply(null, a);
}, },
markdown(obj, keys) { markdown(obj, keys) {
let replacePre = s => { let replaceUI = s => {
return s.split('<pre>').join('<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; ">').split('</pre>').join('</div>') return 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>');
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!keys) { if (!keys) {
if (!obj || !obj.trim()) resolve(""); if (!obj || !obj.trim()) resolve("");
else renderer(obj, s => { else renderer(obj, s => {
resolve(replacePre(s)); resolve(replaceUI(s));
}); });
} else { } else {
let res = obj, cnt = 0; let res = obj, cnt = 0;
@ -54,7 +56,7 @@ module.exports = {
if (res[key].trim()) { if (res[key].trim()) {
cnt++; cnt++;
renderer(res[key], (s) => { renderer(res[key], (s) => {
res[key] = replacePre(s); res[key] = replaceUI(s);
if (!--cnt) resolve(res); if (!--cnt) resolve(res);
}); });
} }

Loading…
Cancel
Save