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 } return (
null, h2: ({ children }) => (

{highlighter(children, highlight)}

), h3: ({ children }) => (

{highlighter(children, highlight)}

), h4: ({ children }) => (

{highlighter(children, highlight)}

), p: ({ children }) => (

{highlighter(children, highlight)}

), ul: ({ children }) =>
    {children}
, ol: ({ children }) => (
    {children}
), li: ({ children }) => (
  • {highlighter(children, highlight)}
  • ), table: ({ children }) => ( {children}
    ), thead: ({ children }) => {children}, tr: ({ children }) => {highlighter(children, highlight)}, th: ({ children }) => {highlighter(children, highlight)}, td: ({ children }) => {highlighter(children, highlight)}, tbody: ({ children }) => {children}, blockquote: ({ children }) => (
    {highlighter(children, highlight)}
    ), pre: ({ children }) => { const child = children.props return {child.children} }, code: ({ children }) => ( {children} ), img: ({ src }) => , a: ({ href, children }) => { return }, }} > {body}
    ) }