Skip to content

Commit 3fbd0b4

Browse files
authored
Merge pull request #4028 from ClickHouse/fix_bug_on_empty_codeblock
fix crash on empty code blocks
2 parents a20d46a + d2a4046 commit 3fbd0b4

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)