MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / PreBlock

Function PreBlock

packages/react/src/components/markdown.tsx:29–43  ·  view source on GitHub ↗
(
  props: ComponentPropsWithoutRef<"pre"> & { children?: ReactNode; node?: unknown },
)

Source from the content-addressed store, hash-verified

27}
28
29function PreBlock(
30 props: ComponentPropsWithoutRef<"pre"> & { children?: ReactNode; node?: unknown },
31) {
32 const child = Children.toArray(props.children)[0];
33 if (
34 isValidElement(child) &&
35 (child.type === "code" || (child.props as Record<string, unknown>)?.className)
36 ) {
37 const childProps = child.props as { className?: string; children?: ReactNode };
38 const lang = childProps.className?.replace("language-", "") ?? undefined;
39 const code = extractText(childProps.children).replace(/\n$/, "");
40 return <CodeBlock code={code} lang={lang} className="my-2" />;
41 }
42 return <pre>{props.children}</pre>;
43}
44
45function Link(props: ComponentPropsWithoutRef<"a"> & { children?: ReactNode; node?: unknown }) {
46 const { children, href, node: _node, ...rest } = props;

Callers

nothing calls this directly

Calls 2

extractTextFunction · 0.85
replaceMethod · 0.65

Tested by

no test coverage detected