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:
parent
6d0a22707c
commit
6476e60c81
4 changed files with 42 additions and 38 deletions
|
@ -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, '<')
|
||||
.replace(/>/g, '>')
|
||||
.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, '<')
|
||||
.replace(/>/g, '>')
|
||||
.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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue