import React from "preact/compat"; export function preprocessText(text: string): React.ReactNode[] { // URL regex pattern const urlPattern = /(https?:\/\/[^\s]+)/g; // Split the text by URLs const parts = text.split(urlPattern); // Process each part and create React elements return parts.map((part, index) => { // Check if this part is a URL if (urlPattern.test(part)) { return ( {part} ); } // Handle newlines in text parts if (part) { return part.split("\n").map((line, lineIndex, array) => ( {line} {lineIndex < array.length - 1 &&
}
)); } return null; }); }