const riot = require('riot'); module.exports = function(tokens, canBreak, escape) { if (canBreak == null) { canBreak = true; } if (escape == null) { escape = true; } const me = riot.mixin('i').me; let text = tokens.map(function(token) { switch (token.type) { case 'text': if (escape) { return token.content .replace(/>/g, '>') .replace(/' : ' '); } else { return token.content .replace(/(\r\n|\n|\r)/g, canBreak ? '
' : ' '); } case 'bold': return '' + token.bold + ''; case 'link': return ''; case 'mention': return '' + token.content + ''; case 'hashtag': // TODO return '' + token.content + ''; } }).join(''); if (me && me.data && me.data.nya) { text = text.replace(/な/g, 'にゃ'); } return text; }