Skip to content

Commit

Permalink
Add syntax highlighting (#26)
Browse files Browse the repository at this point in the history
* feat: Add syntax highlighting

* refact: Replace syntax highlighter to highlight.js

* fix: Use a custom highlight.js pack and add theme

* Adjust style of pre

* chore: Change highlight.js theme to monokai-sublime
  • Loading branch information
hugoabonizio authored and veelenga committed Aug 8, 2017
1 parent 27f7feb commit 40c8c8f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions public/javascripts/highlight.pack.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions public/javascripts/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
document.addEventListener("DOMContentLoaded", (event) => {
toggleSecondary();
signoutListener();
runPrettify();
});

function toggleSecondary() {
Expand Down Expand Up @@ -39,3 +40,7 @@ function signoutListener() {
});
}
}

function runPrettify() {
hljs.initHighlightingOnLoad();
}
3 changes: 1 addition & 2 deletions public/stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,8 @@ pre {
margin-bottom: 1.6em;
max-width: 100%;
overflow: auto;
padding: 0.8em;
padding: 0.25em;
white-space: pre;
white-space: pre-wrap;
word-wrap: break-word;
}

Expand Down
1 change: 1 addition & 0 deletions public/stylesheets/monokai-sublime.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/views/layouts/application.slang
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ html
meta name="viewport" content="width=device-width, initial-scale=1.0"

link rel="stylesheet" href="/stylesheets/main.css"
link rel="stylesheet" href="/stylesheets/monokai-sublime.min.css"
link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"

body.home
Expand Down Expand Up @@ -35,5 +36,6 @@ html
== render_template "layouts/_footer.slang"

script src="/javascripts/main.js"
script src="/javascripts/highlight.pack.js"

== render_template "layouts/_ga.slang"

0 comments on commit 40c8c8f

Please sign in to comment.