mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-11 03:19:42 +02:00
Draft fix for issue #304
This commit is contained in:
@@ -29,32 +29,27 @@ var system = require('system')
|
||||
, webpage = require('webpage')
|
||||
|
||||
|
||||
console.log('phantom.args');
|
||||
console.log(phantom.args.length);
|
||||
console.log(JSON.stringify(phantom.args));
|
||||
|
||||
var page = webpage.create()
|
||||
, files = phantom.args.slice(8, phantom.args.length)
|
||||
, width = phantom.args[7]
|
||||
, files = system.args.slice(9, system.args.length)
|
||||
, width = system.args[8]
|
||||
|
||||
if(typeof width === 'undefined'){
|
||||
if(typeof width === 'undefined' || width==='undefined'){
|
||||
width = 1200;
|
||||
}
|
||||
|
||||
var options = {
|
||||
outputDir: phantom.args[0]
|
||||
, png: phantom.args[1] === 'true' ? true : false
|
||||
, svg: phantom.args[2] === 'true' ? true : false
|
||||
, css: phantom.args[3] !== '' ? phantom.args[3] : '* { margin: 0; padding: 0; }'
|
||||
, sequenceConfig: phantom.args[4]
|
||||
, ganttConfig: phantom.args[5]
|
||||
, verbose: phantom.args[6] === 'true' ? true : false
|
||||
outputDir: system.args[1]
|
||||
, png: system.args[2] === 'true' ? true : false
|
||||
, svg: system.args[3] === 'true' ? true : false
|
||||
, css: system.args[4] !== '' ? system.args[4] : '* { margin: 0; padding: 0; }'
|
||||
, sequenceConfig: system.args[5]
|
||||
, ganttConfig: system.args[6]
|
||||
, verbose: system.args[7] === 'true' ? true : false
|
||||
, width: width
|
||||
}
|
||||
, log = logger(options.verbose)
|
||||
|
||||
// If no css is suuplied make sure a fixed witdth is given to the gant renderer
|
||||
if(phantom.args[3] !== ''){
|
||||
if(system.args[3] !== ''){
|
||||
if(typeof options.ganttConfig === 'undefined'){
|
||||
options.ganttConfig = {};
|
||||
}
|
||||
@@ -73,9 +68,6 @@ page.content = [
|
||||
, '</html>'
|
||||
].join('\n')
|
||||
|
||||
//console.log('page.content');
|
||||
//console.log(JSON.stringify(page.content));
|
||||
//console.log(phantom.args[3]);
|
||||
|
||||
page.injectJs('../dist/mermaid.js')
|
||||
page.onConsoleMessage = function(msg, lineNum, sourceId) {
|
||||
@@ -92,7 +84,7 @@ files.forEach(function(file) {
|
||||
, svgContent
|
||||
, allElements;
|
||||
|
||||
console.log('ready to execute png: ' + filename + '.png')
|
||||
console.log('ready to execute png: ' + filename + '.png ')
|
||||
|
||||
// this JS is executed in this statement is sandboxed, even though it doesn't
|
||||
// look like it. we need to serialize then unserialize the svgContent that's
|
||||
@@ -103,6 +95,7 @@ files.forEach(function(file) {
|
||||
sequenceConfig : options.sequenceConfig,
|
||||
confWidth : options.width
|
||||
})
|
||||
|
||||
oDOM = oParser.parseFromString(svgContent, "text/xml")
|
||||
|
||||
resolveSVGElement(oDOM.firstChild)
|
||||
@@ -123,7 +116,7 @@ files.forEach(function(file) {
|
||||
page.render(options.outputDir + fs.separator + filename + '.png')
|
||||
console.log('saved png: ' + filename + '.png')
|
||||
}
|
||||
console.log('After png save: ' + filename + '.png')
|
||||
|
||||
if (options.svg) {
|
||||
var serialize = new XMLSerializer();
|
||||
fs.write(
|
||||
@@ -247,6 +240,7 @@ function executeInPage(data) {
|
||||
el.className = 'mermaid'
|
||||
elContent = document.createTextNode(contents)
|
||||
el.appendChild(elContent)
|
||||
//el.innerText = '<b>hello</b>\uD800' //contents;
|
||||
|
||||
document.body.appendChild(el)
|
||||
|
||||
@@ -254,6 +248,7 @@ function executeInPage(data) {
|
||||
sequenceDiagram:{useMaxWidth:false},
|
||||
flowchart:{useMaxWidth:false}
|
||||
});
|
||||
//console.log('after initialize',sequenceConfig);
|
||||
|
||||
if(typeof sequenceConfig !== undefined && sequenceConfig !== 'undefined'){
|
||||
//sc = document.createElement("script")
|
||||
@@ -266,6 +261,7 @@ function executeInPage(data) {
|
||||
});
|
||||
}
|
||||
|
||||
//console.log('after initialize 2');
|
||||
if(typeof ganttConfig !== undefined && ganttConfig !== 'undefined'){
|
||||
sc = document.createElement("script")
|
||||
scContent = document.createTextNode('mermaid.ganttConfig = JSON.parse(' + JSON.stringify(ganttConfig) + ');')
|
||||
@@ -280,9 +276,6 @@ function executeInPage(data) {
|
||||
document.body.appendChild(sc)
|
||||
}
|
||||
|
||||
console.log('Generated head');
|
||||
console.log(document.head.innerHTML);
|
||||
//console.log(document.body.innerHTML);
|
||||
mermaid.init();
|
||||
|
||||
svg = document.querySelector('svg')
|
||||
@@ -291,6 +284,7 @@ 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
|
||||
|
Reference in New Issue
Block a user