From 265b6f17caeccdd13bac40a47f36ff04008abed6 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 16 Dec 2020 23:52:30 +0000 Subject: [PATCH] Improve syntax highlighting --- .../custom/opdavies/assets/css/tailwind.pcss | 1 - web/themes/custom/opdavies/assets/js/app.js | 15 ++++++++++++++- web/themes/custom/opdavies/package-lock.json | 9 ++++----- web/themes/custom/opdavies/package.json | 4 ++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/web/themes/custom/opdavies/assets/css/tailwind.pcss b/web/themes/custom/opdavies/assets/css/tailwind.pcss index c4adf24..007a864 100644 --- a/web/themes/custom/opdavies/assets/css/tailwind.pcss +++ b/web/themes/custom/opdavies/assets/css/tailwind.pcss @@ -4,7 +4,6 @@ @import 'tailwindcss/components'; @import './custom-components.pcss'; -@import 'highlightjs/styles/github-gist'; @import './libraries/hljs.pcss'; @import 'tailwindcss/utilities'; diff --git a/web/themes/custom/opdavies/assets/js/app.js b/web/themes/custom/opdavies/assets/js/app.js index 7bd6bda..f812cd2 100644 --- a/web/themes/custom/opdavies/assets/js/app.js +++ b/web/themes/custom/opdavies/assets/js/app.js @@ -1,7 +1,20 @@ import 'alpinejs' import 'focus-visible' import 'styles/tailwind.pcss' -import hljs from 'highlightjs' +import hljs from 'highlight.js/lib/core' +import 'highlight.js/styles/hybrid.css' + +import bash from 'highlight.js/lib/languages/bash' +import ini from 'highlight.js/lib/languages/ini' +import javascript from 'highlight.js/lib/languages/javascript' +import php from 'highlight.js/lib/languages/php' +import yaml from 'highlight.js/lib/languages/yaml' + +hljs.registerLanguage('bash', bash); +hljs.registerLanguage('ini', ini); +hljs.registerLanguage('javascript', javascript); +hljs.registerLanguage('php', php); +hljs.registerLanguage('yaml', yaml); document.addEventListener('DOMContentLoaded', event => { document.querySelectorAll('pre code').forEach(block => { diff --git a/web/themes/custom/opdavies/package-lock.json b/web/themes/custom/opdavies/package-lock.json index b262ae5..8e61528 100644 --- a/web/themes/custom/opdavies/package-lock.json +++ b/web/themes/custom/opdavies/package-lock.json @@ -4488,11 +4488,10 @@ "integrity": "sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==", "dev": true }, - "highlightjs": { - "version": "9.16.2", - "resolved": "https://registry.npmjs.org/highlightjs/-/highlightjs-9.16.2.tgz", - "integrity": "sha512-FK1vmMj8BbEipEy8DLIvp71t5UsC7n2D6En/UfM/91PCwmOpj6f2iu0Y0coRC62KSRHHC+dquM2xMULV/X7NFg==", - "dev": true + "highlight.js": { + "version": "10.4.1", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.4.1.tgz", + "integrity": "sha512-yR5lWvNz7c85OhVAEAeFhVCc/GV4C30Fjzc/rCP0aCWzc1UUOPUk55dK/qdwTZHBvMZo+eZ2jpk62ndX/xMFlg==" }, "hmac-drbg": { "version": "1.0.1", diff --git a/web/themes/custom/opdavies/package.json b/web/themes/custom/opdavies/package.json index 1a01c32..141baa5 100644 --- a/web/themes/custom/opdavies/package.json +++ b/web/themes/custom/opdavies/package.json @@ -13,7 +13,6 @@ "alpinejs": "^2.3.5", "autoprefixer": "^9.8.0", "elliptic": ">=6.5.3", - "highlightjs": "^9.16.2", "lodash": ">=4.17.19", "postcss-import": "^12.0.1", "postcss-loader": "^3.0.0", @@ -22,6 +21,7 @@ "webpack-notifier": "^1.8.0" }, "dependencies": { - "focus-visible": "^5.1.0" + "focus-visible": "^5.1.0", + "highlight.js": "^10.4.1" } }