Parse out meta data from your markdown content


Parse meta Markdown data and render in the browser or server. Transform this:

Optional Heading
tags: test
The two newlines preceding this paragraph are important.

into this:

{ title: '',
  tags: 'test',
  body: '<h1>Optional Heading</h1><p>The two newlines preceding this paragraph are important.</p>' }
npm install metamd
<script type="text/javascript" src="metamd.client.min.js"></script>
var fs = require('fs');
var metamd = require('metamd');
var parsed = metamd(fs.readFileSync('./example/', 'utf-8'));

Will result in:

> { title: '',
    tags: 'test',
    body: 'Page 1\n=\n\nThis is a _test_.\n\n```\nThis is another test\n```' }
> <h1>Page 1
  <p>This is a <em>test</em>.
  <pre><code>This is another test</code></pre>

Returns an instance of Metamd.

Returns an object containing the meta data. If key is provided, just that value will be returned.

Returns the markdown absent of the meta data.

Returns html rendered using marked.

NOTE: Meta data keys should be alphanumneric plus underscores. Nothing else will be parsed. Also be careful not to use reserved words or _body as keys.

Testing is done with mocha and chai and can be run on the server or client. Remember to install the dev dependencies before running the tests.

npm test

Navigate to test/browser/index.html.

If you make changes, you need to recompile for browser usage. After you install the dev dependencies, it's easy:

npm run compile