Sha256: b9fe0d0ae56cc06cfceca8cc286a4523b1de4d1b10033481cf5e7c5b2393d53e

Contents?: true

Size: 1.34 KB

Versions: 38

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/ruby
#
# = bluecloth
#
# Format one or more text files with the markdown formatter.
#
# = Synopsis
#
#   bluecloth [OPTIONS] [FILES]
#
# 
#

BEGIN {
	require 'bluecloth'
	require 'optparse'
}

DocumentWrapper = %{
<html>
  <head><title>%s</title></head>
  <body>
%s
  </body>
</html>
}

def main
	fragment = false
	destination = '.'

	ARGV.options do |oparser|

		oparser.banner = "Usage: #$0 [OPTIONS] FILES"

		# Debug mode
		oparser.on( "--debug", "-d", TrueClass, "Turn debugging output on" ) {
			$DEBUG = true
		}

		# 'Fragment' mode
		oparser.on( "--fragment", "-f", TrueClass,
			"Output HTML fragments instead of whole documents" ) {
			fragment = true
		}

		# Output destination
		#oparser.on( "--output=DESTINATION", "-o DESTINATION", String,
		#	"Write output to DESTINATION instead of the current directory" ) {|arg|
		#	destination = arg
		#}

		oparser.parse!
	end

	# Filter mode if no arguments
	ARGV.push( "-" ) if ARGV.empty?

	ARGV.each {|file|
		if file == '-'
			contents = $stdin.read
		else
			contents = File::read( file )
		end

		bc = BlueCloth::new( contents )
		$stderr.puts "Using BlueCloth version #{BlueCloth::VERSION}"

		if fragment
			$stdout.puts bc.to_html
		else
			$stdout.puts DocumentWrapper % [ file, bc.to_html ]
		end
	}

rescue => err
	$stderr.puts "Aborting: Fatal error: %s" % err.message
	exit 255
end



main

Version data entries

38 entries across 38 versions & 3 rubygems

Version Path
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/bluecloth-2.2.0/bin/bluecloth
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/bluecloth-2.1.0/bin/bluecloth
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/bluecloth-2.1.0/bin/bluecloth
radiant-1.0.0 ruby-debug/ruby/1.8/gems/bluecloth-2.1.0/bin/bluecloth
bluecloth-2.2.0 bin/bluecloth
bluecloth-2.1.0-x86-mswin32 bin/bluecloth
bluecloth-2.1.0-x86-mingw32 bin/bluecloth
bluecloth-2.1.0 bin/bluecloth
bluecloth-2.0.11 bin/bluecloth
bluecloth-2.0.11-x86-mswin32 bin/bluecloth
bluecloth-2.0.11-x86-mingw32 bin/bluecloth
bluecloth-2.0.11pre158-x86-mingw32 bin/bluecloth
bluecloth-2.0.11pre158-x86-mswin32 bin/bluecloth
bluecloth-2.0.11pre158 bin/bluecloth
bluecloth-2.0.10 bin/bluecloth
bluecloth-2.0.9 bin/bluecloth
bluecloth-2.0.7 bin/bluecloth
bluecloth-2.0.7-x86-mswin32 bin/bluecloth
bluecloth-2.0.7-x86-mingw32 bin/bluecloth
bluecloth-2.0.7.pre126 bin/bluecloth