File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -213,13 +213,24 @@ function makeMath_block(open, close) {
213
213
} ;
214
214
}
215
215
216
- function makeMathRenderer ( options ) {
216
+ function makeMathRenderer ( renderingOptions ) {
217
217
if ( ascii2mathml === null ) {
218
- ascii2mathml = require ( 'ascii2mathml' ) ;
218
+ try {
219
+ ascii2mathml = require ( 'ascii2mathml' ) ;
220
+ } catch ( e ) {
221
+ return renderingOptions && renderingOptions . display === 'block' ?
222
+ function ( tokens , idx ) {
223
+ return '<div class="math block">' + tokens [ idx ] . content + '</div>' ;
224
+ } :
225
+ function ( tokens , idx ) {
226
+ return '<span class="math inline">' + tokens [ idx ] . content + '</span>' ;
227
+ } ;
228
+ }
219
229
}
220
- var mathml = ascii2mathml ( Object . assign ( { } , options ) ) ;
221
230
222
- return options && options . display === 'block' ?
231
+ var mathml = ascii2mathml ( Object . assign ( { } , renderingOptions ) ) ;
232
+
233
+ return renderingOptions && renderingOptions . display === 'block' ?
223
234
function ( tokens , idx ) {
224
235
return mathml ( tokens [ idx ] . content ) + '\n' ;
225
236
} :
Original file line number Diff line number Diff line change 33
33
"url" : " https://github.com/runarberg/markdown-it-math/issues"
34
34
},
35
35
"homepage" : " https://github.com/runarberg/markdown-it-math" ,
36
- "dependencies " : {
37
- "ascii2mathml" : " ^0.5.2 "
36
+ "optionalDependencies " : {
37
+ "ascii2mathml" : " ^0.5.3 "
38
38
},
39
39
"devDependencies" : {
40
40
"babelify" : " ^6.3.0" ,
You can’t perform that action at this time.
0 commit comments