summaryrefslogtreecommitdiffstats
path: root/lib/redmine
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-06 17:06:07 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-06 17:06:07 +0000
commit42db3cac06ad7f49dc10c7993e2df54b5bb4b2ab (patch)
tree26f3dc7e68a723cfe7dba800f89a341a467cc167 /lib/redmine
parent22c5e0d61481f4d33d4eab48a7007ad49fb00190 (diff)
downloadredmine-42db3cac06ad7f49dc10c7993e2df54b5bb4b2ab.tar.gz
redmine-42db3cac06ad7f49dc10c7993e2df54b5bb4b2ab.zip
Added code highlighting support in wiki, using this syntax:
<pre><code> <-- cut here <pre><code class="ruby"> Place you code here. </code></pre> cut here --> </pre></code> git-svn-id: http://redmine.rubyforge.org/svn/trunk@710 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine')
-rw-r--r--lib/redmine/wiki_formatting.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb
index b6b2ff802..e9f5eb749 100644
--- a/lib/redmine/wiki_formatting.rb
+++ b/lib/redmine/wiki_formatting.rb
@@ -1,4 +1,5 @@
require 'redcloth'
+require 'coderay'
module Redmine
module WikiFormatting
@@ -24,7 +25,22 @@ module Redmine
def hard_break( text )
text.gsub!( /(.)\n(?!\n|\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks
end
-
+
+ # Patch to add code highlighting support to RedCloth
+ def smooth_offtags( text )
+ unless @pre_list.empty?
+ ## replace <pre> content
+ text.gsub!(/<redpre#(\d+)>/) do
+ content = @pre_list[$1.to_i]
+ if content.match(/<code\s+class="(\w+)">\s?(.+)/m)
+ content = "<code class=\"#{$1} CodeRay\">" +
+ CodeRay.scan($2, $1).html(:escape => false, :line_numbers => :inline)
+ end
+ content
+ end
+ end
+ end
+
AUTO_LINK_RE = %r{
( # leading text
<\w+.*?>| # leading HTML tag, or