Print Friendly, PDF & Email

For those in the quest for the wordpress best syntax highlighting plugin, Miss Lea Verou wordpress plugin “WP Prism Syntax Highlighter” for adding prism.js syntax highlighting is the best source code syntax highlighter available in the market since it’s created by plugin’s author the only issue with it is… its really outdated! the github page of the plugin hasn’t been update for about two years now.

In this post I’ll show you how I updated the code to support syntax highlighting of more languages, like my personal blog correctmycode.blogpot.com does, ¡And make that wordpress plugin even better!.

If you don’t have support for the language the code inside your pre will show in black as in the following image:

prismjs-syntax-error

I strongly recommend you to do a backup of your plugin files.

You just have to google for prism-NAME_OF_THE_LANGUAGE.min.js and will a link to the file, in my case for example we can get the prolog syntax by the link https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/components/prism-prolog.min.js

Once we open the file we will see the definition in this form:

Prism.languages.LANGUAGE_NAME={some definitions}

Fortunately all of the languages in the plugin are in the same fashion.

We will edit the file prism.js of the plugin with the content of every language desidered, prolog in this case and add an exrta semicolon at the end as in the other languages.

prism-editar

Once updated the file changes should be showing inmediately for new users but if you opened you will have the old ve5rsion of the script cached so you shoul press Control R to clean the cache and download the new script file.

prism-resaltado-de-sintaxis-funcionando

Once addeded the language the language will be automatically avalible for seletion using the menu as usual

wordpress best syntax highlighting plugin
That’s how looks the wordpress best syntax highlighting plugin

Hope you find this post useful.

Radio

Do NOT follow this link or you will be banned from the site!