discourse/app/assets/javascripts/pretty-text/engines/discourse-markdown/table.js.es6

39 lines
755 B
Plaintext
Raw Normal View History

export function setup(helper) {
helper.registerPlugin(md => {
md.renderer.rules.table_open = function(){
2017-11-13 02:09:24 -05:00
return '<div class="md-table">\n<table>\n';
};
md.renderer.rules.table_close = function(){
return '</table>\n</div>';
};
});
// we need a custom callback for style handling
helper.whiteList({
custom: function(tag,attr,val) {
if (tag !== 'th' && tag !== 'td') {
return false;
}
if (attr !== 'style') {
return false;
}
return (val === 'text-align:right' || val === 'text-align:left' || val === 'text-align:center');
}
});
helper.whiteList([
'table',
'tbody',
'thead',
'tr',
'th',
'td',
'div.md-table'
]);
}