How do we provide code blocks in these questions?

I've seen this come up a bunch. I managed to accidentally copy a code block in from a forums post, but that doesn't seem the right solution. :)

Update: The Wysiwyg editor now has a preformatted option in the dropdown menu

2 answers

1 accepted

Accepted Answer
3 votes

It's logged as ANSWERS-57. For starters, we're adding a 'preformatted' style option, as a start. Even better would be a top-level code button, so ANSWERS-57 will stay open until that's ready.

UPDATE: We just rolled out an update with a 'Style' menu containing 'Preformatted'. It's a first step towards a code macro.

I agree with Matt Dour's comment on ANSWERS-57

"I don't think the preformatted option for the style does a very good job..."

Personally, I'd like to be able to use similar wiki edit syntax as I would when writing a post in Confluence. This was the behavior on forums.atlassian wasn't it?

Also, why is the text entry field so small. When composing a comment back to posting, being able to only see 4 or 5 lines is pretty limitting, especially if you are trying to convey how to do something with code syntax to someone which likely spans multiple lines at a time.

And what about a preview the post option? What happened to that?

Hi Jim, I agree. We're just now working up a better option for this, which should be posted by Monday (Sept 12). Look for a 'code' button on the far right of the edit bar. We'll also have preview with that.

As for the small size of the text box, that one we haven't changed yet. I've added it as a feature request:

Expand the size of the comment or answer box

We've added a 'code' button (along with [show preview]). Let me know what you think!

I intially attempted to comment back to Jeremy's comment requesting feedback on the recently added 'code' button to the editor - however, the comment button doesn't seem to be working in Safari or Chrome now. So, trying to enter this as an answer.

I am not sure this code block feature is working as intended across browsers.

I do see that we now have a live preview option, which has been helpful while forming this comment to demonstrate what I see happening here ;-)

For what it's worth, I started trying to enter this comment via Safari v5.1 - and the comment button does not seem to work in Safari. The cancel button does, but comment simply does nothing.

I am now typing this sentence before I click the 'code' button, and hitting return for a new line

Noticed also that the formatting drop down menu seems to be not there when typing in a comment

Now, I'll click code, and enter some pseudo code, and then attempt to enter some further descriptive text after the code block.

{replace-and-render}
{replace-item:%thingee%}value{replace-item}
{replace-body}
The Value of Thingee is: %thingee%
{replace-and-render}
Now I can't get OUT of code mode...how do I make it stop entering text as code.
Is this because the format dropdown menu is gone?
I am seeing that if I select and try making this line bold, it looks bold in the edit window, but gets 'strong' tags around it in the preview window
Same thing for italics - it looks italics in the edit window, but in the preview window puts 'em' tags
This one should be a blockquote...but...in the preview window it becomes another code line of it's own, indented.  It's just an indented line in the edit window.

The only way I can find to get out of code block mode, is to select some text, and try making it to a list item and then tell it to not be a list item, then I seem to be back to normal text entry. This is far from intuitive.

Also, what about line wrapping for long lines?

When typing long lines, such as this one, which one would expect to linewrap when it reaches the right edge of the edit window, the window is instead expanding forever to the right (in Safari) or simply scrolling off to the left (in Chrome) as the line gets longer. I'm continuing to type farther and farther to the right, and this line just gets longer and longer and longer, making it more difficult to refer back to a concept a little bit earlier in the current paragraph. Line wrapping sure would be helpful here since I may not ALWAYS want a new paragraph when I hit the return key, which is currently the behaviour of hitting return. This line is now about 4 or 5 text areas wide

Edit:

noticed that preview is not available if editting an existing post (ie: this one)

in chrome, I was able to 'convert' my 'answer' to 'comment' - but was then unable to edit the comment to add a note regarding this. Cannot seem to edit comments at all as the comment button simply doesn't work. Am now attempting to add a new comment to this thread from Firefox 6.0.2 -- since adding comments via Safari and Chrome have been failing so far today for me.

Now I can't get OUT of code mode...how doI makeit stop entering text as code.
I had the same problem. My workaround was to copy the code block, delete it, write what would go after it, and paste the code block in the correct space. :P

Thanks Jim and Laura. These are good suggestions. I've raised four different bug reports:

That fourth one's mine I added, but it seemed obvious!

Jeremy, thanks for opening up issues to followup on these behaviours.

Ticket: Code Block should wrap for long lines

  • This was actually not specific to editing within a code block. I was typing in 'regular' text when I discovered the long lines just scrolling off forever (note, this was while editting, not after saving the comment or answer)

Ticket: Question Marks appearing

  • Guess I forgot to point that one out, good eye!

EDIT: Oddly enough, I was just able to add this comment via Safari - and now adding this edit to it after the fact

EDIT: clarification of the long lines statement above.

Still having problems with trying to put code into comments here on answers...

This one got really messy as urls inside the block of text intended to be treated as code got expanded into HTML

https://answers.atlassian.com/questions/20348/atlassian-cli

This is truly making the use of answers.atlassian.com a whole lot more difficult than the old forums site which used the same type of syntax we are used to using within Confluence itself.

Thanks for pointing it out Jim. I'd like to get this right. I raised a couple bugs/improvements:

We'll investigate both.

I've had the same problem. I can copy and paste a code block

this is a code block

But, I can't seem to use markdown or anything else (at least as of June 3, 2011) to format it in the RTE. I've tried backticks, wiki-like markup (just in case :) ), and looked in sites like:

So, for now, copying and pasting hopefully works. :( This looks like it would be a good addition to answers though and works with OSQA that answers is built upon: http://meta.osqa.net/questions/3834/markdown-with-syntax-highlighter but we can't use that unless it is installed. I'm probably wrong about all of this though and assume this will be fixed or clarified later.

Edit: Read Jeremy's answer. ;)

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