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