mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-07 20:08:48 +00:00
@@ -287,6 +287,9 @@ module Linguist
|
||||
# See if there is a Language for the extension
|
||||
pathname.language ||
|
||||
|
||||
# Look for idioms in first line
|
||||
first_line_language ||
|
||||
|
||||
# Try to detect Language from shebang line
|
||||
shebang_language
|
||||
end
|
||||
@@ -357,6 +360,20 @@ module Linguist
|
||||
end
|
||||
end
|
||||
|
||||
# Internal: Guess language from the first line.
|
||||
#
|
||||
# Look for leading "<?php"
|
||||
#
|
||||
# Returns a Language.
|
||||
def first_line_language
|
||||
# Fail fast if blob isn't viewable?
|
||||
return unless viewable?
|
||||
|
||||
if lines.first.to_s =~ /^<\?php/
|
||||
Language['PHP']
|
||||
end
|
||||
end
|
||||
|
||||
# Internal: Extract the script name from the shebang line
|
||||
#
|
||||
# Requires Blob#data
|
||||
|
||||
Reference in New Issue
Block a user