@@ -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'
@@ -19,11 +17,9 @@ define([
1917 utils ,
2018 i18n ,
2119 cell ,
22- security ,
20+ markdown ,
2321 configmod ,
24- mathjaxutils ,
2522 celltoolbar ,
26- marked ,
2723 CodeMirror ,
2824 gfm ,
2925 ipgfm
@@ -65,7 +61,6 @@ define([
6561 events : this . events } ] ) ;
6662
6763 this . cell_type = this . cell_type || 'text' ;
68- mathjaxutils = mathjaxutils ;
6964 this . rendered = false ;
7065 } ;
7166
@@ -247,8 +242,9 @@ define([
247242 // can reference an image in markdown (using []() or a
248243 // HTML <img>)
249244 var text = this . get_text ( ) ;
250- marked ( text , function ( err , html ) {
251- html = $ ( security . sanitize_html_and_parse ( html ) ) ;
245+ markdown . render ( text , {
246+ sanitize : true ,
247+ } , function ( err , html ) {
252248 html . find ( 'img[src^="attachment:"]' ) . each ( function ( i , h ) {
253249 h = $ ( h ) ;
254250 var key = h . attr ( 'src' ) . replace ( / ^ a t t a c h m e n t : / , '' ) ;
@@ -388,21 +384,11 @@ define([
388384 var text = this . get_text ( ) ;
389385 var math = null ;
390386 if ( text === "" ) { text = this . placeholder ; }
391- var text_and_math = mathjaxutils . remove_math ( text ) ;
392- text = text_and_math [ 0 ] ;
393- math = text_and_math [ 1 ] ;
394- // Prevent marked from returning inline styles for table cells
395- var renderer = new marked . Renderer ( ) ;
396- renderer . tablecell = function ( content , flags ) {
397- var type = flags . header ? 'th' : 'td' ;
398- var style = flags . align == null ? '' : ' style="text-align: ' + flags . align + '"' ;
399- var start_tag = '<' + type + style + '>' ;
400- var end_tag = '</' + type + '>\n' ;
401- return start_tag + content + end_tag ;
402- } ;
403- marked ( text , { renderer : renderer } , function ( err , html ) {
404- html = mathjaxutils . replace_math ( html , math ) ;
405- html = $ ( security . sanitize_html_and_parse ( html ) ) ;
387+ markdown . render ( text , {
388+ with_math : true ,
389+ clean_tables : true ,
390+ sanitize : true ,
391+ } , function ( err , html ) {
406392 // add anchors to headings
407393 html . find ( ":header" ) . addBack ( ":header" ) . each ( function ( i , h ) {
408394 h = $ ( h ) ;
0 commit comments