Sha256: 3cbc1128f62d77d36ed68e3728eb4a3329190677927b128c5f92dc82b3316beb

Contents?: true

Size: 1.83 KB

Versions: 24

Compression:

Stored size: 1.83 KB

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
#
#--
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
#
# This file is part of kramdown which is licensed under the MIT.
#++
#

require 'optparse'
require 'kramdown'

options = {}
format = ['html']
OptionParser.new do |opts|
  opts.banner = "Usage: kramdown [options] [FILE FILE ...]"
  opts.summary_indent = ' '*4

  opts.separator ""
  opts.separator "Command line options:"
  opts.separator ""

  opts.on("-i", "--input ARG", "Specify the input format: kramdown (default), html, GFM or markdown") {|v| options[:input] = v}
  opts.on("-o", "--output ARG", Array, "Specify one or more output formats separated by commas: html (default), kramdown, latex, pdf or remove_html_tags") {|v| format = v}

  opts.on("-v", "--version", "Show the version of kramdown") do
    puts Kramdown::VERSION
    exit
  end
  opts.on("-h", "--help", "Show the help") do
    puts opts.summarize('', 5, 72)
    exit
  end

  opts.separator ""
  opts.separator "kramdown options:"
  opts.separator ""

  Kramdown::Options.definitions.sort.each do |n, definition|
    no = n.to_s.tr('_', '-')
    if definition.type == Kramdown::Options::Boolean
      opts.on("--[no-]#{no}") {|v| options[n] = Kramdown::Options.parse(n, v)}
    else
      type = definition.type
      type = String if type == Symbol || type == Object
      opts.on("--#{no} ARG", type) {|v| options[n] = Kramdown::Options.parse(n, v)}
    end

    definition.desc.split(/\n/).each do |line|
      opts.separator opts.summary_indent + ' '*6 + line
    end
    opts.separator ''
  end

end.parse!

begin
  doc = Kramdown::Document.new(ARGF.read, options)
  result = ''
  format.each {|f| result = doc.send("to_#{f}")}
  puts result
  doc.warnings.each {|warn| $stderr.puts "Warning: #{warn}"}
rescue Kramdown::Error => e
  $stderr.puts "Error: #{e.message}"
  exit(1)
end

Version data entries

24 entries across 23 versions & 7 rubygems

Version Path
logstash-filter-delta-1.1.0 vendor/bundle/jruby/2.2.0/gems/kramdown-1.12.0/bin/kramdown
logstash-filter-delta-1.0.1 vendor/bundle/jruby/2.2.0/gems/kramdown-1.12.0/bin/kramdown
logstash-filter-base64-1.0.4 vendor/bundle/jruby/2.2.0/gems/kramdown-1.12.0/bin/kramdown
logstash-filter-base64-1.0.3 vendor/bundle/jruby/2.2.0/gems/kramdown-1.12.0/bin/kramdown
logstash-filter-delta-1.0.0 vendor/bundle/jruby/2.2.0/gems/kramdown-1.12.0/bin/kramdown
logstash-filter-base64-1.0.2 vendor/bundle/jruby/2.3.0/gems/kramdown-1.12.0/bin/kramdown
logstash-filter-base64-1.0.1 vendor/bundle/jruby/2.3.0/gems/kramdown-1.12.0/bin/kramdown
logstash-filter-base64-1.0.0 vendor/bundle/jruby/2.3.0/gems/kramdown-1.12.0/bin/kramdown
kramdown-1.12.0 bin/kramdown
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/kramdown-1.8.0/bin/kramdown
kramdown-1.11.1 bin/kramdown
kramdown-1.11.0 bin/kramdown
kramdown-1.10.0 bin/kramdown
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/kramdown-1.8.0/bin/kramdown
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/kramdown-1.8.0/bin/kramdown
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/kramdown-1.8.0/bin/kramdown
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-codec-json-2.0.3/vendor/gems/kramdown-1.9.0/bin/kramdown
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/kramdown-1.9.0/bin/kramdown
logstash-codec-json-2.0.3 vendor/gems/kramdown-1.9.0/bin/kramdown
logstash-input-beats-0.9.2 vendor/jruby/1.9/gems/kramdown-1.9.0/bin/kramdown