All Projects → rpearce → parse-md

rpearce / parse-md

Licence: MIT License
Parse Markdown file's metadata from its content

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to parse-md

Coregpx
A library for parsing and creation of GPX location files. Purely Swift.
Stars: ✭ 132 (+780%)
Mutual labels:  metadata, parsing
markright
A customizable markdown parser in Elixir: pure pattern matching.
Stars: ✭ 14 (-6.67%)
Mutual labels:  parsing, markdown-parser
MP4Parse
C++ library for MP4 file parsing.
Stars: ✭ 55 (+266.67%)
Mutual labels:  metadata, parsing
peppy
Project metadata manager for PEPs in Python
Stars: ✭ 29 (+93.33%)
Mutual labels:  metadata
serrano
Low level Ruby client for Crossref
Stars: ✭ 26 (+73.33%)
Mutual labels:  metadata
169254
📟 A simple API that simulate AWS EC2's metadata endpoint
Stars: ✭ 15 (+0%)
Mutual labels:  metadata
audnexus
An audiobook data aggregation API, combining multiple sources of data into one, consistent source.
Stars: ✭ 18 (+20%)
Mutual labels:  metadata
Covfefe
A parser for nondeterministic context free languages
Stars: ✭ 49 (+226.67%)
Mutual labels:  parsing
isogeo-plugin-qgis
Isogeo plugin for QGIS
Stars: ✭ 13 (-13.33%)
Mutual labels:  metadata
apple-receipt
Apple InAppPurchase Receipt - Models, Parser, Validator
Stars: ✭ 25 (+66.67%)
Mutual labels:  parsing
Markdown-for-Documentation
Markdown is a HTML compatible language used for Documentation.
Stars: ✭ 14 (-6.67%)
Mutual labels:  markdown-parser
webargs-starlette
Declarative request parsing and validation for Starlette with webargs
Stars: ✭ 36 (+140%)
Mutual labels:  parsing
QueryArrow
A semantically unified SQL and NoSQL query and update system
Stars: ✭ 17 (+13.33%)
Mutual labels:  metadata
tokenizr
String Tokenization Library for JavaScript
Stars: ✭ 70 (+366.67%)
Mutual labels:  parsing
feast-java
Feast Java Components
Stars: ✭ 12 (-20%)
Mutual labels:  metadata
action-sync-node-meta
GitHub Action that syncs package.json with the repository metadata.
Stars: ✭ 25 (+66.67%)
Mutual labels:  metadata
tools-python
A Python library to parse, validate and create SPDX documents.
Stars: ✭ 65 (+333.33%)
Mutual labels:  parsing
fefe
Validate, sanitize and transform values with proper TypeScript types and zero dependencies.
Stars: ✭ 34 (+126.67%)
Mutual labels:  parsing
latex2unicode
Convert LaTeX markup to Unicode (in Scala and Java)
Stars: ✭ 28 (+86.67%)
Mutual labels:  parsing
nft.storage
😋 Free decentralized storage and bandwidth for NFTs on IPFS and Filecoin.
Stars: ✭ 309 (+1960%)
Mutual labels:  metadata

parseMD

All Contributors npm version npm downloads bundlephobia size

This library exists as a way to pass a markdown file's content and have its metadata and markdown returned as an object containing metadata and content keys.

Note that it is not trying to do anything but solve the markdown metadata vs. content parsing problem and is not parsing the markdown body, itself. You can use something like marked for that.

What It Does

For example,

---
title: This is a test
description: Once upon a time...
---
# Title of my great post
Lorem ipsum dolor...

would be parsed as

{
  metadata: {
    title: "This is a test",
    description: "Once upon a time..."
  },
  content: "# Title of my great post\nLorem ipsum dolor..."
}

Note: This tool expects that your Markdown metadata has --- boundaries, as shown above.

Usage

Installation:

npm i parse-md

Import it where you need it, and then pass it a Markdown file's content:

import fs from 'fs'
import parseMD from 'parse-md'

const fileContents = fs.readFileSync('posts/first.md', 'utf8')
const { metadata, content } = parseMD(fileContents)

console.log(metadata) // { title: 'Great first post', description: 'This is my first great post. Rawr' }
console.log(content) // "# My first post..."

Links

Note about CommonJS

If you need to CommonJS module support, use version 2.x, and require it like this:

const parseMD = require('parse-md').default

Contributors

Thanks goes to these wonderful people (emoji key):


Robert Pearce

💻 📖 💡 🤔 ⚠️

Justin Chan

🐛

Alex Gherghisan

💻 🐛 🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].