hypertext

This commit is contained in:
Martti Malmi 2023-08-16 10:02:53 +03:00
parent 060868ca76
commit 029dbf54a9

View File

@ -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
}
}