How do I add syntax highlighting to a WordPress blog hosted on WordPress.com?
I'd like to have a good syntax highlighter for my WordPress blog. What options do I have available? I often see one which has well-colored syntax highlighting and options to copy to the clipboard. Does anyone have an idea what tool this is?
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.
It has support for almost all programming languages, shell scripts and much more.
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.