In Mattermost 5.14 and up till latest version pasting a code from Github results in a somehow broken formatting. Go to any repo in Github, copy and paste code (not from raw file, but via normal github code viewer) into Mattermost new message field, in web client and you will see it.
5.16.3
For example, go here https://github.com/containers/libpod/blob/master/contrib/imgts/lib_entrypoint.sh#L24 and copy lines 24 to 34. The paste it into new message field.
I expect this:

(Note I had to copy code, paste it into my text editor, copy again and paste to Mattermost to make this screenshot).
But instead pasting results in this:

No idea! :)
I confirm the issue with latest mattermost build: pasting the code from GitHub repo into a chat message adds all extra markup chars like line breaks, tabs etc and looks like this:
|// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.|
|---|
|聽 | // See License.txt for license information.|
|聽 | 聽|
|聽 | package app|
the code example is taken from mattermost server repo https://github.com/mattermost/mattermost-server/blob/master/app/app.go#L1
it would be nice to have clean markup instead like this:
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package app
@hmhealey Do you know if this is related to https://mattermost.atlassian.net/browse/MM-10003 or is a separate issue?
No, that ticket would only affect Markdown after it's posted.
It looks like the code that handles pasting data from Excel is broken because the pasted text is being turned into a table. That feature was added back in January, so it may have been broken since back then (https://github.com/mattermost/mattermost-webapp/pull/2246), but the code for it was updated early in October as well (https://github.com/mattermost/mattermost-webapp/pull/3812).
Ticket here: https://mattermost.atlassian.net/browse/MM-20613.
This is fixed for upcoming v5.20 release,
Most helpful comment
Ticket here: https://mattermost.atlassian.net/browse/MM-20613.