From 12aef93cd61611594ea748fb6976131f86863861 Mon Sep 17 00:00:00 2001 From: broxen Date: Sat, 9 Oct 2021 11:09:54 -0700 Subject: [PATCH] fix: remove excess div wrappers (#4528) * Removing superfluous div wrapping It seems like standalone text is already wrapped in paragraph elements, so this code seems superfluous. Additionally, it adds div wrappers at every line break as described in #4524 * Fix for newlines and returns This change skips newlines and returns to focus on unbounded text only. * misc: fix indentation * misc: fix indentation (2) Co-authored-by: Nicolas Giard --- server/modules/rendering/html-core/renderer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/modules/rendering/html-core/renderer.js b/server/modules/rendering/html-core/renderer.js index 697c0ff4..15ac8db5 100644 --- a/server/modules/rendering/html-core/renderer.js +++ b/server/modules/rendering/html-core/renderer.js @@ -234,11 +234,11 @@ module.exports = { }) // -------------------------------- - // Wrap root text nodes + // Wrap non-empty root text nodes // -------------------------------- $('body').contents().toArray().forEach(item => { - if (item && item.type === 'text' && item.parent.name === 'body') { + if (item && item.type === 'text' && item.parent.name === 'body' && item.data !== `\n` && item.data !== `\r`) { $(item).wrap('
') } })