jormungandr-bite/src/common/text/elements/code.js

18 lines
311 B
JavaScript
Raw Normal View History

2017-02-08 09:07:06 -07:00
/**
* Code
*/
const regexp = /```([\s\S]+?)```/;
module.exports = {
test: x => new RegExp('^' + regexp.source).test(x),
parse: text => {
const code = text.match(new RegExp('^' + regexp.source))[0];
return {
type: 'code',
content: code,
code: code.substr(3, code.length - 6).trim()
};
}
};