Skip to content

Instantly share code, notes, and snippets.

@yuumi3
Created August 7, 2011 02:06
Show Gist options
  • Save yuumi3/1129980 to your computer and use it in GitHub Desktop.
Save yuumi3/1129980 to your computer and use it in GitHub Desktop.
redmine 1.0.2 Wikiの<pre>に赤字を表示するパッチ
require 'redcloth3'
require 'redmine/syntax_highlighting'
require 'redmine/wiki_formatting/textile/formatter'
module Redmine
module WikiFormatting
module Textile
class Formatter < RedCloth3
alias :smooth_offtags_orgin :smooth_offtags
private
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="(color)">\s?(.+)/m)
content = "<code>" + ERB::Util.html_escape($2).gsub('##(', '<span style="color:#F00">').gsub(')##', '</span>')
elsif content.match(/<code\s+class="(\w+)">\s?(.+)/m)
content = "<code class=\"#{$1} syntaxhl\">" +
Redmine::SyntaxHighlighting.highlight_by_language($2, $1)
end
content
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment