forked from javascript-tutorial/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutlinedBlocks.js
More file actions
executable file
·45 lines (34 loc) · 1.15 KB
/
outlinedBlocks.js
File metadata and controls
executable file
·45 lines (34 loc) · 1.15 KB
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
'use strict';
/**
* Client/server plugin
*/
const markdownItContainer = require('markdown-it-container');
const parseAttrs = require('../utils/parseAttrs');
const t = require('i18n');
const LANG = require('config').lang;
t.requirePhrase('markit.outlined', require('../locales/outlined/' + LANG + '.yml'));
module.exports = function(md) {
['warn', 'smart', 'ponder'].forEach(name => {
md.use(markdownItContainer, name, {
marker: '`',
render(tokens, idx, options, env, slf) {
if (tokens[idx].nesting === 1) {
let attrs = parseAttrs(tokens[idx].info, true);
let header = attrs.header;
if (header) {
//header = header.replace(/`(.*?)`/g, '<code>$1</code>');
header = md.renderInline(header);
} else {
header = t(`markit.outlined.${name}`);
}
return `<div class="important important_${name}">
<div class="important__header"><span class="important__type">${header}</span></div>
<div class="important__content">`;
} else {
// closing tag
return '</div></div>\n';
}
}
});
});
};