I have noticed a few comments today that include multiline comment formatting (for example on this answer), and wondered when this was enabled and where this was announced.

I've searched a bit on meta, but feature-requests like Add syntax highlighting and line breaks to comment formatting still have status: declined. Neither the How do comments work? FAQ nor the editing help mention this.

Also, how does it work? As suggested in the comments: Is this a bug?

  • 3
    Can you link to an example comment? As it is, it's not quite clear what you're referring to. – Servy Feb 24 '14 at 21:18
  • 1
    @hichris123: No, like this: do something with very fancy indentation (inline block?) – Bergi Feb 24 '14 at 21:18
  • 19
    sealed class QueryProcessor : IQueryProcessor { private readonly Container container; public QueryProcessor(Container container) { this.container = container; } [DebuggerStepThrough] public TResult Process<TResult>(IQuery<TResult> query) { var handlerType = typeof(IQueryHandler<,>) .MakeGenericType(query.GetType(), typeof(TResult)); dynamic handler = container.GetInstance(handlerType); return handler.Handle((dynamic)query); } } – Robert Harvey Feb 24 '14 at 21:19
  • 12
    I hope that's a bug. – Flexo Feb 24 '14 at 21:20
  • 8
    Oh... this is bad. Please don't teach people how to do this. Please? – Geobits Feb 24 '14 at 21:20
  • My money's on this being a bug, and that non-space whitespace in code probably should be removed from comments, and that this is an overslight. – Servy Feb 24 '14 at 21:20
  • 11
    It's taking all of my willpower not to delete those multiline comments. – George Stocker Feb 24 '14 at 21:21
  • Works on Stack Overflow too. – Robert Harvey Feb 24 '14 at 21:22
  • 16
    This. Is. A. New. Era. – Pekka supports GoFundMonica Feb 24 '14 at 21:22
  • 1
    @RobertHarvey: You're totally blasting the comments section. Could you please shorten it a little bit? :-) – Bergi Feb 24 '14 at 21:23
  • 2
    If you're dealing with SO newbies in python though life just got a whole lot easier @George... where's Martijn? If he's happy then everyone should be! – ben is uǝq backwards Feb 24 '14 at 21:50
  • 2
    This may be when it was added. meta.stackexchange.com/questions/30020/… – Simon Feb 24 '14 at 22:06
  • @Simon: Make that an answer! – Bergi Feb 24 '14 at 22:07
  • @Bergi I want to have 1 rep for this: meta.stackexchange.com/questions/222037/… – Simon Feb 24 '14 at 22:12
  • @George Make my day, Punk! – MikeTheLiar Feb 25 '14 at 0:33

They aren't, it was a bug. When making this change, I swear did read the spec to check for side effects of the change, but somehow the phrase "Lines are broken at newline characters" was able to cross my brain unharmed.

Fixed now. Newlines, that is, not my brain.


how does it work?

This at least I figured out. Simply enter line breaks inside the comment (by pressing Shift+Enter, to prevent automatically submitting the form), and use backticks for code formatting as usual:

My very simple sample comment `with (trivial) {
}` that is going to be indented


My very simple sample comment with (trivial) { code_formatting() } that is going to be indented

Technically, the markup will preserve these whitespaces, and the CSS for this is

code { 
    white-space: pre-wrap;

which also applies to the comment sections.

  • 2
    This is awesome! The potential for abuse is well... – Mysticial Feb 24 '14 at 21:36
  • Aww... Seems like it was too inappropriate even for meta... :( – Mysticial Feb 24 '14 at 21:39
  • 1
    Nothing is too inappropriate for meta – MikeTheLiar Feb 24 '14 at 22:21
  • 5
    THIS IS METAAAAAAAAAAA – michaelb958--Reinstate Monica Feb 24 '14 at 22:22
  • 6
    META? META? WE DON NEED NO STEENKING META! – MikeTheLiar Feb 24 '14 at 22:22
  • 1
    @mikeTheLiar I thought so too. But my 500 newlines comment was insta-deleted. :) – Mysticial Feb 24 '14 at 22:25
  • 1
    @Mysticial that's because I flagged it as "too awesome." Also, the Android app doesn't show the newlines, :( <- that's a sad face – MikeTheLiar Feb 24 '14 at 22:27
  • For anyone who wants to know what 500 newlines looks like, Mysticial has reposted that comment in the sandbox. – michaelb958--Reinstate Monica Feb 25 '14 at 3:10

When this was enabled and where this was announced?

As @Sinon found, it was introduced to prevent Multiple spaces in code in comments get merged into one

I've added this to our stylesheets:

code {
    white-space: pre-wrap; /* don't collapse multiple spaces in code */

– no idea why we never did that; it's an easy enough fix, and these days it's supported by all browsers. This is in the next build.

Is this a bug?

A side effect, at least.

You must log in to answer this question.

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