diff options
author | murphy <murphy@rubychan.de> | 2009-06-27 06:30:00 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2009-06-27 06:30:00 +0000 |
commit | 337ca4282f8a0e25bd1fe04898b1f3919627b0d9 (patch) | |
tree | b1d61691b963cd5f266b25deb4fbdd95390a8f8f | |
parent | c63310f2216caf6d9fb69925c125ecbd75f809fc (diff) | |
download | coderay-337ca4282f8a0e25bd1fe04898b1f3919627b0d9.tar.gz |
Working around a problem with latest RedCloth versions (>= 4.2.0) (issue #119)
-rw-r--r-- | lib/coderay/for_redcloth.rb | 9 |
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 |