-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (33 loc) · 1.02 KB
/
index.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
module.exports = {
hooks: {
/**
* Number each exercise. This is run before HonKit outputs HTML and
* indexes the page.
*/
"page": (page) => {
const regex = /Exercise.<\/strong>/g;
let match = page.content.match(regex);
let i = 0;
while (!!match) {
i++;
const replace = `Exercise ${i}.</strong>`;
page.content = page.content.replace(match[0], replace);
match = page.content.match(regex);
}
return page;
}
},
blocks: {
/**
* Format each exercise. This is run when HonKit parses the book.
*/
exercise: {
process: (block) => {
const { label } = block.kwargs;
const prefix = !!label ? `<strong id="${label}">` : "<strong>";
const suffix = `Exercise.</strong>${block.body}`;
return `${prefix}${suffix}`;
}
}
}
};