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.
OFF0 2 years 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) { export function multilineText(string) {
return string return string
.trimRight() .trimRight()
.replaceAll(/\n{3,}/g, '\n\n')
.split('\n') .split('\n')
.reduce((acc, next, i) => acc.concat(i === 0 ? next : [elem('br'), next]), []); .reduce((acc, next, i) => acc.concat(i === 0 ? next : [elem('br'), next]), []);
} }

Loading…
Cancel
Save