@@ -6,11 +6,9 @@ define([
6
6
'base/js/utils' ,
7
7
'base/js/i18n' ,
8
8
'notebook/js/cell' ,
9
- 'base/js/security ' ,
9
+ 'base/js/markdown ' ,
10
10
'services/config' ,
11
- 'notebook/js/mathjaxutils' ,
12
11
'notebook/js/celltoolbar' ,
13
- 'components/marked/lib/marked' ,
14
12
'codemirror/lib/codemirror' ,
15
13
'codemirror/mode/gfm/gfm' ,
16
14
'notebook/js/codemirror-ipythongfm' ,
@@ -20,11 +18,9 @@ define([
20
18
utils ,
21
19
i18n ,
22
20
cell ,
23
- security ,
21
+ markdown ,
24
22
configmod ,
25
- mathjaxutils ,
26
23
celltoolbar ,
27
- marked ,
28
24
CodeMirror ,
29
25
gfm ,
30
26
ipgfm ,
@@ -67,7 +63,6 @@ define([
67
63
events : this . events } ] ) ;
68
64
69
65
this . cell_type = this . cell_type || 'text' ;
70
- mathjaxutils = mathjaxutils ;
71
66
this . rendered = false ;
72
67
} ;
73
68
@@ -249,8 +244,9 @@ define([
249
244
// can reference an image in markdown (using []() or a
250
245
// HTML <img>)
251
246
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 ) {
254
250
html . find ( 'img[src^="attachment:"]' ) . each ( function ( i , h ) {
255
251
h = $ ( h ) ;
256
252
var key = h . attr ( 'src' ) . replace ( / ^ a t t a c h m e n t : / , '' ) ;
@@ -391,21 +387,11 @@ define([
391
387
var text = this . get_text ( ) ;
392
388
var math = null ;
393
389
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 ) {
409
395
// add anchors to headings
410
396
html . find ( ":header" ) . addBack ( ":header" ) . each ( function ( i , h ) {
411
397
h = $ ( h ) ;
0 commit comments