Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality
Anya is LIVE right now
FREE
Free to watch • No registration required • HD streaming
Code Blocks Should Look a Little Better Around Here from Now on Thanks to highlight.js
I was getting pretty unhappy with the way code blocks looked on this site so I decided to see if there was something I could do about it.
It's been many years now since anyone let me within 10 feet of CSS but for starters I realized that most of my code blocks which are intended to wrap at 74 (as god intended!) were cut off by the width of the text which is intended to be easy to read. I did a little investigation and while I'd never heard of the unit before it turns out that there's a ch unit which is the width of the glyph 0 in the current font.
I use Solarized Light almost exclusively for my themes unless I'm working with a monster who runs a dark theme in whch case I'll switch over to Solarized Dark. Next step was to hit up the CSS values at Solarized's Site and get my theme to be something at a least a little bit prettier than the drab grey that it was before.
But I still wasn't happy. Whatever Keith Gregory has to say on the matter, I like syntax highlighting. While I'm ok with the base experience being nice looking if flat, if someone wants to give me some JS then it can be even better.
A bit of research and I found highlight.js. It had builtin support for Solarized Light and supported the languages I tend to write about so in classic Internet fashion I went with that. Integrating it into Tumblr was as simple as adding
function styleCode() { if (typeof disableStyleCode != 'undefined') { return; } var a = false; $('code').each(function() { if (!$(this).hasClass('Sample')) { $(this).addClass('Sample'); a = true; } }); if (a) { Sample(); } } $(function() {styleCode();});
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality
Anya is LIVE right now
FREE
Free to watch • No registration required • HD streaming
Lately I've been getting more and more snobby about my text editor of choice for writing code, but more specifically the syntax highlighting it provides. At about the same time that I started writing this blog, I tried out [Sublime Text 2 beta](http://www.sublimetext.com/) and have been hooked ever since. I've installed it on my two Ubuntu machines (work & home) and am about to install it on my Windows 7 machine (my second work laptop). At the same time, I discovered the amazing solarized dark color scheme. Since I'm so infatuated with this syntax highlighting scheme it seemed natural to set it up for my blog as well. I had zero previous experience with dynamic syntax highlighting on a blog I just Googled for a good solution that would work with Tumblr. I settled on the solution of using Google Prettify. It's also being used by Google Code and StackOverflow. The problem is that most of my "code" is Bash. For what ever reason, Google Prettify does not do a good job of marking up Bash. It was a very half ass implementation. It looked great on JavaScript, C and HTML, but was shitty for Bash which is the majority of what I post here. After seeing a new JavaScript syntax highlighter released a couple days ago called [Rainbow.js](http://craig.is/making/rainbows), I was motivated to try to find a solution that would satisfy highlighting desires. Rainbow.js was exciting, but still not my solution for Bash since only a few languages are currently supported. I Googled around a bit more and found a post by the creator of [Highlight.js](http://softwaremaniacs.org/soft/highlight/en/). His post was being a bit critical of Rainbow.js. IMHO, he has the right to be critical. His syntax highlighting JavaScript library is far above Google Prettify and is much more versatile with the languages it supports. Best of all - it provides the most thorough syntax highlighting for Bash that I've seen. It even has a built in css scheme for the solarized dark color scheme. If you're reading this then I have already fully switched over the highlighting from Google Prettify to Highlight.js. Here's a sample script to demonstrate the code highlighting. #!/bin/sh echo "Enter the address:\t\t\c" read address_raw address=$(echo "$address_raw" | sed 's/ /+/g') new_address=$(curl -s "http://maps.googleapis.com/maps/api/geocode/xml?address=$address&sensor=false" | \ grep "formatted_address" | \ sed 's/.*//g;s/<\/formatted_address>//g') echo "The validated address is:\t$new_address" The code above works. It just uses Google Maps to correct malformed addresses. Anyway...I'm much more happy now. The only feature that is missing is line numbers. I hope that feature gets added at some point but if not I'll manage. If Rainbow.js ever supports Bash I may give it a try as well.