Switch from marked to markdown-it markdown renderer
This commit is contained in:
parent
7a7dfd5097
commit
b6ecaa9197
|
@ -10,7 +10,7 @@
|
||||||
"keymaster": "madrobby/keymaster",
|
"keymaster": "madrobby/keymaster",
|
||||||
"ace-builds": "~1.2.3",
|
"ace-builds": "~1.2.3",
|
||||||
"parsleyjs": "~2.3.10",
|
"parsleyjs": "~2.3.10",
|
||||||
"marked": "~0.3.2",
|
"markdown-it": "~7.0.0",
|
||||||
"js-yaml": "~3.6.0",
|
"js-yaml": "~3.6.0",
|
||||||
"store-js": "~1.3.16",
|
"store-js": "~1.3.16",
|
||||||
"bootswatch-dist": "3.3.6-flatly",
|
"bootswatch-dist": "3.3.6-flatly",
|
||||||
|
|
|
@ -231,7 +231,7 @@ assets.register('main.js',
|
||||||
'vendor/components-bootstrap/js/bootstrap.js',
|
'vendor/components-bootstrap/js/bootstrap.js',
|
||||||
'vendor/handlebars/handlebars.js',
|
'vendor/handlebars/handlebars.js',
|
||||||
'vendor/js-yaml/dist/js-yaml.js',
|
'vendor/js-yaml/dist/js-yaml.js',
|
||||||
'vendor/marked/lib/marked.js',
|
'vendor/markdown-it/dist/markdown-it.js',
|
||||||
'js/html-sanitizer-minified.js', # don't minify?
|
'js/html-sanitizer-minified.js', # don't minify?
|
||||||
'vendor/highlightjs/highlight.pack.js',
|
'vendor/highlightjs/highlight.pack.js',
|
||||||
'vendor/parsleyjs/dist/parsley.js',
|
'vendor/parsleyjs/dist/parsley.js',
|
||||||
|
|
|
@ -38,15 +38,19 @@ var metaMarked = function(src, opt, callback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
marked.setOptions({
|
var markdownit = window.markdownit({
|
||||||
renderer: new marked.Renderer(),
|
html: true,
|
||||||
gfm: true,
|
linkify: true,
|
||||||
tables: true,
|
highlight: function (str, lang) {
|
||||||
breaks: false,
|
if (lang && hljs.getLanguage(lang)) {
|
||||||
pedantic: false,
|
try {
|
||||||
sanitize: false,
|
return hljs.highlight(lang, str).value;
|
||||||
smartLists: true,
|
} catch (__) {
|
||||||
smartypants: false
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''; // use external default escaping
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Markdown Renderer
|
// Markdown Renderer
|
||||||
|
@ -54,9 +58,8 @@ var MDR = {
|
||||||
meta: null,
|
meta: null,
|
||||||
md: null,
|
md: null,
|
||||||
sanitize: true, // Override
|
sanitize: true, // Override
|
||||||
renderer: new marked.Renderer(),
|
|
||||||
parse: function(md){
|
parse: function(md){
|
||||||
return marked(md, { renderer: this.renderer });
|
return markdownit.render(md);
|
||||||
},
|
},
|
||||||
convert: function(md, sanitize) {
|
convert: function(md, sanitize) {
|
||||||
if (this.sanitize !== null) {
|
if (this.sanitize !== null) {
|
||||||
|
@ -108,13 +111,8 @@ var MDR = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MDR.renderer.table = function(header, body) {
|
// Add some custom classes to table tags
|
||||||
return '<table class="table table-bordered">\n'
|
markdownit.renderer.rules.table_open = function (tokens, idx, options, env, self) {
|
||||||
+ '<thead>\n'
|
tokens[idx].attrPush(['class', 'table table-bordered']);
|
||||||
+ header
|
return self.renderToken(tokens, idx, options);
|
||||||
+ '</thead>\n'
|
|
||||||
+ '<tbody>\n'
|
|
||||||
+ body
|
|
||||||
+ '</tbody>\n'
|
|
||||||
+ '</table>\n';
|
|
||||||
};
|
};
|
Loading…
Reference in a new issue