diff --git a/assets/src/utils/highlightjs.js b/assets/src/utils/highlightjs.js --- a/assets/src/utils/highlightjs.js +++ b/assets/src/utils/highlightjs.js @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018-2020 The Software Heritage developers + * Copyright (C) 2018-2021 The Software Heritage developers * See the AUTHORS file at the top-level directory of this distribution * License: GNU Affero General Public License version 3, or any later version * See top-level LICENSE file for more information @@ -9,7 +9,7 @@ import 'highlight.js'; import 'highlightjs-line-numbers.js'; -import 'highlight.js/styles/github.css'; +import './hljs-swh-theme.css'; import './highlightjs.css'; // add alias to match hljs 10.7 new naming diff --git a/assets/src/utils/hljs-swh-theme.css b/assets/src/utils/hljs-swh-theme.css new file mode 100644 --- /dev/null +++ b/assets/src/utils/hljs-swh-theme.css @@ -0,0 +1,110 @@ +/** + * Copyright (C) 2021 The Software Heritage developers + * See the AUTHORS file at the top-level directory of this distribution + * License: GNU Affero General Public License version 3, or any later version + * See top-level LICENSE file for more information + */ + +/** + highlight.js theme adapted from its old github theme + (c) Vasily Polovnyov +*/ + +.hljs { + display: block; + overflow-x: auto; + padding: 0.5em; + color: #333; + background: #f8f8f8; +} + +.hljs-comment, +.hljs-quote { + color: #998; +} + +.hljs-quote { + font-style: italic; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-subst { + color: #333; + font-weight: bold; +} + +.hljs-number, +.hljs-literal, +.hljs-variable, +.hljs-template-variable, +.hljs-tag .hljs-attr { + color: #008080; +} + +.hljs-string, +.hljs-doctag { + color: #d14; +} + +.hljs-title, +.hljs-section, +.hljs-selector-id { + color: #900; + font-weight: bold; +} + +.hljs-subst { + font-weight: normal; +} + +.hljs-type, +.hljs-class .hljs-title, +.hljs-title.class_, +.hljs-title.class_.inherited__ { + color: #458; + font-weight: bold; +} + +.hljs-tag, +.hljs-name, +.hljs-attribute { + color: #000080; + font-weight: normal; +} + +.hljs-regexp, +.hljs-link { + color: #009926; +} + +.hljs-symbol, +.hljs-bullet { + color: #990073; +} + +.hljs-built_in, +.hljs-builtin-name { + color: #0086b3; +} + +.hljs-meta { + color: #999; + font-weight: bold; +} + +.hljs-deletion { + background: #fdd; +} + +.hljs-addition { + background: #dfd; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} diff --git a/package.json b/package.json --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "d3": "^7.0.0", "datatables.net-responsive-bs4": "^2.2.9", "dompurify": "^2.2.9", - "highlight.js": "^10.7.2", + "highlight.js": "^11.1.0", "highlightjs-line-numbers.js": "^2.8.0", "html-encoder-decoder": "^1.3.9", "iframe-resizer": "^4.3.2", diff --git a/static/json/highlightjs-languages.json b/static/json/highlightjs-languages.json --- a/static/json/highlightjs-languages.json +++ b/static/json/highlightjs-languages.json @@ -23,7 +23,6 @@ "basic", "bnf", "brainfuck", - "c-like", "c", "cal", "capnproto", @@ -80,7 +79,6 @@ "haskell", "haxe", "hsp", - "htmlbars", "http", "hy", "inform7", @@ -118,6 +116,7 @@ "monkey", "moonscript", "n1ql", + "nestedtext", "nginx", "nim", "nix", @@ -164,7 +163,6 @@ "smalltalk", "sml", "sqf", - "sql_more", "sql", "stan", "stata", @@ -187,6 +185,8 @@ "verilog", "vhdl", "vim", + "wasm", + "wren", "x86asm", "xl", "xquery", @@ -204,7 +204,6 @@ "bat": "dos", "bf": "brainfuck", "bind": "dns", - "c": "c-like", "c#": "csharp", "c++": "cpp", "capnp": "capnproto", @@ -228,11 +227,13 @@ "docker": "dockerfile", "dpr": "delphi", "dst": "dust", + "edn": "clojure", "erl": "erlang", + "ex": "elixir", + "exs": "elixir", "f90": "fortran", "f95": "fortran", "feature": "gherkin", - "freepascal": "delphi", "fs": "fsharp", "gemspec": "ruby", "gms": "gams", @@ -242,14 +243,14 @@ "gyp": "python", "h": "c", "h++": "cpp", - "hbs": "htmlbars", + "hbs": "handlebars", "hh": "cpp", "hpp": "cpp", "hs": "haskell", "html": "xml", - "html.handlebars": "htmlbars", - "html.hbs": "htmlbars", - "htmlbars": "htmlbars", + "html.handlebars": "handlebars", + "html.hbs": "handlebars", + "htmlbars": "handlebars", "https": "http", "hx": "haxe", "hxx": "cpp", @@ -270,9 +271,6 @@ "kt": "kotlin", "kts": "kotlin", "lassoscript": "lasso", - "lazarus": "delphi", - "lfm": "delphi", - "lpr": "delphi", "ls": "livescript", "m": "mercury", "mak": "makefile", @@ -289,15 +287,14 @@ "mma": "mathematica", "moo": "mercury", "moon": "moonscript", - "mysql": "sql_more", "nc": "gcode", "nginxconf": "nginx", "nixos": "nix", + "nt": "nestedtext", "obj-c": "objectivec", "obj-c++": "objectivec", "objc": "objectivec", "objective-c++": "objectivec", - "oracle": "sql_more", "osascript": "applescript", "p21": "step21", "pas": "delphi", @@ -306,13 +303,8 @@ "pb": "purebasic", "pbi": "purebasic", "pcmk": "crmsh", + "pde": "processing", "pf.conf": "pf", - "php3": "php", - "php4": "php", - "php5": "php", - "php6": "php", - "php7": "php", - "php8": "php", "pl": "perl", "plist": "xml", "pm": "perl", @@ -322,6 +314,7 @@ "pp": "puppet", "ps": "powershell", "ps1": "powershell", + "pwsh": "powershell", "py": "python", "pycon": "python-repl", "qt": "qml", @@ -332,6 +325,7 @@ "scad": "openscad", "sci": "scilab", "sh": "bash", + "shellsession": "shell", "st": "smalltalk", "stanfuncs": "stan", "step": "step21", @@ -366,7 +360,6 @@ "xsl": "xml", "yml": "yaml", "zep": "zephir", - "zone": "dns", - "zsh": "bash" + "zone": "dns" } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock --- a/yarn.lock +++ b/yarn.lock @@ -7198,10 +7198,10 @@ resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e" integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ== -highlight.js@^10.7.2: - version "10.7.2" - resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.7.2.tgz#89319b861edc66c48854ed1e6da21ea89f847360" - integrity sha512-oFLl873u4usRM9K63j4ME9u3etNF0PLiJhSQ8rdfuL51Wn3zkD6drf9ZW0dOzjnZI22YYG24z30JcmfCZjMgYg== +highlight.js@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.1.0.tgz#0198f7326e64ddfbea5f76b00e84ab542cf24ae8" + integrity sha512-X9VVhYKHQPPuwffO8jk4bP/FVj+ibNCy3HxZZNDXFtJrq4O5FdcdCDRIkDis5MiMnjh7UwEdHgRZJcHFYdzDdA== highlightjs-line-numbers.js@^2.8.0: version "2.8.0"