Listings
AsciiDoc literal blocks, listing blocks and code blocks are converted to formatted blocks in Confluence.
A title can be set for each type of block. The title is rendered as the title of the Confluence panel.
Literal Block
Literal blocks are converted as pre-formatted text.
.... this is a literal block ....
this is a literal block
Listing Block
Listing blocks are converted using the "noformat" macro.
.Title of the listing block ---- this is a listing block ----
this is a listing block
Source Block
Source blocks are converted using the "code" macro. Only languages supported by the Code Block Macro can be used:
actionscript3
, applescript
, bash
, c#
, cpp
, css
, coldfusion
, delphi
, diff
, erl
, groovy
,
xml
, java
, jfx
, js
, php
, perl
, text
, powershell
, py
, ruby
, sql
, sass
, scala
,
vb
, yml
(since Confluence 6.7 only)
[source,java] ---- public class MyCode { // comment } ----
public class MyCode { // comment }
Source Blocks from External Files (Full Content)
Including source code from external files is supported:
[source,java] ---- include::../files/Source.java[] ----
public class Source { // code from included source file }
Source Blocks from External Files (Partial Content)
Restricting the source code to be included based on tags is supported:
[source,java] ---- include::../files/SourceWithMethodTag.java[tags=myMethod] ----
public void myMethod() { // method from included source file }
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:
[source,java,linenums] ---- public class MyCode { // comment } ----
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]
):
[source%linenums] ---- line one line two line three ----
line one line two line three
A custom start line number for a source block can be specified using the start
option:
[source,java,linenums,start=4] ---- public class MyCode { // comment } ----
public class MyCode { // comment }
Collapsed Source Blocks
Collapsing of source blocks is supported via the custom collapse
option:
[source,java,title="Collapsed Source Block",collapse=true] ---- public class MyCode { // long source block that should not be visible by default } ----
Collapsed source blocks are currently not supported by AsciiDoc directly, thus this is a non-standard feature only supported by the Confluence Publisher.
Callouts
Callout are supported well. Due to code blocks limitation in Confluence it is advised to use guarded callouts, i.e. to place the callout into a comment.
[source,java,linenums] ---- public class MyClass { // <1> public static void main(String[] args){ System.out.println("Hello world!");// <2> } } <3> ---- <1> Definition of a Java class <2> print "Hello world!" to the standard out <3> Non-guarded callout. Code will be invalid if you copy it and paste in IDE
will be rendered as:
public class MyClass { // (1) public static void main(String[] args){ System.out.println("Hello world!");// (2) } } (3)
-
Definition of a Java class
-
print "Hello world!" to the standard out
-
Non-guarded callout. Code will be invalid if you copy it and paste in IDE
[source,xml] ---- <hello>world</hello><!--1--> ---- <1> Xml-style callout.
will be rendered as:
<hello>world</hello><!--(1)-->
-
Xml-style callout.
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.
Other advanced features like listing file names are not supported.