summaryrefslogtreecommitdiff
path: root/src/mfm/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/mfm/parse')
-rw-r--r--src/mfm/parse/elements/big.ts2
-rw-r--r--src/mfm/parse/elements/motion.ts20
-rw-r--r--src/mfm/parse/index.ts7
3 files changed, 26 insertions, 3 deletions
diff --git a/src/mfm/parse/elements/big.ts b/src/mfm/parse/elements/big.ts
index ca798986e9..8e39c75a55 100644
--- a/src/mfm/parse/elements/big.ts
+++ b/src/mfm/parse/elements/big.ts
@@ -1,5 +1,5 @@
/**
- * Bold
+ * Big
*/
export type TextElementBig = {
diff --git a/src/mfm/parse/elements/motion.ts b/src/mfm/parse/elements/motion.ts
new file mode 100644
index 0000000000..555a989750
--- /dev/null
+++ b/src/mfm/parse/elements/motion.ts
@@ -0,0 +1,20 @@
+/**
+ * Motion
+ */
+
+export type TextElementMotion = {
+ type: 'motion'
+ content: string
+ motion: string
+};
+
+export default function(text: string) {
+ const match = text.match(/^\(\(\((.+?)\)\)\)/);
+ if (!match) return null;
+ const motion = match[0];
+ return {
+ type: 'motion',
+ content: motion,
+ motion: match[1]
+ } as TextElementMotion;
+}
diff --git a/src/mfm/parse/index.ts b/src/mfm/parse/index.ts
index 066c062559..99c00ae649 100644
--- a/src/mfm/parse/index.ts
+++ b/src/mfm/parse/index.ts
@@ -14,6 +14,7 @@ import { TextElementQuote } from './elements/quote';
import { TextElementSearch } from './elements/search';
import { TextElementTitle } from './elements/title';
import { TextElementUrl } from './elements/url';
+import { TextElementMotion } from './elements/motion';
const elements = [
require('./elements/big'),
@@ -27,7 +28,8 @@ const elements = [
require('./elements/inline-code'),
require('./elements/quote'),
require('./elements/emoji'),
- require('./elements/search')
+ require('./elements/search'),
+ require('./elements/motion')
].map(element => element.default as TextElementProcessor);
export type TextElement = { type: 'text', content: string }
@@ -42,7 +44,8 @@ export type TextElement = { type: 'text', content: string }
| TextElementQuote
| TextElementSearch
| TextElementTitle
- | TextElementUrl;
+ | TextElementUrl
+ | TextElementMotion;
export type TextElementProcessor = (text: string, i: number) => TextElement | TextElement[];
export default (source: string): TextElement[] => {