Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
textile+lhs2html
#!/usr/bin/env ruby
#
# textile+lhs2html
#
# A script for transforming Literate Haskell
# with Textile-formatted text to HTML with
# the help of Ruby and RedCloth.
#
# Written by Christoffer Sawicki in 2009.
# Released into the public domain.
require "redcloth"
require "erb" # for ERB::Util.h
def interact() STDOUT.puts(yield(STDIN.read)) end
interact { |text|
text.split("\n\n").map { |block|
if block.split("\n").all? { |line| line[0] == ?> }
%{<pre><code>#{ERB::Util.h(block)}</code></pre>}
else
RedCloth.new(block).to_html
end
}.join("\n\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.