Skip to content

Instantly share code, notes, and snippets.

@perifer
Created March 26, 2009 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perifer/86065 to your computer and use it in GitHub Desktop.
Save perifer/86065 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'cgi'
require ENV['TM_SUPPORT_PATH'] + '/lib/escape'
FILEPATH = ENV['TM_FILEPATH']
lint = `~/Library/JSLint/jslint.sh`
lint.gsub!(/^Lint at line (\d*) character (\d*):(.+?)\n(?:(.+?)\n\n)?/m) do
"<p><span>Lint at <a href=\"txmt://open?url=file://#{e_url FILEPATH}&line=#{$1}&column=#{$2}\">line #{CGI.escapeHTML($1)}</a>:</span><span class=\"message\">#{CGI.escapeHTML($3)}<span></p>" <<
($3 ? "<pre>#{CGI.escapeHTML($4)}</pre>" : '')
end
lint.gsub!(/^(jslint:)(.+?)$/, '<p><strong>\1</strong>\2</p>')
print <<HTML
<!doctype>
<html>
<head>
<style type="text/css">
p { margin-bottom: 0; }
pre {
background: #f5f5f5;
border: 1px solid #cfcfcf;
font-size: 12px;
margin-top: 2px;
padding: 2px 4px;
}
a {text-decoration:none; color: #1FA8E4}
.message {color: #C76136}
</style>
</head>
<body>
#{lint}
</body>
</html>
HTML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment