identify

Generate id attributes for HTML block elements

npm install identify
7 downloads in the last week
28 downloads in the last month

identify.js

Generate id attributes for HTML block elements.

Usage

var identify = require('identify');
var html = "<h1>The Wizard of Oz</h1><p>The morning after the balloon</p>";
console.log(identify(html));
// <h1 id="the-wizard-of-oz">The Wizard of Oz</h1><p id="the-morning-after">The morning after the balloon</p>

For a more complete example, see gh-pages/example, e.g. deep-linking to the first blockquote.

Install

npm install identify

Options

Pass an extra object to identify() to set options. The defaults are:

{
  block_elements: block_elements,
  anchor: false
}
  • block_elements: a list of elements to add id attributes to. Defaults to all HTML(5) block elements, as specified by the Mozilla Developer Network.

  • anchor: prepend an anchor to each element, for example:

      <h1 id="the-wizard-of-oz"><a href="#the-wizard-of-oz" class="anchor"></a>The Wizard of Oz</h1>
    

Author

Copyright 2012 Tom Vincent http://tlvince.com/contact

License

Released under the MIT License.

npm loves you