Highlight.js: Update and add languages

This commit is contained in:
Andrei Marcu 2020-03-12 16:35:50 -07:00
parent 53e7aa4568
commit 7212cd6555
4 changed files with 85 additions and 143 deletions

View File

@ -100,7 +100,7 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request, fileNam
bytes, err := ioutil.ReadAll(reader)
if err == nil {
extra["extension"] = extension
extra["lang_hl"], extra["lang_ace"] = extensionToHlAndAceLangs(extension)
extra["lang_hl"] = extensionToHlLang(extension)
extra["contents"] = string(bytes)
tpl = Templates["display/bin.html"]
}

View File

@ -2,102 +2,71 @@
/* Tomorrow Comment */
.hljs-comment,
.hljs-title {
.hljs-quote {
color: #8e908c;
}
/* Tomorrow Red */
.hljs-variable,
.hljs-attribute,
.hljs-template-variable,
.hljs-tag,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class,
.hljs-regexp,
.ruby .hljs-constant,
.xml .hljs-tag .hljs-title,
.xml .hljs-pi,
.xml .hljs-doctype,
.html .hljs-doctype,
.css .hljs-id,
.css .hljs-class,
.css .hljs-pseudo {
.hljs-deletion {
color: #c82829;
}
/* Tomorrow Orange */
.hljs-number,
.hljs-preprocessor,
.hljs-pragma,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params,
.hljs-constant {
.hljs-meta,
.hljs-link {
color: #f5871f;
}
/* Tomorrow Yellow */
.ruby .hljs-class .hljs-title,
.css .hljs-rules .hljs-attribute {
.hljs-attribute {
color: #eab700;
}
/* Tomorrow Green */
.hljs-string,
.hljs-value,
.hljs-inheritance,
.hljs-header,
.ruby .hljs-symbol,
.xml .hljs-cdata {
.hljs-symbol,
.hljs-bullet,
.hljs-addition {
color: #718c00;
}
/* Tomorrow Aqua */
.css .hljs-hexcolor {
color: #3e999f;
}
/* Tomorrow Blue */
.hljs-function,
.python .hljs-decorator,
.python .hljs-title,
.ruby .hljs-function .hljs-title,
.ruby .hljs-title .hljs-keyword,
.perl .hljs-sub,
.javascript .hljs-title,
.coffeescript .hljs-title {
.hljs-title,
.hljs-section {
color: #4271ae;
}
/* Tomorrow Purple */
.hljs-keyword,
.javascript .hljs-function {
.hljs-selector-tag {
color: #8959a8;
}
.hljs {
display: block;
overflow-x: auto;
background: white;
color: #4d4d4c;
padding: 0.5em;
}
.hljs-line-numbers {
text-align: right;
border-right: 1px solid #ccc;
margin-right: 5px;
color: #999;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
.hljs-emphasis {
font-style: italic;
}
.coffeescript .javascript,
.javascript .xml,
.tex .hljs-formula,
.xml .javascript,
.xml .vbscript,
.xml .css,
.xml .hljs-cdata {
opacity: 0.5;
}
.hljs-strong {
font-weight: bold;
}

File diff suppressed because one or more lines are too long

143
util.go
View File

@ -1,15 +1,10 @@
package main
func extensionToHlAndAceLangs(extension string) (hlExt, aceExt string) {
func extensionToHlLang(extension string) (hlExt string) {
hlExt, exists := extensionToHl[extension]
if !exists {
hlExt = "text"
}
aceExt, exists = extensionToAce[extension]
if !exists {
aceExt = "text"
}
return
}
@ -18,83 +13,63 @@ func supportedBinExtension(extension string) bool {
return exists
}
var extensionToAce = map[string]string{
"c": "c_cpp",
"h": "c_cpp",
"cpp": "c_cpp",
"clj": "clojure",
"coffee": "coffee",
"cfc": "coldfusion",
"cs": "csharp",
"sh": "sh",
"bash": "sh",
"css": "css",
"go": "golang",
"diff": "diff",
"html": "html",
"xml": "xml",
"ini": "ini",
"java": "java",
"js": "javascript",
"json": "json",
"jsp": "jsp",
"tex": "latex",
"lisp": "lisp",
"less": "less",
"lua": "lua",
"md": "markdown",
"ocaml": "ocaml",
"tcl": "tcl",
"yaml": "yaml",
"php": "php",
"pl": "perl",
"py": "python",
"rb": "ruby",
"sql": "sql",
"apache": "apache",
"cmake": "cmake",
"bat": "dos",
"scala": "scala",
"txt": "text",
}
var extensionToHl = map[string]string{
"c": "cpp",
"h": "cpp",
"cpp": "c_cpp",
"clj": "clojure",
"coffee": "coffee",
"cfc": "coldfusion",
"cs": "csharp",
"sh": "sh",
"bash": "sh",
"css": "css",
"go": "go",
"diff": "diff",
"html": "html",
"htm": "html",
"ini": "ini",
"java": "java",
"js": "javascript",
"json": "json",
"jsp": "jsp",
"tex": "latex",
"lisp": "lisp",
"less": "less",
"lua": "lua",
"ocaml": "ocaml",
"tcl": "tcl",
"nginx": "nginx",
"xml": "xml",
"yaml": "yaml",
"php": "php",
"pl": "perl",
"py": "python",
"rb": "ruby",
"sql": "sql",
"apache": "apache",
"cmake": "cmake",
"bat": "dos",
"scala": "scala",
"txt": "text",
"ahk": "autohotkey",
"apache": "apache",
"applescript": "applescript",
"bas": "basic",
"bash": "sh",
"bat": "dos",
"c": "cpp",
"cfc": "coldfusion",
"clj": "clojure",
"cmake": "cmake",
"coffee": "coffee",
"cpp": "c_cpp",
"cs": "csharp",
"css": "css",
"d": "d",
"dart": "dart",
"diff": "diff",
"dockerfile": "dockerfile",
"elm": "elm",
"erl": "erlang",
"for": "fortran",
"go": "go",
"h": "cpp",
"htm": "html",
"html": "html",
"ini": "ini",
"java": "java",
"js": "javascript",
"json": "json",
"jsp": "jsp",
"kt": "kotlin",
"less": "less",
"lisp": "lisp",
"lua": "lua",
"m": "objectivec",
"nginx": "nginx",
"ocaml": "ocaml",
"php": "php",
"pl": "perl",
"proto": "protobuf",
"ps": "powershell",
"py": "python",
"rb": "ruby",
"rs": "rust",
"scala": "scala",
"scm": "scheme",
"scpt": "applescript",
"scss": "scss",
"sh": "sh",
"sql": "sql",
"tcl": "tcl",
"tex": "latex",
"toml": "ini",
"ts": "typescript",
"txt": "text",
"xml": "xml",
"yaml": "yaml",
"yml": "yaml",
}