you're reading...
General, Syntax Highlighter

Syntax Highlighter 1.2.2

Download: syntax_highlighter_v1_2_2.zip

A couple of bug fixes:

  • Nish told me that some additional characters were getting escaped twice by WordPress so the fix_wp_pre function was modified to re-escape those correctly.
  • Torkar notified me that the line numbers didn’t indent correctly when starting with line 0. I also took the time to support starting with negative line numbers.

And one new feature:

  • The spaces to align the numbers can either occur on the left or right side of the number now. This is a site-wide setting so you can’t change it for a single post. Open up syntax_highlighter2.php. If you set $rightAlignLineNumbers to true then the spaces will appear on the left of the number, making the numbers line up on the right side. If you set $rightAlignLineNumbers to false then the spaces will appear on the right side of the number, making the numbers line up along the left side.

Update: Placed this post in the right category…can’t believe it took two days to notice that
Update2: HAHHAAHHAAHAHA! I can’t believe I’ve edited this post once already and never noticed that I didn’t link to the new download.


About James

I am a Senior Developer/Consultant for InfoPlanIT, LLC. I previously spent over 7 years as a Product Manager for what eventually became ComponentOne, a division of GrapeCity. While there, I helped to create ActiveReports 7, GrapeCity ActiveAnalysis, and Data Dynamics Reports.


12 thoughts on “Syntax Highlighter 1.2.2

  1. Thanx a lot James!

    Posted by torkar | May 29, 2004, 5:50 am
  2. Hmm wel starting with 0 works fine now.

    But going from 9 to 10 makes things look a bit funky still πŸ™‚

    Or is it my css or something else?

    Posted by torkar | May 29, 2004, 5:58 am
  3. We want more Jambo posts – no Jambo posts since 20th May! Go Jambo Go!!!


    Posted by Nish | June 1, 2004, 1:21 am
  4. Yeah, its been a while…I’ve been working on a new project lately…a non-coding project πŸ˜€

    Hopefully I can get it ready within the next week or so.

    Posted by James T. Johnson | June 1, 2004, 1:36 am
  5. thx a lot,Jams.
    But a rightlinenumber can’t appear in my page! I can not fine what error in it,please help me.

    Posted by marvinux | November 27, 2004, 3:47 am
  6. I’m just experiensing with different blog software, plugins and templates
    and I’ve been looking for good syntax hilight plugin. This seems to be
    excellent (others do not work or work poorly)!

    But how do I get my code inside gray box like you have?
    E.g. listview example here:

    The whole ListView.SelectedIndexCollection… thing
    is inside gray box. Makes it easy to read. I want that too,
    but cannot figure out the easy way to do it.

    Posted by Javir | January 31, 2005, 5:58 am
  7. From an e-mail I sent to Javir:

    Hi Javir,

    You need to add some additional CSS to your wp-layout.css file to get the grey box to display. In between the lines of “======” below I’ve copied what I am using in mine. Place that in your wp-layout.css file and you should be good to go.


    pre {
    	background-color: #eee;
    	border-width: 1px;
    	border-color: gray;
    	border-style: solid;
    	padding-left: 5px;
    	padding-top: 2px;
    	padding-bottom: 2px;
    pre, pre span {
    	line-height: 110%;
    	font-size: 11px;
    	font-family: Courier New, monospace;
    pre .linenumber {
    	color: gray;
    	border-right: 1px solid gray;
    pre .comment {
    	color: green;
    pre .keyword {
    	color: blue;
    pre .number {
    	color: red;
    pre .string {
    	color: #990000;
    code {
    	color: #990000;


    Hope that helps

    Posted by James T. Johnson | January 31, 2005, 3:06 pm
  8. Great code! I integrated it into a Wiki (MediaWiki) to provide C# syntax coloring and it works flawlessly!

    Posted by Gunnar Liljas | May 18, 2006, 7:36 am
  9. I like it very much, how about using it in commercial projects ?

    Posted by feha | September 4, 2006, 8:34 am
  10. You are free to use the code however you wish. If I didn’t state it in the code; the Syntax Highlighter uses the FreeBSD license.

    Posted by james | September 4, 2006, 11:25 am
  11. Hi James,
    Unable to download code. seems link is broken. could you please check it out.

    Posted by Anish | September 21, 2008, 1:13 am
  12. I’ve updated the link to the correct site.

    Posted by James | September 22, 2008, 3:31 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: