mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	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:
		| @@ -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. | ||||
|   | ||||
| @@ -264,6 +264,8 @@ module Linguist | ||||
|         Language["Markdown"] | ||||
|       elsif /^(;;|\(define_)/.match(data) | ||||
|         Language["GCC machine description"] | ||||
|       else | ||||
|         Language["Markdown"] | ||||
|       end | ||||
|     end | ||||
|  | ||||
|   | ||||
							
								
								
									
										1
									
								
								samples/Markdown/minimal.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								samples/Markdown/minimal.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| _This_ is a **Markdown** readme. | ||||
		Reference in New Issue
	
	Block a user