File: rdiscount

package info (click to toggle)
ruby-rdiscount 2.2.7.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 480 kB
  • sloc: ansic: 4,798; ruby: 487; makefile: 2
file content (20 lines) | stat: -rwxr-xr-x 772 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env ruby
#
# Usage: [env RDISCOUNT_EXTENSIONS='<extension>,...'] rdiscount [<file>...]
# no <file> or when <file> is '-', read Markdown source text from standard input.
#
# Convert one or more Markdown files to HTML and write to standard output.
# With no <file> or when <file> is '-', read Markdown source text from
# standard input.  Optionally, the RDISCOUNT_EXTENSIONS environment variable
# can specify a comma-separated list of extensions to enable in RDiscount.
#
if ARGV.include?('--help')
  File.read(__FILE__).split("\n").grep(/^# /).each do |line|
    puts line[2..-1]
  end
  exit 0
end

require 'rdiscount'
extensions = ENV['RDISCOUNT_EXTENSIONS'].to_s.split(',').map{ |key| key.to_sym }
STDOUT.write(RDiscount.new(ARGF.read, *extensions).to_html)