Sha256: 1fdea85bcf1e98f0b7d8614fda954306c13e351ea5cc491a55626710a6c47c3a
Contents?: true
Size: 1 KB
Versions: 16
Compression:
Stored size: 1 KB
Contents
#!/usr/bin/env ruby # Usage: commonmarker [--html-renderer] [FILE..] # Convert one or more CommonMark files to HTML and write to standard output. # If no FILE argument is provided, text will be read from STDIN. # With --html-renderer, use the HtmlRenderer renderer rather than the native C # renderer. if ARGV.include?('--help') or ARGV.include?('-h') File.read(__FILE__).split("\n").grep(/^# /).each do |line| puts line[2..-1] end exit 0 end $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w( .. lib )) require 'commonmarker' if ARGV.include?('--version') or ARGV.include?('-v') puts "commonmarker #{CommonMarker::VERSION}" exit 0 end root = File.expand_path('../../', __FILE__) $:.unshift File.expand_path('lib', root) renderer = nil ARGV.delete_if do |arg| if arg =~ /^--html-renderer$/ renderer = CommonMarker::HtmlRenderer.new true else false end end doc = CommonMarker.render_doc(ARGF.read) if renderer STDOUT.write(renderer.render(doc)) else STDOUT.write(doc.to_html) end
Version data entries
16 entries across 16 versions & 1 rubygems