-
Notifications
You must be signed in to change notification settings - Fork 0
/
marp.config.js
57 lines (54 loc) · 1.93 KB
/
marp.config.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
const { Marp } = require("@marp-team/marp-core");
const markdownItContainer = require("markdown-it-container");
// const markdownItSup = require("markdown-it-sup");
// const markdownItSub = require("markdown-it-sub");
const marpKrokiPlugin = require('./kroki-plugin')
module.exports = {
engine: (opts) => {
const marp = new Marp({
...opts,
html: true,
});
marp.use(marpKrokiPlugin);
// plugins
// marp.use(markdownItSup);
// marp.use(markdownItSub);
/// containers
const addContainerBox = (marp, tagName, className, modify = x => x) => {
const re = new RegExp(`^${tagName}:?(.*)$`);
const boxClass = `block ${className === "block" ? "" : className}`;
const headClass = `block-head ${className === "block" ? "" : className + "-head"}`;
marp.use(markdownItContainer, tagName, {
validate: (params) => {
return params.trim().match(re);
},
render: (tokens, idx) => {
const m = tokens[idx].info.trim().match(re);
const name = modify(m ? m[1] : "");
if (tokens[idx].nesting === 1) {
let ret = `<div class="${boxClass}">`;
if (name) {
ret += `<p class="${headClass}">${name}</p>`;
}
ret += `\n`;
return ret;
} else {
return `</div>\n`;
}
}
});
};
addContainerBox(marp, "block", "block");
addContainerBox(marp, "black", "block");
addContainerBox(marp, "info", "info", name => name || "info");
addContainerBox(marp, "blue", "info", name => name || "info");
addContainerBox(marp, "warn", "warn", name => name || "warn");
addContainerBox(marp, "red", "warn", name => name || "warn");
addContainerBox(marp, "footnote", "footnote");
// const theme = marp.themeSet.add(marp.themeSet.pack("default", {
// after: ``,
// }));
// marp.themeSet.addTheme(theme);
return marp;
},
};