Forums

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

Code block macro sometimes renders badly? Why?

Simon Hardy - Francis October 12, 2022

Hello!

I've been using the Code block macro to make my pages shorter by having the embedded code blocks collapsed. Example macro:

```
{code:title=Install Ubuntu packages|theme=FadeToGrey|linenumbers=true|language=bash|firstline=0001|collapse=true}
blah
blah
blah
{code}
```

However, when I load a page containing these macros then half the time the macro appears not to work. When this happens then the 'Expand source' text is missing on all macro instances in the page and none can be expanded :-(

Example screenshot when 'expand' is missing:

expand-missing.png

Example screenshot when 'expand' is present, as expected:

expand-present.png

I have noticed that sometimes when the 'Expand source' 'button' is missing, it can be initially seen for a few 10ths of a second as the page is loaded and rendered, but then disappears. Maybe some kind of race condition during rendering?

There seems to be no obvious reason why sometimes this macro renders correctly and sometimes it doesn't. It's like playing Russian Roulette with confluence :-)

Any ideas how to fix this?

[1] https://confluence.atlassian.com/doc/code-block-macro-139390.html

1 answer

1 accepted

0 votes
Answer accepted
Alex Koxaras -Relational-
Community Champion
October 13, 2022

Hi @Simon Hardy - Francis 

This seems like a bug to me...

There are a couple more bugs reported with code block and expand here:

https://jira.atlassian.com/browse/CONFCLOUD-72618

https://jira.atlassian.com/browse/CONFCLOUD-73446

Perhaps you should also raise a bug here.

Simon Hardy - Francis October 13, 2022

Thanks @Alex Koxaras -Relational- ! I tried to file the bug but I cannot because I'm not a site-admin. However, I will escalate the issue with a site-admin and hopefully they will file the bug :-)

But also, one of the links you kindly posted contains a workaround which works for me :-) Example:

{expand:This works around the code macro expand bug [1]}
{code:theme=FadeToGrey|linenumbers=true|language=java|firstline=0001}
Code macro block without buggy collapse
{code}
[1] https://community.atlassian.com/t5/Confluence-questions/Code-block-macro-sometimes-renders-badly-Why/qaq-p/2161338
{expand}

Alex Koxaras -Relational-
Community Champion
October 13, 2022

Good to know that you've found a workaround! Kindly mark this answer as accepted then, in order to help others who have similar questions. Thank you :)

Like Simon Hardy - Francis likes this
Simon Hardy - Francis October 13, 2022

Site-admin request here [1] :-)

[1] https://support.atlassian.com/requests/JST-810084/

Suggest an answer

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

Atlassian Community Events