Skip to content

Commit 08207bf

Browse files
Copilotmsaroufim
andcommitted
Simplify CodeBlock component for Python-only syntax highlighting
Co-authored-by: msaroufim <[email protected]>
1 parent 6b365e8 commit 08207bf

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

frontend/src/components/codeblock/CodeBlock.test.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ describe("CodeBlock", () => {
1919
expect(screen.getByText(/Hello, world!/)).toBeInTheDocument();
2020
});
2121

22-
it("renders with syntax highlighting", () => {
23-
render(<CodeBlock code={sampleCode} language="javascript" />);
22+
it("renders with Python syntax highlighting", () => {
23+
render(<CodeBlock code={sampleCode} />);
2424
// Check that syntax highlighter is applied - it should create a pre element
2525
const preElement = screen.getByRole("button").closest("[data-testid]") || document.querySelector("pre");
2626
expect(preElement || screen.getByText(/Hello, world!/).closest("pre")).toBeInTheDocument();
@@ -42,13 +42,10 @@ describe("CodeBlock", () => {
4242
});
4343
});
4444

45-
it("accepts language prop for syntax highlighting", () => {
46-
render(<CodeBlock code="print('Hello')" language="python" />);
45+
it("handles Python code properly", () => {
46+
render(<CodeBlock code="print('Hello')" />);
4747
expect(screen.getByText(/Hello/)).toBeInTheDocument();
4848
});
4949

50-
it("defaults to text language when no language specified", () => {
51-
render(<CodeBlock code="plain text" />);
52-
expect(screen.getByText("plain text")).toBeInTheDocument();
53-
});
50+
5451
});

frontend/src/components/codeblock/CodeBlock.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { oneLight } from "react-syntax-highlighter/dist/esm/styles/prism";
1111

1212
interface CodeBlockProps {
1313
code: string;
14-
language?: string;
1514
maxHeight?: number | string;
1615
}
1716

@@ -32,7 +31,7 @@ const styles = {
3231
},
3332
};
3433

35-
export default function CodeBlock({ code, language = "text" }: CodeBlockProps) {
34+
export default function CodeBlock({ code }: CodeBlockProps) {
3635
const [copied, setCopied] = useState(false);
3736
const theme = useTheme();
3837

@@ -76,7 +75,7 @@ export default function CodeBlock({ code, language = "text" }: CodeBlockProps) {
7675
}}
7776
>
7877
<SyntaxHighlighter
79-
language={language}
78+
language="python"
8079
style={oneLight}
8180
customStyle={{
8281
margin: 0,

frontend/src/pages/leaderboard/Leaderboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export default function Leaderboard() {
176176
<CardContent>
177177
<CardTitle fontWeight="bold">Reference Implementation</CardTitle>
178178
<Box>
179-
<CodeBlock code={data.reference} language="cpp" />
179+
<CodeBlock code={data.reference} />
180180
</Box>
181181
</CardContent>
182182
</Card>

0 commit comments

Comments
 (0)