Inline code blocks

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.

7 answers

This widget could not be displayed.

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.

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"

This widget could not be displayed.

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 Champion Sep 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.

This widget could not be displayed.

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.

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

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

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

I mean something like this example from StackOverflow:

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

I also monospace it like Matt does.

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

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

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!

Jon Green I'm New Here Jun 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!

This widget could not be displayed.

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

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.

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

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.

This widget could not be displayed.

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

This widget could not be displayed.

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

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

Same for me

This widget could not be displayed.

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

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Tuesday in Confluence

Add-on evaluation with confluence templates

Atlassian market place contains number of Apps/Addons which improves the capability of out of the box Atlassian products. It is good to follow a plugin evaluation process before install add-ons. So t...

107 views 12 6
Read article

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