:warning: mdast is currently being renamed to remark :warning:
This means all plug-ins and relating projects change too, causing many
changes across the ecosystem. Expect the dust to settle in roughly a day.
See this project at the previous stable commit
c4a51d1.
Add anchors to remark heading nodes.
Works great with remark-html,
used by remark-toc and
remark-man.
Installation
npm:
npm install remark-slug
remark-slug is also available for bower,
component, and
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 ... -u remark-slug
remark ... -u 'remark-slug=library:"npm"'
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:
-
slug
— This plugin;
-
options
(Object?
)
License
MIT © Titus Wormer