|
|
@ -72,23 +72,27 @@ module.exports = { |
|
|
|
return path.resolve.apply(null, a); |
|
|
|
return path.resolve.apply(null, a); |
|
|
|
}, |
|
|
|
}, |
|
|
|
markdown(obj, keys, noReplaceUI) { |
|
|
|
markdown(obj, keys, noReplaceUI) { |
|
|
|
|
|
|
|
let xssfilter = new (require('xssfilter'))(); |
|
|
|
|
|
|
|
let replaceXSS = s => { |
|
|
|
|
|
|
|
return xssfilter.filter(s); |
|
|
|
|
|
|
|
}; |
|
|
|
let replaceUI = s => { |
|
|
|
let replaceUI = s => { |
|
|
|
if (noReplaceUI) return 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>') |
|
|
|
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('<table>').join('<table class="ui table">') |
|
|
|
.split('<blockquote>').join('<div class="ui message">').split('</blockquote>').join('</div>'); |
|
|
|
.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(replaceUI(s)); |
|
|
|
resolve(replaceUI(replaceXSS(s))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
let res = obj, cnt = keys.length; |
|
|
|
let res = obj, cnt = keys.length; |
|
|
|
for (let key of keys) { |
|
|
|
for (let key of keys) { |
|
|
|
renderer(res[key], (s) => { |
|
|
|
renderer(res[key], (s) => { |
|
|
|
res[key] = replaceUI(s); |
|
|
|
res[key] = replaceUI(replaceXSS(s)); |
|
|
|
if (!--cnt) resolve(res); |
|
|
|
if (!--cnt) resolve(res); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|