07d13c9c
isisadmin
polymer catalog
|
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
|
var marked = require('marked');
var renderer = new marked.Renderer();
var firstHeading = true;
var permalinks = [];
renderer.heading = function(text, level) {
var permalink = text.toLowerCase().replace(/[^\w]+/g, '-');
if (permalinks.indexOf(permalink) >= 0) {
permalink = permalink + "-1";
}
permalinks.push(permalink);
var htext = '<h' + level + ' id="' + permalink + '">' + text + '</h' + level + '>';
if (level === 2) {
var out = "";
firstHeading ? firstHeading = false : out += "</section>\n\n";
return out + '<section class="guide-section">\n' + htext + '\n';
} else {
return htext;
}
}
module.exports = function(content) {
permalinks = [];
firstHeading = true;
var out = marked(content, {renderer: renderer});
out += '</section>'
return out;
}
|