Skip to content

Commit

Permalink
Prevent marked from returning inline styles for table cells
Browse files Browse the repository at this point in the history
  • Loading branch information
gnestor committed Aug 1, 2017
1 parent 4f4ff31 commit 8644a15
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion notebook/static/notebook/js/outputarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,16 @@ define([
var text_and_math = mathjaxutils.remove_math(markdown);
var text = text_and_math[0];
var math = text_and_math[1];
marked(text, function (err, html) {
// Prevent marked from returning inline styles for table cells
var renderer = new marked.Renderer();
renderer.tablecell = function (content, flags) {
var type = flags.header ? 'th' : 'td';
var start_tag = '<' + type + '>';
var end_tag = '</' + type + '>\n';
return start_tag + content + end_tag;
};
marked(text, { renderer: renderer }, function (err, html) {
// marked(text, function (err, html) {
html = mathjaxutils.replace_math(html, math);
toinsert.append(html);
});
Expand Down
11 changes: 10 additions & 1 deletion notebook/static/notebook/js/textcell.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,16 @@ define([
var text_and_math = mathjaxutils.remove_math(text);
text = text_and_math[0];
math = text_and_math[1];
marked(text, function (err, html) {
// Prevent marked from returning inline styles for table cells
var renderer = new marked.Renderer();
renderer.tablecell = function (content, flags) {
var type = flags.header ? 'th' : 'td';
var start_tag = '<' + type + '>';
var end_tag = '</' + type + '>\n';
return start_tag + content + end_tag;
};
marked(text, { renderer: renderer }, function (err, html) {
// marked(text, function (err, html) {
html = mathjaxutils.replace_math(html, math);
html = security.sanitize_html(html);
html = $($.parseHTML(html));
Expand Down

0 comments on commit 8644a15

Please sign in to comment.