How do I add syntax highlighting to a WordPress blog hosted on WordPress.com? How do I add syntax highlighting to a WordPress blog hosted on WordPress.com? wordpress wordpress

How do I add syntax highlighting to a WordPress blog hosted on WordPress.com?


On wordpress.com, you can't install plugins, so you have to use Wordpress' built-in widget.

Do it like:

[code language='python'][/code]

Note that those tags go inside your visual editor, not the HTML editor.

You can find more information here.


The best way for syntax highlighting is using prismjs, which is completely free with awesome features.

  1. It has support for almost all programming languages, shell scripts and much more.

  2. It is very light weight and it will not bog down your sites speed like other syntax highlighting plugins.

For configuring prismjs you need to do little code tweaks in your function.php file. Follow the turoails in this blog http://skillslane.com/setup-syntax-highlighter-for-wordpress/


SyntaxHighlighter is a pretty good tool. It uses JavaScript with CSS classes to mark HTML elements that should be highlighted. It also allows code to be copied to the clipboard and printed.