import { ReactNode } from "react"; export function highlightText(text: string, keyword: string): ReactNode { if (!keyword.trim()) { return text; } const escaped = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const regex = new RegExp(`(${escaped})`, "gi"); const parts = text.split(regex); return parts.map((part, index) => regex.test(part) ? ( {part} ) : ( part ) ); }