summaryrefslogtreecommitdiff
path: root/src/common/text/index.js
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-18 20:05:11 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-18 20:05:11 +0900
commit45e8331e261244628b134a18e3d0fbe0ebb3a7dc (patch)
tree44ac1719fcea0a61c33698b23fb89400141e00d9 /src/common/text/index.js
parentBetter notification (diff)
downloadmisskey-45e8331e261244628b134a18e3d0fbe0ebb3a7dc.tar.gz
misskey-45e8331e261244628b134a18e3d0fbe0ebb3a7dc.tar.bz2
misskey-45e8331e261244628b134a18e3d0fbe0ebb3a7dc.zip
:sushi:
Closes #12, #227 and #58
Diffstat (limited to 'src/common/text/index.js')
-rw-r--r--src/common/text/index.js71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/common/text/index.js b/src/common/text/index.js
deleted file mode 100644
index ab1342230c..0000000000
--- a/src/common/text/index.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Misskey Text Analyzer
- */
-
-const elements = [
- require('./elements/bold'),
- require('./elements/url'),
- require('./elements/link'),
- require('./elements/mention'),
- require('./elements/hashtag'),
- require('./elements/code'),
- require('./elements/inline-code'),
- require('./elements/emoji')
-];
-
-function analyze(source) {
-
- if (source == '') {
- return null;
- }
-
- const tokens = [];
-
- function push(token) {
- if (token != null) {
- tokens.push(token);
- source = source.substr(token.content.length);
- }
- }
-
- let i = 0;
-
- // パース
- while (source != '') {
- const parsed = elements.some(el => {
- let tokens = el(source, i);
- if (tokens) {
- if (!Array.isArray(tokens)) {
- tokens = [tokens];
- }
- tokens.forEach(push);
- return true;
- }
- });
-
- if (!parsed) {
- push({
- type: 'text',
- content: source[0]
- });
- }
-
- i++;
- }
-
- // テキストを纏める
- tokens[0] = [tokens[0]];
- return tokens.reduce((a, b) => {
- if (a[a.length - 1].type == 'text' && b.type == 'text') {
- const tail = a.pop();
- return a.concat({
- type: 'text',
- content: tail.content + b.content
- });
- } else {
- return a.concat(b);
- }
- });
-}
-
-module.exports = analyze;