Sha256: c9fe6d68c81ba80869919d2157dbccfec8833ffdf1b65c993b5c22950b0ea716
Contents?: true
Size: 970 Bytes
Versions: 4
Compression:
Stored size: 970 Bytes
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 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::Node.parse_file(ARGF) if renderer STDOUT.write(renderer.render(doc)) else STDOUT.write(doc.to_html) end doc.free
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
commonmarker-0.1.2 | bin/commonmarker |
commonmarker-0.1.1 | bin/commonmarker |
commonmarker-0.1.0 | bin/commonmarker |
commonmarker-0.0.1 | bin/commonmarker |