Please configure Discourse forum engine to have the `text` "programming language" for code blocks by default

When we post code blocks, we can use ``` or ~~~ to open and to close that block.

We can also use programming language to highlight function definition, variables, values, operators:

```java
# ...and to compute them together we use
fn foo(bar, baz) {
let myVar = 123;
let myVar2 = 'out of range';
...
return computeddValue;
}
```

While it is useful for programming code block and usually needs to note exact language, our forum users usually posts log excerpts and shell commands, which could look weird with no language provided.

If not to use text as programming language, than code blocks will looks like plain text perhaps usually more readable.


You can try it by yourself in the next wiki post (start to edit it and check result you have on the right panel).

saved copy (backup) of source code of initial wiki post below made by OP
```
~/.mozilla
~/.cache/mozilla
~/.pulse
```

with `text` specified:

```text
~/.mozilla
~/.cache/mozilla
~/.pulse
```

---

```
Dec 03 15:32:39 pc kernel: audit: type=1130 audit(1638534759.261:596): pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Dec 03 15:32:39 pc audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Dec 03 15:32:39 pc systemd[1]: Started Network Manager Script Dispatcher Service.
Dec 03 15:32:39 pc dbus-daemon[515]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Dec 03 15:32:39 pc systemd[1]: Starting Network Manager Script Dispatcher Service...
Dec 03 15:32:39 pc dbus-daemon[515]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.3' (uid=0 pid=516 comm="/usr/bin/NetworkManager --no-daemon ")
```

with `text` specified:

```text
Dec 03 15:32:39 pc kernel: audit: type=1130 audit(1638534759.261:596): pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Dec 03 15:32:39 pc audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Dec 03 15:32:39 pc systemd[1]: Started Network Manager Script Dispatcher Service.
Dec 03 15:32:39 pc dbus-daemon[515]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Dec 03 15:32:39 pc systemd[1]: Starting Network Manager Script Dispatcher Service...
Dec 03 15:32:39 pc dbus-daemon[515]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.3' (uid=0 pid=516 comm="/usr/bin/NetworkManager --no-daemon ")
```

---

```
Section "ServerFlags"
  Option "IgnoreABI" "1"
EndSection
```

with `text` specified:

```text
Section "ServerFlags"
  Option "IgnoreABI" "1"
EndSection
```

---

```
systemctl --user enable pipewire-media-session
```
which on black forum theme looks like:
![image|518x114](upload://kuqfz8MVebpsxgJ9tGdiadyUORg.png)

and now with `text` specified:

```text
systemctl --user enable pipewire-media-session
```

---

And only sometimes some current default helps to make it more readable:

```
# Remove NVIDIA USB xHCI Host Controller devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"
 
# Remove NVIDIA USB Type-C UCSI devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1"

# Remove NVIDIA Audio devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1"
```

and with `text` specified:

```text
# Remove NVIDIA USB xHCI Host Controller devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"
 
# Remove NVIDIA USB Type-C UCSI devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1"

# Remove NVIDIA Audio devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1"
```

So, may be to make code block have the programming language config of text by default in forum engine as most cases it looks more readable without default highlighting?

1 Like
~/.mozilla
~/.cache/mozilla
~/.pulse

with text specified:

~/.mozilla
~/.cache/mozilla
~/.pulse

Dec 03 15:32:39 pc kernel: audit: type=1130 audit(1638534759.261:596): pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Dec 03 15:32:39 pc audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Dec 03 15:32:39 pc systemd[1]: Started Network Manager Script Dispatcher Service.
Dec 03 15:32:39 pc dbus-daemon[515]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Dec 03 15:32:39 pc systemd[1]: Starting Network Manager Script Dispatcher Service...
Dec 03 15:32:39 pc dbus-daemon[515]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.3' (uid=0 pid=516 comm="/usr/bin/NetworkManager --no-daemon ")

with text specified:

Dec 03 15:32:39 pc kernel: audit: type=1130 audit(1638534759.261:596): pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Dec 03 15:32:39 pc audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Dec 03 15:32:39 pc systemd[1]: Started Network Manager Script Dispatcher Service.
Dec 03 15:32:39 pc dbus-daemon[515]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Dec 03 15:32:39 pc systemd[1]: Starting Network Manager Script Dispatcher Service...
Dec 03 15:32:39 pc dbus-daemon[515]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.3' (uid=0 pid=516 comm="/usr/bin/NetworkManager --no-daemon ")

Section "ServerFlags"
  Option "IgnoreABI" "1"
EndSection

with text specified:

Section "ServerFlags"
  Option "IgnoreABI" "1"
EndSection

systemctl --user enable pipewire-media-session

which on black forum theme looks like:
image

and now with text specified:

systemctl --user enable pipewire-media-session

And only sometimes some current default helps to make it more readable:

# Remove NVIDIA USB xHCI Host Controller devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"
 
# Remove NVIDIA USB Type-C UCSI devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1"

# Remove NVIDIA Audio devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1"

and with text specified:

# Remove NVIDIA USB xHCI Host Controller devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"
 
# Remove NVIDIA USB Type-C UCSI devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1"

# Remove NVIDIA Audio devices, if present
#ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1"

What exactly are you requesting? You just proved that extended syntax is already working. We have no related plugins, so it’s just whatever is default for Discourse. Maybe suggest a plugin that would accomplish what you’re asking for? Please be clear and concise.

I think the OP is talking about this Code highlighting happening when auto-highlighting not enabled - bug - Discourse Meta

Only @admins can do the changes … AFAIK.

I have been using bash most of the time.

I think a bigger problem is that by default discourse doesnt seem to search, or at least not well, the text in code blocks. :scream_cat:

If we can edit or plugin our way around that … “that would be great”. :coffee:

To make text type for the code block as default for the whole forum by configuring forum engine.

Does end-machine has the config/site_settings.yml file?
Perhaps it contains the target settings:

 default_code_lang:
    client: true
    default: "auto"

I would change it to

    default: "text"

and to try if it works.

I do not know how to apply forum engine settings properly: to stop engine, to edit the config file, to start engine
or
may be it has some reload_config_and_apply without stopping of engine.

Could we try?


It is the absolute heuristic thoughts, I do not know exactly: I did not try to deploy the forum engine to test it.