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

I want to have a nice syntax shortcut for my WordPress blog. What are my options? I often see one that has bright syntax highlighting and options for copying to the clipboard. Does anyone have an idea which tool this is?

+41
syntax-highlighting wordpress blogs
Aug 13 '09 at 18:06
source share
8 answers

You cannot install plugins on wordpress.com, so you need to use the built-in Wordpress widget.

Do it like:

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

Note that those tags get into your visual editor, not the HTML editor.

You can find more information here .

+72
Aug 13 '09 at 18:14
source share

SyntaxHighlighter is a pretty good tool. It uses JavaScript with CSS classes to indicate the HTML elements that should be highlighted. It also allows you to copy code to the clipboard and print.

+3
Aug 13 '09 at 18:11
source share

The best way to syntax highlight is to use prismjs, which is completely free of awesome features.

  • It supports almost all programming languages, shell scripts, and more.

  • This is a very light weight, and it will not hurt on your sites, like other syntax highlighting plugins.

To set up prismjs, you need to slightly modify the code in the functions.php file. Follow the turoails on this blog http://skillslane.com/setup-syntax-highlighter-for-wordpress/

+2
Oct 08 '15 at 5:06
source share

http://wordpress.org/extend/plugins/devformatter/

WP Plugin for syntax highlighting!

+1
Aug 13 '09 at 18:10
source share

If you do not want or cannot install the material on your blog, I suggest you use expressions to highlight the code. I described it here .

+1
Aug 13 '09 at 18:12
source share

Here is the offline option (I know what you're asking about an online tool, but just in case ...)

I use standalone blog post processing tools with sample html source code and then just post html.

This is really true:

  • source code offset at least 4 spaces and indicate the language on the first line as :::html
  • run the file through:

python script:

 import markdown html = markdown.markdown(text,['codehilite']) 

I set markdowns using pigments, maybe you can just use pygments for the source code. You will run the file the script suggested, and then copy the html to your blog.

You can reset the css style, select the syntax from pygments, and then either link to it, or include it in your page. I am not sure if Wordpress supports this.

Here's how to set up markdown using pigments to highlight syntax (for Blogger, the only specificity for Blogger is that it updates Blogger css with css to highlight the code).

+1
Jan 18
source share

You can use the syntax of Alex Gorbachev. Its javascript is both very simple and well supported, easy to install and modify. Here are some instructions for a blogger ... but all you have to do is delete the line blogger = true.

http://code-slim-jim.blogspot.com/2010/11/adding-syntax-higher-to-your-blog.html

0
Nov 13 '10 at 5:28
source share

I developed a plugin easy syntax shortcut for WordPress called "Mivak". The plugin has a code editor for quick code entry, checking for errors and syntax highlighting. It is also highliy customizable.

The plugin is hosted on wordpress.org

0
Apr 05 '16 at 6:45
source share



All Articles