Skip to content
Anjunar/ DOCS

Code

Code blocks keep their line breaks and a typed language info string.

Concept

A block, not a mark

ToggleCodeBlock converts the current block. Inside code, Enter inserts a newline; the toolbar can set Scala as the language and indent or outdent the current line.

Edit the listing

Place the caret in code and use the Code toolbar group. Watch the Markdown fence update.

Code example

val message = "Hello"
println(message)

A paragraph after the listing.

12 words · 7 nodes
# Code example ```scala val message = "Hello" println(message) ``` A paragraph after the listing.
Source

Code commands

CodeInfo separates the language from optional fence metadata. Indentation inserts two spaces.

scala
session.dispatch(CodeCommands.ToggleCodeBlock, CodeInfo.empty) session.dispatch(CodeCommands.SetCodeInfo, CodeInfo.of("scala")) session.dispatch(CodeCommands.IndentLine) session.dispatch(CodeCommands.OutdentLine)