-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathplugin.js
45 lines (38 loc) · 1.16 KB
/
plugin.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
// script to style blockquotes for info, warning, success and danger
styleMap = {
'[info]': {
htmlStr: '<i class="fa fa-info-circle"></i>',
className: 'info',
},
'[warning]': {
htmlStr: '<i class="fa fa-exclamation-circle"></i>',
className: 'warning'
},
'[danger]': {
htmlStr: '<i class="fa fa-ban"></i>',
className: 'danger'
},
'[success]': {
htmlStr: '<i class="fa fa-check-circle"></i>',
className: 'success'
}
}
require(["gitbook", "jQuery"], function(gitbook, $) {
// Load
gitbook.events.bind("page.change", function(e, config) {
bqs = $('blockquote');
bqs.each(function(index) {
for (key in styleMap) {
htmlStr = $(this).html()
if (htmlStr.indexOf(key) > 0) {
// remove key from text
var style = styleMap[key];
htmlStr = htmlStr.replace(key, style.htmlStr);
$(this).html(htmlStr);
// set style
$(this).addClass(style.className)
}
}
})
});
});