summaryrefslogtreecommitdiff
path: root/src/text/parse/elements
diff options
context:
space:
mode:
Diffstat (limited to 'src/text/parse/elements')
-rw-r--r--src/text/parse/elements/bold.ts20
-rw-r--r--src/text/parse/elements/code.ts24
-rw-r--r--src/text/parse/elements/emoji.ts20
-rw-r--r--src/text/parse/elements/hashtag.ts25
-rw-r--r--src/text/parse/elements/inline-code.ts24
-rw-r--r--src/text/parse/elements/link.ts27
-rw-r--r--src/text/parse/elements/mention.ts24
-rw-r--r--src/text/parse/elements/quote.ts20
-rw-r--r--src/text/parse/elements/search.ts19
-rw-r--r--src/text/parse/elements/title.ts20
-rw-r--r--src/text/parse/elements/url.ts20
11 files changed, 0 insertions, 243 deletions
diff --git a/src/text/parse/elements/bold.ts b/src/text/parse/elements/bold.ts
deleted file mode 100644
index cf615cd3cc..0000000000
--- a/src/text/parse/elements/bold.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Bold
- */
-
-export type TextElementBold = {
- type: 'bold'
- content: string
- bold: string
-};
-
-export default function(text: string) {
- const match = text.match(/^\*\*(.+?)\*\*/);
- if (!match) return null;
- const bold = match[0];
- return {
- type: 'bold',
- content: bold,
- bold: bold.substr(2, bold.length - 4)
- } as TextElementBold;
-}
diff --git a/src/text/parse/elements/code.ts b/src/text/parse/elements/code.ts
deleted file mode 100644
index f48e945048..0000000000
--- a/src/text/parse/elements/code.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Code (block)
- */
-
-import genHtml from '../core/syntax-highlighter';
-
-export type TextElementCode = {
- type: 'code'
- content: string
- code: string
- html: string
-};
-
-export default function(text: string) {
- const match = text.match(/^```([\s\S]+?)```/);
- if (!match) return null;
- const code = match[0];
- return {
- type: 'code',
- content: code,
- code: code.substr(3, code.length - 6).trim(),
- html: genHtml(code.substr(3, code.length - 6).trim())
- } as TextElementCode;
-}
diff --git a/src/text/parse/elements/emoji.ts b/src/text/parse/elements/emoji.ts
deleted file mode 100644
index 83d3effef5..0000000000
--- a/src/text/parse/elements/emoji.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Emoji
- */
-
-export type TextElementEmoji = {
- type: 'emoji'
- content: string
- emoji: string
-};
-
-export default function(text: string) {
- const match = text.match(/^:[a-zA-Z0-9+-_]+:/);
- if (!match) return null;
- const emoji = match[0];
- return {
- type: 'emoji',
- content: emoji,
- emoji: emoji.substr(1, emoji.length - 2)
- } as TextElementEmoji;
-}
diff --git a/src/text/parse/elements/hashtag.ts b/src/text/parse/elements/hashtag.ts
deleted file mode 100644
index 129041774f..0000000000
--- a/src/text/parse/elements/hashtag.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Hashtag
- */
-
-export type TextElementHashtag = {
- type: 'hashtag'
- content: string
- hashtag: string
-};
-
-export default function(text: string, i: number) {
- if (!(/^\s#[^\s]+/.test(text) || (i == 0 && /^#[^\s]+/.test(text)))) return null;
- const isHead = text[0] == '#';
- const hashtag = text.match(/^\s?#[^\s]+/)[0];
- const res: any[] = !isHead ? [{
- type: 'text',
- content: text[0]
- }] : [];
- res.push({
- type: 'hashtag',
- content: isHead ? hashtag : hashtag.substr(1),
- hashtag: isHead ? hashtag.substr(1) : hashtag.substr(2)
- });
- return res as TextElementHashtag[];
-}
diff --git a/src/text/parse/elements/inline-code.ts b/src/text/parse/elements/inline-code.ts
deleted file mode 100644
index 1dd5affa51..0000000000
--- a/src/text/parse/elements/inline-code.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Code (inline)
- */
-
-import genHtml from '../core/syntax-highlighter';
-
-export type TextElementInlineCode = {
- type: 'inline-code'
- content: string
- code: string
- html: string
-};
-
-export default function(text: string) {
- const match = text.match(/^`(.+?)`/);
- if (!match) return null;
- const code = match[0];
- return {
- type: 'inline-code',
- content: code,
- code: code.substr(1, code.length - 2).trim(),
- html: genHtml(code.substr(1, code.length - 2).trim())
- } as TextElementInlineCode;
-}
diff --git a/src/text/parse/elements/link.ts b/src/text/parse/elements/link.ts
deleted file mode 100644
index b353aebc5c..0000000000
--- a/src/text/parse/elements/link.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Link
- */
-
-export type TextElementLink = {
- type: 'link'
- content: string
- title: string
- url: string
- silent: boolean
-};
-
-export default function(text: string) {
- const match = text.match(/^\??\[([^\[\]]+?)\]\((https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+?)\)/);
- if (!match) return null;
- const silent = text[0] == '?';
- const link = match[0];
- const title = match[1];
- const url = match[2];
- return {
- type: 'link',
- content: link,
- title: title,
- url: url,
- silent: silent
- } as TextElementLink;
-}
diff --git a/src/text/parse/elements/mention.ts b/src/text/parse/elements/mention.ts
deleted file mode 100644
index eda60b530a..0000000000
--- a/src/text/parse/elements/mention.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Mention
- */
-import parseAcct from '../../../acct/parse';
-
-export type TextElementMention = {
- type: 'mention'
- content: string
- username: string
- host: string
-};
-
-export default function(text: string) {
- const match = text.match(/^@[a-z0-9_]+(?:@[a-z0-9\.\-]+[a-z0-9])?/i);
- if (!match) return null;
- const mention = match[0];
- const { username, host } = parseAcct(mention.substr(1));
- return {
- type: 'mention',
- content: mention,
- username,
- host
- } as TextElementMention;
-}
diff --git a/src/text/parse/elements/quote.ts b/src/text/parse/elements/quote.ts
deleted file mode 100644
index bef9ad4988..0000000000
--- a/src/text/parse/elements/quote.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Quoted text
- */
-
-export type TextElementQuote = {
- type: 'quote'
- content: string
- quote: string
-};
-
-export default function(text: string) {
- 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(),
- } as TextElementQuote;
-}
diff --git a/src/text/parse/elements/search.ts b/src/text/parse/elements/search.ts
deleted file mode 100644
index e5d9b9f0c2..0000000000
--- a/src/text/parse/elements/search.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Search
- */
-
-export type TextElementSearch = {
- type: 'search'
- content: string
- query: string
-};
-
-export default function(text: string) {
- const match = text.match(/^(.+?) 検索(\n|$)/);
- if (!match) return null;
- return {
- type: 'search',
- content: match[0],
- query: match[1]
- };
-}
diff --git a/src/text/parse/elements/title.ts b/src/text/parse/elements/title.ts
deleted file mode 100644
index b89739a7c5..0000000000
--- a/src/text/parse/elements/title.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Title
- */
-
-export type TextElementTitle = {
- type: 'title'
- content: string
- title: string
-};
-
-export default function(text: string) {
- const match = text.match(/^【(.+?)】\n/);
- if (!match) return null;
- const title = match[0];
- return {
- type: 'title',
- content: title,
- title: title.substr(1, title.length - 3)
- } as TextElementTitle;
-}
diff --git a/src/text/parse/elements/url.ts b/src/text/parse/elements/url.ts
deleted file mode 100644
index 78b9b1f2f1..0000000000
--- a/src/text/parse/elements/url.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * URL
- */
-
-export type TextElementUrl = {
- type: 'url'
- content: string
- url: string
-};
-
-export default function(text: string) {
- const match = text.match(/^https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+/);
- if (!match) return null;
- const url = match[0];
- return {
- type: 'url',
- content: url,
- url: url
- } as TextElementUrl;
-}