summaryrefslogtreecommitdiff
path: root/src/mfm/parse
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-08-03 23:27:37 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-08-03 23:27:37 +0900
commitd456e5e45c8a2367c9362b1e1d1e87d6959b6977 (patch)
treeafd13b2fb3c9680c592c05dcf10239f21b24a36f /src/mfm/parse
parentFix #2047 (diff)
downloadsharkey-d456e5e45c8a2367c9362b1e1d1e87d6959b6977.tar.gz
sharkey-d456e5e45c8a2367c9362b1e1d1e87d6959b6977.tar.bz2
sharkey-d456e5e45c8a2367c9362b1e1d1e87d6959b6977.zip
Implement new MFM syntax
Diffstat (limited to 'src/mfm/parse')
-rw-r--r--src/mfm/parse/elements/big.ts20
-rw-r--r--src/mfm/parse/index.ts3
2 files changed, 23 insertions, 0 deletions
diff --git a/src/mfm/parse/elements/big.ts b/src/mfm/parse/elements/big.ts
new file mode 100644
index 0000000000..ca798986e9
--- /dev/null
+++ b/src/mfm/parse/elements/big.ts
@@ -0,0 +1,20 @@
+/**
+ * Bold
+ */
+
+export type TextElementBig = {
+ type: 'big'
+ content: string
+ big: string
+};
+
+export default function(text: string) {
+ const match = text.match(/^\*\*\*(.+?)\*\*\*/);
+ if (!match) return null;
+ const big = match[0];
+ return {
+ type: 'big',
+ content: big,
+ big: match[1]
+ } as TextElementBig;
+}
diff --git a/src/mfm/parse/index.ts b/src/mfm/parse/index.ts
index 8d71409e58..066c062559 100644
--- a/src/mfm/parse/index.ts
+++ b/src/mfm/parse/index.ts
@@ -3,6 +3,7 @@
*/
import { TextElementBold } from './elements/bold';
+import { TextElementBig } from './elements/big';
import { TextElementCode } from './elements/code';
import { TextElementEmoji } from './elements/emoji';
import { TextElementHashtag } from './elements/hashtag';
@@ -15,6 +16,7 @@ import { TextElementTitle } from './elements/title';
import { TextElementUrl } from './elements/url';
const elements = [
+ require('./elements/big'),
require('./elements/bold'),
require('./elements/title'),
require('./elements/url'),
@@ -30,6 +32,7 @@ const elements = [
export type TextElement = { type: 'text', content: string }
| TextElementBold
+ | TextElementBig
| TextElementCode
| TextElementEmoji
| TextElementHashtag