import ReactMarkdown from "react-markdown"
import remarkGfm from "remark-gfm"
import CodeBlock from "@/components/CodeBlock"
import remarkMath from "remark-math"
import rehypeKatex from "rehype-katex"
import "katex/dist/katex.min.css"
import BodyLink from "./BodyLink"
import EntryLoadingSkeleton from "./EntryLoadingSkeleton"
import { useSearchParams } from "react-router"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "./ui/table"
const ImagePreprocessor = (src) => {
const filename = src.src.split("/").pop()
const s3RootUrl = "https://eolas.s3.systemsobscure.net/"
return
}
const escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
const highlighter = (children, highlight) => {
if (!highlight || typeof children !== "string") return children
const words = highlight.trim().split(/\s+/)
const pattern = words.length > 1 ? escapeRegex(highlight) : escapeRegex(words[0])
const regex = new RegExp(`\\b(${pattern})\\b`, "gi")
const parts = children.split(regex)
return parts.map((part, i) =>
regex.test(part) ? (
{part}
) : (
part
),
)
}
export default function EntryBody({ body, isLoading }) {
const [searchParams] = useSearchParams()
const highlight = searchParams.get("highlight")
if (isLoading) {
return
{highlighter(children, highlight)}
), ul: ({ children }) =>{highlighter(children, highlight)}), pre: ({ children }) => { const child = children.props return
{children}
),
img: ({ src }) =>