Language Highlighting for Klipper Configuration and Macros

Generally, Discourse supports so-called code blocks to properly format code or code-like content. This functionality should always be used when posting commands, macros, or excerpts from a configuration file. It ensures that relevant formatting, such as indentation, is not lost or interpreted differently.

This formatting can be easily accessed as shown in the following screenshot:
grafik

code_tags

Depending on the settings, it might either be displayed directly (red box) or hidden behind the “cogwheel” symbol (green box).

To further enhance readability and visual appearance, Discourse also supports passing language identifiers in a code block, which will cause the content to be highlighted in a defined way.

We have installed a highlighter that supports highlighting Klipper’s configuration and macro language. It can be activated by passing either kcfg or kmacro to the block highlighting.

This then looks like:

```kcfg
[tmc2130 stepper_x]
cs_pin: PC7
run_current: .5
sense_resistor: 0.120
diag1_pin: !PA4
spi_software_sclk_pin: PD2
spi_software_mosi_pin: PD3
spi_software_miso_pin: PD1
```

Note the 3 backticks that start and end a code block.

With the result in the post or the preview looking like:

[tmc2130 stepper_x]
cs_pin: PC7
run_current: .5
sense_resistor: 0.120
diag1_pin: !PA4
spi_software_sclk_pin: PD2
spi_software_mosi_pin: PD3
spi_software_miso_pin: PD1
7 Likes