Accepts the `source` of the graph as a string, and render an SVG using
mermaid.cli. Returns the path to the rendered SVG.

@param  {string} destination
@param  {string} source
@return {string}
326425
function renderFromFile(inputFile, destination) {
  const unique = crypto.createHmac('sha1', PLUGIN_NAME).update(inputFile).digest('hex');
  const mmdcExecutable = which.sync('mmdc');
  const svgFilename = `${unique}.svg`;
  const svgPath = path.join(destination, svgFilename);

  // Invoke mermaid.cli
  execSync(`${mmdcExecutable} -i ${inputFile} -o ${svgPath} -b transparent`);

  return `./${svgFilename}`;
}
660800
def destination(dest)
      # The url needs to be unescaped in order to preserve the correct filename
      path = File.join(dest, @dir, CGI.unescape(url))

      if ext == '.html' && _localization_original_url !~ /\.html\z/
        path.sub!(Localization::LANG_END_RE, '')
        File.join(path, "index#{ext}#{@lang_ext}")
      else
        path
      end
    end
801353
def destination(dest)
      path = site.in_dest_dir(dest, URL.unescape_path(url))
      path = File.join(path, "index") if url.end_with?("/")
      path << output_ext unless path.end_with? output_ext
      path
    end
865286
function (source, destination) {
    return cont.mapAsync(readFileAsJSON(source), function (json, cb) {
        json.copied = Date.now()
        fs.writeFile(destination, JSON.stringify(json), cb)
    })
}
747326
function (source, destination) {
      if (!source) return null;

      destination = destination || {};

      angular.forEach('left top right bottom width height'.split(' '), function (key) {
        destination[key] = Math.round(source[key]);
      });

      destination.width = destination.width || (destination.right - destination.left);
      destination.height = destination.height || (destination.bottom - destination.top);

      return destination;
    }
310367
public static DestinationUrl createDestinationUrl(String destination) {
        String[] split = splitDestination(destination);
        String host = split[0].trim();
        String jmsDestination = split[1].trim();
        return new DestinationUrl(host, jmsDestination);
    }
508787
function objToGraph(obj, containerName) {
    if (!containerName) containerName = 'definitions';
    let graph = [];

    for (let p in obj[containerName]) {
        let entry = {};
        entry._id = '#/'+containerName+'/'+p;
        entry.links = [];
        graph.push(entry);
    }

    recurse(obj,{identityDetection:true},function(obj,key,state){
        if (isRef(obj,key)) {
            let ptr = obj[key].replace('/$ref','');
            let spath = state.path.replace('/$ref','');
            let target = graph.find(function(e){
                return e._id === ptr;
            });
            if (target) {
                target.links.push(ptr);
            }
            else {
                target = {};
                target._id = ptr;
                target.links = [];
                target.links.push(ptr);
                graph.push(target);
            }
            let source = graph.find(function(e){
                return e._id === spath;
            });
            if (source) {
                //source.links.push(spath);
            }
            else {
                source = {};
                source._id = spath
                source.links = [];
                graph.push(source);
            }
        }
    });

    return graph;
}
186590
function sourceString(source) {
  var message = "<css input>"
  if (source) {
    if (source.input && source.input.file) {
      message = source.input.file
    }
    if (source.start) {
      message += ":" + source.start.line + ":" + source.start.column
    }
  }

  return message
}
933239
function(route, sourcePoint, targetPoint) {

        var namespace = joint.connectors;
        var connector = this.model.connector();
        var defaultConnector = this.paper.options.defaultConnector;

        if (!connector) {
            connector = defaultConnector || {};
        }

        var connectorFn = joint.util.isFunction(connector) ? connector : namespace[connector.name];
        if (!joint.util.isFunction(connectorFn)) {
            throw new Error('dia.LinkView: unknown connector: "' + connector.name + '".');
        }

        var args = joint.util.clone(connector.args || {});
        args.raw = true; // Request raw g.Path as the result.

        var path = connectorFn.call(
            this, // context
            sourcePoint, // start point
            targetPoint, // end point
            route, // vertices
            args, // options
            this // linkView
        );

        if (typeof path === 'string') {
            // Backwards compatibility for connectors not supporting `raw` option.
            path = new g.Path(V.normalizePathData(path));
        }

        return path;
    }
825434
function getSourceMap(options) {
  var sourceMap = options.sourceMap;

  if (sourceMap && typeof sourceMap !== 'string' && options.outFile) {
    sourceMap = options.outFile + '.map';
  }

  return sourceMap && typeof sourceMap === 'string' ? path.resolve(sourceMap) : null;
}
992390
def add_edge(source, destination, weight)
      if @edges.key?(source)
        @edges[source][destination] = weight
      else
        @edges[source] = { destination => weight }
      end
    end
44762
function _gpfStreamPipe (source, destination) {
    _gpfIgnore(destination);
    var iReadableStream = _gpfStreamQueryReadable(source),
        iWritableStream = _gpfStreamPipeToWritable(_gpfArrayTail(arguments)),
        iFlushableStream = _gpfStreamPipeToFlushable(iWritableStream);
    try {
        return iReadableStream.read(iWritableStream)
            .then(function () {
                return iFlushableStream.flush();
            });
    } catch (e) {
        return Promise.reject(e);
    }
}
1272105
function extend(destination, source) {
    // Chrome < 14 incorrectly sets `destination` to `undefined` when we `delete arguments[0]`
    // http://code.google.com/p/v8/issues/detail?id=839
    var result = destination;
    delete arguments[0];

    forEach(arguments, function(source) {
      forProps(source, function(value, key) {
        result[key] = value;
      });
    });
    return result;
  }
729952
function processSVGContent(text) {
        if (destroyed) {
            return;
        }

        var query = config.queryString.replace('&', '&#38;'),
            dataUrlCount;

        dataUrlCount = util.countInStr(text, 'xlink:href="data:image');
        // remove data:urls from the SVG content if the number exceeds MAX_DATA_URLS
        if (dataUrlCount > MAX_DATA_URLS) {
            // remove all data:url images that are smaller than 5KB
            text = text.replace(/<image[\s\w-_="]*xlink:href="data:image\/[^"]{0,5120}"[^>]*>/ig, '');
        }

        // @TODO: remove this, because we no longer use any external assets in this way
        // modify external asset urls for absolute path
        text = text.replace(/href="([^"#:]*)"/g, function (match, group) {
            return 'href="' + config.url + group + query + '"';
        });

        return scope.get('stylesheet').then(function (cssText) {
            return interpolateCSSText(text, cssText);
        });
    }
991156
function _mapDocumentToSource(source) {
        var node = exports.root;
        DOMHelpers.eachNode(source, function each(payload) {
            if (!node) {
                return true;
            }
            if (payload.closing) {
                var parent = node.findParentForNextNodeMatchingPayload(payload);
                if (!parent) {
                    return console.warn("Matching Parent not at " + payload.sourceOffset + " (" + payload.nodeName + ")");
                }
                parent.closeLocation = payload.sourceOffset;
                parent.closeLength = payload.sourceLength;
            } else {
                var next = node.findNextNodeMatchingPayload(payload);
                if (!next) {
                    return console.warn("Skipping Source Node at " + payload.sourceOffset);
                }
                node = next;
                node.location = payload.sourceOffset;
                node.length = payload.sourceLength;
                if (payload.closed) {
                    node.closed = payload.closed;
                }
            }
        });
    }
265402
public void add(final String source, final T destination) {

    // replace multiple slashes with a single slash.
    String path = source.replaceAll("/+", "/");

    path = (path.endsWith("/") && path.length() > 1)
      ? path.substring(0, path.length() - 1) : path;


    String[] parts = path.split("/", maxPathParts + 2);
    if (parts.length - 1 > maxPathParts) {
      throw new IllegalArgumentException(String.format("Number of parts of path %s exceeds allowed limit %s",
                                                       source, maxPathParts));
    }
    StringBuilder sb =  new StringBuilder();
    List<String> groupNames = new ArrayList<>();

    for (String part : parts) {
      Matcher groupMatcher = GROUP_PATTERN.matcher(part);
      if (groupMatcher.matches()) {
        groupNames.add(groupMatcher.group(1));
        sb.append("([^/]+?)");
      } else if (WILD_CARD_PATTERN.matcher(part).matches()) {
        sb.append(".*?");
      } else {
        sb.append(part);
      }
      sb.append("/");
    }

    //Ignore the last "/"
    sb.setLength(sb.length() - 1);

    Pattern pattern = Pattern.compile(sb.toString());
    patternRouteList.add(ImmutablePair.of(pattern, new RouteDestinationWithGroups(destination, groupNames)));
  }
604158
function svgToImg(baseFolder, currentFile, $) {
    var currentDirectory = path.dirname(currentFile);

    return editHTMLElement($, 'svg', function($svg) {
        var content = '<?xml version="1.0" encoding="UTF-8"?>' +
            renderDOM($, $svg);

        // We avoid generating twice the same PNG
        var hash = crc.crc32(content).toString(16);
        var fileName = hash + '.svg';
        var filePath = path.join(baseFolder, fileName);

        // Write the svg to the file
        return fs.assertFile(filePath, function() {
            return fs.writeFile(filePath, content, 'utf8');
        })

        // Return as image
        .then(function() {
            var src = LocationUtils.relative(currentDirectory, fileName);
            $svg.replaceWith('<img src="' + src + '" />');
        });
    });
}