Module: MediaCloth

Defined in:
lib/mediacloth.rb

Overview

Helper module to facilitate MediaCloth usage.

Class Method Summary collapse

Class Method Details

.wiki_to_html(input, options = {}) ⇒ Object

Parses wiki formatted input and generates its HTML representation.

Can reveive options for customizing the HTML renderer and link_handler. These are the available options:

:generator => An HTML generator (see MediaWikiHTMLGenerator)
:link_handler => A link handler (see MediaWikiLinkHandler)
:template_handler => A template inclusion handler (see MediaWikiTemplateHandler)


21
22
23
24
25
26
27
28
29
30
# File 'lib/mediacloth.rb', line 21

def wiki_to_html(input, options={})
  parser = MediaWikiParser.new
  parser.lexer = MediaWikiLexer.new
  tree = parser.parse(input)
  generator = options[:generator] || MediaWikiHTMLGenerator.new
  generator.link_handler = options[:link_handler] if options[:link_handler]
  generator.template_handler = options[:template_handler] if options[:template_handler]
  generator.params = options[:params] if options[:params]
  generator.parse(tree)
end

.wiki_to_signed_wiki(input, options = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mediacloth.rb', line 32

def wiki_to_signed_wiki(input, options={})
  parser = MediaWikiParser.new
  parser.lexer = MediaWikiLexer.new
  tree = parser.parse(input)
  generator = MediaWikiSignedWikiGenerator.new
  generator.link_handler = options[:link_handler] if options[:link_handler]
  generator.template_handler = options[:template_handler] if options[:template_handler]
  generator.params = options[:params] if options[:params]
  generator.parse(tree, input)
  generator.signed_wiki
end