@@ -230,7 +230,7 @@ function ConfigureMathJax() {
230230 //
231231 // Don't need the styles
232232 //
233- delete SVG . config . styles
233+ delete SVG . config . styles ;
234234
235235 SVG . Augment ( {
236236 //
@@ -266,7 +266,7 @@ function ConfigureMathJax() {
266266 // then set the role and mark it as being processed
267267 //
268268 jax = script . MathJax . elementJax ; if ( ! jax ) continue ;
269- jax . SVG = { display : ( jax . root . Get ( "display" ) === "block" ) }
269+ jax . SVG = { display : ( jax . root . Get ( "display" ) === "block" ) } ;
270270 span = div = HTML . Element ( "span" , {
271271 style : { "font-size" : this . config . scale + "%" , display :"inline-block" } ,
272272 className :"MathJax_SVG" , id :jax . inputID + "-Frame" , isMathJax :true , jaxID :this . id
@@ -487,7 +487,11 @@ function GetSVG(result) {
487487 // Add the requested data to the results
488488 //
489489 if ( data . svg ) result . svg = svgdata ;
490- if ( data . png ) result . svgfile = svgfile ;
490+ if ( data . png ) {
491+ result . svgfile = svgfile ;
492+ result . width = svg . getAttribute ( "width" ) . replace ( "ex" , "" ) * jax . SVG . ex ;
493+ result . height = svg . getAttribute ( "height" ) . replace ( "ex" , "" ) * jax . SVG . ex ;
494+ }
491495 if ( data . mathoidStyle ) {
492496 if ( data . svg ) result . svg = svgfile ;
493497 result . mathoidStyle = [
@@ -504,6 +508,8 @@ function GetPNG(result) {
504508 var Readable = require ( 'stream' ) . Readable ;
505509 var s = new Readable ( ) ;
506510 var svgfile = result . svgfile ; delete result . svgfile ;
511+ var width = result . width ; delete result . width ;
512+ var height = result . height ; delete result . height ;
507513 if ( data . png ) {
508514 try {
509515 var svgRenderer = new rsvg ( ) ;
@@ -514,8 +520,9 @@ function GetPNG(result) {
514520 var synch = MathJax . Callback ( function ( ) {
515521 } ) ; // for synchronization with MathJax
516522 svgRenderer . on ( 'finish' , function ( ) {
517- var buffer = svgRenderer . render ( { format : 'png' , width :600 , height :600 } ) . data ;
518- result . png = "data:image/png;base64," + ( buffer || "" ) . toString ( 'base64' ) ;
523+ console . log ( JSON . stringify ( result ) ) ;
524+ var buffer = svgRenderer . render ( { format : 'png' , width : width , height : height } ) . data ;
525+ result . png = "data:image/png;base64," + ( buffer || "" ) . toString ( 'base64' ) ;
519526 synch ( ) ;
520527 } ) ;
521528 s . pipe ( svgRenderer ) ;
0 commit comments