Gitweb Line Highlighting


I made a few more changes today to support line highlighting of gitweb blobs. Like SyntaxHighlighter, the line highlighting is also completely JavaScript driven. When you highlight a line, it updates the fragment portion of the URL in your browser. Then when you send the URL (with the fragment) to someone, they will see the same highlighted code.

Click here for a sample of code highlighting.

Fun exercise in my quest to catch up and learn JavaScript, CSS, et al.

I couldn’t do this by modifying the query string, because that causes a browser reload when changing window.location. I could perhaps have made a “create hyperlink” button that puts the hyperlink with a modified query string into your paste buffer, but that isn’t as easy as just copying the address out of your browser address bar.


crafty said...

I think that you can alter the 'hash' portion of a url via javascript (the bit appearing after a # sign) without causing a redirect. You can use this to create bookmarkable urls - obviously need to interpret these hash links coming in to the page.

Koush said...

Yeah, that is what I did: I modify the fragment/hash.

Treviño said...

Cool. Thing. Thanks!

Another thing that I'm missing a lot is the "categorization" of the projects (by using a "category" file per repository). In the git ML there's a patch for it but I actually can't apply.

Brandon said...

clock i need your help.. i dont want to play wow anymore so i need you to work your magic and find me someone worthy of buying my account please.. i know you have connections bro

see you on vent