How do you paste multi-line code examples into this website?

David Simpson Community Champion Jun 27, 2011

I've seen that other people (e.g. @Charles Miller [Atlassian] in this example) have managed to paste more than 1 line of code into this UI without it splitting the code block into multiple code blocks.

When I do it, each line has it's own one-line code block e.g.

// comment on line 1
// comment on line 2

Or this example.

What's the secret? Please share.

2 answers

1 accepted

1 vote
Colin Goudie Community Champion Jun 27, 2011

I'd say it depends on where you're copying from. Below is copied from a raw output from github. Spacing is screwed (so had to be corrected a bit) but it pasted in one block

When you hit ENTER, by default this starts a new paragraph which will make a new code block. Shift-ENTER keeps the same block

                String authUrl = null;
                    link.createAuthenticatedRequestFactory().createRequest(MethodType.GET, "");
                catch(CredentialsRequiredException e)
                    // if an exception is thrown, we need to prompt for oauth                
                    authUrl = e.getAuthorisationURI().toString();


But why does the formatting suck so hard when compared to stackoverflow or even atlassian's many "code" macros. How about a horizontal scrollbar to stop it wrapping? Not to mention syntax highlighting. Oh and a "preview" function would be great too.

A few days ago we released some improvements to the editor. There's a 'code' button that'll allow syntax highlighiting, a [show preview], and horizontal scrolling.

I hope it's better. There are still more improvements to come.

0 vote
David Simpson Community Champion Jun 27, 2011

OK, it looks like someone fixed the linked example above :)

Suggest an answer

Log in or Join to answer
Community showcase
Jason Wong
Published yesterday in Agility Beta

Welcome to agility

Every team in the world is unique, and so   Atlassian believes   that each and every team's best way of working  needs to  be molded to their unique circumstances  – ...

279 views 6 15
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot