const riot = require('riot'); module.exports = function(tokens, shouldBreak, escape) { if (shouldBreak == null) { shouldBreak = 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, shouldBreak ? '
' : ' '); } 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, 'にゃ') .replace(/にゃでにゃで/g, 'なでなで'); } return text; }