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,
lib/redmine/wiki_formatting/null_formatter/helper.rb,
lib/redmine/wiki_formatting/null_formatter/formatter.rb

Defined Under Namespace

Modules: Macros, NullFormatter, Textile

Constant Summary

@@formatters =
{}

Class Method Summary collapse

Class Method Details

.format_namesObject



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

def format_names
  @@formatters.keys.map
end

.formatter_for(name) ⇒ Object



29
30
31
32
# File 'lib/redmine/wiki_formatting.rb', line 29

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

.helper_for(name) ⇒ Object



34
35
36
37
# File 'lib/redmine/wiki_formatting.rb', line 34

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

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

Yields:

  • (_self)

Yield Parameters:



20
21
22
# File 'lib/redmine/wiki_formatting.rb', line 20

def map
  yield self
end

.register(name, formatter, helper) ⇒ Object

Raises:

  • (ArgumentError)


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

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

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



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

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