Created
November 29, 2009 22:05
-
-
Save qerub/245091 to your computer and use it in GitHub Desktop.
textile+lhs2html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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