From 89a77407f12c2495fe6d95432364658e71ae6602 Mon Sep 17 00:00:00 2001 From: Jonny Gerig Meyer Date: Mon, 22 May 2023 13:13:27 -0400 Subject: [PATCH] Preserve whitespace during HTML truncation (fixes code blocks). --- source/helpers/type.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/helpers/type.ts b/source/helpers/type.ts index 5fa2445f5..df1d5f6f3 100644 --- a/source/helpers/type.ts +++ b/source/helpers/type.ts @@ -32,7 +32,7 @@ export const getLorem = (type: string, number = 1) => { * @see https://github.com/oe/truncate-html */ export const truncateHTML = (html: string, words = 170) => - truncate(html, words, { byWords: true }); + truncate(html, words, { byWords: true, keepWhitespaces: true }); /** * Renders block of Markdown into HTML.