diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-02-11 02:32:00 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-02-11 02:32:00 +0900 |
| commit | 1b2d0806511613077e36a707f24cae215bfce03f (patch) | |
| tree | 1fd3acd227546e5faa7b8ed805e68178bd1e5903 /src/common/text/elements/bold.js | |
| parent | Remove variables tracking system to more simply implementation (diff) | |
| download | misskey-1b2d0806511613077e36a707f24cae215bfce03f.tar.gz misskey-1b2d0806511613077e36a707f24cae215bfce03f.tar.bz2 misskey-1b2d0806511613077e36a707f24cae215bfce03f.zip | |
Refactoring :sparkles:
Diffstat (limited to 'src/common/text/elements/bold.js')
| -rw-r--r-- | src/common/text/elements/bold.js | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/common/text/elements/bold.js b/src/common/text/elements/bold.js index 41a01399dd..ce25764457 100644 --- a/src/common/text/elements/bold.js +++ b/src/common/text/elements/bold.js @@ -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) + }; }; |