Socket
Socket
Sign inDemoInstall

article-data

Package Overview
Dependencies
17
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    article-data

Extract data from your markdown article


Version published
Maintainers
1
Install size
9.02 MB
Created

Readme

Source

article-data

NPM version Build Status Coveralls Status Dependency Status

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;    // title
article.date.text;     // 24 july 2015
article.desc.text;     // desc
article.image.src;     // http://yo.io/
article.content.html;  // <p>desc</p>
                       // <p><img src="http://yo.io/" alt="" /></p>
                       // <p>content1</p>
                       // <p>content2</p>

API

extract(input, dateFormat, dateLocale)

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.

License

MIT © Vladimir Starkov

Keywords

FAQs

Last updated on 11 Aug 2015

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