diff --git a/index.js b/index.js index 6a850c0..a9bb6bc 100644 --- a/index.js +++ b/index.js @@ -58,7 +58,7 @@ function anchor (md, opts) { let slug = token.attrGet('id') if (slug == null) { - slug = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex) + slug = uniqueSlug(opts.slugify(title, state.env), slugs, false, opts.uniqueSlugStartIndex) } else { slug = uniqueSlug(slug, slugs, true, opts.uniqueSlugStartIndex) } diff --git a/test.js b/test.js index 55f0713..146122a 100644 --- a/test.js +++ b/test.js @@ -232,6 +232,13 @@ test('getTokensText', t => { ) }) +test('slugify', t => { + t.is( + md().use(anchor, { slugify: (title, env) => `${env.docId}-${title}` }).render('# bar', { docId: 'foo' }), + '