diff --git a/lib/phantomscript.js b/lib/phantomscript.js index 12a73c625..8e2a26f7a 100644 --- a/lib/phantomscript.js +++ b/lib/phantomscript.js @@ -90,8 +90,9 @@ files.forEach(function(file) { }) oDOM = oParser.parseFromString(svgContent, "text/xml") - + resolveSVGElement(oDOM.firstChild) + setSVGStyle(oDOM.firstChild, options.css) // traverse the SVG, and replace all foreignObject elements // can be removed when https://github.com/knsv/mermaid/issues/58 is resolved @@ -184,6 +185,13 @@ function resolveSVGElement(element) { } } +function setSVGStyle(svg, css) { + if (!css || !svg) {return} + var styles=svg.getElementsByTagName('style'); + if (!styles || styles.length==0) { return } + styles[0].textContent = css; +} + function resolveForeignObjects(element) { return; var children