Add anchors to remark heading nodes using GitHub’s
algorithm.
Works great with remark-html,
used by remark-toc and
remark-man.
Installation
npm:
npm install remark-slug
remark-slug is also available for duo, and as an
AMD, CommonJS, and globals module, uncompressed and compressed.
Usage
Dependencies:
var slug = require('remark-slug');
var remark = require('remark');
var html = require('remark-html');
Process:
var doc = remark().use(slug).use(html).process('# Foo bar');
Yields:
<h1 id="foo-bar">Foo bar</h1>
CLI
remark readme.md -u slug
API
Adds slugs to markdown headings.
Sets data.id
and data.htmlAttributes.id
on heading nodes. The first can be
used by any plugin as a unique identifier, the second tells remark-html to
use its value as an id
attribute. remark-slug does not overwrite these
values when they already exist.
Parameters:
License
MIT © Titus Wormer