mizzkey/src/api/common/text/elements/code.ts
syuilo 45e8331e26 🍣
Closes ,  and 
2017-03-18 20:05:11 +09:00

18 lines
355 B
TypeScript

/**
* Code (block)
*/
import genHtml from '../core/syntax-highlighter';
module.exports = text => {
const match = text.match(/^```([\s\S]+?)```/);
if (!match) return null;
const code = match[0];
return {
type: 'code',
content: code,
code: code.substr(3, code.length - 6).trim(),
html: genHtml(code.substr(3, code.length - 6).trim())
};
};