Module: Redmine::WikiFormatting

Defined in:
lib/redmine/wiki_formatting.rb,
lib/redmine/wiki_formatting/macros.rb,
lib/redmine/wiki_formatting/textile/helper.rb,
lib/redmine/wiki_formatting/textile/formatter.rb

Defined Under Namespace

Modules: Macros, NullFormatter, Textile

Constant Summary

@@formatters =
{}

Class Method Summary collapse

Class Method Details

.format_namesObject



42
43
44
# File 'lib/redmine/wiki_formatting.rb', line 42

def format_names
  @@formatters.keys.map
end

.formatter_for(name) ⇒ Object



32
33
34
35
# File 'lib/redmine/wiki_formatting.rb', line 32

def formatter_for(name)
  entry = @@formatters[name.to_sym]
  (entry && entry[:formatter]) || Redmine::WikiFormatting::NullFormatter::Formatter
end

.helper_for(name) ⇒ Object



37
38
39
40
# File 'lib/redmine/wiki_formatting.rb', line 37

def helper_for(name)
  entry = @@formatters[name.to_sym]
  (entry && entry[:helper]) || Redmine::WikiFormatting::NullFormatter::Helper
end

.map {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



23
24
25
# File 'lib/redmine/wiki_formatting.rb', line 23

def map
  yield self
end

.register(name, formatter, helper) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
# File 'lib/redmine/wiki_formatting.rb', line 27

def register(name, formatter, helper)
  raise ArgumentError, "format name '#{name}' is already taken" if @@formatters[name.to_sym]
  @@formatters[name.to_sym] = {:formatter => formatter, :helper => helper}
end

.to_html(format, text, options = {}, &block) ⇒ Object



46
47
48
# File 'lib/redmine/wiki_formatting.rb', line 46

def to_html(format, text, options = {}, &block)
  formatter_for(format).new(text).to_html(&block)
end