import * as riot from 'riot';
import * as pictograph from 'pictograph';
import CONFIG from './config';
const escape = text =>
text
.replace(/>/g, '>')
.replace(/ {
if (shouldBreak == null) {
shouldBreak = true;
}
const me = (riot as any).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 'url':
return `
${token.html}
`;
case 'inline-code':
return `${token.html}
`;
case 'emoji':
return pictograph.dic[token.emoji] || token.content;
}
}).join('');
// Remove needless whitespaces
text = text
.replace(/ /g, '').replace(/<\/code> /g, '
')
.replace(/
/g, '').replace(/<\/code><\/pre>
/g, '
');
return text;
};