Adding code

Learn how to insert code blocks and inline code in Cadmus.

With Cadmus, you can include snippets of code in your submission by inserting code blocks or inline code.

This article covers how to:

  1. Insert and customise code blocks

  2. Insert inline code

 

Insert and customise code blocks

Code blocks can be used to create distinct sections of code with optional syntax highlighting. You can configure the style of code blocks as well.

code-block@2x

 

To insert a code block

  1. Click the code-icon code icon in the Formatting Toolbar.

  2. Click the code-block-icon code block icon.

  3. A code block will be inserted into the editing area.

TIP! You can also highlight a section of text and click the code block icon to turn it into a code block. Or try the keyboard shortcut ``` + Space.

 

To add syntax highlighting

  1. Click on the code block.

  2. From the code block menu, click on the Language dropdown.

  3. Select a language to enable syntax highlighting, or select Plain Text to remove any highlighting.

code-language@2x

 

To change the code block theme

  1. Click on the code block.

  2. From the code block menu, toggle between Light Theme and Dark Theme using the code-theme-icon theme icon.

code-theme@2x

 

To hide or show line numbers and language caption

  1. Click on the code block.

  2. From the code block menu, click the more icon.

  3. Toggle Line Numbers and Language Caption on or off.

code-line-numbers@2x

 

To delete a code block

  1. Click on the code block.

  2. From the code block menu, click the delete-icon delete icon.

 

 

Insert inline code

You can use inline code for small lines of code or to highlight keywords.

code-inline@2x

 

To insert inline code

  1. Click the code-icon code icon in the Formatting Toolbar.

  2. Click the code-icon inline code icon.

TIP! You can also highlight a section of text and click the inline code icon to turn it into inline code. Or enclose a section of text in `backticks` using the keyboard shortcut.