Module: MediaCloth
- Defined in:
- lib/mediacloth.rb
Overview
Helper module to facilitate MediaCloth usage.
Class Method Summary collapse
-
.wiki_to_html(input, options = {}) ⇒ Object
Parses wiki formatted
input
and generates its HTML representation. - .wiki_to_signed_wiki(input, options = {}) ⇒ Object
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, ={}) parser = MediaWikiParser.new parser.lexer = MediaWikiLexer.new tree = parser.parse(input) generator = [:generator] || MediaWikiHTMLGenerator.new generator.link_handler = [:link_handler] if [:link_handler] generator.template_handler = [:template_handler] if [:template_handler] generator.params = [:params] if [: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, ={}) parser = MediaWikiParser.new parser.lexer = MediaWikiLexer.new tree = parser.parse(input) generator = MediaWikiSignedWikiGenerator.new generator.link_handler = [:link_handler] if [:link_handler] generator.template_handler = [:template_handler] if [:template_handler] generator.params = [:params] if [:params] generator.parse(tree, input) generator.signed_wiki end |