summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author南小北 <nanxiaobei@gmail.com>2018-10-31 22:19:02 +0800
committerGitHub <noreply@github.com>2018-10-31 22:19:02 +0800
commitc53437936b541a34b22e9b71ab531f47c6a41d50 (patch)
tree8cc7eb97e535e7b1667ae2ac045707255bbfb6f5
parent3f18d384bde52441d353ae6731e5f587f0561ab2 (diff)
parent0a1cd00874e1d43c31f9441b1d86706235f1e4ca (diff)
Merge pull request #11 from izdwuut/highlight
Add highlighting of code snippets with numbered lines enabled.
-rw-r--r--layouts/partials/footer.html6
-rw-r--r--layouts/partials/header.html1
-rw-r--r--static/css/style.css40
3 files changed, 40 insertions, 7 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index f5bf812..df8dcda 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -8,15 +8,9 @@
</footer>
<script src="https://cdn.bootcss.com/instantclick/3.0.1/instantclick.min.js" data-no-instant></script>
<script data-no-instant>InstantClick.init();</script>
-<script src="https://cdn.bootcss.com/highlight.js/9.12.0/highlight.min.js" data-no-instant></script>
<script data-no-instant>
- hljs.initHighlightingOnLoad();
addMenuListener();
InstantClick.on('change', function() {
- var blocks = document.querySelectorAll('pre code');
- for (var i = 0; i < blocks.length; i++) {
- hljs.highlightBlock(blocks[i]);
- }
addMenuListener();
});
function addMenuListener() {
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index d1d7c8c..b12278b 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -23,7 +23,6 @@
{{ end -}}
<!-- Styles -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,700,700i" rel="stylesheet">
- <link href="https://cdn.bootcss.com/highlight.js/9.12.0/styles/atom-one-dark.min.css" rel="stylesheet">
<link href="{{.Site.BaseURL}}css/style.css" rel="stylesheet">
<!-- Favicons -->
<link rel="apple-touch-icon" href="{{.Site.BaseURL}}img/apple-touch-icon.png">
diff --git a/static/css/style.css b/static/css/style.css
index 536ac23..489c51c 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -488,3 +488,43 @@ pre, code {
display: none;
}
}
+
+/* Highlight
+------------------------------ */
+.post-content pre code {
+ display: block;
+}
+.post-content table code {
+ padding-top: 0;
+ padding-bottom: 0;
+}
+.post-content pre {
+ margin: 30px 0px;
+ border-radius: 6px;
+}
+.post-content table pre {
+ margin: 20px 0px;
+}
+.highlight table {
+ margin: 30px 0 !important;
+}
+.highlight div {
+ border-radius: 6px;
+}
+.post-content table code {
+ white-space: pre;
+}
+.highlight td:nth-child(2) {
+ width: 100%;
+}
+
+/* Unflavored code fences
+------------------------------ */
+code {
+ padding: 20px;
+}
+pre {
+ border-radius: 6px;
+ background-color: #272822;
+ color: white;
+} \ No newline at end of file