mizzkey/src/common/text/elements/code.js

18 lines
311 B
JavaScript
Raw Normal View History

2017-02-08 17:07:06 +01: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()
};
}
};