forked from cutting-room-floor/wax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
site.js
34 lines (32 loc) · 1.17 KB
/
site.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Application bootstrap.
$.domReady(function() {
// Convert any markdown sections to HTML.
var nav = $('.navigation ul');
$('.md').each(function() {
var html = document.createElement('div');
$(html).html((new Showdown.converter()).makeHtml($(this).html()));
html.className = this.className;
html.id = this.id;
// TODO: free from shackles of jQuery
$(this).hide().after(html);
});
$('h1, h2, h3, h4, h5, h6').each(function(elem, i, wrapped) {
this.setAttribute('id', $(this).text().replace(/[\s\W]+/g, '-').toLowerCase());
var para = document.createElement('a'),
sectionLi = document.createElement('li'),
sectionA = document.createElement('a');
para.innerHTML = '¶'
para.className = 'para'
para.href = '#' + this.id;
sectionA.href = '#' + this.id;
$(sectionA).text($(this).text());
sectionLi.className = this.nodeName;
sectionLi.appendChild(sectionA);
nav.append(sectionLi);
$(this).append(para);
});
$('.run').each(function() {
eval($(this).text());
});
sh_highlightDocument();
});