0.3.0 • Published 6 years ago

mark-to-json v0.3.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

mark-to-json NpmVersion NodeVersion

Parse the markdown into a JSON static file, also support multiple-level directories.

Installing

# npm
npm i mark-to-json --save

# yarn
yarn add mark-to-json

Usage

APIRequireddefaultDescription
tokentrueYour markdown file content including yaml matter
destfalse./default.jsonYour JSON static file will be created at the place based on the current nodejs working path
extraHeaderfalse{}It will be mix in JSON file if you want to add some extra data to JSON static file
contentKeyfalsecontentIt will be the key of markdown content part in JSON static file
filterfalseIt can be used to change output schema (sample).

Sample

const Mtj = require('mark-to-json')

new Mtj({
  token: '---\ntitle: Hello world\n---\nThis is content.',
  dest: './writings/hello-world.json',
  extraHeader: {
    errno: 0
  },
  contentKey: 'content',

  // Only work with one parameter: schema
  filter (schema) {
    // do something
    // `return` is optional
  }
})

// You can find your json file at the './writings/hello-world.json' based on the current nodejs working path

The sample output file: here

Changelog

Changelog