article-data
Extract data from your markdown article
Install
npm install --save article-data
Usage
import extract from './index';
const input = `
# title
_24 july 2015_
desc
![alt](http://yo.io/)
content1
content2`;
const article = extract(input, 'D MMMM YYYY', 'en');
article.title.text;
article.date.text;
article.desc.text;
article.image.src;
article.content.html;
API
Return object { title, date, desc, image, content }
.
I hope that all fields have self-explanatory names. Anyway, desc
and content
should be explained further: desc
— first paragraph without date, content
input without title and date. All the fields are objects with such fields:
- title, desc, content:
text
and html
- date:
text
, html
, unix
and moment
- image:
alt
, src
and html
Also everything in returned object has node
field, which is an AST node, see commonmark API.
input
Required
Type: String
Markdown string.
dateFormat
Required
Type: String
Momentjs format for date, e.g. D MMMM YYYY
.
dateLocale
Required
Type: String
One of 83 available in momentjs locales, e.g. en
or fr
.
Related
License
MIT © Vladimir Starkov