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
Accepted answer

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 votes
David Simpson Community Champion Jun 27, 2011

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 6 hours ago in Agile

What is Scrum? A good, bad, and ugly answer.

In a world of dark-scrum, faux-scrum, and scrum-butt, the question still remains: What is scrum and how do you do it “right?” That’s the question we set out to answer. I'm Max, I've been teaching c...

44 views 0 1
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