vote up 2 vote down star

Is there a way to install a JavaScript plugin to a free wordpress blog? I'm trying to make a development blog, and so far wordpress looks really nice... I'm not ready to commit to buying a domain, and hosting, to do it myself, so I'm just using the free one... And that suits my needs well for now. But it'd be awesome if I could write code in it!

I suppose I could just find a way to generate formatted HTML, and write each post on my computer, then just paste the result into wordpress--but the plugin looks way easier. But I can't find a way to use it. Can it be done?

flag

closed as off-topic by ~quack, Diago Feb 19 at 9:39

Questions on Super User are expected to generally relate to computer software or computer hardware in some way, within the scope defined in the faq.

4 Answers

vote up 8 vote down check

I found a suitable answer shortly after posting this one, with a quick search of the wordpress forums (I guess I should have tried that first).

wordpress.com supports a [sourcecode language='lang'] construct, which is implemented based off of the syntaxhighlighter plugin.

Using it like so:

[sourcecode language='cpp']
#include<stdio.h>

int main(){
    printf("Hello, world!");
}
[/sourcecode]

generates similar output as the plugin. I don't think it supports the same number of languages, however. It supports:

  • bash
  • cpp
  • csharp
  • css
  • delphi
  • html
  • java
  • jscript
  • php
  • python
  • ruby
  • shell
  • sql
  • vb
  • xml

The actual plugin additionally supports these (which are not supported by the wordpress.com version):

  • actionscript3
  • diff
  • groovy
  • javafx
  • perl
  • powershell
  • scala
link|flag
vote up 3 vote down

If you want to be able to install the SyntaxHighlighter in your wordpress blog, your best bet is to host it yourself (download the source from Wordpress.org). The free hosted version at Wordpress.com does not accept plugins, and does not offer the unlimited template customization that you might want to use when integrating SyntaxHighlighter.

You also might want to check out these questions (1, 2) on StackOverflow, as well as a blog post that I wrote on the subject.

If you really want to use the free hosting on WordPress.com, I would suggest using Windows Live Writer to post to your blog. It has a number of extensions that can handle code formatting (my favorite is Insert Code for WLW).

link|flag
helpful if I want to install the blog on my own server, but I just want to toy with it on the free wordpress server for now. – Carson Myers Jul 29 at 9:41
vote up 1 vote down

As I already said use Prettify. It is used by StackOverflow and it works very well. You just include it into your blog top level template and every <code> section get highlighted automagically.

link|flag
vote up 0 vote down

Since you cannot use plug-ins at Wordpress.com, here is an easy way to generate formatted and colored HTML from your code. It is all web-based:

http://pygments.org/

link|flag

Not the answer you're looking for? Browse other questions tagged or ask your own question.