Skip to content

Commit

Permalink
Remove use of remark-slug
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 12, 2018
1 parent ff5eb0d commit 91449c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ var url = require('url')
var propose = require('propose')
var visit = require('unist-util-visit')
var definitions = require('mdast-util-definitions')
var toString = require('mdast-util-to-string')
var hostedGitInfo = require('hosted-git-info')
var urljoin = require('urljoin')
var slug = require('remark-slug')
var slugs = require('github-slugger')()
var xtend = require('xtend/mutable.js')

/* Optional Node dependencies. */
Expand Down Expand Up @@ -75,8 +76,8 @@ function validateLinks(options, fileSet) {
}
}

/* Attach `slug` and a plugin that adds our transformer after it. */
this.use(slug).use(subplugin)
/* Attach a plugin that adds our transformer after it. */
this.use(subplugin)

/* Attach a `completer`. */
if (fileSet) {
Expand All @@ -103,10 +104,9 @@ function apiTransform(tree, file) {
/* Completer for the CLI (multiple files, and support to add more). */
function cliCompleter(set, done) {
var exposed = {}
var check = checkFactory(exposed)

set.valueOf().forEach(expose)
set.valueOf().forEach(check)
set.valueOf().forEach(checkFactory(exposed))

done()

Expand Down Expand Up @@ -169,15 +169,17 @@ function transformerFactory(fileSet, info) {

landmarks[filePath] = true

slugs.reset()

visit(ast, mark)

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

function mark(node) {
var data = node.data || {}
var attrs = data.hProperties || data.htmlAttributes || {}
var id = attrs.name || attrs.id || data.id
var props = data.hProperties || {}
var id = props.name || props.id || data.id || slugs.slug(toString(node))

if (id) {
landmarks[filePath + '#' + id] = true
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
"index.js"
],
"dependencies": {
"github-slugger": "^1.2.0",
"hosted-git-info": "^2.5.0",
"mdast-util-definitions": "^1.0.0",
"mdast-util-to-string": "^1.0.4",
"propose": "0.0.5",
"remark-slug": "^5.0.0",
"unist-util-visit": "^1.0.0",
"urljoin": "^0.1.5",
"xtend": "^4.0.1"
Expand Down

0 comments on commit 91449c6

Please sign in to comment.