Skip to content
This repository
Browse code

Allow commandline usage of SmartyHTML

  • Loading branch information...
commit 18e106593b5e0b5f9ac5f2f56b13c2a38f2fc8b6 1 parent 65f551a
Jon namelessjon authored

Showing 1 changed file with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. +6 2 bin/redcarpet
8 bin/redcarpet
... ... @@ -1,8 +1,9 @@
1 1 #!/usr/bin/env ruby
2   -# Usage: redcarpet [--parse-<extension>...] [--render-<extension>...] [<file>...]
  2 +# Usage: redcarpet [--parse-<extension>...] [--render-<extension>...] [--smarty] [<file>...]
3 3 # Convert one or more Markdown files to HTML and write to standard output. With
4 4 # no <file> or when <file> is '-', read Markdown source text from standard input.
5 5 # With <extension>s, perform additional Markdown processing before writing output.
  6 +# With --smarty, use the SmartyHTML renderer
6 7 if ARGV.include?('--help')
7 8 File.read(__FILE__).split("\n").grep(/^# /).each do |line|
8 9 puts line[2..-1]
@@ -17,6 +18,7 @@ require 'redcarpet'
17 18
18 19 render_extensions = {}
19 20 parse_extensions = {}
  21 +renderer = Redcarpet::Render::HTML
20 22
21 23 ARGV.delete_if do |arg|
22 24 if arg =~ /^--render-([\w-]+)$/
@@ -25,10 +27,12 @@ ARGV.delete_if do |arg|
25 27 elsif arg =~ /^--parse-([\w-]+)$/
26 28 arg = $1.gsub('-', '_')
27 29 parse_extensions[arg.to_sym] = true
  30 + elsif arg == '--smarty'
  31 + renderer = Redcarpet::Render::SmartyHTML
28 32 else
29 33 false
30 34 end
31 35 end
32 36
33   -render = Redcarpet::Render::HTML.new(render_extensions)
  37 +render = renderer.new(render_extensions)
34 38 STDOUT.write(Redcarpet::Markdown.new(render, parse_extensions).render(ARGF.read))

0 comments on commit 18e1065

Please sign in to comment.
Something went wrong with that request. Please try again.