Socket
Socket
Sign inDemoInstall

md-article

Package Overview
Dependencies
63
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    md-article

Extract data from markdown article


Version published
Weekly downloads
2
Maintainers
1
Install size
5.60 MB
Created
Weekly downloads
 

Readme

Source

md-article

NPM version Build Status Coveralls Status Dependency Status

Extract data from your markdown article

Install

npm install --save md-article

Usage

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>

API

extract(input, dateFormat, dateLocale)

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: text and html
  • tags: list, text and html
  • date: text, html, unix and moment

Also everything in returned mdast object node, see MDAST.

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.

  • 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

Roadmap

  • remark instead of commonmark for all markdown helpers

License

MIT © Aleksandr Filatov

Keywords

FAQs

Last updated on 23 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc