This repository has been archived by the owner on Aug 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
markdown.js
58 lines (54 loc) · 2.37 KB
/
markdown.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var beautify = require('./beautify'),
path = require('./path');
exports.header = function (snippet, config) {
var markdown;
markdown = '<h1 class="apollo-widget__title">' + snippet.name + '</h1>';
markdown += '**Category** <span>' + snippet.category + '</span>\n';
markdown += '<span class="apollo-widget__filename" title="' + path.trimRight(path.trimLeft(config.style.docs)) + '/' + snippet.file + '"><strong>File</strong> `' + snippet.file.replace('./', '') + '`</span>' + '\n';
markdown += '**Author/s** ' + (snippet.auth || config.author || 'Not specified' ) + '\n\n';
if (snippet.text) {
markdown += '<p>' + snippet.text + '</p>\n';
}
return markdown;
};
exports.example = function (snippet, index, skipInitialBlock) {
var example;
example = '';
if (skipInitialBlock || false) {
example += '<hr class="apollo-widget__hr">\n';
example += '### ' + snippet.name + '\n\n';
if (snippet.auth) {
example += '**Author/s** ' + snippet.auth + '\n\n';
}
if (snippet.text) {
example += '\n\n' + snippet.text + '\n\n';
}
if (snippet.slug) {
example += '**Selector** `' + snippet.slug.replace(/^([^.]{1,})/, '.$1') + '`' + '\n\n';
}
}
example += '<div class="apollo-title-spacer">';
example += '**HTML example**';
example += '</div>';
example += '<div class="apollo-html-example">';
example += '<div class="apollo-html-example__inner">';
example += '<div class="apollo-html-example__bg"></div>';
example += '<div class="apollo-html-example__container">';
example += snippet.html;
example += '</div>';
example += '</div>';
example += '</div>';
example += '<div class="apollo-title-spacer">';
example += '**HTML code**';
example += '</div>';
example += '<div id="html-example-' + index + '" class="apollo-code-example" data-clipboard-target="#html-example-' + index + ' .highlight .code">\n';
example += '<div class="apollo-code-example__message" data-text="Click to copy">Click to copy</div>\n';
example += '```html \n' + beautify.html(snippet.html) + '\n```\n';
example += '</div>';
return example;
};
exports.footer = function(totalSnippets) {
var footer = '<hr class="apollo-widget__hr">\n';
footer += '**Total examples** <span>' + totalSnippets + '</span>';
return footer;
};