redmineのwikiでhikidoc記法が使いたい
textileはどうも気に入らないと言うことなので
実現可能かどうかテストする意味でとりあえずquick hack
Index: app/helpers/application_helper.rb =================================================================== --- app/helpers/application_helper.rb (revision 439) +++ app/helpers/application_helper.rb (working copy) @@ -125,21 +125,25 @@ # example: # [[link]] -> "link":link # [[link|title]] -> "title":link - text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "\"#{$3 || $1}\":" + format_wiki_link.call(Wiki.titleize($1)) } + text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) {|m| "[[#{$3 || $1}|" + format_wiki_link.call(Wiki.titleize($1)) + "]]" } # turn issue ids to textile links # example: # #52 -> "#52":/issues/show/52 - text = text.gsub(/#(\d+)(?=\b)/) {|m| "\"##{$1}\":" + url_for(:controller => 'issues', :action => 'show', :id => $1) } + text = text.gsub(/#(\d+)(?=\b)/) {|m| "[[##{$1}|" + url_for(:controller => 'issues', :action => 'show', :id => $1) + "]]" } # turn revision ids to textile links (@project needed) # example: # r52 -> "r52":/repositories/revision/6?rev=52 (@project.id is 6) - text = text.gsub(/r(\d+)(?=\b)/) {|m| "\"r#{$1}\":" + url_for(:controller => 'repositories', :action => 'revision', :id => @project.id, :rev => $1) } if @project + text = text.gsub(/r(\d+)(?=\b)/) {|m| "[[#{$1}|" + url_for(:controller => 'repositories', :action => 'revision', :id => @project.id, :rev => $1) + "]]" } if @project # finally textilize text + require 'hikidoc' @do_textilize ||= (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") - text = @do_textilize ? auto_link(RedCloth.new(text).to_html) : simple_format(auto_link(h(text))) + text = @do_textilize ? auto_link(HikiDoc.new(text).to_html) : simple_format(auto_link(h(text))) end def error_messages_for(object_name, options = {})
ひとまずちゃんと表示出来るようになったので、しっかりpluginとして作りますかうん