The code block allows you to embed syntax-highlighted source code into your app. !!! note This block currently supports Python and JavaScript.
| 101 | |
| 102 | |
| 103 | class Code(EmbeddedTextBlock): |
| 104 | """ |
| 105 | The code block allows you to embed syntax-highlighted source code into your app. |
| 106 | |
| 107 | !!! note |
| 108 | This block currently supports Python and JavaScript. |
| 109 | """ |
| 110 | |
| 111 | _tag = "Code" |
| 112 | |
| 113 | def __init__( |
| 114 | self, code: str, language: str = "python", caption: str = None, name: BlockId = None, label: str = None |
| 115 | ): |
| 116 | """ |
| 117 | Args: |
| 118 | code: The source code |
| 119 | language: The language of the code, most common languages are supported (optional - defaults to Python) |
| 120 | caption: A caption to display below the Code (optional) |
| 121 | name: A unique name for the block to reference when adding text or embedding (optional) |
| 122 | label: A label used when displaying the block (optional) |
| 123 | """ |
| 124 | super().__init__(content=code, language=language, caption=caption, name=name, label=label) |
| 125 | |
| 126 | |
| 127 | class HTML(EmbeddedTextBlock): |