This page last changed on Aug 24, 2011 by pwatson.
The Code Block macro allows you to display source code in your document with the appropriate syntax highlighting. The code block displays on the page as shown below:
public static void main(String[] args)
{
System.out.println("Hello World!");
}
|
|
Using the Code Block Macro
To add the Code Block macro to a page:
- In the Confluence editor, choose Insert > Other Macros.
- Find and select the required macro.
You can now type the code block directly into the macro placeholder in the editor. Note that any white space contained in the placeholder is not manipulated in any way by the Code Block macro. This is to provide the writer with flexibility over code indentation.
Parameters
When editing, you can click on the macro placeholder and choose Edit to display the parameters for this macro in the Macro Browser.
Parameters are options that you can set for Confluence macros to control the content or format of the macro output. The table below lists parameters for this macro that can be set in the Macro Browser.
Parameter |
Default |
Description |
Syntax highlighting |
java |
Specifies the language (or environment) for syntax highlighting. The default language is Java but you can choose from one of the following languages/environments:
- actionscript3
- bash
- csharp (C#)
- coldfusion
- cpp (C++)
- css
- delphi
- diff
- erlang
- groovy
- html/xml
- java
- javafx
- javascript
- none (no syntax highlighting)
- perl
- php
- powershell
- python
- ruby
- scala
- sql
- vb
|
Title |
none |
Adds a title to the code block. If specified, the title will be displayed in a header row at the top of the code block. |
Collapsible |
false |
If selected, the code macro's content will be collapsed upon visiting or refreshing the Confluence page. Clicking the expand source link allows you to view this content. If false, the code macro's content is always displayed in full. |
Show line numbers |
false |
If selected, line numbers will be shown to the left of the lines of code. |
First line number |
1 |
When Show line numbers is selected, this value defines the number of the first line of code. |
Theme |
Default |
Specifies the colour scheme used for displaying your code block. Many of these themes are based on the default colour schemes of popular integrated development environments (IDEs). The default theme is Confluence (also known as Default), which is typically black and coloured text on a blank background. However, you can also choose from one of the following other popular themes:
- DJango
- Emacs
- FadeToGrey
- Midnight
- RDark
- Eclipse
- Confluence
|
Working with Macros
Take me back to the Confluence User's Guide.
|