From 6fc245327ce5bb4bb75f1378424635e347dfcd02 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 18 Nov 2011 16:25:00 +0000 Subject: Wiki: allows single section edit (#2222). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7829 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/wiki_formatting.rb | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) (limited to 'lib/redmine/wiki_formatting.rb') 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 - "
Error executing the #{macro} macro (#{e})
" - end || all - else - all - end - end - end end # Default formatter module -- cgit v1.2.3