From d130a93b0fec5748b985d2e7014df3ee74ee086d Mon Sep 17 00:00:00 2001 From: Weves Date: Tue, 12 Sep 2023 12:52:39 -0700 Subject: [PATCH] Fix small spacing issue with keyword highlighting --- web/src/components/search/DocumentDisplay.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web/src/components/search/DocumentDisplay.tsx b/web/src/components/search/DocumentDisplay.tsx index 4b8466bd4..e20f090a8 100644 --- a/web/src/components/search/DocumentDisplay.tsx +++ b/web/src/components/search/DocumentDisplay.tsx @@ -50,7 +50,10 @@ const buildDocumentSummaryDisplay = ( sections.push(["...", false, false]); } }); + console.log(blurb); + console.log(sections); + let previousIsContinuation = sections[0][2]; let previousIsBold = sections[0][1]; let currentText = ""; const finalJSX = [] as (JSX.Element | string)[]; @@ -61,19 +64,21 @@ const buildDocumentSummaryDisplay = ( // remove leading space so that we don't bold the whitespace // in front of the matching keywords currentText = currentText.trim(); + if (!previousIsContinuation) { + finalJSX[finalJSX.length - 1] = finalJSX[finalJSX.length - 1] + " "; + } finalJSX.push( {currentText} ); } else { - // add in trailing space since the next section is bold - // and we will remove any leading spaces when that section is complete - finalJSX.push({currentText + " "}); + finalJSX.push(currentText); } } currentText = ""; previousIsBold = shouldBeBold; + previousIsContinuation = isContinuation; } if (!isContinuation || index === 0) { currentText += " "; @@ -89,7 +94,7 @@ const buildDocumentSummaryDisplay = ( ); } else { - finalJSX.push({currentText}); + finalJSX.push(currentText); } } return finalJSX;