1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

highlighting links

This commit is contained in:
Fedor Katurov 2020-04-10 17:35:51 +07:00
parent c8edb8fcc7
commit 1de4fbfcea

View file

@ -100,6 +100,10 @@ export const formatText = (text: string): string =>
.replace(/(\/\*[\s\S]*?\*\/)/gim, '<span class="grey">$1</span>')
.replace(/([=|-]{5,})/gim, '<hr />')
.replace(/:\|--\|/gim, '://')
.replace(
/(\b(https?|ftp|file):\/\/([-A-Z0-9+&@#%?=~_|!:,.;]*)([-A-Z0-9+&@#%?\/=~_|!:,.;]*)[-A-Z0-9+&@#\/%=~_|])/gi,
'<a href="$1" target="blank" rel="nofollow">$1</a>'
)
.split('\n')
.filter(el => el.trim().length)
.join('\n');