3

There are many instances when the community requests the asker to run certain commands and post the output. They usually ask them to edit their answer and just dump the output of the requested commands.

This method works well when the command produces a one line output. But what if it's something like dmesg or lshw. Often, the output of a command is quite long. This makes the question quite bloated, and sometimes even unreadable.

One way to avoid having the command outputs take up the whole page is to add an expandable item. Something like a text that says

▶ Output of dmesg

that when clicked, expands and shows the output in a box with scroll bars - like the normal code block.

Of course, if this becomes a feature, the site can suggest running relevant commands based on question tags right when the question is being created. That way more time can be saved.

Original on Ask Ubuntu. Wanted to get the whole community's option.


Already asked in 2009. Request for this to be revisited (it is 6 years later now).

3

My first reaction was no, I think what we have now is preferable, and I answered to this effect, pointing out that it makes it immediately clear on first glancing at the question that it contains a code block, which in turn give a feel for the kind of question it is, and the likelihood that I can answer it if I spend time reading it.

As it's been pointed out that on some sites, questions often contain numerous, lengthy code blocks, this is an alternative suggestion which I believe addresses the OP's concern while still keeping it immediately clear that the question contains code.

Currently we display code in a scrollable yet still large block like this:

enter image description here

Instead, we could display it in a small block, which, while obviously being a code block, can be expanded by clicking an expander button:

enter image description here With the ability to both expand and collapse the code blocks in this way, it may even be desirable for them to cease to have scrollbars. Then, when a user chooses to expand a block in order to look at it in detail, the entire block may be visible all at once, and there may be no need to scroll to see any of it (except when appropriate for the user's browser dimensions). However, that is a detail which could be decided separately if necessary.

In the mockup above, I've included buttons the user can click to "expand all code blocks" and "collapse all code blocks", which I think would be useful. For example, on first read of a post containing several code blocks, a user who has already decided to look at the code might wish to expand it all straight away. Then, after reading through the post in detail, the user might collapse all the code and speed-read the post for a recap of the main issues.

0

The page bloat's already limited by the auto-scrollbars that kick in once the code reaches a predetermined length:

Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 
Of course, if this becomes a feature, the site can suggest 

I think what we have now is preferable. It makes it immediately clear on first glancing at the question that it contains a code block. This in turn give a feel for the kind of question it is, and the likelihood that I can answer it if I spend time reading it.

EDIT: it's been pointed out that there could be numerous code blocks in a post, and their length on some sites could be greater than my example suggests. EDIT 2: I'll post another answer detailing an alternative suggestion which takes this into account.

2
  • Now add another 4 that are 2x that length. That's the code output we get on Ask Ubuntu... – Tim Jun 11 '15 at 21:17
  • @Tim hmm, that would be pretty bad, yes. But I think your idea goes too far in removing any resemblance to a code block. How about a short block of code + expander? I've edited my answer to include this suggestion. – Reg Edit Jun 11 '15 at 21:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .