The common uses of code blocks here don’t work well with Discourse’s language detection and syntax highlighting.
- The language detection performs poorly on short samples like shell one-liners.
- For output only, logs, or other plaintext, highlighting is always wrong. It might look nice by coincidence, but it’s essentially random highlighting of numbers or symbols.
- For commands + output, even if it is detected or specified as bash, the highlighting is meant for bash scripts, so the output is wrongly highlighted.
I suggest disabling this feature. Users can specify the language to get correct highlighting when needed (rarely, since this is not a programming forum).
It might also have minor savings in page loading since the detection and highlighting is done on client-side JS (?).
All examples don’t have any language specified after the triple-backticks.
This is detected as CSS:
dnf list --installed kernel
$ mount --all
$ tar xvf foo.tar.gz
Some common shell built-ins are detected as bash:
But other shell built-ins aren’t (CSS again):
Journal output, detected as Apache:
Apr 24 16:07:40 asuja kernel: last_pfn = 0x26f000 max_arch_pfn = 0x400000000 Apr 24 16:07:40 asuja kernel: x86/PAT: Configuration [0-7]: WB WC UC- UC WB WP UC- WT Apr 24 16:07:40 asuja kernel: last_pfn = 0x8f800 max_arch_pfn = 0x400000000
dnf history, detected as SQL:
$ dnf history info last Transaction ID : 757 Begin time : Mon 24 Apr 2023 14:31:26 +08 Begin rpmdb : da3a6d93b2dc2d1044bd471a85ed5d2554dc4f59bc01b64a79d8b040d12413a3 End time : Mon 24 Apr 2023 14:31:29 +08 (3 seconds)