Monthly Archive for March, 2008

It is impossible to validate local PHP files via the built in W3C validation that the TextMate HTML bundle provides because it does not parse the PHP code in the PHP document. I’ve modified the default validation script to retrieve the file using OS X’s built in apache server (the script assumes you have your files in the


directory) so it will work for not only PHP, but any apache-interpreted language. I’ve added the


option to the W3C validator, you can add/remove any validation options to the


command as you see fit.

#!/usr/bin/env ruby -wKU
STDOUT.sync = true

page = `echo $TM_FILEPATH | sed "s|.*/$USER/Sites/|http://localhost/~$USER/|" | xargs curl -s`

open('|curl -sF uploaded_file=@-\;type=text/html -F ss=1', 'r+') do |io|
    io < < page; io.close_write
    while io.gets
        $_.gsub!(/<\/title>/, '\&<base href="">')
        puts $_

Hope everyone had a blessed and happy easter!

Average Rating: 4.5 out of 5 based on 245 user reviews.