summaryrefslogtreecommitdiff
path: root/lib/coderay
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2009-06-27 06:30:00 +0000
committermurphy <murphy@rubychan.de>2009-06-27 06:30:00 +0000
commit337ca4282f8a0e25bd1fe04898b1f3919627b0d9 (patch)
treeb1d61691b963cd5f266b25deb4fbdd95390a8f8f /lib/coderay
parentc63310f2216caf6d9fb69925c125ecbd75f809fc (diff)
downloadcoderay-337ca4282f8a0e25bd1fe04898b1f3919627b0d9.tar.gz
Working around a problem with latest RedCloth versions (>= 4.2.0) (issue #119)
Diffstat (limited to 'lib/coderay')
-rw-r--r--lib/coderay/for_redcloth.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/coderay/for_redcloth.rb b/lib/coderay/for_redcloth.rb
index f5dcf3f..e96e788 100644
--- a/lib/coderay/for_redcloth.rb
+++ b/lib/coderay/for_redcloth.rb
@@ -15,7 +15,9 @@ module CodeRay
def self.install
gem 'RedCloth', '>= 4.0.3' rescue nil
require 'redcloth'
- raise 'CodeRay.for_redcloth needs RedCloth 4.0.3 or later.' unless RedCloth::VERSION.to_s >= '4.0.3'
+ unless RedCloth::VERSION.to_s >= '4.0.3'
+ raise 'CodeRay.for_redcloth needs RedCloth version 4.0.3 or later.'
+ end
RedCloth::TextileDoc.send :include, ForRedCloth::TextileDoc
RedCloth::Formatters::HTML.module_eval do
def unescape(html)
@@ -30,6 +32,11 @@ module CodeRay
undef_method :code, :bc_open, :bc_close, :escape_pre
def code(opts) # :nodoc:
opts[:block] = true
+ if !opts[:lang] && RedCloth::VERSION.to_s >= '4.2.0'
+ # simulating pre-4.2 behavior
+ opts[:text].sub!(/\A\[(\w+)\]/, '')
+ opts[:lang] = $1
+ end
if opts[:lang] && !filter_coderay
require 'coderay'
@in_bc ||= nil