Mastodon Mastodon - Syntax highlighting with wordpress
 logo
  • Home 
  • Tags 
  • Blog posts 
  1. Home
  2. Blog posts
  3. Syntax highlighting with wordpress

Syntax highlighting with wordpress

Posted on January 21, 2017  (Last modified on July 11, 2024) • 1 min read • 158 words
Blog   Dev   Wordpress  
Blog   Dev   Wordpress  
Share via
Link copied to clipboard

On this page
    • How to do this
    • Dislikes
    • Alternative plugins (untested)

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.

 The state of things – technology
PyCharm, Arch linux & Python 3.6 
On this page:
    • How to do this
    • Dislikes
    • Alternative plugins (untested)
In case you want to follow me

Here are some links. The further to the right, the less active.

           
(c) Axel Bock | Powered by Hinode.
Code copied to clipboard