]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #3636 from flozz/syntax-highlight
authorJérémy Benoist <j0k3r@users.noreply.github.com>
Thu, 7 Jun 2018 06:22:14 +0000 (06:22 +0000)
committerGitHub <noreply@github.com>
Thu, 7 Jun 2018 06:22:14 +0000 (06:22 +0000)
Highlight code in articles using highlight.js

app/Resources/static/themes/_global/index.js
app/Resources/static/themes/_global/js/highlight.js [new file with mode: 0644]
package.json

index b810e5d7358d53a13a382807e87379477079efaa..ae598e56e1374a45cb59be9b74f9d69a327e4ee1 100644 (file)
@@ -13,8 +13,10 @@ import './global.scss';
 import './js/shortcuts/entry';
 import './js/shortcuts/main';
 
-import { savePercent, retrievePercent } from './js/tools';
+/* Hightlight */
+import './js/highlight';
 
+import { savePercent, retrievePercent } from './js/tools';
 
 /* ==========================================================================
  Annotations & Remember position
diff --git a/app/Resources/static/themes/_global/js/highlight.js b/app/Resources/static/themes/_global/js/highlight.js
new file mode 100644 (file)
index 0000000..4025fc1
--- /dev/null
@@ -0,0 +1,8 @@
+import 'highlight.js/styles/atom-one-light.css';
+import * as hljs from 'highlight.js';
+
+window.addEventListener('load', () => {
+  document.querySelectorAll('pre').forEach((node) => {
+    hljs.highlightBlock(node);
+  });
+});
index e6659bd33c9a69972cad2776c01dbde15ba4be8e..8d856bbb2803154f22bfbd64e8c610b1a4c4ed0d 100644 (file)
@@ -65,6 +65,7 @@
   "dependencies": {
     "annotator": "git://github.com/wallabag/annotator.git#0f076c7d371ed25eb0793346f46982d90f2c4c85",
     "hammerjs": "^2.0.8",
+    "highlight.js": "^9.12.0",
     "icomoon-free-npm": "^0.0.0",
     "jquery": "^2.1.4",
     "jquery.cookie": "^1.4.1",