Add a lot of extension to language mappings for syntax highlights (#7741)

Data partially based on [CodeMirror's meta.js](https://github.com/codemirror/CodeMirror/blob/master/mode/meta.js).

Fixes: https://github.com/go-gitea/gitea/issues/6057
This commit is contained in:
silverwind 2019-08-05 17:48:31 +02:00 committed by Lunny Xiao
parent 7b009626da
commit 1d8915ad5d
1 changed files with 79 additions and 35 deletions

View File

@ -27,49 +27,93 @@ var (
} }
// Extensions that are same as highlight classes. // Extensions that are same as highlight classes.
// See hljs.listLanguages() for list of language names.
highlightExts = map[string]struct{}{ highlightExts = map[string]struct{}{
".arm": {}, ".applescript": {},
".as": {}, ".arm": {},
".sh": {}, ".as": {},
".cs": {}, ".bash": {},
".cpp": {}, ".bat": {},
".c": {}, ".c": {},
".css": {}, ".cmake": {},
".cmake": {}, ".cpp": {},
".bat": {}, ".cs": {},
".dart": {}, ".css": {},
".patch": {}, ".dart": {},
".erl": {}, ".diff": {},
".go": {}, ".django": {},
".html": {}, ".go": {},
".xml": {}, ".gradle": {},
".hs": {}, ".groovy": {},
".ini": {}, ".haml": {},
".json": {}, ".handlebars": {},
".java": {}, ".html": {},
".js": {}, ".ini": {},
".less": {}, ".java": {},
".lua": {}, ".json": {},
".php": {}, ".less": {},
".py": {}, ".lua": {},
".rb": {}, ".php": {},
".rs": {}, ".scala": {},
".scss": {}, ".scss": {},
".sql": {}, ".sql": {},
".scala": {}, ".swift": {},
".swift": {}, ".ts": {},
".ts": {}, ".xml": {},
".vb": {}, ".yaml": {},
".yml": {},
".yaml": {},
} }
// Extensions that are not same as highlight classes. // Extensions that are not same as highlight classes.
highlightMapping = map[string]string{ highlightMapping = map[string]string{
".txt": "nohighlight", ".ahk": "autohotkey",
".crmsh": "crmsh",
".dash": "shell",
".erl": "erlang",
".escript": "erlang", ".escript": "erlang",
".ex": "elixir", ".ex": "elixir",
".exs": "elixir", ".exs": "elixir",
".f": "fortran",
".f77": "fortran",
".f90": "fortran",
".f95": "fortran",
".feature": "gherkin",
".fish": "shell",
".for": "fortran",
".hbs": "handlebars",
".hs": "haskell",
".hx": "haxe",
".js": "javascript",
".jsx": "javascript",
".ksh": "shell",
".kt": "kotlin",
".l": "ocaml",
".ls": "livescript",
".md": "markdown",
".mjs": "javascript",
".mli": "ocaml",
".mll": "ocaml",
".mly": "ocaml",
".patch": "diff",
".pl": "perl",
".pm": "perl",
".ps1": "powershell",
".psd1": "powershell",
".psm1": "powershell",
".py": "python",
".pyw": "python",
".rb": "ruby",
".rs": "rust",
".scpt": "applescript",
".scptd": "applescript",
".sh": "bash",
".tcsh": "shell",
".ts": "typescript",
".tsx": "typescript",
".txt": "plaintext",
".vb": "vbnet",
".vbs": "vbscript",
".yml": "yaml",
".zsh": "shell",
} }
) )