Category Archives: BlueCloth

Using the Ruby BlueCloth Library(for Markdown)

  1. Attention folks who used this before 11:54 P.M. US Central Time on May 3rd. I fixed a typo in the instructions from gem install ruby to gem install bluecloth.
  2. Install the BlueCloth module by typing in sudo gem install bluecloth. For Windows, you can simply type in gem install bluecloth
  3. Here is the code I created to make it easy to convert Markdown-formatted documents to HTML:
  4. #!/usr/bin/env ruby


    if RUBY_PLATFORM =~ /darwin/

    require rubygems
    require_gem BlueCloth, >=0.0.4
    else
    require BlueCloth

    end

    s = “”
    ARGF.each do |line|
    s << line
    end
    doc = BlueCloth::new(s)
    File.open(markup.html,w) do |file|
    file << doc.to_html
    end

To actually use the code, you can do this:

Download the plaintext script from the Blue Box widget to your left(it is called markit.rb)

*nix, OS X, go to the directory you put this script in, and type in Terminal: ruby markit.rb <yourfile.txt>

where <yourfile.txt> is a placeholder for your actual text file containing the markdown markup (hehe, is that an oxymoron or what). Your result will be put into the file in the same directory called markup.html.

I’ll try to provide a simple GUI frontend for this script(with a file chooser or something else) on of these days, depending on my free time.