1

Why is preceding whitespace stripped out of chat messages? It makes explaining code tidbits much more difficult than it needs to be (especially for languages that depend on such formatting -- eg, Python).


Context: I was just helping a user who had a Django question, but discovered that the user was actually a few steps behind where his/her question would be relevant. So, we moved our comment-dialogue to chat and we cleared up the issue. However, this was a lot harder than it needed to be because the code-samples from the Docs that I/the user posted lost all formatting.

Is there a reason that whitespace is removed? Is it to dissuade users from using chat for this purpose?

5
  • This should only matter when you have a multiline message formatted as code. Does it still happen when you do that? Aug 15, 2014 at 21:07
  • Yuppers -- lemme post a screenshot to clarify what I mean.
    – Casey Falk
    Aug 15, 2014 at 21:07
  • Look at this message for an example of what I'm talking about. Aug 15, 2014 at 21:08
  • Basically, chat messages are formatted as limited markdown. The markdown spec includes stripping extra whitespace. That's why there's a "fixed font" button. Aug 15, 2014 at 21:11
  • Yeah, figured out the issue. If I include a non-code line (say a line that says "For example...") at the start, it sees the entire message as non-code. Definitely a foot-from-the-keyboard error. Should have realized that.
    – Casey Falk
    Aug 15, 2014 at 21:12

1 Answer 1

1

Oops... User Error

If you include a non-code line at the beginning of the message, the entire message is seen as non-code and thus any preceding white-space is trimmed from the lines. If you start the meessage with code, then it's fine.


Example 1:

    def myFunc():
        return 2+2

... Is formatted as...

def myFunc():
    return 2+2

Example 2:

For example...

    def myFunc():
        return 2+2

... is formatted as....

For example...

def myFunc():
return 2+2

You must log in to answer this question.

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