feed: reduce newlines in text notes

This change reduces 3 or more newlines to 2 to keep the output
somewhat sane, i.e. somebody spamming newlines.
pull/29/head
OFF0 1 year ago
parent 9711ca2ecf
commit ec9945cf05
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -33,6 +33,7 @@ export function elem(name = 'div', {data, ...props} = {}, children = []) {
export function multilineText(string) {
return string
.trimRight()
.replaceAll(/\n{3,}/g, '\n\n')
.split('\n')
.reduce((acc, next, i) => acc.concat(i === 0 ? next : [elem('br'), next]), []);
}

Loading…
Cancel
Save