From 590fa0894bb84c6818b86f24cda2a8a74eb084fb Mon Sep 17 00:00:00 2001 From: phairow Date: Thu, 2 Jul 2015 17:52:37 -0700 Subject: [PATCH] Update phantomscript.js clean up --- lib/phantomscript.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/phantomscript.js b/lib/phantomscript.js index 2f3a6513f..20a750ce4 100644 --- a/lib/phantomscript.js +++ b/lib/phantomscript.js @@ -210,6 +210,9 @@ function executeInPage(data) { , elContent , svg , svgValue + , boundingBox + , width + , height toRemove = document.getElementsByClassName('mermaid') if (toRemove && toRemove.length) { @@ -255,27 +258,29 @@ function executeInPage(data) { svg = document.querySelector('svg') - var boundingBox = svg.getBoundingClientRect(); // the initial bonding box of the svg + boundingBox = svg.getBoundingClientRect(); // the initial bonding box of the svg + width = boundingBox.width * 1.5; // adding the scale factor for consistency with output in chrome browser + height = boundingBox.height * 1.5; // adding the scale factor for consistency with output in chrome browser // resizing the body to fit the svg document.body.setAttribute( 'style' - , 'width: ' + (boundingBox.width * 1.5) + '; height: ' + (boundingBox.height * 1.5) + ';' + , 'width: ' + width + '; height: ' + height + ';' ) // resizing the svg via css for consistent display svg.setAttribute( 'style' - , 'width: ' + (boundingBox.width * 1.5) + '; height: ' + (boundingBox.height * 1.5) + ';' + , 'width: ' + width + '; height: ' + height + ';' ) // set witdth and height attributes used to set the viewport when rending png image svg.setAttribute( 'width' - , boundingBox.width * 1.5 + , width ) svg.setAttribute( 'height' - , boundingBox.height * 1.5 + , height ) svgValue = xmlSerializer.serializeToString(svg)