1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

better text nodes appearance

This commit is contained in:
Fedor Katurov 2019-10-17 16:53:52 +07:00
parent 6d0a22707c
commit 6476e60c81
4 changed files with 42 additions and 38 deletions

View file

@ -68,21 +68,23 @@ export const getImageSize = (file: IFile, size?: string): string => getURL(file)
// `${process.env.API_HOST}${image}`.replace('{size}', size);
export const formatText = (text: string): string =>
text
.replace(/(\n{2,})/gi, '\n')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/:\/\//gim, ':|--|')
.replace(/(\/\/[^\n]+)/gim, '<span class="grey">$1</span>')
.replace(/:\|--\|/gim, '://')
.split('\n')
.map(el => `<p>${el}</p>`)
// .map((el, index) =>
// index === 0
// ? `${author ? `<p><b class="comment-author">${author}: </b>` : ''}${el}</p>`
// : `<p>${el}</p>`
// )
.join('');
!text
? ''
: text
.replace(/(\n{2,})/gi, '\n')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/:\/\//gim, ':|--|')
.replace(/(\/\/[^\n]+)/gim, '<span class="grey">$1</span>')
.replace(/:\|--\|/gim, '://')
.split('\n')
.map(el => `<p>${el}</p>`)
// .map((el, index) =>
// index === 0
// ? `${author ? `<p><b class="comment-author">${author}: </b>` : ''}${el}</p>`
// : `<p>${el}</p>`
// )
.join('');
export const formatCommentText = (author: string, text: string): string =>
text