Displaying code in posts

What is the best way to format code in posts here? I use < code > < / code> but it does not color or format the code.
the </> button works sometimes but adding spaces to the front of the line .

I saw THIS post I was wondering if anyone has edited highlight.js for openhab formatting. or is there a better way.

I’m sorry I missed that post the first time it came around. I’ve just been using the indent by four spaces approach.

I think that openHAB rules are similar enough to Java that the java formatting should work just fine. In fact that posting implies Java is the one to use: