Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Section
Column
width60%

Excerpt

Makroen 'code' er nyttig for å presentere kildkode på et vellformatert og lesbart format i Confluence sider. Bruken er veldig rett fram: sett kildekoden din i mellom {code} elementer.

Her er noen eksempler.

XML

No Format

{code:XML
Panel

For other macros, besides that of the source code macro discussed below, please visit The Guide to Confluence Macros.

Excerpt

The source code macro is a useful way of presenting technical information to a group of users online. It's use is very straightforward. Any form of code can be included between {code} elements and we provide arguments for XML, SQL, and Java.

As you read below, look for the bolded code tags to indicate how the highlighting occurs.

XML

Code Block
\{code:XML\
}
<test>
    <another tag="attribute"/>
</test>
\
{code
\
}

...

codecode

gir

Code Block
XML
XML

<test>
    <another tag="attribute"/>
</test>

SQL

No Format

\
{code:SQL
\
}
SELECT * FROM TABLE1 WHERE ID=0 AND NAME NOT IN (SELECT NAME FROM NAMES)
\
{code
\
}

gir

Code Block
SQL
SQL

SELECT * FROM TABLE1 WHERE ID=0 AND NAME NOT IN (SELECT NAME FROM NAMES)

Java

No Format

\
{code:Java
\
}
package com.atlassian.confluence.admin.actions.macros;

import com.atlassian.confluence.renderer.UserMacroLibrary;

public class UserMacroBean
{
    String name;
    String template;

    public UserMacroBean()
    {
    }

    public UserMacroBean(String name, UserMacroLibrary userMacroLibrary)
    {
        this.name = name;
        this.template = userMacroLibrary.getMacroTemplate(name);
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getTemplate()
    {
        return template;
    }

    public void setTemplate(String template)
    {
        this.template = template;
    }
}
\
{code
\
}

...

gir

Code Block
Java
Java

package com.atlassian.confluence.admin.actions.macros;

import com.atlassian.confluence.renderer.UserMacroLibrary;

public class UserMacroBean
{
    String name;
    String template;

    public UserMacroBean()
    {
    }

    public UserMacroBean(String name, UserMacroLibrary userMacroLibrary)
    {
        this.name = name;
        this.template = userMacroLibrary.getMacroTemplate(name);
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getTemplate()
    {
        return template;
    }

    public void setTemplate(String template)
    {
        this.template = template;
    }
}
Column
Info
iconfalse

For mer informasjon, se dokumentasjonen.