Sunday, November 4, 2012

Blogger Code Syntax Highlighting

I really like Wordpress.org's Syntax Highlighter.

http://wordpress.org/extend/plugins/syntaxhighlighter/screenshots/

Particularly the button to copy the raw code without the line numbers.

Unfortunately, this is not easy to implement on Blogger.

The closest I have managed is from this blog:

http://www.cyberack.com/2007/07/adding-syntax-highlighter-to-blogger.html

Which does work, but we're missing the important buttons. Here's a demo of it in action on my saturate.c code - Note Blogger still completely mangles my code after a few lines, and we're missing the important buttons that Wordpress has.

Time to switch to Wordpress, or does anyone have any bright ideas?

(Update - Pastebin seems to work well for me, but it's an external link, not quite the same thing.  http://pastebin.com/4SexdvLq )

Saturate.c



#define _FILE_OFFSET_BITS 64  /* enable large file support  */
#include 
#include 
#include 
#include 
#include 

float nCM=0; /* count of 100's of megs we've written */


void finish(const char *where) {
        printf("%s: wrote %.1f gig file\n",where,0.1*nCM);
        exit(0);
}

void hitError(const char *where) { perror(where); finish(where); }

void writer(int id)
{
        char c=0; /* The byte we're writing */
        int cm=100*1024*1024;
        FILE *f[50];

        int     r;
        int     block[262114];
        int     i;
        char    fName[40];
        int     numFiles=4;

        printf("This is the %i writer, going to create %i files.\nOpened : ", id, numFiles);

        for(i=0; i
(end Code) 






2 comments:

  1. It is awesome, i like the post. Keep up the right standard.
    pst recovery

    ReplyDelete
  2. I’ve learn a few excellent stuff here. Definitely price bookmarking for revisiting. I wonder how so much attempt you place to make the sort of great informative site.
    website design

    ReplyDelete