This repository has been archived by the owner on Oct 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathmarked-config.js
47 lines (45 loc) · 1.54 KB
/
marked-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
var S = require('string');
var marked = require('./marked');
var hljs = require('highlight.js');
marked.setOptions({
renderer: new marked.Renderer(),
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: true,
smartypants: false,
highlight: function (code, lang) {
try {
var highlighted = hljs.highlight(lang,code,true).value;
return highlighted;
} catch (err) {
var highlighted2 = hljs.highlightAuto(code).value;
return highlighted2;
}
},
langPrefix: 'hljs lang-',
tableCss: "table table-bordered",
imgCss: "img-responsive",
blockQuoteCallback: function (blockquote) {
var warning = S(blockquote).toLowerCase().startsWith("<blockquote>\n<p><strong>warning");
if (warning) {
blockquote = blockquote.replace('<br/>', '<br/>').replace('</blockquote>', '</div>');
blockquote = blockquote.replace('<blockquote>', '<div class="alert alert-warning">');
}
var note = S(blockquote).toLowerCase().startsWith("<blockquote>\n<p><strong>note");
if (note) {
blockquote = blockquote.replace('<br/>', '<br/>').replace('</blockquote>', '</div>');
blockquote = blockquote.replace('<blockquote>', '<div class="alert alert-default">');
}
return blockquote;
},
codespanCallback: function (codespan) {
return codespan;
}
});
function render(body) {
return marked(body);
}
module.exports = render;