Code snippets for blogging made easy II - Now with line numbers!

In another post, I wrote about getting syntax-hilighted code in your favourite color scheme in html format to publish in blogger. Today, I added two more functions to the blog-htmlize.el file (link here) (save the file as blog-htmlize.el).
  1. blog-htmlize-region-with-linum
  2. blog-htmlize-buffer-with-linum
These functions produce almost the same output as their without "-with-linum" counterparts. The addition is the line numbers column on the left side of the code.
And unlinke many other online code snippets (see example here), when you try to select the code for copy pasting, only the code is selected and not the numbers. Go ahead and try copy-pasting / selecting text from the following test snippet.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#include <iostream>

using namespace std;

int main ()
{
     cout << "Hello World!" << endl;
     cout << "Here is the code in my favourite color scheme." << endl;
     cout << "You can get it too!" << endl;
     return 0;
}
If you have already added the required lines in your .emacs file as told in that post, to get these new functions, all you have to do is replace the blog-htmlize.el file which you already have with the updated one.

2 comments :

Post a Comment

Note: Only a member of this blog may post a comment.