diff --git a/.travis.yml b/.travis.yml index ac6800a7..7b013349 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ before_install: - git fetch origin master:master - git fetch origin v2.0.0:v2.0.0 - git fetch origin test/attributes:test/attributes + - git fetch origin test/master:test/master - sudo apt-get install libicu-dev -y rvm: - 1.9.3 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee13ae71..d0884dab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ This can usually be solved either by adding a new filename or file name extensio Assuming your code is being detected as the right language (see above), in most cases this is due to a bug in the language grammar rather than a bug in Linguist. [`grammars.yml`][grammars] lists all the grammars we use for syntax highlighting on github.com. Find the one corresponding to your code's programming language and submit a bug report upstream. -You can also try to fix the bug yourself and submit a Pull Request. [This piece from TextMate's documentation](http://manual.macromates.com/en/language_grammars) offers a good introduction on how to work with TextMate-compatible grammars. +You can also try to fix the bug yourself and submit a Pull Request. [This piece from TextMate's documentation](http://manual.macromates.com/en/language_grammars) offers a good introduction on how to work with TextMate-compatible grammars. You can test grammars using [Lightshow](https://lightshow.githubapp.com). Once the bug has been fixed upstream, please let us know and we'll pick it up for GitHub. diff --git a/Gemfile b/Gemfile index 481a4c6e..c804a77a 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,4 @@ source 'https://rubygems.org' gemspec :name => "github-linguist" gemspec :name => "github-linguist-grammars" gem 'test-unit', require: false if RUBY_VERSION >= '2.2' +gem 'byebug' diff --git a/github-linguist.gemspec b/github-linguist.gemspec index 463275f2..578e823c 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.add_dependency 'charlock_holmes', '~> 0.7.3' s.add_dependency 'escape_utils', '~> 1.0.1' s.add_dependency 'mime-types', '>= 1.19' - s.add_dependency 'rugged', '~> 0.22.0b1' + s.add_dependency 'rugged', '~> 0.22.0b4' s.add_development_dependency 'mocha' s.add_development_dependency 'pry' diff --git a/grammars.yml b/grammars.yml index f7d33fff..10361eef 100644 --- a/grammars.yml +++ b/grammars.yml @@ -5,8 +5,6 @@ http://svn.textmate.org/trunk/Review/Bundles/BlitzMax.tmbundle: - source.blitzmax http://svn.textmate.org/trunk/Review/Bundles/Cython.tmbundle: - source.cython -http://svn.textmate.org/trunk/Review/Bundles/F%20Sharp.tmbundle: -- source.fsharp http://svn.textmate.org/trunk/Review/Bundles/Forth.tmbundle: - source.forth http://svn.textmate.org/trunk/Review/Bundles/Parrot.tmbundle: @@ -38,6 +36,8 @@ https://github.com/Drako/SublimeBrainfuck/raw/master/Brainfuck.tmLanguage: - source.bf https://github.com/JohnNilsson/awk-sublime/raw/master/AWK.tmLanguage: - source.awk +https://github.com/JonBons/Sublime-SQF-Language: +- source.sqf https://github.com/MarioRicalde/SCSS.tmbundle: - source.scss https://github.com/Oldes/Sublime-REBOL: @@ -97,6 +97,8 @@ https://github.com/bholt/chapel-tmbundle: - source.chapel https://github.com/brandonwamboldt/sublime-nginx: - source.nginx +https://github.com/bro/bro-sublime: +- source.bro https://github.com/carsonoid/sublime_man_page_support/raw/master/man-groff.tmLanguage: - text.groff https://github.com/ccreutzig/sublime-MuPAD: @@ -131,6 +133,8 @@ https://github.com/euler0/sublime-glsl/raw/master/GLSL.tmLanguage: - source.glsl https://github.com/fancy-lang/fancy-tmbundle: - source.fancy +https://github.com/fsharp/fsharpbinding: +- source.fsharp https://github.com/gingerbeardman/monkey.tmbundle: - source.monkey https://github.com/guillermooo/dart-sublime-bundle/raw/master/Dart.tmLanguage: @@ -215,9 +219,6 @@ https://github.com/slavapestov/factor/raw/master/misc/Factor.tmbundle/Syntaxes/F - source.factor https://github.com/slim-template/ruby-slim.tmbundle: - text.slim -https://github.com/smiledawgg/Bro.tmbundle: -- source.bro -- source.bro.sig https://github.com/staltz/SublimeXtend: - source.xtend https://github.com/statatmbundle/Stata.tmbundle: diff --git a/lib/linguist/file_blob.rb b/lib/linguist/file_blob.rb index bc475023..04441935 100644 --- a/lib/linguist/file_blob.rb +++ b/lib/linguist/file_blob.rb @@ -57,14 +57,20 @@ module Linguist # # Returns a String. def extension - # File.extname returns nil if the filename is an extension. - extension = File.extname(name) - basename = File.basename(name) - # Checks if the filename is an extension. - if extension.empty? && basename[0] == "." - basename - else - extension + extensions.last || "" + end + + # Public: Return an array of the file extensions + # + # >> Linguist::FileBlob.new("app/views/things/index.html.erb").extensions + # => [".html.erb", ".erb"] + # + # Returns an Array + def extensions + basename, *segments = File.basename(name).split(".") + + segments.map.with_index do |segment, index| + "." + segments[index..-1].join(".") end end end diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index f4c7a62e..b811baa5 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -106,8 +106,8 @@ module Linguist # A bit of an elegant hack. If the file is executable but extensionless, # append a "magic" extension so it can be classified with other # languages that have shebang scripts. - extension = FileBlob.new(name).extension - if extension.empty? && blob.mode && (blob.mode.to_i(8) & 05) == 05 + extensions = FileBlob.new(name).extensions + if extensions.empty? && blob.mode && (blob.mode.to_i(8) & 05) == 05 name += ".script!" end @@ -190,8 +190,13 @@ module Linguist # Returns all matching Languages or [] if none were found. def self.find_by_filename(filename) basename = File.basename(filename) - extname = FileBlob.new(filename).extension - (@filename_index[basename] + find_by_extension(extname)).compact.uniq + + # find the first extension with language definitions + extname = FileBlob.new(filename).extensions.detect do |e| + !@extension_index[e].empty? + end + + (@filename_index[basename] + @extension_index[extname]).compact.uniq end # Public: Look up Languages by file extension. diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index db9ece79..02ee451d 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -12,6 +12,10 @@ # search_term - Deprecated: Some languages maybe indexed under a # different alias. Avoid defining new exceptions. # color - CSS hex color to represent the language. +# tm_scope - The TextMate scope that represents this programming +# language. This should match one of the scopes listed in +# the grammars.yml file. Use "none" if there is no grammar +# for this language. # # Any additions or modifications (even trivial) should have corresponding # test change in `test/test_blob.rb`. @@ -45,6 +49,7 @@ APL: extensions: - .apl - .dyalog + tm_scope: none ASP: type: programming @@ -146,6 +151,7 @@ Arc: color: "#ca2afe" extensions: - .arc + tm_scope: none Arduino: type: programming @@ -162,12 +168,14 @@ AsciiDoc: - .asciidoc - .adoc - .asc + tm_scope: none AspectJ: type: programming color: "#1957b0" extensions: - .aj + tm_scope: none Assembly: type: programming @@ -185,6 +193,7 @@ Augeas: type: programming extensions: - .aug + tm_scope: none AutoHotkey: type: programming @@ -194,6 +203,7 @@ AutoHotkey: extensions: - .ahk - .ahkl + tm_scope: none AutoIt: type: programming @@ -286,6 +296,7 @@ Brightscript: type: programming extensions: - .brs + tm_scope: none Bro: type: programming @@ -359,6 +370,7 @@ CLIPS: type: programming extensions: - .clp + tm_scope: none CMake: extensions: @@ -421,6 +433,7 @@ Clean: extensions: - .icl - .dcl + tm_scope: none Clojure: type: programming @@ -449,6 +462,7 @@ CoffeeScript: extensions: - .coffee - ._coffee + - .cjsx - .cson - .iced filenames: @@ -537,6 +551,7 @@ Creole: wrap: true extensions: - .creole + tm_scope: none Crystal: type: programming @@ -606,6 +621,7 @@ Darcs Patch: extensions: - .darcspatch - .dpatch + tm_scope: none Dart: type: programming @@ -633,6 +649,7 @@ Dogescript: color: "#cca760" extensions: - .djs + tm_scope: none Dylan: type: programming @@ -648,6 +665,7 @@ E: color: "#ccce35" extensions: - .E + tm_scope: none ECL: type: programming @@ -655,6 +673,7 @@ ECL: extensions: - .ecl - .eclxml + tm_scope: none Eagle: type: markup @@ -740,6 +759,7 @@ FLUX: extensions: - .fx - .flux + tm_scope: none FORTRAN: type: programming @@ -813,11 +833,13 @@ G-code: - .g - .gco - .gcode + tm_scope: none GAMS: type: programming extensions: - .gms + tm_scope: none GAP: type: programming @@ -826,6 +848,7 @@ GAP: - .gap - .gd - .gi + tm_scope: none GAS: type: programming @@ -839,6 +862,7 @@ GDScript: type: programming extensions: - .gd + tm_scope: none GLSL: group: C @@ -925,6 +949,7 @@ Golo: color: "#f6a51f" extensions: - .golo + tm_scope: none Gosu: type: programming @@ -940,6 +965,7 @@ Grace: type: programming extensions: - .grace + tm_scope: none Grammatical Framework: type: programming @@ -956,6 +982,7 @@ Graph Modeling Language: type: data extensions: - .gml + tm_scope: none Graphviz (DOT): type: data @@ -1010,6 +1037,7 @@ HTML: - .html - .htm - .st + - .xht - .xhtml HTML+Django: @@ -1045,6 +1073,7 @@ HTTP: type: data extensions: - .http + tm_scope: none Hack: type: programming @@ -1052,6 +1081,7 @@ Hack: extensions: - .hh - .php + tm_scope: none Haml: group: HTML @@ -1074,6 +1104,7 @@ Harbour: color: "#0e60e3" extensions: - .hb + tm_scope: none Haskell: type: programming @@ -1099,6 +1130,7 @@ Hy: - .hy aliases: - hylang + tm_scope: none IDL: type: programming @@ -1114,6 +1146,7 @@ IGOR Pro: aliases: - igor - igorpro + tm_scope: none INI: type: data @@ -1134,6 +1167,7 @@ IRC log: extensions: - .irclog - .weechatlog + tm_scope: none Idris: type: programming @@ -1155,6 +1189,7 @@ Inform 7: Inno Setup: extensions: - .iss + tm_scope: none Io: type: programming @@ -1175,11 +1210,13 @@ Isabelle: color: "#fdcd00" extensions: - .thy + tm_scope: none J: type: programming extensions: - .ijs + tm_scope: none JSON: type: data @@ -1287,6 +1324,7 @@ KRL: color: "#f5c800" extensions: - .krl + tm_scope: none Kit: type: markup @@ -1320,6 +1358,7 @@ LOLCODE: extensions: - .lol color: "#cc9900" + tm_scope: none LSL: type: programming @@ -1334,6 +1373,7 @@ LabVIEW: type: programming extensions: - .lvproj + tm_scope: none Lasso: type: programming @@ -1372,12 +1412,14 @@ Liquid: type: markup extensions: - .liquid + tm_scope: none Literate Agda: type: programming group: Agda extensions: - .lagda + tm_scope: none Literate CoffeeScript: type: programming @@ -1554,6 +1596,7 @@ MediaWiki: wrap: true extensions: - .mediawiki + tm_scope: none Mercury: type: programming @@ -1568,6 +1611,7 @@ MiniD: # Legacy searchable: false extensions: - .minid # Dummy extension + tm_scope: none Mirah: type: programming @@ -1589,6 +1633,7 @@ Moocode: type: programming extensions: - .moo + tm_scope: none MoonScript: type: programming @@ -1600,6 +1645,7 @@ MoonScript: Myghty: extensions: - .myt + tm_scope: none NSIS: extensions: @@ -1645,6 +1691,7 @@ Nit: color: "#0d8921" extensions: - .nit + tm_scope: none Nix: type: programming @@ -1652,6 +1699,7 @@ Nix: - .nix aliases: - nixos + tm_scope: none Nu: type: programming @@ -1672,6 +1720,7 @@ NumPy: - .numpy - .numpyw - .numsc + tm_scope: none OCaml: type: programming @@ -1732,6 +1781,7 @@ Omgrofl: extensions: - .omgrofl color: "#cabbff" + tm_scope: none Opa: type: programming @@ -1743,6 +1793,7 @@ Opal: color: "#f7ede0" extensions: - .opal + tm_scope: none OpenCL: type: programming @@ -1767,12 +1818,14 @@ OpenSCAD: type: programming extensions: - .scad + tm_scope: none Org: type: prose wrap: true extensions: - .org + tm_scope: none Ox: type: programming @@ -1780,12 +1833,14 @@ Ox: - .ox - .oxh - .oxo + tm_scope: none Oxygene: type: programming color: "#5a63a3" extensions: - .oxygene + tm_scope: none PAWN: type: programming @@ -1821,18 +1876,21 @@ Pan: color: '#cc0000' extensions: - .pan + tm_scope: none Papyrus: type: programming color: "#6600cc" extensions: - .psc + tm_scope: none Parrot: type: programming color: "#f3ca0a" extensions: - .parrot # Dummy extension + tm_scope: none Parrot Assembly: group: Parrot @@ -1843,6 +1901,7 @@ Parrot Assembly: - .pasm interpreters: - parrot + tm_scope: none Parrot Internal Representation: group: Parrot @@ -1898,12 +1957,14 @@ Perl6: - .pm6 interpreters: - perl6 + tm_scope: none PigLatin: type: programming color: "#fcd7de" extensions: - .pig + tm_scope: none Pike: type: programming @@ -1918,12 +1979,14 @@ Pod: wrap: true extensions: - .pod + tm_scope: none PogoScript: type: programming color: "#d80074" extensions: - .pogo + tm_scope: none PostScript: type: markup @@ -1966,6 +2029,7 @@ Propeller Spin: color: "#2b446d" extensions: - .spin + tm_scope: none Protocol Buffer: type: markup @@ -1989,6 +2053,7 @@ Pure Data: color: "#91de79" extensions: - .pd + tm_scope: none PureScript: type: programming @@ -2087,7 +2152,7 @@ RHTML: group: HTML extensions: - .rhtml - tm_scope: text.html.ruby + tm_scope: text.html.erb aliases: - html+ruby @@ -2098,6 +2163,7 @@ RMarkdown: extensions: - .rmd - .Rmd + tm_scope: none Racket: type: programming @@ -2117,6 +2183,7 @@ Ragel in Ruby Host: aliases: - ragel-rb - ragel-ruby + tm_scope: none Raw token data: search_term: raw @@ -2124,6 +2191,7 @@ Raw token data: - raw extensions: - .raw + tm_scope: none Rebol: type: programming @@ -2143,10 +2211,12 @@ Red: - .reds aliases: - red/system + tm_scope: none Redcode: extensions: - .cw + tm_scope: none RobotFramework: type: programming @@ -2221,6 +2291,7 @@ SAS: color: "#1E90FF" extensions: - .sas + tm_scope: none SCSS: type: markup @@ -2236,7 +2307,7 @@ SQF: extensions: - .sqf - .hqf - tm_scope: source.c++ + tm_scope: source.sqf SQL: type: data @@ -2316,6 +2387,7 @@ Self: color: "#0579aa" extensions: - .self + tm_scope: none Shell: type: programming @@ -2354,6 +2426,7 @@ Shen: color: "#120F14" extensions: - .shen + tm_scope: none Slash: type: programming @@ -2424,6 +2497,7 @@ Stylus: group: CSS extensions: - .styl + tm_scope: none SuperCollider: type: programming @@ -2431,6 +2505,7 @@ SuperCollider: extensions: - .scd - .sc + tm_scope: none Swift: type: programming @@ -2456,6 +2531,7 @@ TXL: type: programming extensions: - .txl + tm_scope: none Tcl: type: programming @@ -2512,6 +2588,7 @@ Textile: wrap: true extensions: - .textile + tm_scope: none Thrift: type: programming @@ -2525,6 +2602,7 @@ Turing: extensions: - .t - .tu + tm_scope: none Twig: type: markup @@ -2785,6 +2863,7 @@ Zimpl: - .zimpl - .zmpl - .zpl + tm_scope: none eC: type: programming @@ -2792,6 +2871,7 @@ eC: extensions: - .ec - .eh + tm_scope: none edn: type: data @@ -2806,6 +2886,7 @@ fish: group: Shell extensions: - .fish + tm_scope: none mupad: extensions: @@ -2846,3 +2927,4 @@ xBase: color: "#3a4040" extensions: - .prg + tm_scope: none diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index a1efbdfa..31ff7ce7 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -110,6 +110,9 @@ # MathJax - (^|/)MathJax/ +# Chart.js +- (^|/)Chart\.js$ + # Codemirror - (^|/)[Cc]ode[Mm]irror/(lib|mode|theme|addon|keymap) diff --git a/lib/linguist/version.rb b/lib/linguist/version.rb index 3dcdd2ec..6aa2f696 100644 --- a/lib/linguist/version.rb +++ b/lib/linguist/version.rb @@ -1,3 +1,3 @@ module Linguist - VERSION = "4.0.2" + VERSION = "4.0.3" end diff --git a/samples/CoffeeScript/example.cjsx b/samples/CoffeeScript/example.cjsx new file mode 100644 index 00000000..def9cf2f --- /dev/null +++ b/samples/CoffeeScript/example.cjsx @@ -0,0 +1,40 @@ +###* @cjsx React.DOM ### +define 'myProject.ReactExampleComponent', [ + 'React' + 'myProject.ExampleStore' + 'myProject.ExampleActions' + 'myProject.ReactExampleTable' +], (React, ExampleStore, ExampleActions, ReactExampleTable ) -> + + ReactExampleComponent = React.createClass + mixins: [ListenMixin] + + getInitialState: -> + rows: ExampleStore.getRows() + meta: ExampleStore.getMeta() + + componentWillMount: -> + @listenTo ExampleStore + + componentDidMount: -> + ExampleActions.getExampleData() + + onStoreChange: -> + if this.isMounted() + @setState + rows: ExampleStore.getRows() + meta: ExampleStore.getMeta() + + componentWillUnmount: -> + @stopListening ExampleStore + + render: -> +