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) bytes, err := ioutil.ReadAll(reader)
if err == nil { if err == nil {
extra["extension"] = extension extra["extension"] = extension
extra["lang_hl"], extra["lang_ace"] = extensionToHlAndAceLangs(extension) extra["lang_hl"] = extensionToHlLang(extension)
extra["contents"] = string(bytes) extra["contents"] = string(bytes)
tpl = Templates["display/bin.html"] tpl = Templates["display/bin.html"]
} }

View File

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

File diff suppressed because one or more lines are too long

107
util.go
View File

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