# A collection of simple regexp-based rules that can be applied to content # to disambiguate languages with the same file extension. # # There two top-level keys: disambiguations and named_patterns. # # disambiguations - a list of disambiguation rules, one for each # extension or group of extensions. # extensions - an array of file extensions that this block applies to. # rules - list of rules that are applied in order to the content # of a file with matching extension. Rules are evaluated # until one of them matches. If none matches, no language # is returned. # language - Language to be returned if the rule matches. # pattern - Ruby-compatible regular expression that makes the rule # match. If no pattern is specified, the rule always match. # Pattern can be a string with a single regular expression # or an array of strings that will be merged in a single # regular expression (with union). # and - An and block merges multiple rules and checks that all of # of them must match. # negative_pattern - Same as pattern, but checks for absence of matches. # named_pattern - A pattern can be reused by specifying it in the # named_patterns section and referencing it here by its # key. # named_patterns - Key-value map of reusable named patterns. # # Please keep this list alphabetized. # --- disambiguations: - extensions: ['.1', '.1in', '.1m', '.1x', '.2', '.3', '.3in', '.3m', '.3p', '.3pm', '.3qt', '.3x', '.4', '.5', '.6', '.7', '.8', '.9', '.man', '.mdoc'] rules: # Document which uses mdoc(7) macros - language: Roff Manpage and: - pattern: '^[.''][ \t]*Dd +(?:[^"\s]+|"[^"]+")' - pattern: '^[.''][ \t]*Dt +(?:[^"\s]+|"[^"]+") +"?(?:[1-9]|@[^\s@]+@)' - pattern: '^[.''][ \t]*Sh +(?:[^"\s]|"[^"]+")' # Document which uses man(7) macros - language: Roff Manpage and: - pattern: '^[.''][ \t]*TH +(?:[^"\s]+|"[^"]+") +"?(?:[1-9]|@[^\s@]+@)' - pattern: '^[.''][ \t]*SH +(?:[^"\s]+|"[^"\s]+)' # Open-ended fallback to unrendered Roff source - language: Roff - extensions: ['.as'] rules: - language: ActionScript pattern: '^\s*(package\s+[a-z0-9_\.]+|import\s+[a-zA-Z0-9_\.]+;|class\s+[A-Za-z0-9_]+\s+extends\s+[A-Za-z0-9_]+)' - language: AngelScript - extensions: ['.asc'] rules: - language: Public Key pattern: '^(----[- ]BEGIN|ssh-(rsa|dss)) ' - language: AsciiDoc pattern: '^[=-]+(\s|\n)|{{[A-Za-z]' - language: AGS Script pattern: '^(\/\/.+|((import|export)\s+)?(function|int|float|char)\s+((room|repeatedly|on|game)_)?([A-Za-z]+[A-Za-z_0-9]+)\s*[;\(])' - extensions: ['.asy'] rules: - language: LTspice Symbol pattern: '^SymbolType[ \t]' - language: Asymptote - extensions: ['.bb'] rules: - language: BlitzBasic pattern: '(<^\s*; |End Function)' - language: BitBake pattern: '^\s*(# |include|require)\b' - extensions: ['.builds'] rules: - language: XML pattern: '^(\s*)(?i:)' - language: JavaScript pattern: '(?m:\/\/|("|'')use strict\1|export\s+default\s|\/\*.*?\*\/)' - extensions: ['.f'] rules: - language: Forth pattern: '^: ' - language: Filebench WML pattern: 'flowop' - language: Fortran named_pattern: fortran - extensions: ['.for'] rules: - language: Forth pattern: '^: ' - language: Fortran named_pattern: fortran - extensions: ['.fr'] rules: - language: Forth pattern: '^(: |also |new-device|previous )' - language: Frege pattern: '^\s*(import|module|package|data|type) ' - language: Text - extensions: ['.fs'] rules: - language: Forth pattern: '^(: |new-device)' - language: 'F#' pattern: '^\s*(#light|import|let|module|namespace|open|type)' - language: GLSL pattern: '^\s*(#version|precision|uniform|varying|vec[234])' - language: Filterscript pattern: '#include|#pragma\s+(rs|version)|__attribute__' - extensions: ['.gd'] rules: - language: GAP pattern: '\s*(Declare|BindGlobal|KeyDependentOperation)' - language: GDScript pattern: '\s*(extends|var|const|enum|func|class|signal|tool|yield|assert|onready)' - extensions: ['.gml'] rules: - language: XML pattern: '(?i:^\s*(\<\?xml|xmlns))' - language: Graph Modeling Language pattern: '(?i:^\s*(graph|node)\s+\[$)' - language: Game Maker Language - extensions: ['.gs'] rules: - language: Gosu pattern: '^uses java\.' - extensions: ['.h'] rules: - language: Objective-C named_pattern: objectivec - language: C++ named_pattern: cpp - extensions: ['.hh'] rules: - language: Hack pattern: '<\?hh' - extensions: ['.ice'] rules: - language: JSON pattern: '\A\s*[{\[]' - language: Slice - extensions: ['.inc'] rules: - language: PHP pattern: '^<\?(?:php)?' - language: POV-Ray SDL pattern: '^\s*#(declare|local|macro|while)\s' - extensions: ['.l'] rules: - language: Common Lisp pattern: '\(def(un|macro)\s' - language: Lex pattern: '^(%[%{}]xs|<.*>)' - language: Roff pattern: '^\.[A-Za-z]{2}(\s|$)' - language: PicoLisp pattern: '^\((de|class|rel|code|data|must)\s' - extensions: ['.ls'] rules: - language: LoomScript pattern: '^\s*package\s*[\w\.\/\*\s]*\s*{' - language: LiveScript - extensions: ['.lsp', '.lisp'] rules: - language: Common Lisp pattern: '^\s*\((?i:defun|in-package|defpackage) ' - language: NewLisp pattern: '^\s*\(define ' - extensions: ['.m'] rules: - language: Objective-C named_pattern: objectivec - language: Mercury pattern: ':- module' - language: MUF pattern: '^: ' - language: M pattern: '^\s*;' - language: Mathematica pattern: '\*\)$' - language: MATLAB pattern: '^\s*%' - language: Limbo pattern: '^\w+\s*:\s*module\s*{' - extensions: ['.md'] rules: - language: Markdown pattern: - '(^[-A-Za-z0-9=#!\*\[|>])|<\/' - '\A\z' - language: GCC Machine Description pattern: '^(;;|\(define_)' - language: Markdown - extensions: ['.ml'] rules: - language: OCaml pattern: '(^\s*module)|let rec |match\s+(\S+\s)+with' - language: Standard ML pattern: '=> |case\s+(\S+\s)+of' - extensions: ['.mod'] rules: - language: XML pattern: '\s' - extensions: ['.pro'] rules: - language: Prolog pattern: '^[^\[#]+:-' - language: INI pattern: 'last_client=' - language: QMake and: - pattern: HEADERS - pattern: SOURCES - language: IDL pattern: '^\s*function[ \w,]+$' - extensions: ['.properties'] rules: - language: INI and: - named_pattern: key_equals_value - pattern: '^[;\[]' - language: Java Properties and: - named_pattern: key_equals_value - pattern: '^[#!]' - language: INI named_pattern: key_equals_value - language: Java properties pattern: '^[^#!][^:]*:' - extensions: ['.props'] rules: - language: XML pattern: '^(\s*)(?i:)\s*(\d{2}:\d{2}:\d{2},\d{3})$' - extensions: ['.t'] rules: - language: Perl named_pattern: perl5 - language: Perl 6 named_pattern: perl6 - language: Turing pattern: '^\s*%[ \t]+|^\s*var\s+\w+(\s*:\s*\w+)?\s*:=\s*\w+' - extensions: ['.toc'] rules: - language: World of Warcraft Addon Data pattern: '^## |@no-lib-strip@' - language: TeX pattern: '^\\(contentsline|defcounter|beamer|boolfalse)' - extensions: ['.ts'] rules: - language: XML pattern: ' ' # Heads up - we don't usually write heuristics like this (with no regex match) - language: Scilab - extensions: ['.tsx'] rules: - language: TypeScript pattern: '^\s*(import.+(from\s+|require\()[''"]react|\/\/\/\s*' - '^\s*template\s*<' - '^[ \t]*try' - '^[ \t]*catch\s*\(' - '^[ \t]*(class|(using[ \t]+)?namespace)\s+\w+' - '^[ \t]*(private|public|protected):$' - 'std::\w+' fortran: '^(?i:[c*][^abd-z]| (subroutine|program|end|data)\s|\s*!)' key_equals_value: '^[^#!;][^=]*=' objectivec: '^\s*(@(interface|class|protocol|property|end|synchronised|selector|implementation)\b|#import\s+.+\.h[">])' perl5: '\buse\s+(?:strict\b|v?5\.)' perl6: '^\s*(?:use\s+v6\b|\bmodule\b|\b(?:my\s+)?class\b)'