How to add macro inside code block

We are using Confluence 4.3.7.

I would like to embed a user-info macro inside a code block. That way a set of commands will have the current username inside the code block example.

This doesn't seem possible as no macro can be inserted inside a code block?

So, is there a way to format a set of text+macro so that it looks like a code block?

2 answers

1 accepted

I found a much simpler approach:

Use a panel macro and use macros inside it.

I don't think you can insert macro into a code block. You can play with the css by adding the macro into a container and add custom css to make it look like the way you want.

Thanks for the feedback. Unfortunately I'm not a web developer and not familiar with CSS at all. I managed to google and play with some parameters to make a border around text. But the box does not extend cleanly like the "code" macro. How do I find out what the code macro settings are so that "fred1" text matches"fred2" below?

Fred1 properly formatted using code macro:

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

Fred 2 improperly formatted as I do not know what CSS settings are used in code macro:

<ac:macro ac:name="span">
<ac:parameter ac:name="style">border-style:dashed; border-width: 1px; padding: 10px 10px; border-radius:5px;</ac:parameter>
<ac:parameter ac:name="class">Code Block</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body> fred2</ac:rich-text-body>
</ac:macro>
</p>

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,941 views 27 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you