Skip to content
Yamuno
Browse

Code Blocks

Markdown Macro+ for Confluence supports syntax-highlighted code blocks for multiple programming languages, making your technical documentation more readable and professional.

Basic Code Blocks

Create a code block using triple backticks:

```python
def hello_world():
    print("Hello, World!")
```

Syntax Highlighting

Specify the language after the opening backticks for syntax highlighting:

```javascript
function calculateSum(a, b) {
    return a + b;
}
```

Supported Languages

  • Python
  • JavaScript
  • Java
  • C/C++
  • Ruby
  • PHP
  • SQL
  • HTML/CSS
  • Shell scripts
  • Go, Rust, Kotlin, Swift, YAML, JSON, Markdown and many more

Code colours follow Confluence's light or dark theme. Code blocks without a language are shown without highlighting.

Copy button

Hover over a code block, or move to it with the keyboard, to show a Copy button that copies the code.

Inline Code

Use single backticks for inline code:

Use the `print()` function to output text

Best Practices

  1. Always specify the language for proper syntax highlighting
  2. Use inline code for short snippets within text
  3. Use code blocks for longer examples
  4. Include comments to explain complex code
  5. Format code properly for better readability

Using Confluence's built-in code snippet instead of Markdown? See inline code and code blocks in Confluence for the native shortcuts and settings.

Guides for Markdown Macro+ for Confluence

Stuck on something this page does not cover? Ask the developers.