class AppSwarmWikiLinkHandler def initialize(baseurl) @baseurl=baseurl end def url_for(resource) @baseurl+"/"+resource end #Method invoked to resolve references to resources of unknown types. The #type is indicated by the resource prefix. Examples of inline links to #unknown references include: #* [[Media:video.mpg]] (prefix Media, resource video.mpg) #* [[Image:pretty.png|100px|A ''pretty'' picture]] (prefix Image, # resource pretty.png, and options 100px and A # pretty picture. #The return value should be a well-formed hyperlink, image, object or #applet tag. def link_for(prefix, resource, options=[]) "#{prefix}:#{resource}(#{options.join(', ')})" end end def appswarm_wiki_to_html(wiki,baseurl) parser = MediaWikiParser.new parser.lexer = MediaWikiLexer.new ast = parser.parse(wiki) walker = MediaWikiHTMLGenerator.new walker.link_handler=AppSwarmWikiLinkHandler.new(baseurl) walker.parse(ast) walker.html end