github-linguist 4.7.4 → 4.7.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,19 @@
1
1
  module Linguist
2
2
  module Strategy
3
3
  class Modeline
4
- EmacsModeline = /-\*-\s*(?:(?!mode)[\w-]+\s*:\s*(?:[\w+-]+)\s*;?\s*)*(?:mode\s*:)?\s*([\w+-]+)\s*(?:;\s*(?!mode)[\w-]+\s*:\s*[\w+-]+\s*)*;?\s*-\*-/i
5
- VimModeline = /vim:\s*set.*\s(?:ft|filetype)=(\w+)\s?.*:/i
4
+ EMACS_MODELINE = /-\*-\s*(?:(?!mode)[\w-]+\s*:\s*(?:[\w+-]+)\s*;?\s*)*(?:mode\s*:)?\s*([\w+-]+)\s*(?:;\s*(?!mode)[\w-]+\s*:\s*[\w+-]+\s*)*;?\s*-\*-/i
5
+
6
+ # First form vim modeline
7
+ # [text]{white}{vi:|vim:|ex:}[white]{options}
8
+ # ex: 'vim: syntax=perl'
9
+ VIM_MODELINE_1 = /(?:vim|vi|ex):\s*(?:ft|filetype|syntax)=(\w+)\s?/i
10
+
11
+ # Second form vim modeline (compatible with some versions of Vi)
12
+ # [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
13
+ # ex: 'vim set syntax=perl:'
14
+ VIM_MODELINE_2 = /(?:vim|vi|Vim|ex):\s*se(?:t)?.*\s(?:ft|filetype|syntax)=(\w+)\s?.*:/i
15
+
16
+ MODELINES = [EMACS_MODELINE, VIM_MODELINE_1, VIM_MODELINE_2]
6
17
 
7
18
  # Public: Detects language based on Vim and Emacs modelines
8
19
  #
@@ -22,7 +33,7 @@ module Linguist
22
33
  #
23
34
  # Returns a String or nil
24
35
  def self.modeline(data)
25
- match = data.match(EmacsModeline) || data.match(VimModeline)
36
+ match = MODELINES.map { |regex| data.match(regex) }.reject(&:nil?).first
26
37
  match[1] if match
27
38
  end
28
39
  end
@@ -1,3 +1,3 @@
1
1
  module Linguist
2
- VERSION = "4.7.4"
2
+ VERSION = "4.7.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-linguist
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.4
4
+ version: 4.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: charlock_holmes