mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-17 11:14:12 +01:00
fixed css, sequenceConfig, and ganttConfig being sent as buffer to phantomjs
made verbose cli argument a boolean
This commit is contained in:
@@ -28,7 +28,6 @@ var system = require('system')
|
||||
, fs = require('fs')
|
||||
, webpage = require('webpage')
|
||||
|
||||
|
||||
var page = webpage.create()
|
||||
, files = system.args.slice(9, system.args.length)
|
||||
, width = system.args[8]
|
||||
@@ -40,21 +39,15 @@ var options = {
|
||||
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]
|
||||
, css: fs.read(system.args[4])
|
||||
, sequenceConfig: system.args[5] !== 'null' ? JSON.parse(fs.read(system.args[5])) : '{}'
|
||||
, ganttConfig: system.args[6] !== 'null' ? fs.read(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(system.args[3] !== ''){
|
||||
if(typeof options.ganttConfig === 'undefined'){
|
||||
options.ganttConfig = {};
|
||||
}
|
||||
options.ganttConfig.useWidth = 1200;
|
||||
}
|
||||
options.sequenceConfig.useMaxWidth = false;
|
||||
|
||||
page.content = [
|
||||
'<html>'
|
||||
@@ -218,7 +211,7 @@ function resolveForeignObjects(element) {
|
||||
function executeInPage(data) {
|
||||
var xmlSerializer = new XMLSerializer()
|
||||
, contents = data.contents
|
||||
, sequenceConfig = data.sequenceConfig
|
||||
, sequenceConfig = JSON.stringify(data.sequenceConfig)
|
||||
, ganttConfig = data.ganttConfig
|
||||
, toRemove
|
||||
, el
|
||||
@@ -229,7 +222,7 @@ function executeInPage(data) {
|
||||
, width
|
||||
, height
|
||||
, confWidth = data.confWidth
|
||||
|
||||
|
||||
toRemove = document.getElementsByClassName('mermaid')
|
||||
if (toRemove && toRemove.length) {
|
||||
for (var i = 0, len = toRemove.length; i < len; i++) {
|
||||
@@ -242,41 +235,24 @@ function executeInPage(data) {
|
||||
elContent = document.createTextNode(contents)
|
||||
el.appendChild(elContent)
|
||||
//el.innerText = '<b>hello</b>\uD800' //contents;
|
||||
|
||||
|
||||
document.body.appendChild(el)
|
||||
|
||||
mermaid.initialize({
|
||||
sequenceDiagram:{useMaxWidth:false},
|
||||
flowchart:{useMaxWidth:false},
|
||||
logLevel:1
|
||||
});
|
||||
|
||||
var config = {
|
||||
sequenceDiagram: sequenceConfig,
|
||||
flowchart: {useMaxWidth: false},
|
||||
logLevel: 1
|
||||
};
|
||||
|
||||
mermaid.initialize(config);
|
||||
|
||||
//console.log('after initialize',sequenceConfig);
|
||||
|
||||
if(typeof sequenceConfig !== undefined && sequenceConfig !== 'undefined'){
|
||||
//sc = document.createElement("script")
|
||||
//scContent = document.createTextNode('mermaid.sequenceConfig = JSON.parse(' + JSON.stringify(sequenceConfig) + ');')
|
||||
//sc.appendChild(scContent)
|
||||
sc = document.createElement("script")
|
||||
scContent = document.createTextNode('mermaid.ganttConfig = ' + ganttConfig + ';')
|
||||
sc.appendChild(scContent)
|
||||
|
||||
//document.body.appendChild(sc)
|
||||
mermaid.initialize({
|
||||
sequenceDiagram:JSON.parse(sequenceConfig)
|
||||
});
|
||||
}
|
||||
|
||||
//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) + ');')
|
||||
sc.appendChild(scContent)
|
||||
|
||||
document.body.appendChild(sc)
|
||||
}else{
|
||||
sc = document.createElement("script")
|
||||
scContent = document.createTextNode('mermaid.ganttConfig = {useWidth:1200};')
|
||||
sc.appendChild(scContent)
|
||||
|
||||
document.body.appendChild(sc)
|
||||
}
|
||||
document.body.appendChild(sc)
|
||||
|
||||
mermaid.init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user