Going Stellar

Home/Confluence storage format reference

Confluence storage format

code macro languages in Confluence storage format

The language parameter takes any string without error. Highlighting works only for the languages the macro knows, and every other value is stored as written but drawn with the Java brush. ADF renames a few values on the way through.

Storage format

<ac:parameter ac:name="language">bash</ac:parameter>

In the editor

HowNote
Choose the syntax highlighting language for the blockPer the Atlassian documentation. The documented choices are: ActionScript, AppleScript, Bash, C#, C++, CSS, ColdFusion, Delphi, Diff, Erlang, Groovy, HTML and XML, Java, Java FX, JavaScript, Plain Text, PowerShell, Python, Ruby, SQL, Sass, Scala and Visual Basic.

As ADF (Confluence Cloud)

The ADF that Confluence Cloud builds for:

<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:plain-text-body><![CDATA[ls -la]]></ac:plain-text-body></ac:structured-macro>
{
 "type": "doc",
 "content": [
  {
   "type": "codeBlock",
   "attrs": {
    "language": "shell"
   },
   "content": [
    {
     "text": "ls -la",
     "type": "text"
    }
   ]
  }
 ],
 "version": 1
}

Examples

Storage format sent

<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">bash</ac:parameter><ac:plain-text-body><![CDATA[ls -la]]></ac:plain-text-body></ac:structured-macro>

Highlight a shell command. The stored page uses the bash brush and ADF calls the language shell.

Rendered view (HTML)

<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="code" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: bash; gutter: false; theme: Confluence" data-theme="Confluence">ls -la</pre>
</div></div>

Storage format after the round trip through ADF

<ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="language">bash</ac:parameter><ac:plain-text-body><![CDATA[ls -la]]></ac:plain-text-body></ac:structured-macro>

Sent to Confluence Cloud on .

Storage format sent

<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">js</ac:parameter><ac:plain-text-body><![CDATA[let a]]></ac:plain-text-body></ac:structured-macro>

Use the short name js. It is stored and rendered with the js brush.

Rendered view (HTML)

<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="code" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: js; gutter: false; theme: Confluence" data-theme="Confluence">let a</pre>
</div></div>

Storage format after the round trip through ADF

<ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="language">js</ac:parameter><ac:plain-text-body><![CDATA[let a]]></ac:plain-text-body></ac:structured-macro>

Sent to Confluence Cloud on .

Storage format sent

<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">javascript</ac:parameter><ac:plain-text-body><![CDATA[let a]]></ac:plain-text-body></ac:structured-macro>

Use the long name javascript. It highlights, but ADF folds it into js when saved back.

Rendered view (HTML)

<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="code" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: javascript; gutter: false; theme: Confluence" data-theme="Confluence">let a</pre>
</div></div>

Storage format after the round trip through ADF

<ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="language">js</ac:parameter><ac:plain-text-body><![CDATA[let a]]></ac:plain-text-body></ac:structured-macro>

Sent to Confluence Cloud on .

Storage format sent

<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">yaml</ac:parameter><ac:plain-text-body><![CDATA[a: 1]]></ac:plain-text-body></ac:structured-macro>

Use a language outside the documented list. YAML is accepted and drawn with the Java brush.

Rendered view (HTML)

<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="code" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java; gutter: false; theme: Confluence" data-theme="Confluence">a: 1</pre>
</div></div>

Storage format after the round trip through ADF

<ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="language">yaml</ac:parameter><ac:plain-text-body><![CDATA[a: 1]]></ac:plain-text-body></ac:structured-macro>

Sent to Confluence Cloud on .

Storage format sent

<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">unknownlang</ac:parameter><ac:plain-text-body><![CDATA[x]]></ac:plain-text-body></ac:structured-macro>

Use a made-up language name. Nothing is rejected, which hides typos.

Rendered view (HTML)

<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="code" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java; gutter: false; theme: Confluence" data-theme="Confluence">x</pre>
</div></div>

Storage format after the round trip through ADF

<ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="language">unknownlang</ac:parameter><ac:plain-text-body><![CDATA[x]]></ac:plain-text-body></ac:structured-macro>

Sent to Confluence Cloud on .

Storage format sent

<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">text</ac:parameter><ac:plain-text-body><![CDATA[plain]]></ac:plain-text-body></ac:structured-macro>

Use text for unhighlighted output. ADF names it plaintext and the value returns as text.

Rendered view (HTML)

<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="code" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: text; gutter: false; theme: Confluence" data-theme="Confluence">plain</pre>
</div></div>

Storage format after the round trip through ADF

<ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="language">text</ac:parameter><ac:plain-text-body><![CDATA[plain]]></ac:plain-text-body></ac:structured-macro>

Sent to Confluence Cloud on .

Storage format sent

<ac:structured-macro ac:name="code"><ac:parameter ac:name="language">mermaid</ac:parameter><ac:plain-text-body><![CDATA[graph TD
  A-->B]]></ac:plain-text-body></ac:structured-macro>

Use mermaid as the language. The view shows the diagram source as plain text with the Java brush, so no diagram is drawn. The language name survives the ADF round trip.

Rendered view (HTML)

<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-id="<id>" data-macro-name="code" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java; gutter: false; theme: Confluence" data-theme="Confluence">graph TD
  A--&gt;B</pre>
</div></div>

Storage format after the round trip through ADF

<ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="language">mermaid</ac:parameter><ac:plain-text-body><![CDATA[graph TD
  A-->B]]></ac:plain-text-body></ac:structured-macro>

Sent to Confluence Cloud on .

What changes in conversion

  • Unknown values are never rejected or rewritten. yaml, json, typescript, go and unknownlang all came back unchanged.
  • javascript is shortened to js and python to py when the page is written back from ADF. js, bash, sql, xml, java, text and powershell returned as they were.
  • ADF uses its own names for some values. bash is shell, and text is plaintext, and both return to the storage names.
  • A block saved with no language has no language parameter and is drawn with the Java brush.

Pitfalls

  • A typo in the language is silent. The block renders in the Java brush and nothing warns about it.
  • Do not compare language strings after a Cloud editor save. Expect js instead of javascript and py instead of python.
  • yaml, json, typescript and go are outside the documented list and were drawn with the Java brush in the tested pages.

Questions and answers

Which brush is used for an unlisted language?

Java. The stored view shows brush: java for yaml, json, typescript, go and made-up names.

Is plain text supported?

Yes. The value text gave a text brush and came back unchanged.

Sources

  1. Insert the code block macro (Atlassian Support)
  2. Atlassian Document Format: document structure (Atlassian Developer)

Markdown version · All storage format pages