GithubHelp home page GithubHelp logo

mdtojson's Introduction

mds-to-json

parse md files to json.

  • usage
npm install
  • test
npm run test

example:

var mdToJson = require('../src/index.js'),
    path = require('path');

let {
    parsedFiles
} = mdToJson({});

var res = parsedFiles(path.join(__dirname, './_posts'));
console.log(res.total);
console.log(res.data[0].meta);
console.log(res.data[0].summary);
console.log(res.data[0].content);

output

  • res type: Object
var res = {
    total: 10,
    data: [
        {
            meta:{ title: '简单的dom库和轻量级mvvm框架的尝试',
            date: 2016-02-21T19:07:19.000Z,
            tags: [ 'js' ],
            id: '0',
            createTime: '2016-02-22',
            url: '2016-02-22-简单的dom库和轻量级mvvm框架的尝试',
            strTag: 'js' }
        }
    ]
}

API

  • parseFiles | Function

    return parsed data by json. 按 json 格式返回处理后的数据.

  • use add a plugin

  • parse

    • params
      • marked: Object marked options
      • dirname: 'String' the soure dirname

    parse file use plugin

  • plugins

examples:

var mdToJson = require('mds-to-json')();

mdToJson.use((res, next)=>{
    console.log(res.total);

    next(res);
})

mdToJson.use('printTotal', (res, next)=>{
    console.log(res.total);

    next(res);
})

mdToJson.parse((res)=>{
    console.log(res);
})

who used?

ssr-web(A fast, simple & powerful blog framework, powered by Node.js and Vue.)

mdtojson's People

Contributors

xiaofuzi avatar

Stargazers

 avatar fanjr avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

lemniscarte

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.