mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge pull request #1639 from pchaigno/asc
Heuristic rule to detect AsciiDoc files
This commit is contained in:
@@ -25,6 +25,9 @@ module Linguist
|
||||
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
|
||||
result = disambiguate_cl(data, languages)
|
||||
end
|
||||
if languages.all? { |l| ["AsciiDoc", "AGS Script"].include?(l) }
|
||||
result = disambiguate_asc(data, languages)
|
||||
end
|
||||
return result
|
||||
end
|
||||
end
|
||||
@@ -88,6 +91,12 @@ module Linguist
|
||||
matches
|
||||
end
|
||||
|
||||
def self.disambiguate_asc(data, languages)
|
||||
matches = []
|
||||
matches << Language["AsciiDoc"] if /^=+(\s|\n)/.match(data)
|
||||
matches
|
||||
end
|
||||
|
||||
def self.active?
|
||||
!!ACTIVE
|
||||
end
|
||||
|
||||
@@ -77,6 +77,12 @@ class TestHeuristcs < Test::Unit::TestCase
|
||||
assert_equal Language["IDL"], results.first
|
||||
end
|
||||
|
||||
def test_asc_asciidoc_by_heuristics
|
||||
languages = ["AGS Script", "AsciiDoc"]
|
||||
results = Heuristics.disambiguate_asc(fixture("AsciiDoc/list.asc"), languages)
|
||||
assert_equal Language["AsciiDoc"], results.first
|
||||
end
|
||||
|
||||
def test_ts_typescript_by_heuristics
|
||||
languages = ["TypeScript", "XML"]
|
||||
results = Heuristics.disambiguate_ts(fixture("TypeScript/classes.ts"), languages)
|
||||
|
||||
Reference in New Issue
Block a user