How to convert markdown content in Confluence using Confluence CLI

To insert markdown content in Confluence, you can follow two approaches:

  • Embed markdown content into a Confluence page using Confluence CLI (recommended).

For more information see: https://appfire.atlassian.net/wiki/spaces/SUPPORT/pages/edit-v2/398655493?draftShareId=da2dbb49-db34-4c8c-ae91-317ae7b06051

OR

  • Convert markdown content to the Confluence storage format (markup) using the markdown parameter.
    Note that the conversion may cause inaccuracies when rendering the markdown in the Confluence storage format.

The focus of this article is to show you how to convert markdown content using Confluence CLI.

Converting markdown content - instructions

Note that by default, markdown is converted to markup unless the noconvert parameter is selected.

"--action storePage --noConvert --markdown" --continue

You can convert markdown pages, files and text to the Confluence storage format.

To begin, create a markdown page or a file that you can convert.

StorePage Action for creating a markdown page

Use the storePage action to create a markdown page for conversion.

 --action storePage --space SPACENAME --title "PAGENAME" --content "this creates my testpage for markdown conversion"

For more information on the parameters for converting markdown to the storage format, check storePage

storePage Examples

Check the Examples | Examples storePage to view a variety of examples on how you can use the storePage action.

Required Parameters

Optional Parameters

Space

content
Content for page, attachment, comment, or question.

Title or ID

content2
Content for page added after content and file content.

Content or file

file
This parameter points to the path of the file based content or result output. For some action it may be a directory path.

 

input
Line of input used in place of file data for run actions. One or more input parameters are used as lines instead of using the file parameter. In some cases requiring a file parameter, it may be necessary to use a special value of + to indicate to use the input parameters instead.

 

markdown
This parameter converts rendered Markdown content to storage format. This may not work for all Markdown content.
Consider using the markdown macro instead for a more accurate display of Markdown content in Confluence.

 

convertToStorageFormat Action for converting markdown to Confluence storage format.

When you convert markdown to the Confluence storage format, use the action convertToStorageFormat together with the relevant parameters.

convertToStorageFormat

You can convert to Confluence storage format the following parameters:

  • content

  • content2

  • file

  • input

  • markdown

For more information on the parameters for converting markdown to the storage format, check convertToStorageFormat

convertToStorageFormat Examples

--action convertToStorageFormat --content "{@macroName@:param1=xxxxx}bodyText{@macroName@}" --findReplace "@macroName@:wiki"

--action convertToStorageFormat --content "{wiki:param1=xxxxx}" --file "-" --content2 "{wiki}"

--action convertToStorageFormat --content "{wiki:param1=xxxxx}bodyText" --content2 "{wiki}"