parses a markdown file and returns a configuration object

Installation | API | Annotated source License

NPM version Build Status Dependency Status JavaScript Style Guide KLP


npm install mdconf-from --save


This package assumes that:

  1. The markdown file is utf8 encoded.
  2. There is a single h1 section.
  3. There is a ## Configuration section, like this.

See also mdconf to learn how Markdown driven configuration works.


// Suppose you are parsing this file itself.
var config = require('mdconf-from')('')

console.log( // bar


This package does not use any configuration at all, this section is here only for test and documentation purpouse.

Annotated source

Actually this package is a wrapper around mdconf.

var fs = require('fs')
var mdconf = require('mdconf')

function mdconfFrom (file) {

Parse the markdown in given file.

  var content = fs.readFileSync(file, 'utf8')
  var markdownObj = mdconf(content)

Extract the Configuration section.

  var rootKey = Object.keys(markdownObj)[0]
  var config = markdownObj[rootKey].configuration

  return config

Export function

module.exports = mdconfFrom