diff options
author | murphy <murphy@rubychan.de> | 2009-10-18 17:54:57 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2009-10-18 17:54:57 +0000 |
commit | 6b2ef608ee8165dc8b275cb16b6405b90c820bbf (patch) | |
tree | af9269ceac9dc432c16fb19b1edd3090d547e5ba /lib | |
parent | 1021e89dcd86fc3caf182d568cad9f244d8bd375 (diff) | |
download | coderay-6b2ef608ee8165dc8b275cb16b6405b90c820bbf.tar.gz |
Fixing for_redcloth for latest RedCloth versions.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/coderay/for_redcloth.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/coderay/for_redcloth.rb b/lib/coderay/for_redcloth.rb index e96e788..0857aba 100644 --- a/lib/coderay/for_redcloth.rb +++ b/lib/coderay/for_redcloth.rb @@ -29,21 +29,26 @@ module CodeRay } html.gsub(/&(?:amp|quot|[gl]t);/) { |entity| replacements[entity] } end - undef_method :code, :bc_open, :bc_close, :escape_pre + undef 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 + if opts[:text].sub!(/\A\[(\w+)\]/, '') + if CodeRay::Scanners[$1].plugin_id == 'plaintext' + opts[:text] = $& + opts[:text] + else + opts[:lang] = $1 + end + end end if opts[:lang] && !filter_coderay require 'coderay' @in_bc ||= nil format = @in_bc ? :div : :span + opts[:text] = unescape(opts[:text]) unless @in_bc highlighted_code = CodeRay.encode opts[:text], opts[:lang], format, :stream => true highlighted_code.sub!(/\A<(span|div)/) { |m| m + pba(@in_bc || opts) } - highlighted_code = unescape(highlighted_code) unless @in_bc highlighted_code else "<code#{pba(opts)}>#{opts[:text]}</code>" |