diff --git a/app/views/wiki/edit.rhtml b/app/views/wiki/edit.rhtml index 56ed5d8..368ab09 100644 --- a/app/views/wiki/edit.rhtml +++ b/app/views/wiki/edit.rhtml @@ -25,3 +25,7 @@ <% end %>
+ +<% content_for :header_tags do %> + <%= stylesheet_link_tag 'scm' %> +<% end %> diff --git a/app/views/wiki/show.rhtml b/app/views/wiki/show.rhtml index 06eca76..31c4b60 100644 --- a/app/views/wiki/show.rhtml +++ b/app/views/wiki/show.rhtml @@ -37,3 +37,7 @@ <%= submit_tag l(:button_add) %> <% end %> <% end %> + +<% content_for :header_tags do %> + <%= stylesheet_link_tag 'scm' %> +<% end %> diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index b6b2ff8..e9f5eb7 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|$)|[{|]))/, "\\1content + text.gsub!(//) do + content = @pre_list[$1.to_i] + if content.match(/ \s?(.+)/m) + content = "
" + + 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 diff --git a/public/stylesheets/scm.css b/public/stylesheets/scm.css index 88d7cec..338229b 100644 --- a/public/stylesheets/scm.css +++ b/public/stylesheets/scm.css @@ -29,7 +29,7 @@ table.list thead th.list-filename { /************* Coderay styles *************/ -.CodeRay { +table.CodeRay { background-color: #fafafa; } .CodeRay pre { margin: 0px } diff --git a/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html.rb b/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html.rb index 0c66f68..f0a123e 100644 --- a/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html.rb +++ b/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html.rb @@ -25,6 +25,10 @@ module Encoders # # == Options # + # === :escape + # Escape html entities + # Default: true + # # === :tab_width # Convert \t characters to +n+ spaces (a number.) # Default: 8 @@ -70,6 +74,7 @@ module Encoders FILE_EXTENSION = 'html' DEFAULT_OPTIONS = { + :escape => true, :tab_width => 8, :level => :xhtml, @@ -145,6 +150,7 @@ module Encoders @HTML_ESCAPE = HTML_ESCAPE.dup @HTML_ESCAPE["\t"] = ' ' * options[:tab_width] + @escape = options[:escape] @opened = [nil] @css = CSS.new options[:style] @@ -222,7 +228,7 @@ module Encoders def token text, type if text.is_a? ::String - if text =~ /#{HTML_ESCAPE_PATTERN}/o + if @escape && (text =~ /#{HTML_ESCAPE_PATTERN}/o) text = text.gsub(/#{HTML_ESCAPE_PATTERN}/o) { |m| @HTML_ESCAPE[m] } end @opened[0] = type