@@ -195,6 +195,10 @@ function ConfigureMathJax() {
195
195
AddError ( "SVG - Unknown character: U+" + message [ 1 ] . toString ( 16 ) . toUpperCase ( ) +
196
196
" in " + ( message [ 2 ] . fonts || [ "unknown" ] ) . join ( "," ) , ! undefinedChar ) ;
197
197
} ) ;
198
+ MathJax . Hub . Register . MessageHook ( "CommonHTML Jax - unknown char" , function ( message ) {
199
+ AddError ( "CHTML - Unknown character: U+" + message [ 1 ] . toString ( 16 ) . toUpperCase ( ) +
200
+ " in " + ( message [ 2 ] . fonts || [ "unknown" ] ) . join ( "," ) , ! undefinedChar ) ;
201
+ } ) ;
198
202
MathJax . Hub . Register . MessageHook ( "MathML Jax - unknown node type" , function ( message ) {
199
203
AddError ( "MathML - Unknown node type: " + message [ 1 ] ) ;
200
204
} ) ;
@@ -825,7 +829,9 @@ function RestartMathJax() {
825
829
// %%% cache results?
826
830
// %%% check types and values of parameters
827
831
//
828
- exports . typeset = function ( data , callback ) {
832
+
833
+ // callback API for compatibility with MathJax
834
+ var cbTypeset = function ( data , callback ) {
829
835
if ( ! callback || typeof ( callback ) !== "function" ) {
830
836
if ( displayErrors ) console . error ( "Missing callback" ) ;
831
837
return ;
@@ -841,6 +847,17 @@ exports.typeset = function (data,callback) {
841
847
if ( serverState == STATE . READY ) StartQueue ( ) ;
842
848
}
843
849
850
+ // main API, callback and promise compatible
851
+ exports . typeset = function ( data , callback ) {
852
+ if ( callback ) cbTypeset ( data , callback ) ;
853
+ else return new Promise ( function ( resolve , reject ) {
854
+ cbTypeset ( data , function ( output , input ) {
855
+ if ( output . errors ) reject ( output . errors ) ;
856
+ else resolve ( output , input ) ;
857
+ } ) ;
858
+ } ) ;
859
+ } ;
860
+
844
861
//
845
862
// Manually start MathJax (this is done automatically
846
863
// when the first typeset() call is made)
0 commit comments