How do I format a {} as inline-code?

Julien August 12, 2015

When writing or commenting on a ticket or documentation in either JIRA or Confluence, I often highlight variable names or values with the inline-code markers (which is two open curly-braces, text, two closed curly-braces).

{{$foo}}

Now something that comes up regularly is the construct {}, which I just had to make italic instead of inline-code, because I don't understand how to escape it properly to make it show up.

I have tried a variety of things, including backslashes and spaces at various places. In the following I'll use a markdown-like syntax to show which part is highlighted. Things in backticks `$foo` are turning up inside the highlighted area in the rendered JIRA output.

{{{}}}     # {`}`
{{ {} }}   # {{ {} }}
{{\{\}}}   # {`}`
{{\{}}}    # {`}`
{{{\}}}    # {{    (that one is my favourite)
           # {\}}
           # }
{{{{}}}}   # {`}`
{{{}}{{}}} # `}{`

This is highly weird. And very frustrating. This thing is relevant to JavaScript, JSON data and various other programming languages.

How do I make that thing highlighted correctly?

6 answers

2 votes
Martin Seysen April 27, 2018
1 vote
Nicolas Lefebvre April 17, 2017

My solution was to separate the }}} with soft hyphens (https://en.wikipedia.org/wiki/Soft_hyphen).

 

That way, You can do something like this:

{{{ \}­}} # returns { }, code formatted. There is a soft hyphen character between the first and second }.

I'm guessing this comes much too late for Julien, but hopefully any future people seeing this will find this useful.

1 vote
Julien August 12, 2015

Yes. Or {code}. But I want to be able to say something like "By default, this method will return {{]}}", but with an empty object, not an empty array.

0 votes
kristian.alnaes October 17, 2019

There is now specific programming language support in code blocks. Specify the language in the leading code block as described in the Syntax guide.

 

Use {code: json} for example to handle those pesky curly braces when pasting json.

Didier Loiseau October 17, 2019

OP's issue is with inline code style, not code blocks.

Like # people like this
0 votes
Daniel Gibbs October 7, 2019

Is there still no easy-to-use solution for this?

0 votes
Wim Deblauwe
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 12, 2015

If you don't need it inline, you can use {noformat}, but you probably know this.

Suggest an answer

Log in or Sign up to answer