2023-09-05 21:37:39 +02:00
|
|
|
/*
|
|
|
|
|
* Vencord, a Discord client mod
|
|
|
|
|
* Copyright (c) 2023 Vendicated and contributors
|
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
2026-01-23 20:36:45 +01:00
|
|
|
import { findCssClassesLazy } from "@webpack";
|
2023-09-05 21:37:39 +02:00
|
|
|
import { Parser } from "@webpack/common";
|
|
|
|
|
|
2026-01-23 20:36:45 +01:00
|
|
|
const CodeContainerClasses = findCssClassesLazy("markup", "codeContainer");
|
2023-09-05 21:37:39 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Renders code in a Discord codeblock
|
|
|
|
|
*/
|
|
|
|
|
export function CodeBlock(props: { content?: string, lang: string; }) {
|
|
|
|
|
return (
|
|
|
|
|
<div className={CodeContainerClasses.markup}>
|
|
|
|
|
{Parser.defaultRules.codeBlock.react(props, null, {})}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-01-06 00:24:54 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Renders inline code like `this`
|
|
|
|
|
*/
|
|
|
|
|
export function InlineCode({ children }: { children: React.ReactNode; }) {
|
|
|
|
|
return (
|
|
|
|
|
<span className={CodeContainerClasses.markup}>
|
|
|
|
|
<code className="inline">{children}</code>
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|