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.
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 http://validator.w3.org/check', 'r+') do |io|
io < < page; io.close_write
$_.gsub!(/<\/title>/, '\&<base href="http://validator.w3.org/">')
Hope everyone had a blessed and happy easter!