Coder Social home page Coder Social logo

rowhit / endophile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thejohnnybrown/endophile

0.0 1.0 0.0 78 KB

A Clojure markdown parsing tool wrapping the java pegdown library. It is designed to convert markdown into clojure data structures, which can then be used to generate HTML through another library, such as enlive or hiccup.

Clojure 38.07% HTML 61.93%

endophile's Introduction

endophile

Build Status

A Clojure markdown parsing tool wrapping java's pegdown library. It is designed to convert markdown into clojure data structures, which can then be used to generate HTML through another library, such as enlive or hiccup.

Endophile fully passes the original markdown test suite.

Usage

In project.clj, :dependencies [[endophile "0.2.1"] ...]

endophile.core/md takes a markdown string, and returns an org.pegdown.ast.RootNode, the root of the document's parse tree. endophile.core/to-clj converts a RootNode into a clojure data structure. Currently it returns nodes as used in clojure.xml and in the enlive HTML library.

So for example,

(ns my-namespace
  (:use [endophile.core :only [mp to-clj html-string]]
        [endophile.hiccup :only [to-hiccup]]
        [hiccup.core :only [html]]))

;; parsed is an org.pegdown.RootNode
(def parsed (mp (slurp "README.md")))

;; convert to html using clojure.xml and enlive
(println (html-string (to-clj parsed)))

;; convert to html using hiccup
(println (html (to-hiccup parsed)))

Will convert README.md to html. Also you can run it from the command line, like so,

lein run -m endophile.core README.md > README.html

There is also an implementation that returns hiccup-style vectors. See hiccup.clj.

TODO

Currently does not support the full complement of extensions available through pegdown. Pull requests are encouraged.

License

Copyright © 2013 Jonathan Brown

Distributed under the Eclipse Public License, the same as Clojure.

endophile's People

Contributors

deraen avatar igoryuga avatar jarppe avatar jbarber avatar malcolmsparks avatar outamaa avatar rippedathlete avatar snurppa avatar thejohnnybrown avatar

Watchers

 avatar

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.