From 141a0063ad4c7b755abb849f23992cb7f68efeaa Mon Sep 17 00:00:00 2001 From: Jonathan Keller Date: Mon, 6 Nov 2017 22:38:05 -0800 Subject: [PATCH] Adding custom CSS to the internal SVG stylesheet --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index b95ffda..ef676d4 100644 --- a/index.js +++ b/index.js @@ -70,6 +70,7 @@ backgroundColor = backgroundColor || 'white' ;(async () => { const browser = await puppeteer.launch() const page = await browser.newPage() + page.on('console', msg => console.log('PAGE LOG:', ...msg.args)); page.setViewport({ width, height }) await page.goto(`file://${path.join(__dirname, 'index.html')}`) @@ -78,7 +79,7 @@ backgroundColor = backgroundColor || 'white' const definition = fs.readFileSync(input, 'utf-8') var myconfig, myCSS - + if (configFile) { myconfig = JSON.parse(fs.readFileSync(configFile, 'utf-8')) } @@ -111,6 +112,11 @@ backgroundColor = backgroundColor || 'white' } window.mermaid.init(undefined, container) + + if (myCSS) { + window.document.getElementById('mermaidChart0').getElementsByTagName('style')[0].innerHTML = myCSS; + } + }, definition, theme, myconfig, myCSS) if (output.endsWith('svg')) {