diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-06-15 21:16:42 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-06-15 21:16:42 +0000 |
commit | 3ae42cb32617670cb6c99a60f5cda2cf961d110c (patch) | |
tree | 2348af8e781435538aed5517b0c2087432b42c78 /lib/redmine/wiki_formatting.rb | |
parent | 7fb35abd10e3da24188f0f4325d4ba001687ebac (diff) | |
download | redmine-3ae42cb32617670cb6c99a60f5cda2cf961d110c.tar.gz redmine-3ae42cb32617670cb6c99a60f5cda2cf961d110c.zip |
Better handle html-only emails (#16962).
git-svn-id: http://svn.redmine.org/redmine/trunk@14313 e93f8b46-1217-0410-a6f0-8f06a7374b81
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 |