What are the parameters to use for a code block in JIRA?

I had gone to https://confluence.atlassian.com/doc/code-block-macro-139390.html to see the various parameters I can use in the code block. I've taken the example at the bottom of the page to copy from but so far only title seems to work for me. I.e. linenumbers, firstline, collapse all don't work. I tried language=java and it seems to work but it's not working for my JavaDoc comments.

My code fragment is as follows:

{code:title=DateTimeUtil.java|theme=FadeToGrey|linenumbers=true|language=java|firstline=0245|collapse=true}
/**
* Prints a list of days of week into a cohesive label that can be displayed properly.
* This takes into consideration that 1 means Sunday and 7 means Saturday and sorts it
* properly with Monday being the first day of the week. This also generates a range
* notation with " - " as a separator if there are consecutive days. Otherwise, this
* will list out days (and ranges) in a comma-separated way.
*
* @param daysOfWeek a List of Integers each representing a day of the week. It uses the
* Calendar field DAY_OF_WEEK as basis where 1 means Sunday and 7 means
* Saturday
* @return a prettily printed label that describes all the days that this List represents
*/
public static String prettyPrint(List<Integer> daysOfWeek)
{
  return "";
}
{code}

1 answer

0 vote

Hi Paul,

Can you confirm if you're trying to do this in Jira or Confluence? Your title says Jira but the documentation and collection you chose is Confluence, so I want to make sure to give you the proper information.

Kind Regards,
Shannon

Thanks Shannon for replying. I'm doing this in JIRA, but Googling brought me the Confluence link I pasted - it should really be the same anyway no? I'm saying this of course tongue-in-cheek because even though I made the decision to use an all-Atlassian stack including bitbucket, JIRA, Confluence, and HipChat, there are at least three different pseudo-mark-down ways to post code. And don't get me started on how to do bullet points :) BTW I can't wait to try Stride!

Anyway, I'm probably just nit-picking now because I'm fine just simply using {code} to demarcate my code fragments but wanted to learn more on how to use it fully.

Thanks,
Paul

Hi Paul,

No worries! The Jira code notation is going to be a bit different since the article you're reading for Confluence is based on a specific Confluence macro.

Here in the Advanced Text Formatting Notation for Jira you can see how you're able to use the {code} and {panel} macros:

I was also able to find a few requests for your missing features:

  • JRASERVER-63346 Add line number support to the {code} tag in Mark-up
  • JRASERVER-33995 Collapsible Content within a Comment (closed recently as Won't Fix)

One thing you might be interested in is this 3rd party add-on:

It seems to do the same thing as the {code} syntax but provides a lot more options. Perhaps it's worth giving it a try? 

Let me know if you have any questions about any of this. 

 Kind Regards,
Shannon

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,901 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