リモートユーザーのHTMLで表現されたプロフィールをMFMに変換するように
This commit is contained in:
parent
3633d7ada1
commit
79d1bf30a4
29 changed files with 90 additions and 92 deletions
27
src/mfm/parse/elements/link.ts
Normal file
27
src/mfm/parse/elements/link.ts
Normal file
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue