1
- import * as hljs from 'highlight.js' ;
1
+ import hljs from 'highlight.js' ;
2
2
import MarkdownIt from 'markdown-it' ;
3
3
import { filterXSS , getDefaultCSSWhiteList , getDefaultWhiteList , IWhiteList } from 'xss' ;
4
4
import { mermaidRender , refreshMermaid } from '../plugins/mermaid' ;
@@ -15,21 +15,23 @@ export class MDRenderService {
15
15
if ( lang && hljs . getLanguage ( lang ) ) {
16
16
try {
17
17
return hljs . highlight ( str , { language : lang } ) . value ;
18
- } catch ( _ ) { }
18
+ } catch ( _ ) { }
19
19
}
20
20
return '' ;
21
- }
21
+ } ,
22
22
} ) as any ;
23
23
private baseUrl = '' ;
24
24
private breaks = true ;
25
25
private renderParse : Function | undefined ;
26
26
27
27
constructor ( ) {
28
28
this . setDefaultXss ( ) ;
29
- this . mdt . use ( tocAndAnchor , {
30
- linkify : false ,
31
- anchorLink : false
32
- } ) . use ( mermaidRender , { id : 'devui-mermaid' } ) ;
29
+ this . mdt
30
+ . use ( tocAndAnchor , {
31
+ linkify : false ,
32
+ anchorLink : false ,
33
+ } )
34
+ . use ( mermaidRender , { id : 'devui-mermaid' } ) ;
33
35
}
34
36
35
37
private setDefaultXss ( ) {
@@ -46,7 +48,6 @@ export class MDRenderService {
46
48
this . xssWhiteList [ 'path' ] = [ 'style' , 'class' , 'd' , 'id' , 'fill' , 'stroke' ] ;
47
49
this . xssWhiteList [ 'th' ] = [ 'style' ] ;
48
50
this . xssWhiteList [ 'td' ] = [ 'style' ] ;
49
-
50
51
}
51
52
52
53
setBaseUrl ( url : string ) {
@@ -71,15 +72,15 @@ export class MDRenderService {
71
72
72
73
setCustomXssRules ( rules : ICustomXssRule [ ] ) {
73
74
if ( rules ) {
74
- rules . forEach ( rule => {
75
+ rules . forEach ( ( rule ) => {
75
76
this . xssWhiteList [ rule [ 'key' ] ] = rule [ 'value' ] ;
76
77
} ) ;
77
78
}
78
79
}
79
80
80
81
setCustomRendererRules ( rules : ICustomRenderRule [ ] ) {
81
82
if ( rules ) {
82
- rules . forEach ( rule => {
83
+ rules . forEach ( ( rule ) => {
83
84
this . mdt . renderer . rules [ rule [ 'key' ] ] = rule [ 'value' ] ;
84
85
} ) ;
85
86
}
@@ -90,7 +91,7 @@ export class MDRenderService {
90
91
}
91
92
92
93
setPlugins ( plugins : Array < MdPlugin > ) {
93
- plugins . forEach ( item => {
94
+ plugins . forEach ( ( item ) => {
94
95
const { plugin, opts } = item ;
95
96
this . mdt . use ( plugin , opts ) ;
96
97
} ) ;
@@ -139,7 +140,7 @@ export class MDRenderService {
139
140
top : true ,
140
141
left : true ,
141
142
bottom : true ,
142
- right : true
143
+ right : true ,
143
144
} ) ,
144
145
} ,
145
146
} ) ;
@@ -153,7 +154,7 @@ export class MDRenderService {
153
154
154
155
public setRules ( mdRules : Record < string , any > ) : void {
155
156
if ( mdRules ) {
156
- Object . keys ( mdRules ) . forEach ( rule => {
157
+ Object . keys ( mdRules ) . forEach ( ( rule ) => {
157
158
this . mdt [ rule ] . set ( mdRules [ rule ] ) ;
158
159
} ) ;
159
160
}
0 commit comments