jormungandr-bite/src/text/parse/elements/code.ts
2018-04-02 12:58:53 +09:00

17 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())
};
};