From 6b2ef608ee8165dc8b275cb16b6405b90c820bbf Mon Sep 17 00:00:00 2001 From: murphy Date: Sun, 18 Oct 2009 17:54:57 +0000 Subject: Fixing for_redcloth for latest RedCloth versions. --- lib/coderay/for_redcloth.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/coderay') 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 "#{opts[:text]}" -- cgit v1.2.1