This page last changed on Jan 24, 2005 by cmiller.

Allows you to display code in your document with the appropriate syntax highlighting.

Usage:
{code:language} ... code ... {code}
OR
{code} ... java code ... {code}

Parameter Required Default Description
language no Java Specify the programming language. Currently supported: Java, XML and SQL.

Example 1: Java
{code}
public String getFoo()
{
return foo;
}
{code}

gives:

public String getFoo()
{
    return foo;
}

Example 2: XML
{code:XML}
<test>
<another tag="attribute"/>
</test>
{code}

gives:

<test>
    <another tag="attribute"/>
</test>
SELECT * FROM TABLE1 WHERE ID=0 AND NAME NOT IN (SELECT NAME FROM NAMES)
Posted by at Jul 01, 2004 05:34

Is there a way to extend this macro with support for additional languages? For that matter, are there (yet) any sorts of Java APIs for Confluence, as there are for Jira?

Posted by jrk at Jul 13, 2004 10:43

Jonathan,

Yes - certainly you can plug in your own syntax highlighting classes. Each language has a little class that implements an interface to represent the syntax highlighting.

With regards to the Java API, you have the same APIs in Confluence as you do for JIRA (in fact more as the Confluence SOAP/XML-RPC APIs are more comprehensive).

Cheers,
Mike

Posted by mike@atlassian.com at Jul 14, 2004 18:49

Yes, where are those little syntax highlighting classes located again? And how and where do I get to / edit / make them?

Thanks!

Posted by dlooijen@purdue.edu at Jul 28, 2004 15:01

Having out-of-the-box support for C++ and Python syntax would be very useful.
Ta,
os.

Posted by os at Jul 12, 2005 07:14

I have a code snippet with a || in it for or and the formatting is getting all messed up. Any ideas of what I can do?

Posted by christy.schmitt@searchamerica.com at Aug 17, 2005 10:51

Can you please tell me:

  • exactly what markup you have
  • what you think it should look like
  • what it actually looks like

The characters '||' look OK to me in a {code} macro:

a || b
Posted by tom@atlassian.com at Aug 17, 2005 19:08

I'm just using the default Confluence markup I believe.
When I use the 2 vertical bars within the code macro it takes me out of "code" mode at that point. I can escape the vertical bars and then it looks just like your example.

Posted by christy.schmitt@searchamerica.com at Aug 18, 2005 09:28

Can you tell me exactly what markup you have? You can paste it in your reply to this comment if you like.

Which version of Confluence are you using?

Posted by tom@atlassian.com at Aug 18, 2005 18:56

I know this sounds lame, but syntax highlighting for VB and VBScript would really help my Microsoft-centric developers out. Yeah, learning Java would help them more. Still, one battle at a time.

Posted by gpullis at Sep 08, 2006 16:49
Document generated by Confluence on Mar 22, 2007 20:54