get-md-content

get content from markdown article

Usage no npm install needed!

<script type="module">
  import getMdContent from 'https://cdn.skypack.dev/get-md-content';
</script>

README

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