Unexpected formatting in triple-tick code blocks

I know a new editor is in the works, but presumably the underlying markdown will be the same, and its interpolation will stay the same, so…

In triple-backtick (```) code blocks, I’ve noticed that some formatting is improperly applied. Here’s a screenshot from me fixing a user’s post. This is the before:

If I change it to a single-tick block there’s no formatting, as expected (please ignore the Grammarly underline on the left):

Hi @ganncamp. What is the value of the “Default code lang” site setting on that forum?

It’s auto

The auto lang for this particular code block is detecting the language as markdown, that’s why:

(lang=auto; my incomplete snippet is detected as ruby)

sonar-scanner … etc etc include=src/**,apps/**,include/**,gui/** -Dsonar=true…

(lang=markdown)

sonar-scanner … etc etc include=src/**,apps/**,include/**,gui/** -Dsonar=true…

(lang=text)

sonar-scanner … etc etc include=src/**,apps/**,include/**,gui/** -Dsonar=true…

(lang=bash)

sonar-scanner … etc etc include=src/**,apps/**,include/**,gui/** -Dsonar=true…

You can change this for every post by changing the default code lang to text or one post by writing e.g.:

```text
sonar-scanner … etc etc include=src/**,apps/**,include/**,gui/** -Dsonar=true…
```

producing the (lang=text) block above

6 Likes

But why would formatting ever be applied in a code block?

It’s just syntax highlighting your code, but with the wrong language after HighlightJS “auto-detected” it.

Notice the same doesn’t happen here on Meta unless you explicitly start your code block with ```auto, because we have “Default code lang” set as text.

4 Likes