diff --git a/cpp/parser/GumboNormalizer.c b/cpp/parser/GumboNormalizer.c index 5a6210f15..562a745f1 100644 --- a/cpp/parser/GumboNormalizer.c +++ b/cpp/parser/GumboNormalizer.c @@ -638,8 +638,12 @@ static void flatten_li_node(GumboNode *node, buffer_t *ib, buffer_t *out, li_ctx_t *ctx); static void flush_li_buffer(buffer_t *ib, buffer_t *out, li_ctx_t *ctx) { - if (ib->len == 0) + /* Whitespace around blocks inside an
a
\nAsdasd
Asdasd
"), "Asdasd
Asdasd
"); + // Whitespace around blocks inside a list item must not add empty items. + EXPECT_EQ(GumboParser::normalizeHtml( + "a
\nb
\na
b
. EXPECT_EQ(GumboParser::normalizeHtml("
a
hellob
"), "a
hello
b
"); diff --git a/src/web/__tests__/htmlNormalizer.test.ts b/src/web/__tests__/htmlNormalizer.test.ts index 04547a2de..8501ea353 100644 --- a/src/web/__tests__/htmlNormalizer.test.ts +++ b/src/web/__tests__/htmlNormalizer.test.ts @@ -616,6 +616,12 @@ describe('htmlNormalizer', () => { 'Asdasd
Asdasd
Asdasda
', ], ['Asdasd
Asdasd
', 'Asdasd
Asdasd
'], + // Whitespace around blocks inside a list item must not add empty items. + [ + 'a
\nb
\na
b
. ['
a
hellob
', 'a
hello
b
'], // Spaces inside text / between inlines must be preserved. diff --git a/src/web/normalization/htmlNormalizer.ts b/src/web/normalization/htmlNormalizer.ts index 35e6ef8a2..bb4f96090 100644 --- a/src/web/normalization/htmlNormalizer.ts +++ b/src/web/normalization/htmlNormalizer.ts @@ -432,7 +432,12 @@ function flushLiBuffer( out: { buf: string }, ctx: LiCtx ): void { - if (ib.buf.length === 0) return; + // Whitespace around blocks inside ana
\n