Giter Club home page Giter Club logo

md2star's Introduction

murray

Convert JSON ML tree into whatever format.

A JSON ML tree is created by the markdown-js project as an intermediate format. This project provides a walker to walk that tree format, calling into a set of passed rendering functions to allow you to write out your own resulting format.

A sample (and unfinished) HTML renderer exists that implements rendering for headings, paragraphs, links, lists and emphasis items.

The original motivation for this project was to allow rendering of markdown into React components. By supplying our own renderer to this walker, we are able to render components from our React component library, instead of plain HTML.

Installation

npm install --save murray

Usage

var walker = require('murray');

var markdownString = fs.readFileSync(pathToMarkdownFile).toString();

var htmlString = walker(walker.htmlRenderer)(markdownString);

var myReactComponentRenderer = {
  join: function (items) { return items; }
  para: function (children) { <p>{children}</p> }
  header: function (options, children) {
    <MyHeadingComponent level = {options.level}>
      {children}
    </MyHeadingComponent>
  }
  ...
};

var reactElement = walker(myReactComponentRenderer)(markdownString);

Name

Why is it called Murray? Well, it's a (tree) walker, and texas-ranger was already taken, and Murray Walker is awesome:

Murray Walker being awesome

md2star's People

Contributors

tomhicks avatar tomhicks-bsf avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

md2star's Issues

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.