diff options
Diffstat (limited to 'lib/redmine/wiki_formatting.rb')
-rw-r--r-- | lib/redmine/wiki_formatting.rb | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 0635aad8b..2f25fe0e6 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -17,6 +17,8 @@ module Redmine module WikiFormatting + class StaleSectionError < Exception; end + @@formatters = {} class << self @@ -29,6 +31,10 @@ module Redmine @@formatters[name.to_s] = {:formatter => formatter, :helper => helper} end + def formatter + formatter_for(Setting.text_formatting) + end + def formatter_for(name) entry = @@formatters[name.to_s] (entry && entry[:formatter]) || Redmine::WikiFormatting::NullFormatter::Formatter @@ -43,7 +49,7 @@ module Redmine @@formatters.keys.map end - def to_html(format, text, options = {}, &block) + def to_html(format, text, options = {}) text = if Setting.cache_formatted_text? && text.size > 2.kilobyte && cache_store && cache_key = cache_key_for(format, options[:object], options[:attribute]) # Text retrieved from the cache store may be frozen # We need to dup it so we can do in-place substitutions with gsub! @@ -53,9 +59,6 @@ module Redmine else formatter_for(format).new(text).to_html end - if block_given? - execute_macros(text, block) - end text end @@ -70,33 +73,6 @@ module Redmine def cache_store ActionController::Base.cache_store end - - MACROS_RE = / - (!)? # escaping - ( - \{\{ # opening tag - ([\w]+) # macro name - (\(([^\}]*)\))? # optional arguments - \}\} # closing tag - ) - /x unless const_defined?(:MACROS_RE) - - # Macros substitution - def execute_macros(text, macros_runner) - text.gsub!(MACROS_RE) do - esc, all, macro = $1, $2, $3.downcase - args = ($5 || '').split(',').each(&:strip) - if esc.nil? - begin - macros_runner.call(macro, args) - rescue => e - "<div class=\"flash error\">Error executing the <strong>#{macro}</strong> macro (#{e})</div>" - end || all - else - all - end - end - end end # Default formatter module |