Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/markedjs/marked-custom-heading-id

Add custom id to headings with {#...} syntax
https://github.com/markedjs/marked-custom-heading-id

custom extension heading id marked

Last synced: 2 months ago
JSON representation

Add custom id to headings with {#...} syntax

Awesome Lists containing this project

README

        

# marked-custom-heading-id

Specify a custom heading id in headings with the [Markdown Extended Syntax](https://www.markdownguide.org/extended-syntax/#heading-ids) `# heading {#custom-id}`

The heading will be rendered with the string between `{#` and `}`

The id must be a valid id with the following criteria:

- Must start with a letter (`A-Z`, `a-z`)
- Must only contain word characters (`A-Z`, `a-z`, `0-9`, `_`) or dashes (`-`)

# Usage

```js
import { marked } from "marked";
import customHeadingId from "marked-custom-heading-id";

// or UMD script
//
//

marked.use(customHeadingId());

marked("# heading {#custom-id}");
//

heading


```