index.js
function transformerFactory(fileSet, info) {
  return transformer

  // Transformer. Adds references files to the set.
  function transformer(ast, file) {
    var filePath = file.path
    var space = file.data
    var links = []
    var landmarks = {}
    var references
    var current
    var link
    var pathname

    /* istanbul ignore if - stdin */
    if (!filePath) {
      return
    }

    references = gatherReferences(file, ast, info, fileSet)
    current = getPathname(filePath)

    for (link in references) {
      pathname = getPathname(link)

      if (
        fileSet &&
        pathname !== current &&
        getHash(link) &&
        links.indexOf(pathname) === -1
      ) {
        links.push(pathname)
        fileSet.add(pathname)
      }
    }

    landmarks[filePath] = true

    slugs.reset()

    visit(ast, mark)

    space[referenceId] = references
    space[landmarkId] = landmarks

    function mark(node) {
      var data = node.data || {}
      var props = data.hProperties || {}
      var id = props.name || props.id || data.id

      if (!id && node.type === 'heading') {
        id = slugs.slug(toString(node))
      }

      if (id) {
        landmarks[filePath + '#' + id] = true
      }
    }
  }
}
function transformerFactory(fileSet, info) {
  return transformer

  // Transformer. Adds references files to the set.
  function transformer(ast, file) {
    var filePath = file.path
    var space = file.data
    var links = []
    var landmarks = {}
    var references
    var current
    var link
    var pathname

    /* istanbul ignore if - stdin */
    if (!filePath) {
      return
    }

    references = gatherReferences(file, ast, info, fileSet)
    current = getPathname(filePath)

    for (link in references) {
      pathname = getPathname(link)

      if (
        fileSet &&
        pathname !== current &&
        getHash(link) &&
        links.indexOf(pathname) === -1
      ) {
        links.push(pathname)
        fileSet.add(pathname)
      }
    }

    landmarks[filePath] = true

    slugs.reset()

    visit(ast, mark)

    space[referenceId] = references
    space[landmarkId] = landmarks

    function mark(node) {
      var data = node.data || {}
      var props = data.hProperties || {}
      var id = props.name || props.id || data.id

      if (!id && node.type === 'heading') {
        id = slugs.slug(toString(node))
      }

      if (id) {
        landmarks[filePath + '#' + id] = true
      }
    }
  }
}
Factory to create a transformer based on the given info and set.