function toSvg(node, options) {
    options = options || {}
    copyOptions(options)
    return Promise.resolve(node)
      .then(function (node) {
        return cloneNode(node, options.filter, true)
      })
      .then(embedFonts)
      .then(inlineImages)
      .then(applyOptions)
      .then(function (clone) {
        return makeSvgDataUri(
          clone,
          options.width || util.width(node),
          options.height || util.height(node),
          options.escapePercentSign
        )
      })

    function applyOptions(clone) {
      if (options.bgcolor) clone.style.backgroundColor = options.bgcolor

      if (options.width) clone.style.width = options.width + 'px'
      if (options.height) clone.style.height = options.height + 'px'

      if (options.style)
        Object.keys(options.style).forEach(function (property) {
          clone.style[property] = options.style[property]
        })

      return clone
    }
  }
@param {Node} node - The DOM Node object to render
@param {Object} options - Rendering options
@param {Function} options.filter - Should return true if passed node should be included in the output
         (excluding node means excluding it's children as well). Not called on the root node.
@param {String} options.bgcolor - color for the background, any valid CSS color value.
@param {Number} options.width - width to be applied to node before rendering.
@param {Number} options.height - height to be applied to node before rendering.
@param {Object} options.style - an object whose properties to be copied to node's style before rendering.
@param {Number} options.quality - a Number between 0 and 1 indicating image quality (applicable to JPEG only),
              defaults to 1.0.
@param {String} options.imagePlaceholder - dataURL to use as a placeholder for failed images, default behaviour is to fail fast on images we can't fetch
@param {Boolean} options.cacheBust - set to true to cache bust by appending the time to the request url
@return {Promise} - A promise that is fulfilled with a SVG image data URL