How can I escape curly braces within {code} tags?

I was trying to show someone how to use the {code} tag in a comment in Crucible. I want to wrap my example in code tags, but have the literal "{code}" show up in the example.

Hey girl, I heard you like putting code in your comments.

{code}
\{code\}
// Your code goes here.
\{code\}
{code}

And this is how it came out:

Hey girl, I heard you like putting code in your comments.
\{code\}
    // Your code goes here.
    \{code\}

How can I enter the comment so that it appears like this?

Hey girl, I heard you like putting code in your comments.
{code}
    // Your code goes here.
    {code}

10 answers

This widget could not be displayed.

You can use HTML escape characters to do the curly braces: 

{ = {

} = }

 

Example: {{{your text here}}}

Doesn't work in {code} tags.

Jason, you are right, it does not work with {code} tags. It does work for the problem that Patrick was having: Hey girl, I heard you like putting code in your comments. {code} // Your code goes here. {code} As far as I know, in {code} tags there is no need to escape curly braces. You might need to put the actual tag in it's own line: {code} { "Name": "Somename" "Lastname": "Somelastname" } {code}

This widget could not be displayed.

Sigh. I can't figure out how to enter code in the question so it doesn't create several disjointed code blocks.

You guys, this would be so much easier if you just got rid of these proprietary markup languages and switched to Markdown.

This widget could not be displayed.

Another vote for switching to Markdown!  It shouldn't take half an hour to find a way to get a close-curly-brace in a code section.  Backspace escaping should work for code sections like it does for underscores in underline sections.  The JIRA markup language is as inconsistent as it is buggy.

This widget could not be displayed.

This solution works if you don't mind your text being bold:

example 1:

{foo}

  1. type the "*" character
  2. type the "{" character
  3. type your text
  4. type the "*" character twice. This effectively ends a bold run and starts another bold run.
  5. type the "}" character.
  6. type the "*" character to end the bolding.

example 2:

{{code}}

  1. type the "*" character
  2. type the "{" character twice
  3. type your text
  4. type the "}" character.
  5. type the "*" character twice. This effectively ends a bold run and starts another bold run.
  6. type the "}" character.
  7. type the "*" character to end the bolding.

 

This absolutely works and was the only way I could enter the regex "[- 0-9_\p{Ll}\p{Lu}\p{Lt}]" into a JIRA comment ... though in raw it does look like this: *"[- 0-9_\p**{**Ll**}**\p**{**Lu**}**\p**{**Lt**}**\]"*

This widget could not be displayed.

With underscores, one can backslash an underscore mid-underline-section to get a literal underline there.  With double curly braces around code, one cannot backslash a close-curly-brace mid-code-section to get a literal close-curly-brace there.

 

Example without proper escaping:

{{my_dict = {}}}    renders as    my_dict = {}

 

Example attempting to use a backslash to escape the close-curly-brace (which doesn't work):

{{my_dict = {\}}}  renders as     my_dict = {}

 

Is there a sane alternative that works in this case?

I'm not seeing one in the other answers to this question.  The double-star trick mentioned in another answer does not work in the case of code sections (delineated with double curly braces).

The trick I have found to work is to close the curly brace section early, then put the single close-curly-brace in its own code section.  Thus, the workaround to get one close-curly-brace in your code section is the mind-numbing sequence of:

}}{{}}}

That'll put a close curly brace at the end of a code section.  You'll need to reopen the code-section with a {{ after all of that if you're not yet at the end of your code section.

 

Example of the functioning workaround:

{{my_dict = }}{{}}}     renders as      my_dict = {}

 

There really needs to be a better way.

 

 

This widget could not be displayed.

Hi,

In order to escape it, you can do this:

1- {

2- }

3- Then place the cursor in the middle of {} and type

Hope this works.

Thanks. That doesn't work.

Can you please get a backslash to escape a close-curly-brace inside a code-section?

This widget could not be displayed.

Amen to that.

This widget could not be displayed.
This widget could not be displayed.

You could try doubling the curly braces. So, you type "{{" and "}}" instead of "{" and "}".

I am not sure if that will work in Crucible, but I know it works on JIRA comments and descriptions.

This widget could not be displayed.

Is this still unresolved?

Jan Heinz I'm New Here Aug 30, 2018

It is. We have Jira in our company, and the visual editor still corrupts the ending braces in a code block, and I haven't found a way to fix them.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

591 views 7 6
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