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

Accepted Answer
1 vote

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;
                try
                {
                    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 Tuesday in Featured Groups

Tuesday tips & tricks: What is the Atlassian Community?

It's officially Tuesday, which means it's officially time for another tip to help you better navigate this space we call the Atlassian Community. 😄 I got a great question from community member, Sa...

91 views 3 6
View post

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