WordPress code highlighter, the choosen one

July 9th, 2008 § 0 comments § permalink

I’m going to write about programming in next posts, that’s means I need a way to show some code here and there. My posts need a code highlighter to be clear :^)

I googled for a while to find a decent code highlighter. I found several code highlighters, some do it on the fly in JavaScript, some others do it server side, and some one let Google do it :^D. I’ve found a comparison too.

Well, I installed all of these, tried them and finally WP-syntax wins! Why?

  • It’s server-side, if you do not trust me or my site who cares? you will see highlighted code anyway ;^)
  • Supports a painless copy & paste,  when you copy from most of the other highlighters and paste in a simple text editor the code comes with more \n and # than what the author wrote… and maybe with line numbers too!
  • Supports line numbers, and the coolest part is that you can start from the line you want, it could be very useful!
  • And last but not least: I like it :^D, i’ll maybe fix the css to fit with the theme when I’ll end it (that’s cool but I want one written by me :^)

The only very bad thing is that the switching from HTML visual and WYSIWYG visual is very painful, I hope they’ll improve that!

Anyway here is the proof :^)

94
95
96
97
98
99
100
101
102
103
104
105
106
107
def fooer(count=200,start=2): # a decent foo should have at least 2 'o'
    for i in xrange(start, start+count):
        yield 'f' + 'o'*i
 
def allfoo():
    ppl = ('I','You','He','She','It','We','You','They')
    ippl = iter(ppl)
    for s in fooer(len(ppl)):
        i = ippl.next()
        if i in ('He','She','It'):
            s += 'es'
        print i,s
 
allfoo()

That’s, actually, the proof of how you can code very useless things but they are highlighted pretty well anyway :^D

return ‘Bye’