Trying out the Code Syntax Block Plugin


I’m not a huge fan of plugins for key parts of the site. There are some blog posts that no longer make sense because they used, for example, the iframe plugin to embed Google Maps. That said, my previous solution for displaying code on the site – special CSS is also brittle because I lose it whenever I change themes. I think at some point I also lost it when I upgraded a theme. So, since WordPress is all about blocks now, thanks to Gutenberg, I’ve decided to try out this Code Syntax plugin I heard about on WordPress Tavern.

Here’s some Adafruit Python code I had loaded in the other tab:

import time
import board
import adafruit_ahtx0

# Create the sensor object using I2C
sensor = adafruit_ahtx0.AHTx0(board.I2C())

while True:
    print("\nTemperature: %0.1f C" % sensor.temperature)
    print("Humidity: %0.1f %%" % sensor.relative_humidity)
    time.sleep(2)

I think it looks GREAT. I’d like to maybe have it be able to show line numbers (edit later that day: I found the line numbers option!) as well as have an ability to copy it (which helps sometimes with formatting when copying from a website). But it’s orders of magnitude better than anything I’ve ever used or configured before and I think I’ll be going back to old posts to retrofit this. I think the best part is that it’s just an extension on the built-in code block (which I’m surprised doesn’t have something like this built-in) so I think if the plugin stopped working it could fail gracefully.

Here’s a screenshot in case this changes in the future so you could know what I was referring to at the time: