Skip to content

Commit c9efc1f

Browse files
committed
1 parent 25159f5 commit c9efc1f

File tree

4 files changed

+100
-3
lines changed

4 files changed

+100
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ You can watch it in action [here](https://panossakkos.github.io/personal-jekyll-
3030
* RSS feed
3131
* Cool (anti-procrastinating) 404 page
3232
* [Android Web App mode](https://developer.chrome.com/multidevice/android/installtohomescreen)
33+
* Syntax highlighting
3334
* Forcing of https protocol
3435
* Protection from Email harvesting
3536
* Travis CI integration with [html-proofer](https://github.com/gjtorikian/html-proofer)

_includes/head.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<meta name="author" content="{{site.author}}">
1717
<meta name="keywords" content="{{site.keyword}}">
1818
<link rel="canonical" href="{{page.url | replace:'index.html','' | prepend: site.baseurl}}">
19-
{% if page.url == "/404.html" | prepend: {{site.baseurl}} %}
20-
<meta http-equiv="refresh" content="20; url={{site.baseurl}}/">
21-
{% endif %}
2219
<title>{{site.title}} {% if page.title %} | {{page.title}}{% endif %}</title>
2320

2421
<!-- Bootstrap Core CSS -->
@@ -44,8 +41,25 @@
4441
{% if site.favicon %}
4542
<link rel="shortcut icon" type="image/x-icon" href="{{site.baseurl}}{{site.favicon}}">
4643
{% endif %}
44+
45+
{% if page.url == "/404.html" | prepend: {{site.baseurl}} %}
46+
<meta http-equiv="refresh" content="20; url={{site.baseurl}}/">
47+
{% endif %}
48+
4749
{% if site.web-app-mode %}
50+
51+
<!-- Android Web App mode -->
52+
4853
<link rel="manifest" href="{{site.baseurl}}/manifest.json">
54+
55+
{% endif %}
56+
57+
{% if page.section-type == "post" %}
58+
59+
<!-- Code highlighting in Post pages -->
60+
61+
<link href="{{site.baseurl}}/css/syntax.css" rel="stylesheet">
62+
4963
{% endif %}
5064
</head>
5165

_posts/2015-06-19-writing-posts.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,17 @@ In order to generate the tag pages, simply run the *generate-tags* script from t
5555
The script will parse all your posts, and generate the tag pages for the newly added tags.
5656

5757
If you are not using Github Pages, you can automate the execution of this script during build time.
58+
59+
### Syntax highlighting
60+
61+
If you want to include a code snippet in your post, simply use the following syntax:
62+
63+
{% highlight c linenos %}
64+
#include<stdio.h>
65+
66+
int main()
67+
{
68+
printf("Hello, world of syntax highlighting!");
69+
return 0;
70+
}
71+
{% endhighlight %}

css/syntax.css

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
.highlight { background: #ffffff; }
2+
.highlight .c { color: #999988; font-style: italic } /* Comment */
3+
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
4+
.highlight .k { font-weight: bold } /* Keyword */
5+
.highlight .o { font-weight: bold } /* Operator */
6+
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
7+
.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
8+
.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
9+
.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
10+
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
11+
.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
12+
.highlight .ge { font-style: italic } /* Generic.Emph */
13+
.highlight .gr { color: #aa0000 } /* Generic.Error */
14+
.highlight .gh { color: #999999 } /* Generic.Heading */
15+
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
16+
.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
17+
.highlight .go { color: #888888 } /* Generic.Output */
18+
.highlight .gp { color: #555555 } /* Generic.Prompt */
19+
.highlight .gs { font-weight: bold } /* Generic.Strong */
20+
.highlight .gu { color: #aaaaaa } /* Generic.Subheading */
21+
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
22+
.highlight .kc { font-weight: bold } /* Keyword.Constant */
23+
.highlight .kd { font-weight: bold } /* Keyword.Declaration */
24+
.highlight .kp { font-weight: bold } /* Keyword.Pseudo */
25+
.highlight .kr { font-weight: bold } /* Keyword.Reserved */
26+
.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
27+
.highlight .m { color: #009999 } /* Literal.Number */
28+
.highlight .s { color: #d14 } /* Literal.String */
29+
.highlight .na { color: #008080 } /* Name.Attribute */
30+
.highlight .nb { color: #0086B3 } /* Name.Builtin */
31+
.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
32+
.highlight .no { color: #008080 } /* Name.Constant */
33+
.highlight .ni { color: #800080 } /* Name.Entity */
34+
.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
35+
.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
36+
.highlight .nn { color: #555555 } /* Name.Namespace */
37+
.highlight .nt { color: #000080 } /* Name.Tag */
38+
.highlight .nv { color: #008080 } /* Name.Variable */
39+
.highlight .ow { font-weight: bold } /* Operator.Word */
40+
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
41+
.highlight .mf { color: #009999 } /* Literal.Number.Float */
42+
.highlight .mh { color: #009999 } /* Literal.Number.Hex */
43+
.highlight .mi { color: #009999 } /* Literal.Number.Integer */
44+
.highlight .mo { color: #009999 } /* Literal.Number.Oct */
45+
.highlight .sb { color: #d14 } /* Literal.String.Backtick */
46+
.highlight .sc { color: #d14 } /* Literal.String.Char */
47+
.highlight .sd { color: #d14 } /* Literal.String.Doc */
48+
.highlight .s2 { color: #d14 } /* Literal.String.Double */
49+
.highlight .se { color: #d14 } /* Literal.String.Escape */
50+
.highlight .sh { color: #d14 } /* Literal.String.Heredoc */
51+
.highlight .si { color: #d14 } /* Literal.String.Interpol */
52+
.highlight .sx { color: #d14 } /* Literal.String.Other */
53+
.highlight .sr { color: #009926 } /* Literal.String.Regex */
54+
.highlight .s1 { color: #d14 } /* Literal.String.Single */
55+
.highlight .ss { color: #990073 } /* Literal.String.Symbol */
56+
.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
57+
.highlight .vc { color: #008080 } /* Name.Variable.Class */
58+
.highlight .vg { color: #008080 } /* Name.Variable.Global */
59+
.highlight .vi { color: #008080 } /* Name.Variable.Instance */
60+
.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
61+
62+
/* Make line numbers unselectable: excludes line numbers from copy-paste user ops */
63+
.highlight .lineno {-webkit-user-select: none;-moz-user-select: none; -o-user-select: none;}
64+
.lineno::-moz-selection {background-color: transparent;} /* Mozilla specific */
65+
.lineno::selection {background-color: transparent;} /* Other major browsers */
66+
.highlight .lineno { color: #ccc; display:inline-block; padding: 0 5px; border-right:1px solid #ccc; }
67+
.highlight pre code { display: block; white-space: pre; overflow-x: auto; word-wrap: normal; }
68+
.highlight { text-align: left; }

0 commit comments

Comments
 (0)