New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vcarl/remark-headings

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vcarl/remark-headings

Remark plugin to extract heading metadata while processing markdown files

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.9K
decreased by-12.79%
Maintainers
1
Weekly downloads
 
Created
Source

remark-headings

A remark plugin to add metadata about headings to the parsed output.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

yarn add @vcarl/remark-headings

Use

Running:

import remarkHeadings from '@vcarl/remark-headings';

import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkStringify from "remark-stringify";

const processor = unified()
  .use(remarkParse)
  .use(remarkStringify)
  .use(remarkHeadings);

const input = fs.readFileSync("input.md");

/*
# Heading 1
## Heading 2
### Heading 3
*/
const vfile = await processor.process(input);

console.log(vfile.data.headings)

Yields:

[
  {"depth": 1, "value": "Heading 1"},
  {"depth": 2, "value": "Heading 2"},
  {"depth": 3, "value": "Heading 3"},
]

As a courtesy, any other data found to be attached to the node by other plugins will be forwarded through. For instance if you're using remark-heading-id, that custom ID will look like:

[
  {"depth": 1, "value": "Heading 1", "data": {"id": "custom-id"}},
  {"depth": 2, "value": "Heading 2"},
  {"depth": 3, "value": "Heading 3"},
]

License

[MIT][license] © [Carl Vitullo][author]

Keywords

FAQs

Package last updated on 14 Oct 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc