mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-10 19:09:44 +02:00
Fix for issue #204, added width option to the CLI. Default value for width is 1200.
Added logger using es6 syntax
This commit is contained in:
@@ -30,8 +30,14 @@ var system = require('system')
|
||||
|
||||
|
||||
var page = webpage.create()
|
||||
, files = phantom.args.slice(7, phantom.args.length)
|
||||
, options = {
|
||||
, files = phantom.args.slice(8, phantom.args.length)
|
||||
, width = phantom.args[7]
|
||||
|
||||
if(typeof width === 'undefined'){
|
||||
width = 1200;
|
||||
}
|
||||
|
||||
var options = {
|
||||
outputDir: phantom.args[0]
|
||||
, png: phantom.args[1] === 'true' ? true : false
|
||||
, svg: phantom.args[2] === 'true' ? true : false
|
||||
@@ -39,6 +45,7 @@ var page = webpage.create()
|
||||
, sequenceConfig: phantom.args[4]
|
||||
, ganttConfig: phantom.args[5]
|
||||
, verbose: phantom.args[6] === 'true' ? true : false
|
||||
, width: width
|
||||
}
|
||||
, log = logger(options.verbose)
|
||||
|
||||
@@ -80,7 +87,8 @@ files.forEach(function(file) {
|
||||
svgContent = page.evaluate(executeInPage, {
|
||||
contents : contents,
|
||||
ganttConfig : options.ganttConfig,
|
||||
sequenceConfig : options.sequenceConfig
|
||||
sequenceConfig : options.sequenceConfig,
|
||||
confWidth : options.width
|
||||
})
|
||||
oDOM = oParser.parseFromString(svgContent, "text/xml")
|
||||
|
||||
@@ -213,6 +221,7 @@ function executeInPage(data) {
|
||||
, boundingBox
|
||||
, width
|
||||
, height
|
||||
, confWidth = data.confWidth
|
||||
|
||||
toRemove = document.getElementsByClassName('mermaid')
|
||||
if (toRemove && toRemove.length) {
|
||||
@@ -257,7 +266,8 @@ function executeInPage(data) {
|
||||
document.body.appendChild(sc)
|
||||
}
|
||||
|
||||
|
||||
//console.log(document.head.innerHTML);
|
||||
//console.log(document.body.innerHTML);
|
||||
mermaid.init();
|
||||
|
||||
svg = document.querySelector('svg')
|
||||
@@ -266,25 +276,27 @@ function executeInPage(data) {
|
||||
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
|
||||
|
||||
var scalefactor = confWidth/(width-8);
|
||||
|
||||
// resizing the body to fit the svg
|
||||
document.body.setAttribute(
|
||||
'style'
|
||||
, 'width: ' + width + '; height: ' + height + ';'
|
||||
, 'width: ' + (confWidth-8) + '; height: ' + (height*scalefactor) + ';'
|
||||
)
|
||||
// resizing the svg via css for consistent display
|
||||
svg.setAttribute(
|
||||
'style'
|
||||
, 'width: ' + width + '; height: ' + height + ';'
|
||||
, 'width: ' + (confWidth-8) + '; height: ' + (height*scalefactor) + ';'
|
||||
)
|
||||
|
||||
// set witdth and height attributes used to set the viewport when rending png image
|
||||
svg.setAttribute(
|
||||
'width'
|
||||
, width
|
||||
, confWidth
|
||||
)
|
||||
svg.setAttribute(
|
||||
'height'
|
||||
, height
|
||||
, height*scalefactor
|
||||
)
|
||||
|
||||
svgValue = xmlSerializer.serializeToString(svg)
|
||||
|
Reference in New Issue
Block a user