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:
Example screenshot when 'expand' is present, as expected:
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
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.
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}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.