diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-02-27 12:32:01 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-02-27 12:32:01 +0900 |
| commit | 68dd705500bd98b7b00606e861de170939e3d528 (patch) | |
| tree | 9b071fee3270ff9383abdc49c7f34494c1daa7f9 /src/api/common | |
| parent | Fix bug (diff) | |
| download | sharkey-68dd705500bd98b7b00606e861de170939e3d528.tar.gz sharkey-68dd705500bd98b7b00606e861de170939e3d528.tar.bz2 sharkey-68dd705500bd98b7b00606e861de170939e3d528.zip | |
#1153
Diffstat (limited to 'src/api/common')
| -rw-r--r-- | src/api/common/text/elements/quote.ts | 14 | ||||
| -rw-r--r-- | src/api/common/text/index.ts | 11 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/api/common/text/elements/quote.ts b/src/api/common/text/elements/quote.ts new file mode 100644 index 0000000000..cc8cfffdc4 --- /dev/null +++ b/src/api/common/text/elements/quote.ts @@ -0,0 +1,14 @@ +/** + * Quoted text + */ + +module.exports = text => { + const match = text.match(/^"([\s\S]+?)\n"/); + if (!match) return null; + const quote = match[0]; + return { + type: 'quote', + content: quote, + quote: quote.substr(1, quote.length - 2).trim(), + }; +}; diff --git a/src/api/common/text/index.ts b/src/api/common/text/index.ts index 47127e8646..1e2398dc38 100644 --- a/src/api/common/text/index.ts +++ b/src/api/common/text/index.ts @@ -10,6 +10,7 @@ const elements = [ require('./elements/hashtag'), require('./elements/code'), require('./elements/inline-code'), + require('./elements/quote'), require('./elements/emoji') ]; @@ -33,12 +34,12 @@ export default (source: string) => { // パース while (source != '') { const parsed = elements.some(el => { - let tokens = el(source, i); - if (tokens) { - if (!Array.isArray(tokens)) { - tokens = [tokens]; + let _tokens = el(source, i); + if (_tokens) { + if (!Array.isArray(_tokens)) { + _tokens = [_tokens]; } - tokens.forEach(push); + _tokens.forEach(push); return true; } else { return false; |