1.0.0 • Published 9 years ago
get-md-content v1.0.0
get-md-content
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
- get-md-date - get date from markdown article
- get-md-desc - get description from markdown article
- get-md-image - get image from markdown article
- get-md-title - get title from markdown article
License
MIT © Vladimir Starkov