Access Keys:
Skip to content (Access Key - 0)

code macro

Note: If you're looking for examples of macro source code, you can download the source for most plugins on Atlassian's SubVersion Repository.

Overview:

The {code} macro is used to display syntax highlited source code...

This macro is an extension to the noformat macro which has the ability to apply syntax highlighting to various types of source code:

  • Java (default)
  • JavaScript
  • ActionScript
  • XML
  • HTML
  • SQL

As you can imagine, the macro is mainly aimed at techies, but it's useful if you need to show snippets of HTML such as how to include a link to your site, etc.

Parameters:

To syntax-highlight code, simply wrap it in {code} macro tags and specify the language to use:

{code:language}Your source code{code}
Parameter Required Default Notes
default Java The "language" default parameter defines what type of syntax highligting to use:
  • Java (default)
  • JavaScript
  • ActionScript
  • XML
  • HTML
  • SQL

Examples:

Standard Use

Hints and Tips

The macro is ideal for including snippets of code on your pages because the syntax highlighting makes them easier to read (to us techies at least!)

You can improve the look and feel of the code macro and noformat macro using the following CSS:

/* code and noformat blocks */

div.code, div.preformatted {
overflow: auto;
background-color: #F8F7EF;
}

div.codeContent, div.preformattedContent {
background-color: #F8F7EF;
}

div.code, div.preformatted {
border-style: solid;
}
Q Can I display other languages?
A Yes, but they probably won't get syntax highligted properly. Just choose the syntax closest to the language you are using and hope for the best!

See Also:



Ask questions, get help and report bugs & issues on our Community Site

View old comments


Adaptavist Theme Builder Powered by Atlassian Confluence