Created
August 7, 2011 02:06
-
-
Save yuumi3/1129980 to your computer and use it in GitHub Desktop.
redmine 1.0.2 Wikiの<pre>に赤字を表示するパッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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