switch to coderay, no need for python

This commit is contained in:
John Bintz 2013-06-03 10:19:12 -04:00
parent 9e7d2651d7
commit ff07425cb6
2 changed files with 7 additions and 10 deletions

View File

@ -2,12 +2,12 @@
require 'thin' require 'thin'
require 'rack' require 'rack'
require 'pygmentize' require 'coderay'
require 'redcarpet' require 'redcarpet'
require 'optparse' require 'optparse'
options = { :port => 6789, :verbose => false } options = { port: 6789, verbose: false }
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "Usage: sharkfrown [options]" opts.banner = "Usage: sharkfrown [options]"
@ -16,13 +16,10 @@ OptionParser.new do |opts|
end.parse! end.parse!
class Sharkfrown class Sharkfrown
class PygmentizeHTML < Redcarpet::Render::HTML class CodeRayHTML < Redcarpet::Render::HTML
def block_code(code, language) def block_code(code, language)
require 'pygmentize' require 'coderay'
result = Pygmentize.process(code, language) CodeRay.scan(code, language.to_sym).div
result = "<pre>#{code}</pre>" if result.empty?
result
end end
end end
@ -75,7 +72,7 @@ class Sharkfrown
</head> </head>
<body> <body>
<a href=".">Back</a> <a href=".">Back</a>
#{Redcarpet::Markdown.new(PygmentizeHTML, :fenced_code_blocks => true).render(File.read(file))} #{Redcarpet::Markdown.new(CodeRayHTML, fenced_code_blocks: true).render(File.read(file))}
</body> </body>
</html> </html>
HTML HTML

View File

@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"] gem.require_paths = ["lib"]
gem.version = Sharkfrown::VERSION gem.version = Sharkfrown::VERSION
gem.add_dependency 'pygmentize' gem.add_dependency 'coderay'
gem.add_dependency 'thin' gem.add_dependency 'thin'
gem.add_dependency 'redcarpet' gem.add_dependency 'redcarpet'
end end