Content & Editing
Code blocks allow source code and other pre-formatted text to be displayed with syntax highlighting while preserving spacing and indentation.
A code block can be added in several ways:
From the editor toolbar
Through the slash command menu
By typing three backticks (```), similar to Markdown
Once inserted, code can be typed directly into the block or pasted from another source.
Tabs, spaces and indentation are preserved in code blocks.
function hello() {
console.log("Hello world!");
}For short snippets within normal text, inline code can be used instead of a full code block. Inline code can be toggled with Ctrl + E on Windows and Linux or Command + E on macOS.
Docvora automatically detects the programming language used in a code block and applies syntax highlighting. In the above example Javascript is automatically detected and used.
Code blocks adapt to the configured site appearance so they remain suitable for the active theme.
Code blocks do not display line numbers.
Long lines scroll horizontally rather than wrapping onto additional lines.
On published pages, a copy button is displayed in the top right corner of the code block, allowing the contents to be copied quickly.
Code blocks do not include a filename, title or caption. These options are handled separately when working with uploaded files.