Markdown formatting labels for codeblock

When I am writing a message, I paste a command line as a multiline codeblock, I would like to have it formatted (colorized).

If I paste a json, I can use the following:

```json
{
   "field": "value"
}
```

and it’s highlighted/formatted as JSON document.

But it’s a mess with CLI/shell code. Nothing really works with labels like shell, bash, sh (no formatting applied). Only powershell works somehow, but the formatting is broken.

The following code block:

```shell
curl --request POST \
  --url http://host/path \
  --header 'authorization: Bearer {{bearer_access_token}}' \
  --header 'content-type: application/json' \
  --data '{
  "name": "{{name}}"
}'
```

is displayed as regular code block (text with no formatting).

If I specify powershell label, then it has some flaws (see the number highlighting in the URL):

Where is the documentation listing all the possible labels for various supported highlighting formats?

Why powershell works, but no general labels like shell, bash, sh?

They use a formatting library but no idea exactly what. You need to read the code.

You should make sure all backticks are on a separate line.

On your post you are putting code on the same line as the backticks. Like:

Backticks Code

Code

Code

Backticks

Should be more like this:

Backticks

Code

Code

Code

Backticks

In my post opening backticks are followed by “label” I mentioned, that declares the highlighting I want. It’s a standard markdown syntax for code blocks in Stack Overflow (offical SO docs) and many many other platforms. I believe it’s been pretty much a standard for a very long time.

Shot from SO docs:

As I can see, SO uses highlight.js library that contains “bash” highlighting (see their GitHub discussion with an example of “backticks with label”). It’s strange that no standard labels for shell code apply for codeblock highlighting in RocketChat.

I can’t recall which lubrary they use. Plese have a read.

If you read the changelogs et al you will see that the format I mentioned with backticks clearly above & below code has been their “standard” for a year or more (search github). It may not accept labels.

It is the way it is.

They don’t necessarily conform to anyone elses standards, be that SO or anyone else.

That is their perogative. They do what suits them.

Of course if you don’t like that you are free to open a PR in the feature requests repo, or to take the source code and build whatever suits you. The power of open source!

Then why do these two code blocks have different highlighting?

The rendered result is in the next message due to the restrictions of the forum (one image per post)

See my previous response :man_shrugging:

^^^^^^^^^^^^^^^^

^^^^^^^^^^^^^^^^