diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-06-21 01:21:57 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-06-21 01:21:57 +0900 |
| commit | 79d1bf30a49e1fd1ef1f8b743a9aff84d104fb89 (patch) | |
| tree | ed8f50f01cc50cf851dc0d0f399ed7e0f514f6c6 /src/mfm/parse/elements/link.ts | |
| parent | Disable transitions to avoid memory leak (diff) | |
| download | misskey-79d1bf30a49e1fd1ef1f8b743a9aff84d104fb89.tar.gz misskey-79d1bf30a49e1fd1ef1f8b743a9aff84d104fb89.tar.bz2 misskey-79d1bf30a49e1fd1ef1f8b743a9aff84d104fb89.zip | |
リモートユーザーのHTMLで表現されたプロフィールをMFMに変換するように
Diffstat (limited to 'src/mfm/parse/elements/link.ts')
| -rw-r--r-- | src/mfm/parse/elements/link.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mfm/parse/elements/link.ts b/src/mfm/parse/elements/link.ts new file mode 100644 index 0000000000..b353aebc5c --- /dev/null +++ b/src/mfm/parse/elements/link.ts @@ -0,0 +1,27 @@ +/** + * 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; +} |