forked from intuit/Ignite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
markdownit.config.js
110 lines (100 loc) · 2.77 KB
/
markdownit.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* eslint-disable import/no-unresolved */
const path = require('path');
const highlightjs = require('highlight.js');
const renderBlogFrontMatter = require('./dist/extensions/front-matter-render');
const makePlugin = require('./dist/extensions/ignite-plugin').default;
const splitPlugins = plugins => {
const markdownPlugins = [];
let ignitePlugins = [];
plugins.forEach(plugin => {
if (Array.isArray(plugin)) {
ignitePlugins.push(plugin);
} else {
markdownPlugins.push(plugin);
}
});
ignitePlugins = ignitePlugins.map(plugin => {
if (plugin[1][0] === '.' || plugin[1][0] === '/') {
plugin[1] = path.resolve(plugin[1]);
return plugin;
}
return plugin;
});
return {
markdownPlugins,
ignitePlugins
};
};
const generateConfig = plugins => {
const { markdownPlugins, ignitePlugins } = splitPlugins(plugins);
const pluginTokens = ignitePlugins.map(plugin => makePlugin(plugin[0]));
return {
xhtmlOut: true,
plugins: [
require('./dist/extensions/jsx-fence'),
'markdown-it-jsx',
[
'markdown-it-checkbox',
{
divWrap: true
}
],
'markdown-it-br',
'markdown-it-sub',
'markdown-it-mark',
'markdown-it-ins',
'markdown-it-sup',
'markdown-it-highlight-lines',
['markdown-it-front-matter', renderBlogFrontMatter],
[
'markdown-it-anchor',
{
permalink: true,
permalinkSymbol: '',
permalinkClass: 'fas fa-hashtag headerLink',
level: 2
}
],
'markdown-it-emoji',
[
'markdown-it-attrs',
{
leftDelimiter: '/',
rightDelimiter: '\\'
}
],
'markdown-it-external-links',
[
'markdown-it-table-of-contents',
{
includeLevel: [2, 3]
}
],
require('./dist/extensions/jsx-inline'),
require('./dist/extensions/font-awesome'),
require('./dist/extensions/bulma-tag'),
require('./dist/extensions/bulma-progress'),
require('./dist/extensions/bulma-hero'),
require('./dist/extensions/bulma-message'),
require('./dist/extensions/bulma-box'),
require('./dist/extensions/bulma-button'),
require('./dist/extensions/bulma-row'),
require('./dist/extensions/bulma-tile'),
require('./dist/extensions/collapse'),
require('./dist/extensions/embed'),
require('./dist/extensions/code-tabs'),
require('./dist/extensions/div'),
...pluginTokens,
...markdownPlugins
],
highlight: (code, language) => {
return language && highlightjs.getLanguage(language)
? highlightjs.highlight(language, code).value
: code;
}
};
};
module.exports = {
splitPlugins,
generateConfig
};