uniorg-slug
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

uniorg-slug

uniorg plugin to add anchors headings using GitHub's algorithm. Similar to rehype-slug but respects org-mode's CUSTOM_ID (as org-html-export).

Install

npm install uniorg-slug

Use

import { unified } from 'unified';
import uniorgParse from 'uniorg-parse';
import { uniorgSlug } from 'uniorg-slug';
import uniorg2rehype from 'uniorg-rehype';
import html from 'rehype-stringify';

const node = unified()
  .use(uniorgParse)
  .use(uniorgSlug)
  .use(uniorg2rehype)
  .use(html)
  .processSync(`
* headline
** nested headline
:PROPERTIES:
:CUSTOM_ID: blah
:END:
** headline
:PROPERTIES:
:ID: my-id
:END:
~id~ property is ignored.
`);

console.log(node.toString());

will output:

  <h1 id="headline">headline</h1>
  <h2 id="blah">nested headline</h2>
  <h2 id="headline-1">headline</h2>
  <p><code class="inline-code">id</code> property is ignored.</p>

License

GNU General Public License v3.0 or later

Package Sidebar

Install

npm i uniorg-slug

Weekly Downloads

59

Version

1.0.1

License

GPL-3.0-or-later

Unpacked Size

39.9 kB

Total Files

6

Last publish

Collaborators

  • rasendubi
  • thomasfkjorna