CodeBlock

interface CodeBlock : Block

Represents a code block in a Notion page. Code blocks are used to display formatted code snippets with syntax highlighting. They support various programming languages and can be used to share code examples or technical documentation.

Code blocks can contain rich text content and maintain proper code formatting, including indentation and line breaks.

See also

Properties

Link copied to clipboard
abstract val children: List<Block>?
Link copied to clipboard
abstract val created: Timestamp
Link copied to clipboard
abstract val id: UuidString
Link copied to clipboard
abstract val language: String

The programming language of the code block. This determines the syntax highlighting rules applied to the code. Common values include "javascript", "python", "java", "kotlin", etc. If the language is not supported, a generic code highlighting will be used.

Link copied to clipboard
abstract val lastEdited: Timestamp
Link copied to clipboard
abstract val text: RichTextList?

The rich text content of the code block. This contains the actual code snippet with any formatting or mentions. If null, the code block is empty.