New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

article-data

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

article-data

Extract data from your markdown article

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-56.25%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 11 Aug 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc