From eaa03e15ed81bc962812f069ccf92f60ca7d33d4 Mon Sep 17 00:00:00 2001 From: Edmundo Ruiz Date: Tue, 3 Feb 2015 21:09:32 -0800 Subject: [PATCH] Improved Heuristics for .asc files. --- lib/linguist/heuristics.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index 578dc872..0986e2f0 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -151,12 +151,15 @@ module Linguist end disambiguate "AsciiDoc", "AGS Script", "Public Key" do |data| - if /^=+(\s|\n)/.match(data) + if /^[=-]+(\s|\n)|{{[A-Za-z]/.match(data) Language["AsciiDoc"] - elsif /^((\/\/)|((import|export)\s+)?(function|int|float|char)\s+((room|repeatedly|on|game)_)?([A-Za-z]+[A-Za-z_0-9]+))\s*[;\(]?/.match(data) + elsif /^(\/\/.+|((import|export)\s+)?(function|int|float|char)\s+((room|repeatedly|on|game)_)?([A-Za-z]+[A-Za-z_0-9]+)\s*[;\(])/.match(data) Language["AGS Script"] - else /^-----BEGIN/.match(data) + elsif /^-----BEGIN/.match(data) Language["Public Key"] + else + # Plain text can also be AsciiDoc. + Language["AsciiDoc"] end end