Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaydson/marked-metadata
Markdown parser (using marked) with metadata header support
https://github.com/jaydson/marked-metadata
Last synced: 3 months ago
JSON representation
Markdown parser (using marked) with metadata header support
- Host: GitHub
- URL: https://github.com/jaydson/marked-metadata
- Owner: jaydson
- Created: 2014-06-04T02:49:39.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-13T05:01:23.000Z (over 10 years ago)
- Last Synced: 2024-10-09T12:38:48.978Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 317 KB
- Stars: 9
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
marked-metadata
================
[![Build Status](https://travis-ci.org/jaydson/marked-metadata.svg?branch=master)](https://travis-ci.org/jaydson/marked-metadata)Markdown parser (using marked) with metadata header support.
## Installing
```shell
npm install marked-metadata
```Then, just require marked-metadata in your project:
```javascript
var mkmeta = require('marked-metadata');
```## How to use
marked-metadata was built on top of the awesome [marked](https://github.com/chjj/marked).
But sometimes you need some meta information about the markdown file.
Normally a pattern like is used to define a header metadata:
```text```
Or something like this pattern:
```text
---
layout: post
title: hello world
---
```With marked-metadata you can parse any header metadata, using the defineTokens method:
```javascript
var md = new MarkedMetaData('./test/test.md');
md.defineTokens('');
```You can get just the markdown metadata:
```javascript
var md = new MarkedMetaData('./test/test.md');
md.defineTokens('');
var meta = md.metadata();
```And you can get just the markdown content (without the header)
```javascript
var md = new MarkedMetaData('./test/test.md');
md.defineTokens('');
var content = md.markdown();
```You can crop a markdown file by a given identifier:
```javascript
var md2 = new MarkedMetaData('./test/test.md');
md2.defineTokens('');
md2.markdown({ crop : '{{more}}'});
```## Contribute
Fork > Pull-request## Tests
```shell
npm test
```