Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

This question already has an answer here:

I've just answered a question in SO where I had to post four snippets of XML (yes, it was a JavaEE question, how did you guess?)

I made an effort to keep the snippets short and meaningful, but all this code can clutter the visuals of the page, and moves attention away from the rest of the answer.

The site can already detect which parts of the question or answer are code, and paints them in a different font and background. What if it could also add a small toggle button that hides/display each snippet of code?

An example. Displayed: A crudely drawn image of a widget whose purpose is to collapse a block of code, complete with an arrow pointing to this widget and a description "button to hide snippet" of said widget.

Hidden: The same widget as before, only this time it is in a different state and the associated block of code has been truncated according to the requested feature's behaviour. An arrow continues to point at the widget but it is accompanied by another arrow pointing out that an ellipsis (...) symbol should be used to indicate the aforementioned truncation has taken place.

Please acknowledge my superior Photoshop skillzs.

share|improve this question

marked as duplicate by gnat, S.L. Barth, Patrick Hofman, Shadow Wizard, Fish Below the Ice Jul 21 '15 at 12:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

It's a bit of a clunkily edited question, but this proposal which asks for code collapse (and then some) has been denied. – Grace Note Nov 24 '10 at 19:26
You people are too lazy to correctly add your alternate image text. I took the liberty of supplying it on your behalf. Think of Stack Overflow's visually impared users the next time you post images, Leonel. – JSONBog Nov 24 '10 at 20:13
@26: you've inflicted superfluous "u"s on blind people yet again! Why do you hate the blind so? – Shog9 Nov 24 '10 at 20:16
@shognine: I appeal to only the most Canadian of blind people. The blind people of lesser countries will have to make do. – JSONBog Nov 24 '10 at 20:17
@26: Aye. A thousand apologies. I promise I'll be more careful next time. – Leonel Nov 24 '10 at 20:36
Aside: the site does not "detect" code, it provides a formatting option for code (well, two one for inline and one for blocks). – dmckee Nov 24 '10 at 21:12

For the record, this now exists (at least for some languages).

<!- begin snippet: js hide: true -->

<!-- language: lang-js -->

alert(2+ 40);

<!-- end snippet -->

Note: because of the way HTML-comments work here, you'll need to add an extra '-' inside the first comment-tag for that to work.

When you do it, it will look like:

alert(2+ 40);

share|improve this answer

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