Node - codeBlock

Purpose

The codeBlock node is a container for lines of code.

Type

codeBlock is a top-level block node.

Example

1 2 3 4 5 6 7 8 9 10 11 12 { "type": "codeBlock", "attrs": { "language": "javascript" }, "content": [ { "type": "text", "text": "var foo = {};\nvar bar = [];" } ] }

Fields

NameRequiredTypeValue
typestring"codeBlock"
contentarrayAn array of nodes
attrsobject
attrs.languagestringLanguage of the code lines

Content

content takes an array of one or more text nodes without marks.

Attributes

  • language for syntax highlighting, a code language supported by Prism. See available languages imports for a list of the languages supported in Prism. If set to text or an unsupported value, code is rendered as plain, monospaced text.

Rate this page: