Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.86 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env ruby
  2. require 'cgi'
  3.  
  4. lint = `java org.mozilla.javascript.tools.shell.Main ~/Library/JSLint/jslint.js "$TM_FILEPATH"`
  5.  
  6. lint.gsub!(/^(Lint at line )(\d+)(.+?:)(.+?)\n(?:(.+?)\n\n)?/m) do
  7.   "<p><strong>#{CGI.escapeHTML($1)}<a href=\"txmt://open?url=file://TM_FILEPATH&line=#{CGI.escapeHTML($2)}\">#{CGI.escapeHTML($2)}</a>#{CGI.escapeHTML($3)}</strong>#{CGI.escapeHTML($4)}" <<
  8.     ($5 ? "<pre>#{CGI.escapeHTML($5)}</pre>" : '')
  9. end
  10.  
  11. lint.gsub!(/^(jslint:)(.+?)$/, '<p><strong>\1</strong>\2</p>')
  12. lint.gsub!(/TM_FILEPATH/, ENV['TM_FILEPATH'])
  13.  
  14. print <<HTML
  15. <!doctype>
  16. <html>
  17. <head>
  18.   <style type="text/css">
  19.     p { margin-bottom: 0; }
  20.     pre {
  21.       background: #f5f5f5;
  22.       border: 1px solid #cfcfcf;
  23.       font-size: 12px;
  24.       margin-top: 2px;
  25.       padding: 2px 4px;
  26.     }
  27.   </style>
  28. </head>
  29. <body>
  30.   #{lint}
  31. </body>
  32. </html>
  33. HTML