@@ -359,11 +359,18 module Redmine #:nodoc: | |||||
359 | # Registers a wiki formatter. |
|
359 | # Registers a wiki formatter. | |
360 | # |
|
360 | # | |
361 | # Parameters: |
|
361 | # Parameters: | |
362 |
# * +name+ - |
|
362 | # * +name+ - formatter name | |
363 | # * +formatter+ - formatter class, which should have an instance method +to_html+ |
|
363 | # * +formatter+ - formatter class, which should have an instance method +to_html+ | |
364 | # * +helper+ - helper module, which will be included by wiki pages |
|
364 | # * +helper+ - helper module, which will be included by wiki pages (optional) | |
365 | def wiki_format_provider(name, formatter, helper) |
|
365 | # * +html_parser+ class reponsible for converting HTML to wiki text (optional) | |
366 | Redmine::WikiFormatting.register(name, formatter, helper) |
|
366 | # * +options+ - a Hash of options (optional) | |
|
367 | # * :label - label for the formatter displayed in application settings | |||
|
368 | # | |||
|
369 | # Examples: | |||
|
370 | # wiki_format_provider(:custom_formatter, CustomFormatter, :label => "My custom formatter") | |||
|
371 | # | |||
|
372 | def wiki_format_provider(name, *args) | |||
|
373 | Redmine::WikiFormatting.register(name, *args) | |||
367 | end |
|
374 | end | |
368 |
|
375 | |||
369 | # Returns +true+ if the plugin can be configured. |
|
376 | # Returns +true+ if the plugin can be configured. |
@@ -35,7 +35,9 module Redmine | |||||
35 |
|
35 | |||
36 | formatter, helper, parser = args.any? ? |
|
36 | formatter, helper, parser = args.any? ? | |
37 | args : |
|
37 | args : | |
38 | %w(Formatter Helper HtmlParser).map {|m| "Redmine::WikiFormatting::#{name.classify}::#{m}".constantize} |
|
38 | %w(Formatter Helper HtmlParser).map {|m| "Redmine::WikiFormatting::#{name.classify}::#{m}".constantize rescue nil} | |
|
39 | ||||
|
40 | raise "A formatter class is required" if formatter.nil? | |||
39 |
|
41 | |||
40 | @@formatters[name] = { |
|
42 | @@formatters[name] = { | |
41 | :formatter => formatter, |
|
43 | :formatter => formatter, |
General Comments 0
You need to be logged in to leave comments.
Login now