Fly, Penguin!

I blog so I don't forget.

Syntax highlighting with wordpress

1 minute read #blog #dev #wordpress

This is just a test for syntax highlighting. Which I really really really wanted to have. Even if it’s WordPress and not something cool like hugo.

So, let’s try:

import random

class RndTest:
    def __init__(self):
        print("Oy! 'this is python!")
        self.rnd_seed = random.random()

    @classmethod
    def do_nothing(cls, nothing):
        print("Doing {} now ;)".format(nothing))

That doesn’t look so bad, right?

How to do this

  • install the crayon syntax highlight plugin
  • when writing posts, your toolbar will have a new icon looking like this: <>
  • press it, and an “add code” dialog will open
  • do your thing
  • save
  • done

Like.

Dislikes

  • I don’t know which JS engine this thing uses (if any public one in particular)
  • I like highlight.js

(So, none really)

Alternative plugins (untested)

To be honest, the only real contender in installation base and features seems to be Syntax Highlighter Evolved. I have not tried it, but if you don’t like crayon, that looks like the one to go.