Refactoring

This commit is contained in:
syuilo
2017-02-11 02:32:00 +09:00
parent c20cd97be2
commit 1b2d080651
6 changed files with 52 additions and 68 deletions

View File

@@ -2,16 +2,13 @@
* Bold
*/
const regexp = /\*\*(.+?)\*\*/;
module.exports = {
test: x => new RegExp('^' + regexp.source).test(x),
parse: text => {
const bold = text.match(new RegExp('^' + regexp.source))[0];
return {
type: 'bold',
content: bold,
bold: bold.substr(2, bold.length - 4)
};
}
module.exports = text => {
const match = text.match(/^\*\*(.+?)\*\*/);
if (!match) return null;
const bold = match[0];
return {
type: 'bold',
content: bold,
bold: bold.substr(2, bold.length - 4)
};
};