Sha256: 98074e4ac9a9a9e1e1db2826db657f6498817f8b3b8f700e8cca9bdcc32509c3
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
#!/usr/bin/env ruby # Usage: commonmarker [--html-renderer] [--list-extensions] [--extension=EXTENSION] [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. # With --extension=EXTENSION, EXTENSION will be used for parsing, and HTML # output unless --html-renderer is specified. 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) extensions = CommonMarker.extensions active_extensions = [] renderer = nil ARGV.delete_if do |arg| if arg =~ /^--html-renderer$/ renderer = CommonMarker::HtmlRenderer.new true elsif arg =~ /^--list-extensions$/ puts extensions exit 0 elsif arg =~ /^--extension=(.+)$/ if extensions.include?($1) active_extensions << $1 else STDERR.puts "extension #$1 not found" exit 1 end true else false end end doc = CommonMarker.render_doc(ARGF.read, :default, active_extensions) if renderer STDOUT.write(renderer.render(doc)) else STDOUT.write(doc.to_html(:default, active_extensions)) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
commonmarker-0.11.0 | bin/commonmarker |