Extract data from your markdown article
npm install --save md-article
import extract from 'md-article';
const input = `
# title
_24 june 2016_
#tag1 #tag2 #tag3;
desc
content1
content2`;
const article = extract(input, 'D MMMM YYYY', 'en');
article.title.text; // title
article.date.text; // 24 june 2016
article.tags.text; // tag1 tag2 tag3
article.content.html; // <p>desc</p>
// <p>content1</p>
// <p>content2</p>Return object { title, date, tags, content }.
I hope that all fields have self-explanatory names.
Anyway, tags and content should be explained further: desc — paragrapgh with elements like #tag1 #tag2;, content input without title, tags and date. All the fields are objects with such fields:
- title, content:
textandhtml - tags:
list,textandhtml - date:
text,html,unixandmoment
Also everything in returned mdast object node, see MDAST.
Required
Type: String
Markdown string.
Required
Type: String
Momentjs format for date, e.g. D MMMM YYYY.
Required
Type: String
One of 83 available in momentjs locales, e.g. en or fr.
- md-title — get title from markdown article
- md-date — get date from markdown article
- md-tags — get tags from markdown article
- md-content — get content from markdown article
-
remarkinstead ofcommonmarkfor all markdown helpers
MIT © Aleksandr Filatov