Skip to content

Commit d3d5ba6

Browse files
committed
Fix markdown syntax highlighting
1 parent d5032ad commit d3d5ba6

4 files changed

Lines changed: 209 additions & 0 deletions

File tree

include/header.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ $css_files = array(
1111
if (isset($config['css'])) {
1212
$css_files = array_merge($css_files, (array) $config['css']);
1313
}
14+
if (isset($config["css_overwrite"])) {
15+
$css_files = $config["css_overwrite"];
16+
}
1417

1518
foreach($css_files as $filename) {
1619
// files that do not start with / are assumed to be located in the /styles

include/layout.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,11 @@ function site_header($title = '', $config = array())
512512
$curr = $config["current"];
513513
$classes = $config['classes'];
514514

515+
if (isset($_COOKIE["MD"]) || isset($_GET["MD"])) {
516+
$classes .= "markdown-content";
517+
$config["css_overwrite"] = array("/styles/i-love-markdown.css");
518+
}
519+
515520
if (empty($title)) {
516521
$title = "Hypertext Preprocessor";
517522
}

js/common.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ Mousetrap.bind("l o g o enter", function(e) {
312312
var time = new Date().getTime();
313313
$(".brand img").attr("src", "/images/logo.php?refresh&time=" + time);
314314
});
315+
Mousetrap.bind("u n r e a d a b l e enter", function(e) {
316+
document.cookie = 'MD=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT';
317+
location.reload(true);
318+
});
319+
Mousetrap.bind("r e a d a b l e enter", function(e) {
320+
document.cookie = 'MD=1; path=/';
321+
location.reload(true);
322+
});
315323

316324
$(window).load(function()
317325
{

styles/i-love-markdown.css

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
/*
2+
* Thanks to brilliant work by Andrea D. (aka NKjoep):
3+
* https://github.com/NKjoep
4+
*
5+
* See:
6+
* https://github.com/NKjoep/i-love-markdown.css
7+
*/
8+
.markdown-content *,
9+
.markdown-content *:before,
10+
.markdown-content *:after {
11+
font-size: 14px;
12+
font-family: monospace;
13+
line-height: 1.1;
14+
margin: 0;
15+
padding: 0;
16+
font-weight: normal;
17+
font-style: normal;
18+
}
19+
.markdown-content h1,
20+
.markdown-content h2,
21+
.markdown-content h3,
22+
.markdown-content h4,
23+
.markdown-content h5,
24+
.markdown-content h6 {
25+
margin-bottom: 1em;
26+
margin-bottom: 2ch;
27+
}
28+
.markdown-content h1:before {
29+
content: '# ';
30+
}
31+
.markdown-content h2:before {
32+
content: '## ';
33+
}
34+
.markdown-content h3:before {
35+
content: '### ';
36+
}
37+
.markdown-content h4:before {
38+
content: '#### ';
39+
}
40+
.markdown-content h5:before {
41+
content: '##### ';
42+
}
43+
.markdown-content h6:before {
44+
content: '###### ';
45+
}
46+
.markdown-content pre,
47+
.markdown-content blockquote {
48+
margin: 1em 1em 1em 1em;
49+
margin: 2ch 2ch 2ch 2ch;
50+
clear: both;
51+
}
52+
.markdown-content pre code:before,
53+
.markdown-content pre code:after {
54+
content: '```';
55+
display: block;
56+
}
57+
.markdown-content p {
58+
margin: 0 0 1em 0;
59+
margin: 0 0 2ch 0;
60+
}
61+
.markdown-content p code:before,
62+
.markdown-content p code:after {
63+
content: '`';
64+
}
65+
.markdown-content blockquote {
66+
position: relative;
67+
padding-left: 1em;
68+
padding-left: 2ch;
69+
overflow: hidden;
70+
}
71+
.markdown-content blockquote:after {
72+
content: ">\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>\A>";
73+
white-space: pre;
74+
position: absolute;
75+
top: 0;
76+
left: 0;
77+
}
78+
.markdown-content li {
79+
list-style-type: none;
80+
list-style-position: inside;
81+
padding-left: 3ch;
82+
}
83+
.markdown-content ul,
84+
.markdown-content ol {
85+
margin: 0 0 1em 0;
86+
margin: 0 0 2ch 0;
87+
}
88+
.markdown-content ul ul,
89+
.markdown-content ol ul,
90+
.markdown-content ul ol,
91+
.markdown-content ol ol {
92+
margin: 0 0 0 2ch;
93+
}
94+
.markdown-content ul > li:before {
95+
content: '- ';
96+
float: left;
97+
margin: 0 0.5em 0 0;
98+
margin: 0 0 0 -3ch;
99+
}
100+
.markdown-content ol > li:before {
101+
content: '1. ';
102+
float: left;
103+
margin: 0 0.5em 0 0;
104+
margin: 0 0 0 -3ch;
105+
}
106+
.markdown-content em {
107+
font-weight: normal;
108+
font-style: normal;
109+
}
110+
.markdown-content em:before,
111+
.markdown-content em:after {
112+
content: '*';
113+
}
114+
.markdown-content del {
115+
font-weight: normal;
116+
font-style: normal;
117+
text-decoration: none;
118+
}
119+
.markdown-content del:before,
120+
.markdown-content del:after {
121+
content: '~~';
122+
}
123+
.markdown-content strong {
124+
font-weight: normal;
125+
font-style: normal;
126+
}
127+
.markdown-content strong:before,
128+
.markdown-content strong:after {
129+
content: '__';
130+
}
131+
.markdown-content a:before {
132+
content: '[';
133+
}
134+
.markdown-content a:after {
135+
content: "](" attr(href) ")";
136+
}
137+
.markdown-content a:link,
138+
.markdown-content a:visited,
139+
.markdown-content a:hover,
140+
.markdown-content a:active,
141+
.markdown-content a:focus {
142+
color: #000;
143+
text-decoration: none;
144+
}
145+
.markdown-content hr {
146+
margin: 0 0 1em 0;
147+
margin: 0 0 2ch 0;
148+
display: block;
149+
border: 0;
150+
background-color: transparent;
151+
}
152+
.markdown-content hr:after {
153+
content: '----';
154+
}
155+
.markdown-content th:before,
156+
.markdown-content td:before {
157+
content: '|';
158+
}
159+
.markdown-content th:last-child:after,
160+
.markdown-content td:last-child:after {
161+
content: '|';
162+
}
163+
.markdown-content img {
164+
height: 0;
165+
width: 0;
166+
font-size: 0;
167+
color: transparent;
168+
position: relative;
169+
content: "";
170+
}
171+
.markdown-content img:before,
172+
.markdown-content img:after {
173+
position: absolute;
174+
top: 0;
175+
left: 0;
176+
}
177+
.markdown-content img:before {
178+
content: '![' attr(alt) '](' attr(src) ' "' attr(title) '")';
179+
}
180+
.markdown-content table {
181+
margin: 0 0 1em 0;
182+
margin: 0 0 2ch 0;
183+
text-align: left;
184+
}
185+
.markdown-content th[style],
186+
.markdown-content td[style] {
187+
text-align: left !important;
188+
}
189+
190+
191+
.brand, #mainmenu-toggle-overlay, #mainmenu-toggle, #trick {
192+
display: none;
193+
}

0 commit comments

Comments
 (0)