Code Blocks

Display syntax-highlighted code examples in multiple programming languages in your documentation.

Code blocks display formatted source code with syntax highlighting, making technical documentation clear and readable. Mordoc supports code blocks in multiple programming languages.

Inline code

For short code snippets within sentences, use single backticks:

SyntaxResult
Markdown
Use the `npm run build` to build your project.
``
Use the npm run build to build your project.

Multi-line code blocks

Create code blocks using triple backticks with an optional language identifier:

SyntaxResult
Markdown
```javascript
function greet(name) {
  console.log(`Hello, ${name}!`);
}
```
Javascript
function greet(name) {
  console.log(`Hello, ${name}!`);
}

Next steps

  • Callouts - Create styled alert and info boxes
  • Cards - Build visual card layouts