Codeviewer plugin test

Back a few years ago, I used a code syntax highlighter called Code Viewer that was created by Aaron Schaefer at Elastic Dog. That has since been taken over by HÃ¥kan Carlström. I spent too many hours this weekend getting this plugin setup to parse Python source code. It uses GeSHi to highlight the code syntax, and I had to hack up the GeSHi CSS and my own CSS to get the Python source code to look like I wanted, but it’s about there. I highly recommend this plugin if you are looking to highlight source code of virtually any modern language. The coolest part of it is that it links to a source code file and you just point to that file, you don’t have to include the code in the post. Below is a sampling of the output, with my own CSS styling applied.

  1. def grabNewImages( self ):
  2. """ Recurses thru directories and looks for images to upload. I only want to upload my '5-star' images, so we scan the IPTC tags for 'r5', my way of tagging my pics I really like (usually get prints of r5s) """
  3. images = []
  4. for dirpath, dirnames, filenames in os.walk(IMAGE_DIR):
  5. for f in filenames :
  6. # Grab IPTC keywords
  7. info = IPTCInfo(os.path.join(dirpath, f))
  8. # Is it a 5-star photo?
  9. if 'r5' in info.keywords:
  10. print 'File to upload:',os.path.join(dirpath, f)
  11. ext = f.lower().split('.')[-1]
  12. if ( ext == 'jpg' or ext == 'gif' or ext == 'png' ):
  13. images.append( os.path.normpath( dirpath + '/' + f ) )
  14. images.sort()
  15. return images

Leave a Reply