Socket
Book a DemoInstallSign in
Socket

@cmdlucas/markdown-metadata

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cmdlucas/markdown-metadata

Parse metadata in a markdown document

1.0.7
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Markdown Metadata

Build Status

Markdown metadata extractor. Extract metadata from a markdown document.

Installation

Install the latest version with npm or Yarn:

$ npm install @cmdlucas/markdown-metadata
$ yarn add @cmdlucas/markdown-metadata

Usage

In order to be parsed, metadata must be placed at the beginning of the markdown document between two triple dashes. Example:

---
title: Lorem ipsum dolor sit amet
author: Marcus Antonius
keywords: latin, ipsum
---

Vestibulum tortor quam, *feugiat vitae*, ultricies eget, tempor sit amet, ante.

Here's how to parse the metadata:

const metadataParser = require('@cmdlucas/markdown-metadata');

// Assuming source is a string containing the markdown document
const source = '--- title: Lorem...';

// Parse source. Result is a two-property object
const result = metadataParser(source);

// The first property, 'metadata', is the object of parsed metadata. Example:
//
// {
//     'title': 'Lorem ipsum dolor sit amet',
//     'author': 'Marcus Antonius',
//     'keywords': 'latin, ipsum'
// };
result.metadata;

// The second property, 'content', is the document source without metadata. Example:
//
// Vestibulum tortor quam, *feugiat vitae*, ultricies eget, tempor sit amet, ante.
result.content;

Parse Support

Currently, only yaml is supported. Future versions intend to support toml and other popular file configuration formats.

License

Markdown Metadata extractor is licensed under the MIT License. See the LICENSE file for details.

Keywords

markdown

FAQs

Package last updated on 16 Jun 2020

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.