Created
May 4, 2011 03:42
-
-
Save davidcornu/954719 to your computer and use it in GitHub Desktop.
Textmate JSLint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'cgi' | |
lint = `/usr/local/bin/jslint4java #{ENV['TM_FILEPATH']}` | |
lrxp = Regexp.new(/jslint:.+.js:(\d+):(\d+):(.+)/i) | |
output = String.new | |
lint.split("\n").each do |error| | |
match = lrxp.match(error) | |
line = `cat #{ENV['TM_FILEPATH']} | head -#{match[1]} | tail -1` | |
output << "<p><a href='txmt://open?url=file://#{ENV['TM_FILEPATH']}&line=#{match[1]}'><b>Error at Line #{match[1]} Character #{match[2]}:</b></a> #{match[3]}</p><pre>#{CGI.escapeHTML(line).lstrip}</pre>" | |
end | |
print <<HTML | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
pre{ | |
border: 1px solid #cecece; | |
background: #eee; | |
font-size: 12px; | |
padding: 2px 4px; | |
} | |
p > a{ | |
text-decoration: none; | |
color: black; | |
} | |
p > a:hover{ | |
text-decoration: underline; | |
} | |
</style> | |
</head> | |
<body> | |
#{output} | |
</body> | |
</html> | |
HTML |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires:
brew install jslint4java
Input: Entire File
Output: HTML