TextMate: Local CSS Validation
Categories: Uncategorized
Although TextMate comes with a built in CSS validation command it would sometimes fail for me depending on where I was working from (some locations have proxy software on the main router). I rewrote the command in the style of the PHP-HTML validator I posted earlier. You can add more validation options using -F
. I’ve only used this script on CSS only files, it might not work on inline CSS in HTML documents.
[code lang=”bash”]#!/usr/bin/env ruby -wKU
scope = STDIN.read
scope.gsub!(/< /?style.*?>/, ”)
open(‘|curl -sF file=@-;type=text/css -F lang=en http://jigsaw.w3.org/css-validator/validator’, ‘r+’) do |io|
io < < scope
io.close_write
while io.gets
$_.gsub!(//, ‘&’)
print $_
end
end
[/code]