MCPcopy Create free account
hub / github.com/dailydotdev/apps / code

Function code

packages/shared/src/components/RenderMarkdown.tsx:180–278  ·  view source on GitHub ↗
({
          node,
          inline,
          className: codeClassName,
          children,
          style,
          ...props
        })

Source from the content-addressed store, hash-verified

178 return <img src={src} alt={alt} {...props} />;
179 },
180 code({
181 node,
182 inline,
183 className: codeClassName,
184 children,
185 style,
186 ...props
187 }) {
188 const match = /language-(\w+)/.exec(codeClassName || '');
189 const language = match?.[1];
190 const Wrapper = language ? SyntaxHighlighterAsync : SyntaxHighlighter;
191 if (language) {
192 loadLanguages();
193 }
194
195 return (
196 <>
197 {!inline && (
198 <div className="flex h-10 items-center justify-between bg-surface-float px-3">
199 <Typography
200 type={TypographyType.Callout}
201 bold
202 color={TypographyColor.Secondary}
203 tag={TypographyTag.Span}
204 className="inline leading-8"
205 >
206 {language || 'Code snippets'}
207 </Typography>
208 <div className="flex gap-2">
209 <Button
210 variant={ButtonVariant.Tertiary}
211 icon={<CopyIcon />}
212 disabled={copying || isLoading}
213 size={ButtonSize.Small}
214 onClick={() => {
215 if (onCopy) {
216 onCopy();
217 }
218 copy({
219 textToCopy: String(children),
220 });
221 }}
222 />
223 {header?.buttons ? header.buttons : null}
224 </div>
225 </div>
226 )}
227
228 {!inline ? (
229 <div
230 className={classNames(
231 'px-5 py-3',
232 isExpanded || !isExpandable
233 ? undefined
234 : 'max-h-[8.4375rem]',
235 )}
236 ref={(element) => {
237 if (isExpandable && element && !canExpand) {

Callers

nothing calls this directly

Calls 4

loadLanguagesFunction · 0.85
onCopyFunction · 0.85
copyFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected