The codeBlock node is a container for lines of code.
This is roughly equivalent to the combination of the <pre> and <code> HTML tags, although there may be more complicated styling, including language-aware syntax highlighting.
If the language is unspecified or its value is not one of the supported languages, then the codeBlock renders as plain, monospace text.
Although codeBlock accepts text nodes as content, they are not permitted to use any marks.
1 2 3codeBlock("var foo = {};\nvar bar = [];") .language("javascript");
1 2 3 4 5 6 7 8 9 10 11 12 13{ "type": "codeBlock", "attrs": { "language": "javascript" }, "content": [ { "type": "text", "text": "var foo = {};\nvar bar = [];" } ] }
1 2 3var foo = {}; var bar = [];
Note: This example output is not using AtlasKit to render the code block, so while it gives a vague impression of what a “code block” is, it does not faithfully reproduce the actual presentation in Atlassian products. In particular, this is a different syntax highlighting color scheme.
| Confluence | Jira |
|---|---|
| ✅ | ✅ |
codeBlock.↩︎attrs property is optional in the JSON schema and need not be provided to successfully parse these nodes. However, the Fabric Editor always includes the attrs map even when the language is not specified.↩︎localId, when present, will typically be a random UUID. This is not enforced by the schema.↩︎uniqueId property has not been documented internally. It appears to be redundant, serving the same function that localId serves for other nodes and attributes, just without following that standard naming convention. Your humble documentation author speculates that it probably isn’t used.↩︎Rate this page: