summaryrefslogtreecommitdiff
path: root/src/api/common/text
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/api/common/text
parentBetter notification (diff)
downloadmisskey-45e8331e261244628b134a18e3d0fbe0ebb3a7dc.tar.gz
misskey-45e8331e261244628b134a18e3d0fbe0ebb3a7dc.tar.bz2
misskey-45e8331e261244628b134a18e3d0fbe0ebb3a7dc.zip
:sushi:
Closes #12, #227 and #58
Diffstat (limited to '')
-rw-r--r--src/api/common/text/core/syntax-highlighter.ts (renamed from src/common/text/core/syntax-highlighter.js)8
-rw-r--r--src/api/common/text/elements/bold.ts (renamed from src/common/text/elements/bold.js)0
-rw-r--r--src/api/common/text/elements/code.ts (renamed from src/common/text/elements/code.js)2
-rw-r--r--src/api/common/text/elements/emoji.ts (renamed from src/common/text/elements/emoji.js)0
-rw-r--r--src/api/common/text/elements/hashtag.ts (renamed from src/common/text/elements/hashtag.js)0
-rw-r--r--src/api/common/text/elements/inline-code.ts (renamed from src/common/text/elements/inline-code.js)2
-rw-r--r--src/api/common/text/elements/link.ts (renamed from src/common/text/elements/link.js)0
-rw-r--r--src/api/common/text/elements/mention.ts (renamed from src/common/text/elements/mention.js)0
-rw-r--r--src/api/common/text/elements/url.ts (renamed from src/common/text/elements/url.js)0
-rw-r--r--src/api/common/text/index.ts (renamed from src/common/text/index.js)8
10 files changed, 11 insertions, 9 deletions
diff --git a/src/common/text/core/syntax-highlighter.js b/src/api/common/text/core/syntax-highlighter.ts
index 06c59777e7..c0396b1fc6 100644
--- a/src/common/text/core/syntax-highlighter.js
+++ b/src/api/common/text/core/syntax-highlighter.ts
@@ -114,7 +114,7 @@ const elements = [
// comment
code => {
if (code.substr(0, 2) != '//') return null;
- const match = code.match(/^\/\/(.+?)\n/);
+ const match = code.match(/^\/\/(.+?)(\n|$)/);
if (!match) return null;
const comment = match[0];
return {
@@ -187,7 +187,7 @@ const elements = [
regexp += char;
}
}
-
+
if (thisIsNotARegexp) return null;
if (regexp == '') return null;
if (regexp[0] == ' ' && regexp[regexp.length - 1] == ' ') return null;
@@ -299,7 +299,7 @@ const elements = [
];
// specify lang is todo
-module.exports = (source, lang) => {
+export default (source: string, lang?: string) => {
let code = source;
let html = '';
@@ -317,6 +317,8 @@ module.exports = (source, lang) => {
if (e) {
push(e);
return true;
+ } else {
+ return false;
}
});
diff --git a/src/common/text/elements/bold.js b/src/api/common/text/elements/bold.ts
index ce25764457..ce25764457 100644
--- a/src/common/text/elements/bold.js
+++ b/src/api/common/text/elements/bold.ts
diff --git a/src/common/text/elements/code.js b/src/api/common/text/elements/code.ts
index 99fe6a183c..4821e95fe2 100644
--- a/src/common/text/elements/code.js
+++ b/src/api/common/text/elements/code.ts
@@ -2,7 +2,7 @@
* Code (block)
*/
-const genHtml = require('../core/syntax-highlighter');
+import genHtml from '../core/syntax-highlighter';
module.exports = text => {
const match = text.match(/^```([\s\S]+?)```/);
diff --git a/src/common/text/elements/emoji.js b/src/api/common/text/elements/emoji.ts
index e24231a223..e24231a223 100644
--- a/src/common/text/elements/emoji.js
+++ b/src/api/common/text/elements/emoji.ts
diff --git a/src/common/text/elements/hashtag.js b/src/api/common/text/elements/hashtag.ts
index 048dbd8929..048dbd8929 100644
--- a/src/common/text/elements/hashtag.js
+++ b/src/api/common/text/elements/hashtag.ts
diff --git a/src/common/text/elements/inline-code.js b/src/api/common/text/elements/inline-code.ts
index 37e9b1a0ff..9f9ef51a2b 100644
--- a/src/common/text/elements/inline-code.js
+++ b/src/api/common/text/elements/inline-code.ts
@@ -2,7 +2,7 @@
* Code (inline)
*/
-const genHtml = require('../core/syntax-highlighter');
+import genHtml from '../core/syntax-highlighter';
module.exports = text => {
const match = text.match(/^`(.+?)`/);
diff --git a/src/common/text/elements/link.js b/src/api/common/text/elements/link.ts
index 35563ddc3d..35563ddc3d 100644
--- a/src/common/text/elements/link.js
+++ b/src/api/common/text/elements/link.ts
diff --git a/src/common/text/elements/mention.js b/src/api/common/text/elements/mention.ts
index e0fac4dd76..e0fac4dd76 100644
--- a/src/common/text/elements/mention.js
+++ b/src/api/common/text/elements/mention.ts
diff --git a/src/common/text/elements/url.js b/src/api/common/text/elements/url.ts
index 1003aff9c3..1003aff9c3 100644
--- a/src/common/text/elements/url.js
+++ b/src/api/common/text/elements/url.ts
diff --git a/src/common/text/index.js b/src/api/common/text/index.ts
index ab1342230c..47127e8646 100644
--- a/src/common/text/index.js
+++ b/src/api/common/text/index.ts
@@ -13,7 +13,7 @@ const elements = [
require('./elements/emoji')
];
-function analyze(source) {
+export default (source: string) => {
if (source == '') {
return null;
@@ -40,6 +40,8 @@ function analyze(source) {
}
tokens.forEach(push);
return true;
+ } else {
+ return false;
}
});
@@ -66,6 +68,4 @@ function analyze(source) {
return a.concat(b);
}
});
-}
-
-module.exports = analyze;
+};