Socket
Socket
Sign inDemoInstall

remark-frontmatter

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-frontmatter

Frontmatter (yaml, toml, and more) support for remark


Version published
Weekly downloads
1.1M
increased by8.27%
Maintainers
1
Weekly downloads
 
Created

What is remark-frontmatter?

The remark-frontmatter package is a plugin for the remark processor that allows you to parse and manipulate frontmatter in Markdown files. Frontmatter is typically used to include metadata at the beginning of a Markdown document, often in YAML or TOML format.

What are remark-frontmatter's main functionalities?

Parsing YAML frontmatter

This feature allows you to parse YAML frontmatter in a Markdown file. The code sample demonstrates how to use the remark-frontmatter plugin to parse YAML frontmatter and process the Markdown content.

const remark = require('remark');
const frontmatter = require('remark-frontmatter');

const markdown = `---
title: Example Title
date: 2023-10-01
---

# Hello World
`;

remark()
  .use(frontmatter, ['yaml'])
  .process(markdown, function (err, file) {
    if (err) throw err;
    console.log(String(file));
  });

Parsing TOML frontmatter

This feature allows you to parse TOML frontmatter in a Markdown file. The code sample demonstrates how to use the remark-frontmatter plugin to parse TOML frontmatter and process the Markdown content.

const remark = require('remark');
const frontmatter = require('remark-frontmatter');

const markdown = `+++
title = "Example Title"
date = "2023-10-01"
+++

# Hello World
`;

remark()
  .use(frontmatter, ['toml'])
  .process(markdown, function (err, file) {
    if (err) throw err;
    console.log(String(file));
  });

Parsing multiple types of frontmatter

This feature allows you to parse multiple types of frontmatter (e.g., YAML and TOML) in a Markdown file. The code sample demonstrates how to use the remark-frontmatter plugin to parse both YAML and TOML frontmatter and process the Markdown content.

const remark = require('remark');
const frontmatter = require('remark-frontmatter');

const markdown = `---
title: Example Title
date: 2023-10-01
---

# Hello World
`;

remark()
  .use(frontmatter, ['yaml', 'toml'])
  .process(markdown, function (err, file) {
    if (err) throw err;
    console.log(String(file));
  });

Other packages similar to remark-frontmatter

Keywords

FAQs

Package last updated on 04 Dec 2017

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