diff options
Diffstat (limited to 'lib/redmine/wiki_formatting.rb')
-rw-r--r-- | lib/redmine/wiki_formatting.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index c4e4bb7c3..4fd5ea8e8 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -28,12 +28,19 @@ module Redmine yield self end - def register(name, formatter, helper, options={}) + def register(name, *args) + options = args.last.is_a?(Hash) ? args.pop : {} name = name.to_s raise ArgumentError, "format name '#{name}' is already taken" if @@formatters[name] + + formatter, helper, parser = args.any? ? + args : + %w(Formatter Helper HtmlParser).map {|m| "Redmine::WikiFormatting::#{name.classify}::#{m}".constantize} + @@formatters[name] = { :formatter => formatter, :helper => helper, + :html_parser => parser, :label => options[:label] || name.humanize } end @@ -42,6 +49,10 @@ module Redmine formatter_for(Setting.text_formatting) end + def html_parser + html_parser_for(Setting.text_formatting) + end + def formatter_for(name) entry = @@formatters[name.to_s] (entry && entry[:formatter]) || Redmine::WikiFormatting::NullFormatter::Formatter @@ -52,6 +63,11 @@ module Redmine (entry && entry[:helper]) || Redmine::WikiFormatting::NullFormatter::Helper end + def html_parser_for(name) + entry = @@formatters[name.to_s] + (entry && entry[:html_parser]) || Redmine::WikiFormatting::HtmlParser + end + def format_names @@formatters.keys.map end |