Sha256: 91458ead25ec66b9595dbba4eb43d7759ba26ec48ab808f2aabb85245d41391a
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
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: #* <tt>[[Media:video.mpg]]</tt> (prefix <tt>Media</tt>, resource <tt>video.mpg</tt>) #* <tt>[[Image:pretty.png|100px|A ''pretty'' picture]]</tt> (prefix <tt>Image</tt>, # resource <tt>pretty.png</tt>, and options <tt>100px</tt> and <tt>A # <i>pretty</i> picture</tt>. #The return value should be a well-formed hyperlink, image, object or #applet tag. def link_for(prefix, resource, options=[]) "<a href=\"javascript:void(0)\">#{prefix}:#{resource}(#{options.join(', ')})</a>" 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appswarm-0.0.1 | apps/wiki/lib/media_wiki_html.rb |