TheSeg / marked-gfm-heading-id

Add unique heading ids like GitHub

Home Page:https://www.npmjs.com/package/marked-gfm-heading-id

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

marked-gfm-heading-id

Add ids to headings like GitHub.

Usage

import { marked } from "marked";
import { gfmHeadingId } from "marked-gfm-heading-id";

// or UMD script
// <script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
// <script src="https://cdn.jsdelivr.net/npm/marked-gfm-heading-id/lib/index.umd.js"></script>

const options = {
	prefix: "my-prefix-",
};

marked.use(gfmHeadingId(options));

marked("# heading");
// <h1 id="my-prefix-heading">heading</h1>

options

option type default description
prefix string "" A string to prepend to all ids.

About

Add unique heading ids like GitHub

https://www.npmjs.com/package/marked-gfm-heading-id

License:MIT License


Languages

Language:JavaScript 99.3%Language:TypeScript 0.7%