Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update phantomscript.js #182

Merged
merged 3 commits into from
Jul 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions lib/phantomscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ function executeInPage(data) {
, elContent
, svg
, svgValue
, boundingBox
, width
, height

toRemove = document.getElementsByClassName('mermaid')
if (toRemove && toRemove.length) {
Expand Down Expand Up @@ -254,6 +257,32 @@ function executeInPage(data) {
mermaid.init();

svg = document.querySelector('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: ' + width + '; height: ' + height + ';'
)
// resizing the svg via css for consistent display
svg.setAttribute(
'style'
, 'width: ' + width + '; height: ' + height + ';'
)

// set witdth and height attributes used to set the viewport when rending png image
svg.setAttribute(
'width'
, width
)
svg.setAttribute(
'height'
, height
)

svgValue = xmlSerializer.serializeToString(svg)

//console.log(document.body.outerHTML);
Expand Down