@@ -181,13 +181,24 @@ MathJax.Extension.mml2jax = {
181
181
createPreview : function ( math , script ) {
182
182
var preview = this . config . preview ;
183
183
if ( preview === "none" ) return ;
184
- if ( preview === "alttext" ) {
185
- var text = math . getAttribute ( "alttext" ) ;
186
- if ( text != null ) { preview = [ this . filterPreview ( text ) ] } else { preview = null }
187
- }
184
+ if ( preview === "mathml" ) { preview = math }
185
+ else if ( preview === "alttext" || preview === "altimg" ) {
186
+ var alttext = this . filterPreview ( math . getAttribute ( "alttext" ) ) ;
187
+ if ( preview === "alttext" ) {
188
+ if ( alttext != null ) { preview = MathJax . HTML . TextNode ( alttext ) } else { preview = null }
189
+ } else {
190
+ var src = math . getAttribute ( "altimg" ) ;
191
+ if ( src != null ) {
192
+ // FIXME: use altimg-valign when display="inline"?
193
+ var style = { width : math . getAttribute ( "altimg-width" ) , height : math . getAttribute ( "altimg-height" ) } ;
194
+ preview = MathJax . HTML . Element ( "img" , { src :src , alt :alttext , style :style } ) ;
195
+ } else { preview = null }
196
+ }
197
+ }
188
198
if ( preview ) {
189
- preview = MathJax . HTML . Element ( "span" , { className :MathJax . Hub . config . preRemoveClass } , preview ) ;
190
- script . parentNode . insertBefore ( preview , script ) ;
199
+ var span = MathJax . HTML . Element ( "span" , { className :MathJax . Hub . config . preRemoveClass } ) ;
200
+ span . appendChild ( preview ) ;
201
+ script . parentNode . insertBefore ( span , script ) ;
191
202
}
192
203
} ,
193
204
0 commit comments