From 59abe002ec5a3ac6202edb166296dcbc6c2b9de6 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Mon, 10 Feb 2020 14:09:16 -0700 Subject: [PATCH] Enabled code highlighting in READMEs via highlight.js --- app/resources/js/app.js | 3 +++ app/resources/sass/app.scss | 3 +++ package-lock.json | 5 +++++ package.json | 1 + webpack.mix.js | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/resources/js/app.js b/app/resources/js/app.js index 4e0f95a..e96a7d7 100644 --- a/app/resources/js/app.js +++ b/app/resources/js/app.js @@ -19,6 +19,9 @@ const app = new Vue({ } }); +let hljs = require('highlight.js'); +hljs.initHighlightingOnLoad(); + let link = document.getElementById('scroll-to-top'); window.addEventListener('scroll', function() { if (window.scrollY > 10) { diff --git a/app/resources/sass/app.scss b/app/resources/sass/app.scss index 39828c4..ed8d8e3 100644 --- a/app/resources/sass/app.scss +++ b/app/resources/sass/app.scss @@ -9,6 +9,9 @@ $fa-font-path: "./webfonts"; @import "~@fortawesome/fontawesome-free/scss/brands.scss"; @import "~@fortawesome/fontawesome-free/scss/solid.scss"; +// Code highlighting +@import "~highlight.js/scss/github.scss"; + // Fonts @import url("https://fonts.googleapis.com/css?family=Source+Code+Pro|Work+Sans:200,400&display=swap"); diff --git a/package-lock.json b/package-lock.json index b86be99..c32a7ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4926,6 +4926,11 @@ "integrity": "sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==", "dev": true }, + "highlight.js": { + "version": "9.18.1", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.18.1.tgz", + "integrity": "sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg==" + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", diff --git a/package.json b/package.json index 04bcf3b..83064a4 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "axios": "^0.19.2", + "highlight.js": "^9.18.1", "vue": "^2.6.11" }, "devDependencies": { diff --git a/webpack.mix.js b/webpack.mix.js index 3adb28e..817bebd 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -26,7 +26,7 @@ mix.purgeCss({ extensions: ['html', 'js', 'php', 'scss', 'twig', 'vue'], folders: ['app'], whitelist: ['html', 'body', 'main', 'fab', 'far', 'fas'], - whitelistPatterns: [/^fa\-/] + whitelistPatterns: [/^fa\-/, /^hljs/] }); if (mix.inProduction()) {