Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Inline code blocks

Marcel Izgin September 19, 2016

Hi there!

I am desperately trying to write some inline code within my documentation. In StackOverflow and GitHub I would do `my code`. For code blocks I do ```my code``` which also does not work (but I can work with the code macro). Something like that:

image2016-9-19 22:51:21.png

So how can I do that? Thank you for your support.

12 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

92 votes
Blake Perdue September 1, 2017

This has been and continues to be a serious weakness of Confluence and Hipchat.

Confluence is used heavy by software teams. Software teams speak in sentences mixed with code. Forcing us to use code blocks that break the flow of a sentence is a really poor flow.

Slack gets this 100% right. I can type:

We should really consider using `const toolpane =` instead of using `var toolpane =` when we don't expect the variable to change

That should just work. Meaning it will auto-format my inline code snippets. It works on Slack. It works on Github. It is high-time it works on Confluence as well. 

Anything less is just a bad experience. I haven't met a single person yet who disagrees with that.

SharperTool September 24, 2017

I could NOT agree more with you Blake.

Confluence is almost certainly 90% used by code teams, but it's code documentation capabilities are not just bad, they are "WORST IN CLASS"

Like # people like this
Wayne Ritchie July 22, 2019

Spot on, the markup used by Atlassian is bad.  MS Teams, GitHub, Slack and nearly everything in inline code snippet is as simple as using back-ticks. Why does Atlassian think they need their own version of Markup? ...why not use something already tried and true; that actually is useful!

Like # people like this
Andreas Nie-Fröhlich August 13, 2019

the new editor experience allows formating via backticks (e.g. `my inline code`). You can also select your inline code and press CTRLSHIFT+m on Windows.

Like # people like this
Ilya Zarembsky September 11, 2019

UPDATE: Backticks started working for me two minutes after I posted this comment. I appreciate the respect.

It is absolutely bananas that backticks don't do the trick in 2019. The only reason Confluence can get away with this is that it's a de facto monopoly.

Like # people like this
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 13, 2019

The code has moved on in the last 2 years.  Move with it.

Like Enric Martinez likes this
markusz January 14, 2020

AFAIK backticks don't work for me as of now. As a user I really have no idea how to check the version of the server though.

Like # people like this
John McCabe February 10, 2020

Does anyone know when the backticks thing was introduced? I'm on 7.0.1 build 8202 and haven't seen it work, but that was an upgrade on September 21st last year, which is later than Ilya's "started working" message above.

Enric Martinez June 17, 2020

I use {code:bash}my code{code}

Agree that it should be the backtick though as this is ten times more typing ant it gets utterly annoying if you have to type sentences laced with code... which is what we do on our helpdesk.

Rupert Ward June 17, 2020

Can you not update your version and/or use the new editor? They have fixed this, backticks work fine in the new editor. I guess the chances are they'll not be retrofitting it to old versions.

markusz June 17, 2020

@Rupert Ward The thing is many users here are not administrators, and you know how slow IT upgrade things...The thing is `code` is a basic feature for a Markdown-like syntax and should be introduced from the beginning.

Rupert Ward June 17, 2020

@markusz  Oh dear is it still not working for you either? Take your point, very much. I don't think we can expect them to time travel though :D 

Frankly if it were up to me I'd be ditching confluence for a proper wiki. I miss markdown - always thought that the lack of wysiwyg was one of the great strengths of a wiki.

It was just the nature of Enric's post and the fact that it's a top of the thread made me wonder if they were aware that the rest of the thread includes the possibility of code backticks in confluence

32 votes
Joel H October 3, 2018

Is the backtick `code` shortcut coming to confluence server any time soon?

Dharanitharan February 7, 2020

`block`

Like Enric Martinez likes this
22 votes
SharperTool September 24, 2017

Hey Atlassian, while I'm on a rant.

The {code} macro.. It just grinds at me each and every time I use it. I can happily edit that inline, but then I just have to grab the mouse, and click the title, click edit, wait (I swear.. 5 seconds.. GEEZE!!), then find syntax highlighting, click the fucking dropdown, find my code.. and click that, and finally I"m fucking done!!

Holy shit - I'm seriously just pissed off THINKING ABOUT HOW PAINFUL THIS IS!

Throw me a bone here--- make this thing have the ability to pick a code block WITH highlighting all from the keyboard.

Peter DeWitt
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 24, 2017

Ed I feel your pain.  Why not open an support request for Confluence with the change you want to see.  That way it can be tracked and voted up by everyone else.

Like olisteadman likes this
SharperTool September 24, 2017
Like # people like this
Wayne Ritchie July 22, 2019

Thanks for opening up that ticket Ed.  Nice to see that Atlassian has taken this soo seriously that it has been sitting for nearly two years and still awaiting verification.  That's Atlassian's way of saying thanks for using our product and giving feedback/opening an issue... we just don't care!  More reason to move to another platform; although I'm tied to this at work but I use better products for all projects outside of my 9-5.

Like Peter Flynn likes this
4 votes
Nancy Wilson August 2, 2018

Looks like they have fixed it for Confluence Cloud. I entered an open backtick, typed inline code text, then entered a close backtick. The delimited text rendered as code.  See the updates to the issue cited above:

https://confluence.atlassian.com/confcloud/confluence-editing-improvements-945107733.html

https://confluence.atlassian.com/confcloud/keyboard-shortcuts-markdown-and-autocomplete-724764956.html

1 vote
Andreas Nie-Fröhlich August 13, 2019

it has been mentioned before, I summarize it again:

In the new editor experience of Confluence (tested on Cloud Edition) you can use CTRL+SHIFT+m to trigger monospace formating. It will have a grey background and will look like inline code.

Also you can use `my inline code` (backticks) to trigger the monospace formating.

See the documentation on keyboard shortcuts

Nancy Wilson August 13, 2019

on  the Mac, it's cmd+shift +m, but it does not render highlights, only monospace.  Does the highlighting render on Windows?

Andreas Nie-Fröhlich August 14, 2019

Yes, the background is highlighted with a light grey color.

Rupert Ward October 11, 2019

I'm seeing no highlight on Windows :(

Nancy Wilson October 18, 2019

Hi, folks.

Good news! It works in the new editor.  Atlassian sent this email to admins 14 October:

To our Confluence admins,

It's time to get your teams using the new editing experience in Confluence Cloud which enables anyone to create beautiful, powerful pages effortlessly. We will be rolling this new experience out as the default way to create new pages in the coming weeks.


Create with the new experience
1. Create a new page in your Confluence Cloud instance.
2. Select the template labeled "Try the new editing experience" from the create modal.
3. Voilà! You're ready to start creating a page with the new experience.


Try out the best parts of the new experience
• Use the slash command (/) to add anything from tables to images, and keep focused with in-context toolbars.
• Our new live macros provide previews of your content so you can see exactly how content will look after publishing.
• Use the new media experience to add files from Dropbox, Google Drive, or even GIPHY. 

Rupert Ward February 10, 2020

I'm using the new (cloud) editor now and can confirm that it works exactly as desired. Only with pages created using the new editor though - old pages need to be converted.

 

inline_code_confluence.jpg

Like markusz likes this
markusz February 10, 2020

@Rupert Ward which version are you using? We are using 6.13.10 which is probably the reason...

Rupert Ward February 10, 2020

Sorry, I'm just a user and it's not clear to me how I can find that out. Happy to have a look see if someone can tell me where to look...

Like markusz likes this
markusz February 10, 2020

I think that if you scroll to the bottom it shows something like this:

 

Rupert Ward February 10, 2020

Sorry but I don't see any kind of footer on our site.

I found some pages saying I could find the version number in the (?) -> About Confluence pop-up, and as the "ajs-version-number" string in the page source. Both those are giving me this...

1000.0.0-11e909e1050d

Like markusz likes this
markusz February 10, 2020

Ah we probably have different setups. I'm also a user so I have no idea how to check the version with other methods. But thanks anyway!

1 vote
Max Cascone January 22, 2019

I would suggest that Jira comments are just as important, if not more, of a place to support robust code-style text entry. I am going with the {{{color:green}MY CODE TEXT{color}}} hack - thanks for that, @nancywilson - for now, but it's a LOT of extra cruft to have to write in.

1 vote
Ian McLaughlin December 13, 2017

Wrap inline code blocks in {{double curly braces}}, works for me.

Artem Karavaev April 25, 2018

It doesn't work for me in Confluence Cloud. If I write {{double curly braces}} It will show without any format. 

Ezekiel Inalegwu Akoji May 16, 2018

Same for me

Deleted user September 5, 2018

Same. This is a big problem for standard documentation.

Like # people like this
Nancy Wilson September 5, 2018

Guys.

They've added Markdown support to Confluence Cloud:  entering backticks around the text will render it as inline code (monospace):

https://confluence.atlassian.com/confcloud/keyboard-shortcuts-markdown-and-autocomplete-724764956.html

Like Michal Orlik likes this
Vicki Foss October 2, 2018

But it still doesn't add gray highlighting; the code blends in with the rest of the text.  The monospace part was always easy to accomplish.  It's the highlighting that was needed.

:'(

Nancy Wilson October 2, 2018

Use the highlight option.  

image.png

Vicki Foss October 2, 2018

Hi Nancy, that only changes the color of the text, not background color / highlight.

Nancy Wilson October 2, 2018

sorry - misunderstood. Is this what you want to do?

image.png

Vicki Foss October 2, 2018

Thank you for following up, Nancy.  I don't want to insert a block of code; I want to insert inline code (as the original question asks for).  I haven't been able to figure out how to get it to work with markdown, either (with the monospaced text + gray background).  If you've gotten it to work, I'd love to hear how you did it!  Thanks again.

Can Özcan October 17, 2018

As Nancy said. Markdown can help here. But its not native. You have to open up the Markup editor (Ctrl+Shift+D) and select Markdown instead of Confluence Wiki. There you can type your code in and wrap it like `foo` in order to get the monospace style.

But I wonder if it is possible to use the CSS div wrapper. Does anyone have knowledge about that?

Nancy Wilson October 18, 2018

You can use css and divs to good effect, but as Atlassian plans to deprecate divs as well as other helpful styling, we've decided not to build our pages this way (much as it pains me to have to live within the confines of Confluence Cloud's WYSIWYG implementation - I get it, I just don't like it). 

https://confluence.atlassian.com/confcloud/we-re-cleaning-up-the-macro-browser-946028471.html

1 vote
Blake Perdue September 24, 2017

Please comment on these tickets for these issues to get Atlassian to fix this sh!t.

Inline code blockshttps://jira.atlassian.com/browse/CONFCLOUD-57638

Macros modal takes 5-6 seconds to loadhttps://jira.atlassian.com/browse/CONFCLOUD-57639

1 vote
Milo Test
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.
September 19, 2016

Have you tried putting the Code Block macro within a span macro?

Marcel Izgin September 20, 2016

Nope, I don't know how to do that. Searched for "span" in macros and couldn't find it. I'm using Confluence in German though.

Milo Test
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.
September 20, 2016

It's part of the free Content Formatting for Confluence macros from Adaptavist.

Blake Perdue September 24, 2017

Macros are slow and they break the flow of a sentence. I should be able to mix code into a sentence. Github and Slack support this. Why can't Atlassian support it as well? It's simply the way developers write now. 

It's a major product gap imho.

Like # people like this
1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 19, 2016

I think you may have answered your own question - use the "code" macro.  Use braces to avoid having to use the mouse to pick stuff.

Marcel Izgin September 19, 2016

But that's not inline - am I missing something?

Like # people like this
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 19, 2016

I think I might be, what do you mean by "inline"?

MattS
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.
September 20, 2016

I select the code in a sentence and make it Monospace.

Marcel Izgin September 20, 2016

I mean something like this example from StackOverflow:

image2016-9-19 22:51:21.png

Like Enric Martinez likes this
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 20, 2016

I also monospace it like Matt does.

Milo Test
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.
September 20, 2016

To be clear, start typing your paragraph, then when you want to put in some code, type two open curly braces—the code—and two close curly braces, then continue typing the rest of the text:

I.e. Text {{code}} text

Result: Here comes some code 10 PRINT "Hello" and there is goes.

To get the gray highlight, à la StackOverflow, wrap the code in the Highlight macro:

image2016-9-20 16:9:37.png

image2016-9-20 16:11:43.png

Like Tor Nizan likes this
Peter Flynn February 9, 2018

There are so many escaping bugs with double curly braces that they are really unreliable to use in practice...

Like # people like this
Jon Green June 28, 2018

If only that worked, Mika. But if I'm trying to discuss a variable or macro that starts and end with underscores, double-curlies do nothing:

This is a sentence about the {{_MACRO_NAME_}} macro.

...certainly monospaces the macro name, but also strips the underscores and italicises it. Which is exactly _not_ what I wanted!

Because programmers never use identifiers starting and ending with underscores, do they? :)  (Hint: C, C++, ...)

So far as I can tell, there's no way of inlining code in such a way that formatting characters are not processed. The noformat directive throws its contents into a separate, boxed, paragraph - uuuugly!

Like juanmendes likes this
Jon Green June 28, 2018

Hah! Solution! (Well, in my case anyway.)

Switch to text edit mode, and write the leading and trailing underscores as _ instead.

Yes, it's truly horrible, using HTML character entities rather than, oh, I dunno, human-comprehensible text, but it does work.

Meanwhile - as far as I'm concerned, allowing any formatting primitives to work inside a {{...}} block is a bug. Atlassian, please fix!

Wayne Ritchie October 17, 2019

@Nic Brough -Adaptavist- 

I think I might be, what do you mean by "inline"?

Are you kidding me?  "There's no such thing as a dumb question." ...yeah, that there, is a dumbass question! 

Humm, what does "inline" mean?  Well, it is INLINE with the rest of the content; as opposed to BLOCK.  

Nic, yo brough, `const hasAnyKnowledgeOfDevelopment: boolean = false;`, that is INLINE with the rest of the text.  FYI

```
if (you see something that is block scoped) {

  // you can assume that it is NOT inline
}

```

Like juanmendes likes this
Andreas Nie-Fröhlich October 17, 2019

offtopic: @Wayne Ritchie are you seriously attacking Nic for a comment that he as made over 3 years ago?!?

Wayne Ritchie October 18, 2019

@Andreas Nie-Fröhlich 
Nope, just amazed a "Community Leader" doesn't know what inline means in the context.  Hopefully over the past few years they've managed to figure out the difference between inline and block; if not, I just didn't want them to continue on not knowing something so fundamental.  ...especially as a Community Leader...  ...and yet there are still no `inline code highlighting` abilities for the platform; making the text mono doesn't count! Yes, YEARS later!

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 19, 2019

<sigh>  It's not my fault you can't understand the question.

Henner Wöhler April 3, 2020

Someone is wrong on the internet! XD

0 votes
Jesse Hartman March 5, 2021

Friends,

This did it for me.

Double mustaches do the trick just like the famous Houdini (whose mustache never appeared because... well, Houdini).

{{inline code thing}}

If you need anything more advanced, I saw examples of this:

{code:SQL} <some SQL here> {code}

Markus Zhang March 11, 2021

This is the only one that works for me. Thank you!

0 votes
Nancy Wilson February 8, 2019

Ok, so I think what @Vicki Foss & others are looking for is a simple way to create this kind of highlighting:

https://cimpress-support.atlassian.net/wiki/spaces/CI/pages/188743804/File+Prep

I think it's easiest to use the HTML macro and apply standard code notation to get the desired effect.  Really not such heavy lifting.

<p>You can <span style="background-color:#c5d9f7;"> <code>highlight inline code sections</code></span> using the HTML macro and standard code notation for span tags.</p>

John McCabe May 23, 2019

Sorry if this is a stupid question, but can this be easily done while you're typing, without resorting to the mouse etc? I'm a bit new to Confluence, but....

Many thanks

John McCabe May 23, 2019

As an aside, I'm looking to do this in a cloud-based instance, so we don't have html macro available there :-(

Nancy Wilson May 23, 2019

 

You (or your admin) can add the HTML macro to your Confluence instance.

John McCabe May 23, 2019

Thanks for your reply Nancy, but the 'standard' HTML macro can't be enabled on a cloud instance, as I understand it - see https://community.atlassian.com/t5/Confluence-questions/HTML-Macro-for-Confluence-Cloud/qaq-p/104061.

Max Cascone May 23, 2019

I always use {code} ... as much code as you need here .... {code}

 

You can specify syntax formatting with {code:sql}.....{code} etc

 

similar to {panel} but implies {noformat} and syntax highlighting. 

 

Or, is that specific to Jira?

Max Cascone May 23, 2019

@John McCabe , I'm not sure about HTML, although I'm pretty sure I've used an HTML block somewhere on my cloud confluence, but there is a free Markdown extension you can use instead, which is probably better to use than HTML anyway.

https://marketplace.atlassian.com/apps/1212654/render-markdown?hosting=cloud&tab=overview

Nancy Wilson May 23, 2019

also see my post above from Sept. 2018 :

There is native Markdown support in Confluence Cloud: 

https://confluence.atlassian.com/confcloud/keyboard-shortcuts-markdown-and-autocomplete-724764956.html

John McCabe May 23, 2019

Thanks for those replies. I'll take a look at them but, for reference, what I'm looking to achieve is something like when you#re in the editor and type:

{span:style=border: 1px solid #c5c5c3; border-radius: 3px; background-color: #eef;}

Then, in the box that opens, enter something like:

`cd /home/john/subdir`

It's similar to what you (Nancy) linked to before with the red text and the grey background, but a little prettier :-)

Nancy Wilson May 31, 2019

Pretty counts!

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events