get-md-content

1.0.0 • Public • Published

get-md-content

NPM version Build Status Coveralls Status Dependency Status

get content from markdown article

Install

npm install --save get-md-content

Usage

import getContent from 'get-md-content';
 
const isHeader = node => node.type === 'Header'; // small helper function
 
const simple = `
# header
 
content`;
 
// simple get content without header
getContent(simple, ['header']).text); // content
getContent(simple, [/header/]).text); // content
getContent(simple, [isHeader]).text); // content
 
const basic = `
# header
 
20 December 2012
 
content
 
with two paragraphs`;
 
// basic get content without header and date
getContent(basic, [/header/, /december/gim]).text; // content\n\nwith two paragraphs

API

getContent(input, removeList)

input

Required
Type: String

Markdown string.

removeList

Type: Array of Function || RegExp || String
Default: []

Matched nodes will be removed.
String or RegExp will be matched against plaintext markdown nodes.
Function takes commonmark node as a first param, and ast iteration event as a second param. Check out commonmark-helpers shortcuts and commonmark api

Related

License

MIT © Vladimir Starkov

Package Sidebar

Install

npm i get-md-content

Weekly Downloads

7

Version

1.0.0

License

MIT

Last publish

Collaborators

  • iamstarkov