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

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 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
Answer accepted
Colin Goudie
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.
June 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;
                try
                {
                    link.createAuthenticatedRequestFactory().createRequest(MethodType.GET, "");
                }
                catch(CredentialsRequiredException e)
                {
                    // if an exception is thrown, we need to prompt for oauth                
                    authUrl = e.getAuthorisationURI().toString();
                }

 
JamieA
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.
June 27, 2011

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.

Jeremy Largman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 16, 2011

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 at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 27, 2011

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events