mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-15 18:40:56 +02:00
Fix small spacing issue with keyword highlighting
This commit is contained in:
parent
cf2bd8a40c
commit
d130a93b0f
@ -50,7 +50,10 @@ const buildDocumentSummaryDisplay = (
|
|||||||
sections.push(["...", false, false]);
|
sections.push(["...", false, false]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log(blurb);
|
||||||
|
console.log(sections);
|
||||||
|
|
||||||
|
let previousIsContinuation = sections[0][2];
|
||||||
let previousIsBold = sections[0][1];
|
let previousIsBold = sections[0][1];
|
||||||
let currentText = "";
|
let currentText = "";
|
||||||
const finalJSX = [] as (JSX.Element | string)[];
|
const finalJSX = [] as (JSX.Element | string)[];
|
||||||
@ -61,19 +64,21 @@ const buildDocumentSummaryDisplay = (
|
|||||||
// remove leading space so that we don't bold the whitespace
|
// remove leading space so that we don't bold the whitespace
|
||||||
// in front of the matching keywords
|
// in front of the matching keywords
|
||||||
currentText = currentText.trim();
|
currentText = currentText.trim();
|
||||||
|
if (!previousIsContinuation) {
|
||||||
|
finalJSX[finalJSX.length - 1] = finalJSX[finalJSX.length - 1] + " ";
|
||||||
|
}
|
||||||
finalJSX.push(
|
finalJSX.push(
|
||||||
<b key={index} className="text-gray-200 bg-pink-950">
|
<b key={index} className="text-gray-200 bg-pink-950">
|
||||||
{currentText}
|
{currentText}
|
||||||
</b>
|
</b>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// add in trailing space since the next section is bold
|
finalJSX.push(currentText);
|
||||||
// and we will remove any leading spaces when that section is complete
|
|
||||||
finalJSX.push(<span key={index}>{currentText + " "}</span>);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentText = "";
|
currentText = "";
|
||||||
previousIsBold = shouldBeBold;
|
previousIsBold = shouldBeBold;
|
||||||
|
previousIsContinuation = isContinuation;
|
||||||
}
|
}
|
||||||
if (!isContinuation || index === 0) {
|
if (!isContinuation || index === 0) {
|
||||||
currentText += " ";
|
currentText += " ";
|
||||||
@ -89,7 +94,7 @@ const buildDocumentSummaryDisplay = (
|
|||||||
</b>
|
</b>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
finalJSX.push(<span key={sections.length}>{currentText}</span>);
|
finalJSX.push(currentText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return finalJSX;
|
return finalJSX;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user