Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

insert info/tip/note/warning via Markdown

Maciej Kopa December 21, 2022 edited

Hi,

 

I want to add any of the above panels when pasting markdown to editor, is this possible?

e.g. I want to change this note to be a confluence panel note:

```

### I'm a Markdown file

Some more markdown text...

> NOTE: Hello, I'm a nice note :)

```

What should I paste to achieve this?

 

ref: https://support.atlassian.com/confluence-cloud/docs/insert-the-info-tip-note-and-warning-macros/#Wiki-markup-example

2 answers

1 accepted

0 votes
Answer accepted
Maciej Kopa December 27, 2022

It turns out that it's possible in the following implementation:

1. Script must look for some defined custom structure inside our markdown file, e.g.

!!! tip useful-tip
block of text that is in the tip macro

2. We change this to macro body written in html, e.g. (haven't tested)

<ac:structured-macro ac:name="tip">
<ac:parameter ac:name="title">useful tip</ac:parameter>
<ac:parameter ac:name="body">block of text that is in the tip macro</ac:parameter>
</ac:structured-macro>
 

And send to confluence space as a new page or update the existing one. 

 

If someone reads this, it also works (lack of documentation!!!) for fenced code blocks and other macros, just change:

``` Java
some code
```

to

<ac:structured-macro ac:name="code">

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

<ac:plain-text-body><![CDATA[some code]]></ac:plain-text-body>

</ac:structured-macro>

 cheers

0 votes
Alex Koxaras _Relational_
Community Champion
December 21, 2022

Hi @Maciej Kopa 

What exactly do you want to achieve? The way you can add a panel is by either clicking on + on the header and choosing Info, or by typing / and then info.

Maciej Kopa December 22, 2022

Hi @Alex Koxaras _Relational_ 

I want to achieve what you have said, but via API, not Confluence page manually. 

Alex Koxaras _Relational_
Community Champion
December 22, 2022

You should be able to update content with this endpoint

PUT /wiki/rest/api/content/{id}

https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content/#api-wiki-rest-api-content-id-put

Maciej Kopa December 27, 2022 edited

yes, however, it wasn't the question. check my answer if interested :)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events