2017-02-08 17:07:06 +01:00
|
|
|
/**
|
2017-02-11 18:38:47 +01:00
|
|
|
* Code (block)
|
2017-02-08 17:07:06 +01:00
|
|
|
*/
|
|
|
|
|
|
2017-03-18 12:05:11 +01:00
|
|
|
import genHtml from '../core/syntax-highlighter';
|
2017-02-11 18:38:47 +01:00
|
|
|
|
2017-02-10 18:32:00 +01:00
|
|
|
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(),
|
2017-02-11 18:38:47 +01:00
|
|
|
html: genHtml(code.substr(3, code.length - 6).trim())
|
2017-02-10 18:32:00 +01:00
|
|
|
};
|
2017-02-08 17:07:06 +01:00
|
|
|
};
|