nanka iroiro
This commit is contained in:
17
src/common/text/elements/code.js
Normal file
17
src/common/text/elements/code.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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()
|
||||
};
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user