@@ -4,9 +4,10 @@ var url = require('url')
44var propose = require('propose')
55var visit = require('unist-util-visit')
66var definitions = require('mdast-util-definitions')
7+var toString = require('mdast-util-to-string')
78var hostedGitInfo = require('hosted-git-info')
89var urljoin = require('urljoin')
9−var slug = require('remark-slug')
10+var slugs = require('github-slugger')()
1011var xtend = require('xtend/mutable.js')
1112
1213/* Optional Node dependencies. */
@@ -75,8 +76,8 @@ function validateLinks(options, fileSet) {
7576 }
7677 }
7778
78− /* Attach `slug` and a plugin that adds our transformer after it. */
79− this.use(slug).use(subplugin)
79+ /* Attach a plugin that adds our transformer after it. */
80+ this.use(subplugin)
8081
8182 /* Attach a `completer`. */
8283 if (fileSet) {
@@ -103,10 +104,9 @@ function apiTransform(tree, file) {
103104/* Completer for the CLI (multiple files, and support to add more). */
104105function cliCompleter(set, done) {
105106 var exposed = {}
106− var check = checkFactory(exposed)
107107
108108 set.valueOf().forEach(expose)
109− set.valueOf().forEach(check)
109+ set.valueOf().forEach(checkFactory(exposed))
110110
111111 done()
112112
@@ -169,6 +169,8 @@ function transformerFactory(fileSet, info) {
169169
170170 landmarks[filePath] = true
171171
172+ slugs.reset()
173+
172174 visit(ast, mark)
173175
174176 space[referenceId] = references
@@ -176,8 +178,8 @@ function transformerFactory(fileSet, info) {
176178
177179 function mark(node) {
178180 var data = node.data || {}
179− var attrs = data.hProperties || data.htmlAttributes || {}
180− var id = attrs.name || attrs.id || data.id
181+ var props = data.hProperties || {}
182+ var id = props.name || props.id || data.id || slugs.slug(toString(node))
181183
182184 if (id) {
183185 landmarks[filePath + '#' + id] = true