Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Prism.JS #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 220 additions & 0 deletions assets/css/prism.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/* http://prismjs.com/download.html?themes=prism&languages=markup+css+css-extras+clike+javascript+java+php&plugins=line-highlight+line-numbers+autolinker+file-highlight */
/**
* * prism.js default theme for JavaScript, CSS and HTML
* * Based on dabblet (http://dabblet.com)
* * @author Lea Verou
* */

code[class*="language-"],
pre[class*="language-"] {
color: black;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
direction: ltr;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;


-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;

-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}

pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}

pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}

@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}

/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}

:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}

.token.punctuation {
color: #999;
}

.namespace {
opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol {
color: #905;
}

.token.selector,
.token.attr-name,
.token.string,
.token.builtin {
color: #690;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string,
.token.variable {
color: #a67f59;
background: hsla(0,0%,100%,.5);
}

.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}


.token.regex,
.token.important {
color: #e90;
}

.token.important {
font-weight: bold;
}

.token.entity {
cursor: help;
}

pre[data-line] {
position: relative;
padding: 1em 0 1em 3em;
}

.line-highlight {
position: absolute;
left: 0;
right: 0;
padding: inherit 0;
margin-top: 1em; /* Same as .prism’s padding-top */

background: hsla(24, 20%, 50%,.08);
background: -moz-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
background: -webkit-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
background: -o-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
background: linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));

pointer-events: none;

line-height: inherit;
white-space: pre;
}

.line-highlight:before,
.line-highlight[data-end]:after {
content: attr(data-start);
position: absolute;
top: .4em;
left: .6em;
min-width: 1em;
padding: 0 .5em;
background-color: hsla(24, 20%, 50%,.4);
color: hsl(24, 20%, 95%);
font: bold 65%/1.5 sans-serif;
text-align: center;
vertical-align: .3em;
border-radius: 999px;
text-shadow: none;
box-shadow: 0 1px white;
}

.line-highlight[data-end]:after {
content: attr(data-end);
top: auto;
bottom: .4em;
}
pre.line-numbers {
padding-top: 15px;
padding-bottom: 35px;
position: relative;
padding-left: 3.8em;
counter-reset: linenumber;
}

pre.line-numbers > code {
position: relative;
}

.line-numbers .line-numbers-rows {
position: absolute;
pointer-events: none;
top: 0;
font-size: 100%;
left: -3.8em;
width: 3em; /* works for line-numbers below 1000 lines */
letter-spacing: -1px;
border-right: 1px solid #999;

-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;

}

.line-numbers-rows > span {
pointer-events: none;
display: block;
counter-increment: linenumber;
}

.line-numbers-rows > span:before {
content: counter(linenumber);
color: #999;
display: block;
padding-right: 0.8em;
text-align: right;
}
.token a {
color: inherit;
}

5 changes: 2 additions & 3 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ table {
.site-nav-item a:hover {
color: #424242; }


/* ============================================================ */
/* Post */
/* ============================================================ */
Expand All @@ -218,9 +219,7 @@ table {
margin: 0 40px; }

.post-header {
border-bottom: 6px solid #303030;
margin: 0 0 50px;
padding: 0 0 80px;
padding: 0 0 40px;
text-align: center;
text-transform: uppercase; }

Expand Down
2 changes: 2 additions & 0 deletions assets/js/nprogress.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
*/

NProgress.done = function(force) {
Prism.highlightAll();

if (!force && !NProgress.status) return this;

return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
Expand Down
29 changes: 29 additions & 0 deletions assets/js/prism.js

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

1 change: 1 addition & 0 deletions assets/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ jQuery(function($) {
});
}
}

}
});

Expand Down
6 changes: 4 additions & 2 deletions default.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<link rel="stylesheet" type="text/css" href="{{asset "css/style.css"}}" />
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&subset=latin,cyrillic-ext,latin-ext,cyrillic" />
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet">

<link rel="stylesheet" type="text/css" href="{{asset "css/prism.css"}}" />

{{! Ghost outputs important style and meta data with this tag }}
{{ghost_head}}
</head>
Expand Down Expand Up @@ -74,6 +75,7 @@
<script type="text/javascript" src="{{asset "js/nprogress.js"}}"></script>
<script type="text/javascript" src="{{asset "js/jquery.fitvids.js"}}"></script>
<script type="text/javascript" src="{{asset "js/scripts.js"}}"></script>

<script type="text/javascript" src="{{asset "js/prism.js"}}"></script>
<script type="text/javascript">Prism.highlightAll();</script>
</body>
</html>