Code block
The code block feature supports inserting and editing preformatted code blocks with the assigned programming language. Code Block is a valuable feature to include software-related issues such as code listings, snippets, or another software element in your content in an accessible and attractive way. So the readers can quickly locate the code blocks as they stand out from the normal content text.
Sonat supports multiple code block languages, including Plain text, C, C#, C++, CSS, Diff, HTML, Java, JavaScript, PHP, Python, Ruby, TypeScript, XML.
Inserting codes is also possible through inline code formatting. Check basic text style to learn more.
Insert a code block
- Click the dropdown arrow next to the toolbar code block button
to choose your programming language. Scroll down to see the complete list. (Clicking the code block button without selecting a language will apply the plain text as default) and the type in the block to insert your desired code block.
Or
- start the line with
```to format it as a code block using autoformatting features.
★ | Note: Although live code block highlighting does not take place in the editor as you type and edit, the content will be highlighted when displayed on the viewer. |

Typing around code blocks
there might be times when there is no obvious way to set the caret before and after a code block to type out of the block boundary. This can happen when a block of code is the first and/or last part of the topic content or when it is preceded and/or followed by a widget (table, image, etc.). Here's how you can edit around code blocks:
Type before the code block
- Put the selection at the beginning of the code block and press Enter.
- Move the selection to the new line that has been created and press Enter again.
A new paragraph will be created before the code block, and you can type your content.
Type after the code block
Put the selection at the end of the code block, and press Enter three times. A new paragraph will be created after the code block, and you can type your content.
Preserving/changing line indentation
When typing in a code block, the current line's indentation is preserved when you hit Enter and create a new line to speed up the editing. However, you can change the indentation of codes using keyboard shortcuts or toolbar buttons.
Increase indentation
- Select the line/lines of code you want to intend
- Press the Tab key or click the increase indent button on the toolbar.
Decrease indentation
- Select the line/lines of code you want to intend
- Press the Shift+Tab key or click the decrease indent button on the toolbar.