Skip to content

Commit d2a4046

Browse files
authored
fix crash on empty code blocks
1 parent 780d3d2 commit d2a4046

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/theme/CodeBlock/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import CodeViewer from "../../components/CodeViewer";
44

55

66
function countLines(text) {
7+
// Handle undefined or null input
8+
if (!text) return 1; // Return 1 as default line count
79
// Split the string by newline characters
810
const lines = text.split('\n');
911
// Return the number of lines

0 commit comments

Comments
 (0)