From ec9945cf0564f709942384e3983bed22824971b9 Mon Sep 17 00:00:00 2001 From: OFF0 Date: Fri, 9 Dec 2022 11:51:08 +0100 Subject: [PATCH] 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. --- src/domutil.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/domutil.js b/src/domutil.js index 3d6409e..96c94fb 100644 --- a/src/domutil.js +++ b/src/domutil.js @@ -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]), []); }