Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
    public void myMethod() {
        // method from included source file
    }

Anchor
_line_numbers
_line_numbers
Line Numbers

Line numbers for source blocks can be enabled either using the :source-linenums-option: attribute globally for all source blocks on the page, or per source block using the linenums option:

No Format
[source,java,linenums]
----
public class MyCode {
    // comment
}
----
Code Block
languagejava
linenumberstrue
public class MyCode {
    // comment
}

In case no source language is specified for the source block, line numbers have to be enabled using [source%linenums] (not [source,linenums]):

No Format
[source%linenums]
----
line one
line two
line three
----
Code Block
linenumberstrue
line one
line two
line three

A custom start line number for a source block can be specified using the start option:

No Format
[source,java,linenums,start=4]
----
public class MyCode {
    // comment
}
----
Code Block
languagejava
firstline4
linenumberstrue
public class MyCode {
    // comment
}

Anchor
_collapsed_source_blocks
_collapsed_source_blocks
Collapsed Source Blocks

Collapsing of source blocks is supported via the custom collapse option:

No Format
[source,java,title="Collapsed Source Block",collapse=true]
----
public class MyCode  {
    // long source block that should not be visible by default
}
----
Code Block
languagejava
titleCollapsed Source Block
collapsetrue
public class MyCode  {
    // long source block that should not be visible by default
}
Info

Collapsed source blocks are currently not supported by AsciiDoc directly, thus this is a non-standard feature only supported by the Confluence Publisher.

Anchor
_source_highlighting
_source_highlighting
Source Highlighting

AsciiDoc source highlighters (e.g. CodeRay) are not supported, in favor of using the source highlighting support of Confluence. Thus, any configured AsciiDoc source highlighter is automatically disabled when publishing to Confluence.

Note

Other advanced features like listing file names or callouts are not supported.