add solveMarkdownLinks to eventUtils
This commit is contained in:
parent
01fe023d06
commit
1dea2f76ad
@ -8,12 +8,21 @@ export function solveTextLinks(text){
|
||||
}
|
||||
return `${space}<a href="${hyperlink}" target="_blank">${url}</a>`;
|
||||
}
|
||||
)
|
||||
}
|
||||
export function parseMessage(msg){
|
||||
return solveTextLinks(
|
||||
msg.replace(/>.*\n/gm, '').trim()
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
);
|
||||
}
|
||||
export function solveMarkdownLinks(text){
|
||||
return (text || '').replace(
|
||||
/\[([\w\s\d/\\._+-]+)]\(((?:\/|https?:\/\/)[\w\d/.?=#_+-]+)\)/gi,
|
||||
(match, text, url)=>{
|
||||
return `<a href="${url}" target="_blank">${text}</a>`;
|
||||
}
|
||||
);
|
||||
}
|
||||
export function fixHtml(text){
|
||||
return text.replace(/>.*\n/gm, '').trim()
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
}
|
||||
export function parseMessage(text){
|
||||
return solveMarkdownLinks(solveTextLinks(fixHtml(text)));
|
||||
}
|
Loading…
Reference in New Issue
Block a user