Class MediaWikiHTMLGenerator
In: lib/mediacloth/mediawikihtmlgenerator.rb
Parent: MediaWikiWalker

HTML generator for a MediaWiki parse tree

Typical use case:

 parser = MediaWikiParser.new
 parser.lexer = MediaWikiLexer.new
 ast = parser.parse(input)
 walker = MediaWikiHTMLGenerator.new
 walker.parse(ast)
 puts walker.html

Methods

Attributes

html  [R] 

Public Class methods

[Source]

    # File lib/mediacloth/mediawikihtmlgenerator.rb, line 16
16:     def initialize
17:         @html = ""
18:     end

Protected Instance methods

[Source]

    # File lib/mediacloth/mediawikihtmlgenerator.rb, line 36
36:     def parse_formatted(ast)
37:         tag = formatting_to_tag(ast)
38:         @html += "<#{tag}>"
39:         super(ast)
40:         @html += "</#{tag}>"
41:     end

[Source]

    # File lib/mediacloth/mediawikihtmlgenerator.rb, line 43
43:     def parse_list(ast)
44:         tag = list_tag(ast)
45:         @html += "<#{tag}>"
46:         super(ast)
47:         @html += "</#{tag}>"
48:     end

[Source]

    # File lib/mediacloth/mediawikihtmlgenerator.rb, line 50
50:     def parse_list_item(ast)
51:         @html += "<li>"
52:         super(ast)
53:         @html += "</li>"
54:     end

[Source]

    # File lib/mediacloth/mediawikihtmlgenerator.rb, line 56
56:     def parse_preformatted(ast)
57:         super(ast)
58:     end

[Source]

    # File lib/mediacloth/mediawikihtmlgenerator.rb, line 60
60:     def parse_section(ast)
61:         @html += "<h#{ast.level}>"
62:         @html += ast.contents.strip
63:         @html += "</h#{ast.level}>"
64:         super(ast)
65:     end

[Source]

    # File lib/mediacloth/mediawikihtmlgenerator.rb, line 26
26:     def parse_text(ast)
27:         tag = formatting_to_tag(ast)
28:         if tag[0].empty?
29:             @html += ast.contents
30:         else
31:             @html += "<#{tag[0]}#{tag[1]}>#{ast.contents}</#{tag[0]}>"
32:         end
33:         super(ast)
34:     end

[Source]

    # File lib/mediacloth/mediawikihtmlgenerator.rb, line 22
22:     def parse_wiki_ast(ast)
23:         super(ast)
24:     end

[Validate]