📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

remark-custom-heading-id

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-custom-heading-id

remark plugin to support Markdown Extension for custom heading IDs

2.0.0
latest
Source
npm
Version published
Weekly downloads
7K
20.79%
Maintainers
0
Weekly downloads
 
Created
Source

Build Status codecov

remark-custom-heading-id

Support for Heading ID Markdown Extensions for Remark, compatible with MDX.js.

Get Started

Most users should use remark-custom-heading-id:

$ npm install remark-custom-heading-id --save

... with vanilla Remark

import {remarkHeadingId} from 'remark-custom-heading-id';
import {remark} from 'remark';
import html from 'remark-rehype';
import stringify from 'rehype-stringify';

const result = remark()
  .use(remarkHeadingId)
  .use(html)
  .use(stringify)
  .processSync(`# Hello, world {#hello}`);
console.log(String(result));

// Outputs:
// <h1 id="hello">Hello, world<h1>

... with MDX Remark

import {remarkHeadingId} from 'remark-custom-heading-id';
import {remark} from 'remark';
import remarkMdx from 'remark-mdx';
import html from 'remark-rehype';
import stringify from 'rehype-stringify';

const result = remark()
  .use(remarkMdx)
  .use(remarkHeadingId)
  .use(html)
  .use(stringify)
  .processSync(`# Hello, world {#hello}`);

console.log(String(result));

// Outputs:
// <h1 id="hello">Hello, world<h1>

... with MDX-based plugins (e.g. next-mdx-remote)

import {remarkHeadingId} from 'remark-custom-heading-id';
import {serialize} from 'next-mdx-remote/serialize'; // or similar...

export default async function getMdxProps(source) {
  return await serialize(source, {
    mdxOptions: {
      remarkPlugins: [remarkHeadingId],
    },
  });
}

Keywords

unified

FAQs

Package last updated on 22 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts