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) }
|
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
|
||||||
result = disambiguate_cl(data, languages)
|
result = disambiguate_cl(data, languages)
|
||||||
end
|
end
|
||||||
|
if languages.all? { |l| ["AsciiDoc", "AGS Script"].include?(l) }
|
||||||
|
result = disambiguate_asc(data, languages)
|
||||||
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -88,6 +91,12 @@ module Linguist
|
|||||||
matches
|
matches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.disambiguate_asc(data, languages)
|
||||||
|
matches = []
|
||||||
|
matches << Language["AsciiDoc"] if /^=+(\s|\n)/.match(data)
|
||||||
|
matches
|
||||||
|
end
|
||||||
|
|
||||||
def self.active?
|
def self.active?
|
||||||
!!ACTIVE
|
!!ACTIVE
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ class TestHeuristcs < Test::Unit::TestCase
|
|||||||
assert_equal Language["IDL"], results.first
|
assert_equal Language["IDL"], results.first
|
||||||
end
|
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
|
def test_ts_typescript_by_heuristics
|
||||||
languages = ["TypeScript", "XML"]
|
languages = ["TypeScript", "XML"]
|
||||||
results = Heuristics.disambiguate_ts(fixture("TypeScript/classes.ts"), languages)
|
results = Heuristics.disambiguate_ts(fixture("TypeScript/classes.ts"), languages)
|
||||||
|
|||||||
Reference in New Issue
Block a user