From 029dbf54a9213e8b5c6a803b237cd007776662ea Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Wed, 16 Aug 2023 10:02:53 +0300 Subject: [PATCH] hypertext --- src/js/components/HyperText.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/components/HyperText.tsx b/src/js/components/HyperText.tsx index 77f56ff5..8ae9e31d 100644 --- a/src/js/components/HyperText.tsx +++ b/src/js/components/HyperText.tsx @@ -29,11 +29,11 @@ const HyperText = memo( processedChildren = processedChildren.map((x, index, array) => { if (typeof x === 'string') { - if (index < array.length - 1 && !array[index + 1].props?.href) { + if (index < array.length - 1 && !array[index + 1]?.props?.href) { x = x.replace(/\n+$/, ''); // Remove trailing newlines if next element is not a link } - if (index > 0 && !array[index - 1].props?.href) { + if (index > 0 && !array[index - 1]?.props?.href) { x = x.replace(/^\n+/, ''); // Remove leading newlines if previous element is not a link } }