Skip to content

Commit 4c98c80

Browse files
Merge pull request #546 from powerium/patch/syntax-highlighting
2 parents 2b63fb1 + ff35995 commit 4c98c80

File tree

1 file changed

+14
-3
lines changed
  • packages/react-notion-x/src/third-party

1 file changed

+14
-3
lines changed

packages/react-notion-x/src/third-party/code.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,20 @@ export const Code: React.FC<{
2828
const copyTimeout = React.useRef<number>()
2929
const { recordMap } = useNotionContext()
3030
const content = getBlockTitle(block, recordMap)
31-
const language = (
32-
block.properties?.language?.[0]?.[0] || defaultLanguage
33-
).toLowerCase()
31+
const language = (() => {
32+
const languageNotion = (
33+
block.properties?.language?.[0]?.[0] || defaultLanguage
34+
).toLowerCase()
35+
36+
switch (languageNotion) {
37+
case 'c++':
38+
return 'cpp'
39+
case 'f#':
40+
return 'fsharp'
41+
default:
42+
return languageNotion
43+
}
44+
})()
3445
const caption = block.properties.caption
3546

3647
const codeRef = React.useRef()

0 commit comments

Comments
 (0)