nanka iroiro
This commit is contained in:
parent
5ad6877090
commit
a68efc1e5e
4 changed files with 52 additions and 20 deletions
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()
|
||||
};
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue