Skip to content
forked from yeah/mcbean

McBean converts HTML into Markdown or Textile (and vice-versa).

Notifications You must be signed in to change notification settings

southbridgeio/mcbean

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

McBean

Description

McBean can convert documents from one format to another. McBean currently supports:

  • HTML

  • Markdown (a subset)

  • Textile (a subset)

  • Creole (a subset)

with the help of Loofah, Nokogiri, RDiscount, RedCloth and Creole.

“You can’t teach a Sneetch.” – Sylvester McMonkey McBean

Features

  • Transforms HTML into Markdown, and Markdown into HTML (with help from RDiscount).

  • Transforms HTML into Textile, and Textile into HTML (with help from RedCloth).

  • Transforms HTML into Creole, and Creole into HTML (with help from Creole).

  • Textile <-> Markdown

  • Textile <-> Creole

  • Creole <-> Markdown

  • Emitted HTML is sanitized (thanks to Loofah).

  • Fancy-pants command line utility, “mcbean”.

Problems

  • Only supports a limited subset of Markdown, Textile and Creole. Patches welcome.

Synopsis

Wrap your document (which can be either a String or an IO object):

mcbean = McBean.fragment your_html_fragment

or

mcbean = McBean.document your_html_document

or

mcbean = McBean.markdown your_markdown

or

mcbean = McBean.textile your_textile

or

mcbean = McBean.creole your_creole

And then generate the desired markup format:

mcbean.to_html
mcbean.to_markdown
mcbean.to_textile
mcbean.to_creole

Also, mcbean provides a command-line utility installed into your gem path:

$ mcbean --html="http://en.wikipedia.org/wiki/The_Sneetches_and_Other_Stories" --to-markdown
$ mcbean --markdown="treetop-1.4.2/doc/grammar_composition.markdown" --to-textile

You can try out McBean at the live demo site: mcbean.heroku.com

Side Note: Fragments vs Documents

Generally speaking, if you expect to have a DOCTYPE and a single root &lt;html&gt; node, you have a document. If you don’t expect to have a single root node, you have a fragment.

Requirements

  • Loofah >= 0.4.7 (and thusly Nokogiri)

  • RDiscount >= 1.6.0

  • RedCloth >= 4.2.0

  • Creole >= 0.3.7

Install

  • sudo gem install mcbean

Shout Outs

Thanks to David Loren Parsons and Ryan Tomayko for RDiscount.

Thanks to Jason Garber for RedCloth.

Thanks to Lars Christensen and Daniel Mendler for Creole.

License

(The MIT License)

Copyright © 2010 Mike Dalessio

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

McBean converts HTML into Markdown or Textile (and vice-versa).

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%