const riot = require('riot'); const nyaize = require('nyaize').default; const emojinize = require('emojinize'); const CONFIG = require('./config'); const escape = text => text .replace(/>/g, '>') .replace(/ { if (shouldBreak == null) { shouldBreak = true; } const me = riot.mixin('i').me; let text = tokens.map(token => { switch (token.type) { case 'text': return escape(token.content) .replace(/(\r\n|\n|\r)/g, shouldBreak ? '
' : ' '); case 'bold': return '' + escape(token.bold) + ''; case 'link': return ''; case 'mention': return '' + token.content + ''; case 'hashtag': // TODO return '' + escape(token.content) + ''; case 'code': return '
' + token.html + '
'; case 'inline-code': return '' + token.html + ''; case 'emoji': return emojinize.encode(token.content) } }).join(''); text = text .replace(/ /g, '').replace(/<\/code> /g, '') .replace(/
/g, '
').replace(/<\/code><\/pre>
/g, '
'); if (me && me.data && me.data.nya) { text = nyaize(text); } return text; };