@@ -6,11 +6,9 @@ define([
66 'base/js/utils' ,
77 'base/js/i18n' ,
88 'notebook/js/cell' ,
9- 'base/js/security ' ,
9+ 'base/js/markdown ' ,
1010 'services/config' ,
11- 'notebook/js/mathjaxutils' ,
1211 'notebook/js/celltoolbar' ,
13- 'components/marked/lib/marked' ,
1412 'codemirror/lib/codemirror' ,
1513 'codemirror/mode/gfm/gfm' ,
1614 'notebook/js/codemirror-ipythongfm' ,
@@ -20,11 +18,9 @@ define([
2018 utils ,
2119 i18n ,
2220 cell ,
23- security ,
21+ markdown ,
2422 configmod ,
25- mathjaxutils ,
2623 celltoolbar ,
27- marked ,
2824 CodeMirror ,
2925 gfm ,
3026 ipgfm ,
@@ -67,7 +63,6 @@ define([
6763 events : this . events } ] ) ;
6864
6965 this . cell_type = this . cell_type || 'text' ;
70- mathjaxutils = mathjaxutils ;
7166 this . rendered = false ;
7267 } ;
7368
@@ -249,8 +244,9 @@ define([
249244 // can reference an image in markdown (using []() or a
250245 // HTML <img>)
251246 var text = this . get_text ( ) ;
252- marked ( text , function ( err , html ) {
253- html = $ ( security . sanitize_html_and_parse ( html ) ) ;
247+ markdown . render ( text , {
248+ sanitize : true ,
249+ } , function ( err , html ) {
254250 html . find ( 'img[src^="attachment:"]' ) . each ( function ( i , h ) {
255251 h = $ ( h ) ;
256252 var key = h . attr ( 'src' ) . replace ( / ^ a t t a c h m e n t : / , '' ) ;
@@ -391,21 +387,11 @@ define([
391387 var text = this . get_text ( ) ;
392388 var math = null ;
393389 if ( text === "" ) { text = this . placeholder ; }
394- var text_and_math = mathjaxutils . remove_math ( text ) ;
395- text = text_and_math [ 0 ] ;
396- math = text_and_math [ 1 ] ;
397- // Prevent marked from returning inline styles for table cells
398- var renderer = new marked . Renderer ( ) ;
399- renderer . tablecell = function ( content , flags ) {
400- var type = flags . header ? 'th' : 'td' ;
401- var style = flags . align == null ? '' : ' style="text-align: ' + flags . align + '"' ;
402- var start_tag = '<' + type + style + '>' ;
403- var end_tag = '</' + type + '>\n' ;
404- return start_tag + content + end_tag ;
405- } ;
406- marked ( text , { renderer : renderer } , function ( err , html ) {
407- html = mathjaxutils . replace_math ( html , math ) ;
408- html = $ ( security . sanitize_html_and_parse ( html ) ) ;
390+ markdown . render ( text , {
391+ with_math : true ,
392+ clean_tables : true ,
393+ sanitize : true ,
394+ } , function ( err , html ) {
409395 // add anchors to headings
410396 html . find ( ":header" ) . addBack ( ":header" ) . each ( function ( i , h ) {
411397 h = $ ( h ) ;
0 commit comments