Permalink
Browse files

Allow commandline usage of SmartyHTML

  • Loading branch information...
1 parent 65f551a commit 18e106593b5e0b5f9ac5f2f56b13c2a38f2fc8b6 @namelessjon namelessjon committed Mar 4, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 bin/redcarpet
View
@@ -1,8 +1,9 @@
#!/usr/bin/env ruby
-# Usage: redcarpet [--parse-<extension>...] [--render-<extension>...] [<file>...]
+# Usage: redcarpet [--parse-<extension>...] [--render-<extension>...] [--smarty] [<file>...]
# 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.
# With <extension>s, perform additional Markdown processing before writing output.
+# With --smarty, use the SmartyHTML renderer
if ARGV.include?('--help')
File.read(__FILE__).split("\n").grep(/^# /).each do |line|
puts line[2..-1]
@@ -17,6 +18,7 @@ require 'redcarpet'
render_extensions = {}
parse_extensions = {}
+renderer = Redcarpet::Render::HTML
ARGV.delete_if do |arg|
if arg =~ /^--render-([\w-]+)$/
@@ -25,10 +27,12 @@ ARGV.delete_if do |arg|
elsif arg =~ /^--parse-([\w-]+)$/
arg = $1.gsub('-', '_')
parse_extensions[arg.to_sym] = true
+ elsif arg == '--smarty'
+ renderer = Redcarpet::Render::SmartyHTML
else
false
end
end
-render = Redcarpet::Render::HTML.new(render_extensions)
+render = renderer.new(render_extensions)
STDOUT.write(Redcarpet::Markdown.new(render, parse_extensions).render(ARGF.read))

0 comments on commit 18e1065

Please sign in to comment.