Skip to content

Instantly share code, notes, and snippets.

@jjulian
Created May 27, 2010 14:08
Show Gist options
  • Save jjulian/415835 to your computer and use it in GitHub Desktop.
Save jjulian/415835 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'cgi'
# EDIT ME! PATH TO YOUR jslint.js file
lint = `java org.mozilla.javascript.tools.shell.Main ~/Library/JSLint/jslint.js "$TM_FILEPATH"`
lint.gsub!(/^(Lint at.+?:)(.+?)\n(?:(.+?)\n\n)?/m) do
"<p><strong>#{CGI.escapeHTML($1)}</strong>#{CGI.escapeHTML($2)}</p>" <<
($3 ? "<pre>#{CGI.escapeHTML($3)}</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;
}
</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