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.
- checksums.yaml +4 -4
- data/lib/linguist/generated.rb +30 -1
- data/lib/linguist/heuristics.rb +8 -0
- data/lib/linguist/languages.json +1 -1
- data/lib/linguist/languages.yml +32 -7
- data/lib/linguist/samples.json +1328 -467
- data/lib/linguist/strategy/modeline.rb +14 -3
- data/lib/linguist/version.rb +1 -1
- metadata +2 -2
@@ -1,8 +1,19 @@
|
|
1
1
|
module Linguist
|
2
2
|
module Strategy
|
3
3
|
class Modeline
|
4
|
-
|
5
|
-
|
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(
|
36
|
+
match = MODELINES.map { |regex| data.match(regex) }.reject(&:nil?).first
|
26
37
|
match[1] if match
|
27
38
|
end
|
28
39
|
end
|
data/lib/linguist/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2016-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: charlock_holmes
|