aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2019-08-05 17:48:31 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2019-08-05 23:48:31 +0800
commit1d8915ad5d9889c02dd98ab2c2f29aa8f5ee4dfa (patch)
treee4e079a5e0a04789a703527d3275085aae8a71a9
parent7b009626da2a8a2a46e0e205a3a7ce46cdf7ced2 (diff)
downloadgitea-1d8915ad5d9889c02dd98ab2c2f29aa8f5ee4dfa.tar.gz
gitea-1d8915ad5d9889c02dd98ab2c2f29aa8f5ee4dfa.zip
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
-rw-r--r--modules/highlight/highlight.go114
1 files changed, 79 insertions, 35 deletions
diff --git a/modules/highlight/highlight.go b/modules/highlight/highlight.go
index 4334480566..ffd88656ae 100644
--- a/modules/highlight/highlight.go
+++ b/modules/highlight/highlight.go
@@ -27,49 +27,93 @@ var (
}
// Extensions that are same as highlight classes.
+ // See hljs.listLanguages() for list of language names.
highlightExts = map[string]struct{}{
- ".arm": {},
- ".as": {},
- ".sh": {},
- ".cs": {},
- ".cpp": {},
- ".c": {},
- ".css": {},
- ".cmake": {},
- ".bat": {},
- ".dart": {},
- ".patch": {},
- ".erl": {},
- ".go": {},
- ".html": {},
- ".xml": {},
- ".hs": {},
- ".ini": {},
- ".json": {},
- ".java": {},
- ".js": {},
- ".less": {},
- ".lua": {},
- ".php": {},
- ".py": {},
- ".rb": {},
- ".rs": {},
- ".scss": {},
- ".sql": {},
- ".scala": {},
- ".swift": {},
- ".ts": {},
- ".vb": {},
- ".yml": {},
- ".yaml": {},
+ ".applescript": {},
+ ".arm": {},
+ ".as": {},
+ ".bash": {},
+ ".bat": {},
+ ".c": {},
+ ".cmake": {},
+ ".cpp": {},
+ ".cs": {},
+ ".css": {},
+ ".dart": {},
+ ".diff": {},
+ ".django": {},
+ ".go": {},
+ ".gradle": {},
+ ".groovy": {},
+ ".haml": {},
+ ".handlebars": {},
+ ".html": {},
+ ".ini": {},
+ ".java": {},
+ ".json": {},
+ ".less": {},
+ ".lua": {},
+ ".php": {},
+ ".scala": {},
+ ".scss": {},
+ ".sql": {},
+ ".swift": {},
+ ".ts": {},
+ ".xml": {},
+ ".yaml": {},
}
// Extensions that are not same as highlight classes.
highlightMapping = map[string]string{
- ".txt": "nohighlight",
+ ".ahk": "autohotkey",
+ ".crmsh": "crmsh",
+ ".dash": "shell",
+ ".erl": "erlang",
".escript": "erlang",
".ex": "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",
}
)