forked from Imangazaliev/git-tips
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.doxie.render.js
More file actions
44 lines (33 loc) · 763 Bytes
/
.doxie.render.js
File metadata and controls
44 lines (33 loc) · 763 Bytes
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
35
36
37
38
39
40
41
42
43
44
function escapeStr(str) {
return str
.replace(/\"/g, '\\"')
.replace(/\n/g, '\\n');
}
var renderItem = function(data) {
var lines = [
'### ' + data.title,
];
if (data.description !== undefined) {
lines.push(data.description);
}
lines = lines.concat(['```sh',
data.tip,
'```\n',
]);
if (Array.isArray(data.alternatives)) {
lines.push('__Alternatives:__');
data.alternatives.map(function(alternative){
lines = lines.concat(['```sh', alternative, '```\n'])
});
}
return lines.join('\n');
};
function render(data){
var data = data.data;
var lines = [
`\n## ${data.title}\n`,
];
lines = lines.concat(data.items.map(renderItem));
return lines.join('\n');
}
module.exports = render;