Class: WikiRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/wiki_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(url_generator, locale_code = nil) ⇒ WikiRenderer

Returns a new instance of WikiRenderer.



25
26
27
28
29
# File 'lib/wiki_renderer.rb', line 25

def initialize(url_generator, locale_code=nil)
  @html_generator = MediaWikiHTMLGenerator.new
  @translator = Translator.for(locale_code)
  @html_generator.link_handler = url_generator
end

Instance Method Details

#render_wiki_diff(old_text, new_text) ⇒ Object



36
37
38
39
40
41
# File 'lib/wiki_renderer.rb', line 36

def render_wiki_diff(old_text, new_text)
  old_result = render_wiki_text(old_text)    
  new_result = render_wiki_text(new_text)

  HtmlDiffRenderer.new.render_html_diff(old_result, new_result)
end

#render_wiki_text(text) ⇒ Object



31
32
33
34
# File 'lib/wiki_renderer.rb', line 31

def render_wiki_text(text)
  localized_text = @translator.localize(text).delete("\r")
  wiki_to_html(localized_text)
end