Pages

Monday, October 22, 2012

Source code listing in blogger.com

Using Paste Bin

Pastebin.com seems to be unreliable sometimes. So, I think you'd better be using syntax highlighter if possible. You can use Paste Bin for pasting programming source code. After your pasting code, you'll have embed menu. When clicked, it will give you the javascript so that you can copy and paste. This is the source code to paste from pastebin.com.
<script src="http://pastebin.com/embed_js.php?i=ELanScfL"></script>
And this is the result.

Syntax Highligter

You can use syntax highligher also. The HTML code you need is as follows.







  Pattern p = Pattern.compile("rename_method\\(" + // ignore 'rename_method('
    "\"([^\"]*)\"," +                        // find '"....",'
    "\"([^\"]*)\"," +
    "\"([^\"]*)\""  +
    "\\)");                                  // ignore closing ')'
  Matcher m = p.matcher(refactoring);
  
  boolean result = m.find();
  if (result)
  {
   beforeMethodName = m.group(1);
   afterMethodName = m.group(2);
  }
You'll get this as a result.
  Pattern p = Pattern.compile("rename_method\\(" + // ignore 'rename_method('
    "\"([^\"]*)\"," +                        // find '"....",'
    "\"([^\"]*)\"," +
    "\"([^\"]*)\""  +
    "\\)");                                  // ignore closing ')'
  Matcher m = p.matcher(refactoring);
  
  boolean result = m.find();
  if (result)
  {
   beforeMethodName = m.group(1);
   afterMethodName = m.group(2);
  }
You can also refer to this post.

google-code-prettify

This post teaches about google-code-prettify, and I think it's also simple and useful.
... # Your code goes here

Easier way to embed java script/HTML in blogpost

Refer to this post, with it, you can just use pre tag. Your code now becomes this.

  Pattern p = Pattern.compile("rename_method\\(" + // ignore 'rename_method('
    "\"([^\"]*)\"," +                        // find '"....",'
    "\"([^\"]*)\"," +
    "\"([^\"]*)\""  +
    "\\)");                                  // ignore closing ')'
  Matcher m = p.matcher(refactoring);
  
  boolean result = m.find();
  if (result)
  {
   beforeMethodName = m.group(1);
   afterMethodName = m.group(2);
  }

No comments:

Post a Comment