A lightweight JavaScript library for parsing Markdown metadata and content separately
npm install parsemarkjs
Import
// import ParseMark from './ParseMark.module.js'; // if you have downloaded the js file
import ParseMark from 'parsemarkjs';
Include the following script tag in your HTML file:
<script src="https://cdn.jsdelivr.net/gh/SH20RAJ/ParseMark@main/ParseMark.js"></script>
const markdown = `
---
title: "Sample Post"
tags: javascript, library, markdown
datePublished: Fri, 04 Feb 2024 12:00:00 GMT
---
# Sample Post
This is a sample post content.
`;
const parser = new ParseMark(markdown);
const metadata = parser.getMetadata();
console.log('Metadata:', metadata);
const rawMetadata = parser.getRawMetadata();
console.log('Raw Metadata:', rawMetadata);
const content = parser.getContent();
console.log('Content:', content);
This project is licensed under the MIT License - see the LICENSE file for details.