Prefer Markdown over GCC Machine Description (#3523)

* Add minimal Markdown sample
* Heuristic defaults to Markdown on no match
* Allow Linguist to detect empty blobs
This commit is contained in:
Yuki Izumi
2017-03-20 13:07:54 +11:00
committed by GitHub
parent 3bbfc907f3
commit 5c6f690b97
3 changed files with 5 additions and 2 deletions

View File

@@ -15,9 +15,9 @@ class << Linguist
# see Linguist::LazyBlob and Linguist::FileBlob for examples
#
# Returns Language or nil.
def detect(blob)
def detect(blob, allow_empty: false)
# Bail early if the blob is binary or empty.
return nil if blob.likely_binary? || blob.binary? || blob.empty?
return nil if blob.likely_binary? || blob.binary? || (!allow_empty && blob.empty?)
Linguist.instrument("linguist.detection", :blob => blob) do
# Call each strategy until one candidate is returned.

View File

@@ -264,6 +264,8 @@ module Linguist
Language["Markdown"]
elsif /^(;;|\(define_)/.match(data)
Language["GCC machine description"]
else
Language["Markdown"]
end
end

View File

@@ -0,0 +1 @@
_This_ is a **Markdown** readme.